ShadingColorMaterial in Away3D 4.x???

Software: Away3D 4.x

BoomerSooner, Newbie
Posted: 08 March 2012 09:58 PM   Total Posts: 5

This may have already been answered, but is there a way to use the equivalent of a ShadingColorMaterial from Away3D 3.6 in Away3D 4.x?

I have a mesh I defined from vertices and triangles. I want to render the mesh with solid coloring on each face so the shading only comes from different colors on different faces.

I recently wrote a lot of code using the really old Papervision3D. (*sigh* I know, why did I do that?? shut eye) In Papervision, there was a material called a FlatShadeMaterial that I really like. Can I do something similar in Away3D 4.x??

If anybody has some example code, that’d rule.

Thanks!!!!

   

Avatar
Fabrice Closier, Administrator
Posted: 08 March 2012 10:58 PM   Total Posts: 1265   [ # 1 ]

for the flatShading, its very easy, just say Explode(myMesh);
any lighted material applied on it will display each and every face. (the reverse can be obtained with the weld class, giving you a smooth surface when lighted)

However coloring per face (lighted or not) doesn’t go as in the old days where the draw was a shapefill with a solid color. You can of course write a custom agal code and build your own material and pass class for that, as you need to define a color at per vertex.
The easyer way for you would be to draw once a map with say 256 colors, and simply place the uvs per face at the different color location on the map.
You can access the data you need like this:  mesh.geometry.subGeometries[index].indexData, to retreive the buffer pointers per face, as they may not be in a regular sequence, and the uvs using the method mesh.geometry.subGeometries[index].UVData;
Once you have updated your uv’s buffer, update the geometry.
mesh.geometry.subGeometries[index].updateUVData(uvs).

If you search on these functions names in this forum, you will find tons of usefull tips.

   
   

X

Away3D Forum

Member Login

Username

Password

Remember_me



X