How to create (and ideally animate) a custom mesh?

Software: Away3D 4.x

jcward, Newbie
Posted: 21 October 2013 10:34 PM   Total Posts: 2

Hi all,

I can’t find any example code for creating a custom mesh (programmatically, i.e. just a surface or Object composed of triangles I specify in code.)  I want to generate objects or landscape programmatically, and the second step (after creating a custom mesh) would be to animate it, perhaps changing the triangles or vertices on an ENTER_FRAME listener.

I posted a Stackoverflow question with a few more details.  Feel free to answer there or here, whatever you like.

Thanks,
-Jeff

   

Lexcuk, Newbie
Posted: 22 October 2013 07:58 PM   Total Posts: 17   [ # 1 ]

This is cube

//http://swf-flash.blogspot.com/2013/04/understanding-3d-animation-of-cube.html
public function makeContainer(posX:Number,  posY:Number):ObjectContainer3D {
      
var con:ObjectContainer3D = new ObjectContainer3D();
      var 
c3:ObjectContainer3D = new ObjectContainer3D();
      var 
geometry:Geometry = new Geometry();
      var 
subGeometry:SubGeometry = new SubGeometry();
      var 
s:Number 100;
      var 
vertexData:Vector.<Number> = Vector.<Number>([sssss, -s
      -
ss, -ssss, -ss, -s, -sss, -s, -s, -s, -s, -ss, -s
      
ss, -s, -s, -s, -sss, -ss, -ss, -s, -ss, -ss, -s, -s
      -
ss, -ss, -s, -ss, -s, -s, -sss, -sssss, -s, -s
      
ssss, -sss, -s, -ssss, -ssss, -ss, -sss
      -
s, -sss, -ssss, -ss, -s, -s, -s, -s, -sss, -s, -s
      -
s, -s, -ss, -s]);
      var 
uvData:Vector.<Number> = Vector.<Number>([00.530.5
      
3100.5310130.5
      
30.53130.531313
      
03030.53030.530.530.5
      
10.53110.51131301030.5
      
1010.52/30.5001/301/30.5001/30.500.5]);
      var 
indexData:Vector.<uint> = new Vector.<uint>();
      for (var 
i:int 036i++) indexData.push(i);
      
      
      
subGeometry.updateVertexData(vertexData);
      
      
subGeometry.updateUVData(uvData);
      
      
subGeometry.updateIndexData(indexData);
      
      
subGeometry.autoDeriveVertexNormals true;
      
      
subGeometry.autoDeriveVertexTangents true;
      
      
geometry.subGeometries.push(subGeometry);
      
      var 
cM:Mesh = new Mesh(geometryblaMaterial);
      
      
c3.addChild(cM);
      
      
con.addChild(c3);       con.positi Vector3D(posX0posY);
      return 
con;
   
   

jcward, Newbie
Posted: 22 October 2013 08:49 PM   Total Posts: 2   [ # 2 ]

Thanks for your response!  I found another example in this forum.

And looking at the source code in src/away3d/primitives, I see that all of these are, in fact, examples of creating meshes using Geometry and SubGeometry.

I’ll play with this info, and see about animating vertex changes.  It seems like there are many ways to do it, from transforming entire meshes or geometries to writing vertex shaders.

What a big, fascinating world this GPU-centric system is.

   
   

X

Away3D Forum

Member Login

Username

Password

Remember_me



X