ObjectContainer3D Mesh, Geometry & Efficience

Software: Away3D 4.x

Suese, Newbie
Posted: 15 January 2013 07:16 AM   Total Posts: 6

I’m trying to generate and display a tile grid for my game.

My first attempt consists of creating an ObjectContainer3D and adding 64x64 meshes based off the same PlaneGeometry and a series of 4 different ColorMaterials

psuedo-code:

colour_materials[4] generate materials(...)
plane = new PlaneGeometry(...)

for (
x,z) = (0,0)-(64,64)
   
colour lookup_colour_material(x,y)
   
mesh = new meshplanecolour )
   
mesh.x
   mesh
.z
   mesh
.lookup_height(x,y)
   
add child mesh 

However this method goes excruciatingly slow at both start-up and render-time. 

What would be a better method for doing this with Away3D?

   

Dentaku, Newbie
Posted: 21 January 2013 06:57 PM   Total Posts: 8   [ # 1 ]

One optimization would be to clone the mesh, instead of creating a new one in the loop every time. I believe this will cause the geometry to batch, increasing render performance. (could be wrong though)

colour_materials[4] generate materials(...)
plane = new PlaneGeometry(...)

   
originalMesh = new meshplanecolour )

for (
x,z) = (0,0)-(64,64)
   
colour lookup_colour_material(x,y)
   
mesh originalMesh.clone() as Mesh;
   
mesh.x
   mesh
.z
   mesh
.lookup_height(x,y)
   
add child mesh 

You could also place all the tiles in a bitmap, and put that on a big plane. This would make it hard to edit tiles though, because you would have to modify and reupload the bitmap every time you change a tile. And there also is a size restriction for bitmap objects.

The best way would be to have a big plane with a tilesheet (all the tiles in a single image). And modify the UV coordinates to show different sections (tiles) of the tilesheet at different points of the plane.
Unfortunately I am struggeling with UV mapping in away3D myself, and cannot provide the technique to do this.

   
   

X

Away3D Forum

Member Login

Username

Password

Remember_me



X