0

I'm going to make a tile-based 3D RPG game in Flash AS3 with Away3D API.

my problem is that i dont really understand the away3d api so far..

I want to make a "blocks" class. if i load the tile-map-data, i want to make something like this:

viewport.addchild( tileArray[ layer ][ x ][ y ] );

so this would be in a loop.

so far so good, but this would have to be a 3dObject.

to fill that array with that 3dObject i want to make something like this.

tileArray[ layer ][ x ][ y ] = myBlocksClass.getBlock( "grassCube" );

so the getBlock functon in myBlocksClass sould return me a 3dObject.

<edit>

those blocks should be some sort of blocks like in minecraft ( grassCube, dirtCube,... ) so i want to load multiple instances of one block in a map

</edit>

how can i do this ? does anyone can give me any idea or maybe a reference ?

and YES i've allready looked in all awaylable resources / documentarys / examples, but i could't figute it out anyway.

UPDATE:

the question is more to code. i know the theory, but actionscript3 for game dev is nearly new to me.

how to structure the class for the "blocks" ?

Ace
  • 1,437
  • 6
  • 28
  • 46

1 Answers1

1

Most of 3D applications actually are tile based. For example popular terrain implementation is set of chunks with hight resolution mash for close range and low for far. Those chunks(and every objects in scene) are organised in scene graph. normally its octree. Octree terrain

Allso there is frustum culling

And engine renders only those nodes that are partially(or totally) inside View pyramid.

Here is Away3D realisation

Case-specific optimisation allso very important but very tricky. For example terrain mesh vertices order and chunk size optimised for GPU chace hits and could be GPU specific (build for specific client) and in the same time related to amount of textures and shading (you do not want to swap materials if you do not need so it good idea to render chunks with same material one by one then swap material) Or if you have let's say 1000 textured cubes you need only one model that will be drawn 1000 times with different materials. It's good for GPU memory but its like 10000 draw calls and could hurt your performance badly. So you may want to weld them to bigger objects that fits nicely in octree nodes and have combined textures. But you obviously want to discard those cubes that are underground and can't be seen.

JAre
  • 4,666
  • 3
  • 27
  • 45
  • 1
    yeah well explained , but i know all that stuff. ^^ my questin was more tp the code. so in c# ( d3d, xna, opengl ) i would just make a list, and in the class i would define the mesh, position, material and so on. but i dont know how i could make this in actionscript3. i've tryed to make a 2d array that holds my custom class, where i was just havin a planeGeometry. but i doesnt really work. also i dont know how i can make INSTANCES in as3 to prevent memory issues as you've written... – Ace Nov 15 '12 at 12:47