How do I get vertex data from a Mesh?

Software: Away3D 4.x

Avatar
vonWolfehaus, Newbie
Posted: 04 January 2012 01:32 AM   Total Posts: 14

Update: Turns out I didn’t look far enough into SubGeometry. There’s a vertexData getter about halfway down. Still, if someone knows of a better way to make the top and side faces grouped into separate Meshes, that’d be cool.

I just dived into away3d 4 to get my prototype working but I’m having a hard time finding a way to get the positions of the vertices of the Cylinder primitive.

I basically copied the Cylinder into a new class so that it will only create a hexagonal cylinder (for a hex-tile based game you see). I need to change the material of the top part and sides separately though, so I have to delete the top faces and create my own (which can be done with 4 tris instead of Cylinder’s 6 anyway).

Using FaceHelper.removeFaces() I’ve accomplished that, but now I need to get the top verts from the remaining geometry and use those positions to create the new faces and add those as a separate Mesh.

[...]

Any help is much appreciate. I’m open to other methods for achieving the desired end result (in bold above) too! Thanks.

   

inSertCodE, Sr. Member
Posted: 04 January 2012 02:25 AM   Total Posts: 105   [ # 1 ]

You’re approach needs improvement. My suggestion is that you focus on understanding on how creating a geometry works. After that you create your own geometry from scratch depending on what you need.

For example the terrain editor I’m building *attachment* can not be done using the existing primitives (for example plane). Whole terrain is single mesh…

 

   

Avatar
vonWolfehaus, Newbie
Posted: 04 January 2012 02:55 AM   Total Posts: 14   [ # 2 ]

No point in doing work I don’t have to. All I have to do to get exactly what I need is to create a few new tris using Cylinder’s vertices. And that’s a huge enough pain as it is.

 

   

inSertCodE, Sr. Member
Posted: 04 January 2012 12:38 PM   Total Posts: 105   [ # 3 ]

Either way you first have to understand how geometry works before you can manipulate it. It really isn’t that complex as many people think.
There are few posts on the forum explaining the geometry and you can have a look at any primitive class.

 

   

John Brookes, Moderator
Posted: 04 January 2012 02:21 PM   Total Posts: 732   [ # 4 ]

The cylinder already has a parameter to remove the top and bottom sides. So no need to use remove faces.

You could if you wanted create a cylinder without a top face and then use the polygon primitive to add the top face back with its own unique material.
Then use the Merge class so you end up with 1 mesh and a subgeometry for each material.

Or even I think the same can be acheived with linear or Lathe extrude class. You can pass paremeter for top bottom side etc.

Or a little hack to the cylinder class so you have different areas of the UV map for top bottom sides.
http://www.shrewballooba.co.uk/CylinderJB.as

UVMAP

 

   

Avatar
vonWolfehaus, Newbie
Posted: 05 January 2012 04:46 AM   Total Posts: 14   [ # 5 ]

Thanks guys, I got it working really fast by simply modeling the hex and mapping the UVs in my 3d app and loading it.

I need a material on top, a second material on the top part of the sides, and a third material on the bottom part of the sides that repeats a texture.

JohnBrookes, I had to delete the top part of the Cylinder primitive because it used 6 polys when it only needed 4, plus its UVs were really messed up.

Thanks anyway guys!

 

   
   

X

Away3D Forum

Member Login

Username

Password

Remember_me



X