|
dmk, Jr. Member
Posted: 09 September 2014 10:04 AM Total Posts: 32
Let’s say I’ve loaded in a 3d model and want to tint a specific face a different color, but maintain the look and feel of the texture itself.
What would be the different approaches to do this, and what would you recommend (assume little prior knowledge working with Away3D and 3D models in general, i.e. just watched my first tutorial on uv wrapping….)?
|
theMightyAtom, Sr. Member
Posted: 09 September 2014 12:21 PM Total Posts: 669
[ # 1 ]
The quick answer is, keep that face as a separate object when modelling.
The more complicated answer is to use a ray trace to identify the particular face (typically a mouse event) and use the target faces’ 3 uv coordinates to colour an area on the BitmapTexture used in the TextureMaterial.
Good Luck!
|
dmk, Jr. Member
Posted: 09 September 2014 12:25 PM Total Posts: 32
[ # 2 ]
Thanks! For a relatively simple object, is there a huge performance difference between the two approaches?
I.e. assume it’s 4 planes that will each be textured separately now, and like 8 other primitives attached (as opposed to one object, uv shifted on the fly)
|
dmk, Jr. Member
Posted: 09 September 2014 12:28 PM Total Posts: 32
[ # 3 ]
Also… just to consider the more advanced approach, let’s say we just have a cube and we know which face we want to target
How to derive the uv coordinates from that?
|
theMightyAtom, Sr. Member
Posted: 09 September 2014 12:45 PM Total Posts: 669
[ # 4 ]
For a cube I would keep things separate, definitely. Then you can give each side a name, and easily control them independently.
Performance wise, you want to keep things small. The smallest possible mesh you could make, memory wise, would be 6 planes that share THE SAME GEOMETRY.
As the number of faces goes up, it becomes necessary to keep the mesh count down, and merge objects together when possible. This first becomes an issue with several thousand faces, so I wouldn’t worry about it.
Cheers!
|
rdoi, Member
Posted: 10 September 2014 08:55 PM Total Posts: 86
[ # 5 ]
Hi there,
Im not sure how deep you want to go, but I think you could do it with subgeometries.
Basic concept:
You can set different materials for a mesh, as long as its geometry is separated in subgeometries.
You could extend the Geometry class, adding a method that detaches the desired polygon from the main subgeometry and creates dynamically the subgeometry to receive the highlighted material.
Or, you could create a custom geometry assembled with multiple subgeometries, one for each face you want to highlight, and set the each material accordingly.
They are basicaly the same concept of what @theMightyAtom suggested, but in a subgeometry level.
|
Fabrice Closier, Administrator
Posted: 10 September 2014 10:28 PM Total Posts: 1265
[ # 6 ]
or if you make an atlas , using uvanimator, simply goto(0-6); from mouse event details you get the uv’s, so if you order your map a bit, you can test rects. No geom involved or updated, no perf impact. Just a smart photoshop work…
If all 6 combos would not fit on one map for res reasons, the swap is also handled by the animator for you.
|