per triangle material

Software: Away3D 4.x

koblongata, Newbie
Posted: 23 September 2013 11:06 AM   Total Posts: 28

Hello there, wondering is it possible to assign one material to a triangle in a mesh?

   

Avatar
GoroMatsumoto, Sr. Member
Posted: 23 September 2013 12:08 PM   Total Posts: 166   [ # 1 ]

At first, there is no usual easy way to do it.
But you can.

You should use a texture that include all textures you want use.
And set UVs of each triangles in that texture.

You have to learn about manipulating UVs by hand.
I recommend to you to start the learning with simplest geometry.

PlaneGeometry is simplest in Away3d.

mesh = new Mesh(new PlaneGeometrymaterial);
mesh.geometry.convertToSeparateBuffers();
trace(mesh.geometry.subGeometries[0].vertexData);
trace(mesh.geometry.subGeometries[0].UVData); 

You can see vertices and UVs data by trace().
And modify UVs and update the mesh’s UV data, like this way.

var uvs:Vector.<Number> = mesh.geometry.subGeometries[0].UVData;

//...manipulating uvs by hand...

SubGeometry(mesh.geometry.subGeometries[0]).updateUVData(uvs); 

If you can manage with PlaneGeometry,
you should try with more complex geometries.

Cheers.

 

   

koblongata, Newbie
Posted: 23 September 2013 12:55 PM   Total Posts: 28   [ # 2 ]

Thank you! yes it is complicated to me smile looking into it now.

I found this post:
http://greencollective.nl/blog/?p=54

I think it’s basically talking about the same thing? you can have multiple materials for planes and than merge them, and have materials stay.

how about have a custom triangle geometry like plane geometry and have them merged like above? and if only ColorMaterial needed then uvs don’t matter right?

   

Avatar
GoroMatsumoto, Sr. Member
Posted: 23 September 2013 02:30 PM   Total Posts: 166   [ # 3 ]

The article’s way is not similar with the way that I described.

If you need only simple geometry like a cube,
the article’s way is easy and simple way.

But if you need more complex geometry,
It’s not so good way.
(Even using the custom triangle geometry.)

One of the problem will occur on it’s performance.
Because that merged mesh have multiple materials.
And “Context3D.drawTriangles” calls on each materials. at least.
The “draw calls” is one of big factor of performance on GPU rendering.

Second problem is the custom triangle geometry.
If you build the class, you need know about geometry structure.
And I think that a strictly manipulating of positions and rotating of the geometry is not so easy.

Anyway, you should describe more about your situation.
Showing sketches, models, textures… and so on.
Somebody may help you more clearly.

Cheers.

   

Avatar
GoroMatsumoto, Sr. Member
Posted: 23 September 2013 02:36 PM   Total Posts: 166   [ # 4 ]

If you want to use particles as mesh, this may helps you.
http://away3d.com/forum/viewthread/4963/

   

koblongata, Newbie
Posted: 23 September 2013 10:20 PM   Total Posts: 28   [ # 5 ]

Hi, thanks for the insight, sorry I didn’t not explain so well

I was making a simple mesh “drawing” tool, the idea is like this:
https://www.cubby.com/pl/index.swf/_abf2c6b70e374de19d35edd798fbf308

it would create mesh out of triangulated closed paths with some “holes” (they are actually extruded in the end)
and each path can assign a color to it (it’s randomized here), and the resulting triangles would have the same color as well

it was done in pv3d, (in pv3d a triangle has a material), good only for cartoon like stuff though, wanting to continue the idea on away3d…

   

koblongata, Newbie
Posted: 23 September 2013 10:30 PM   Total Posts: 28   [ # 6 ]

That particle mesh is very cool, imagining some hologram like stuff smile
noted, would come in handy. Thanks.

   

Avatar
GoroMatsumoto, Sr. Member
Posted: 24 September 2013 08:53 AM   Total Posts: 166   [ # 7 ]

I see.
Maybe you can do that with the classes of extrusion in Away3d.

http://away3d.com/livedocs/away3d/4.1.1Beta/away3d/extrusions/package-detail.html

There are not so many information about these classes on internet.
Try to explore in this forum.

Forum search “extrude”:
http://away3d.com/forum/search_results/b55bdd104ac2229321137d92d5451634/

Maybe you can use these classes:
DelaunayMesh,
LinearExtrude,
PathExtrude,
for making something like above link demo.

But these classes are not so updated very well…
Good luck!

   

koblongata, Newbie
Posted: 24 September 2013 09:03 PM   Total Posts: 28   [ # 8 ]

OK Thanks!

   
   

X

Away3D Forum

Member Login

Username

Password

Remember_me



X