Accessing vertices of a mesh in Away3D 4

Software: Away3D 4.x

Chris B, Newbie
Posted: 13 January 2012 02:23 PM   Total Posts: 4

Hi,

Once a Mesh has been created, is it possible to access the vertices that make up the mesh and modify them?

In Away3D 3.6, I would create an array that held the vertex data, I’d then create the mesh based on that data - I’d be able to modify the vertices afterwards and a re-render would update with the new vertex positions. In this way I could animate an actual mesh in real-time without having to have a pre-determined animation.

I can build my faces OK using the FaceHelper.addFace function, but then I can’t figure out how I can go back in and change the position of an individual vertex at a later point in execution. The only possibility I can see is to remove all the faces and re-add them again, but that seems like a long-winded (and probably inefficient) approach.

Thanks,

Chris.

   

Avatar
Fabrice Closier, Administrator
Posted: 13 January 2012 03:06 PM   Total Posts: 1265   [ # 1 ]

var vertices:Vector.<Number> = mesh.geometry.subGeometries[0].vertexData;
The vertices of the mesh subgeometry 0 (ordered as x,y,z,x,y,z,x,y,z)

if you have a big mesh(more than 65365 vertices), you have to loop over the SubGeometry objects

after your changes, you need to notify the subgeometry that something has changed.
mesh.geometry.subGeometries[0].updateVertexData(vertices);

   

Chris B, Newbie
Posted: 13 January 2012 03:18 PM   Total Posts: 4   [ # 2 ]

Thanks for the quick reply… but the mesh.geometry.geometries object doesn’t seem to exist? Compiler reports:

Access of possibly undefined property geometries through a reference with a static type away3d.core.base:Geometry.

I have the latest source from GitHub. Geometries.as doesn’t seem to have anything like that. Am I missing something?

Chris.

   

Chris B, Newbie
Posted: 13 January 2012 03:26 PM   Total Posts: 4   [ # 3 ]

... I found:

private var _subGeometries : Vector.<SubGeometry>;

In away3d.core.base.Geometry, so I exposed that as public and tried the above example again.. looks like it *should* work in theory, but doesn’t seem to be updating anything on-screen.

   

Avatar
Fabrice Closier, Administrator
Posted: 13 January 2012 03:31 PM   Total Posts: 1265   [ # 4 ]

Oops, sorry for the typo: subGeometries. Previous reply updated.

   

Chris B, Newbie
Posted: 13 January 2012 03:36 PM   Total Posts: 4   [ # 5 ]

haha! I managed to find _subGeometries, but not the more obvious subGeometries! Thanks, still not sure why I’m not seeing any actual update on-screen, but I think I’m getting there.

   

parele, Jr. Member
Posted: 12 March 2013 05:29 AM   Total Posts: 43   [ # 6 ]

i need help with this , i cant trace the mouse over my planes vertices

   
   

X

Away3D Forum

Member Login

Username

Password

Remember_me



X