multi threading : draw cubes while.  . .

Software: Away3D 4.x

Babylon, Jr. Member
Posted: 10 September 2012 06:19 PM   Total Posts: 39

Hey,
to my understanding actionscript doesn’t do multi threading? I was wondering if there was some type of work around.

Id like to move a character around and while he is moving around, it draws objects pretty continuously (world generation) so that as he walks, the objects he gets far away from disappear, and it begins rendering objects ahead of him to be ready by the time he gets there.

Any ideas?

Thanks,
B

   

Avatar
80prozent, Sr. Member
Posted: 10 September 2012 06:33 PM   Total Posts: 430   [ # 1 ]

hi babylon

i recently played arround with the new worker classes (flash 11.4) and away3d 4.

in short, a workerclass is a swf, loadet into a second instance of the flashplayerplugin. it runs in the background, and communicates with your main swf.

i used it to calculate lots of geometry-data and than update the data when finished.

see here to get started:

http://esdot.ca/site/2012/intro-to-as3-workers-part-3-nape-physics-starling

hope that helps

 

 Signature 

sorry…i hope my actionscript is better than my english…

   

Avatar
Alexander Seifert, Moderator
Posted: 11 September 2012 07:58 PM   Total Posts: 129   [ # 2 ]

Threads are not going to be supported on mobile devices (via AIR) for the time being. That renders it pretty much useless for cross-platform development.

Are you going to stay browser-only? If so, probably the best way to go =) However, keep in mind that you need to take backwards compatibility into account. Not everyone will have the newest version of Flash Player install and thus won’t support Threads.

What are your intentions?
Cheers!
Alex

 

 Signature 
signature_image

http://www.deltastrike.org

   

Babylon, Jr. Member
Posted: 13 September 2012 05:30 AM   Total Posts: 39   [ # 3 ]

Hey guys,

Sorry for the late replay. As this is a Independent Project for school I wouldn’t mind staying with non-platform strictly new flash players. But I also don’t want to take the easy way out.

I’ve been spending so much time trying to make my own 3D game (with zero knowledge of 3D programming) that I find my self so swamped.

What I’m trying to do:
I generate a world made of cubes (like mine craft) and the user can walk around and ‘harvest’ the cubes and replace them as they please.

When the user walks farther into the world, I need the world to render with him. At the same time I need to un-render what he is too far away from. Since it will need to render a LOT of cubes every step the user takes in a specific direction, I was thinking of a way to do it in real time.

My system right now is kind of funny. I generate a terrain with the terrain function (which might be away physics) and I use the getheightmap function to store the y axis.

I cycle through my 3-D array and draw cubes using the y-axis data from the terrain map. I then merge my many cubes into 1 ‘world’ object.

In order to keep mouse interaction on a per-cube basis, I figure my character will only need to be able to click on maybe the first 30 cubes near him. So I create 30 cubes that mimic the size, location and texture of the cubes merged into the ‘world’ object, and just re-use these temporary 30 cubes as I walk around, or harvest cubes up. So in reality I’m causing 31 objects to be drawn to the screen.

So when you click a temporary cube to harvest it I set the vertexdata corresponding to my cube in the world object to null (if this really deletes properly I don’t know).
ex:

FinalMesh.geometry.subGeometries[1].vertexData[i*3] null;
FinalMesh.geometry.subGeometries[1].vertexData[(i*3)+1] null;
FinalMesh.geometry.subGeometries[1].vertexData[(i*3)+2] null

So when I walk around, having something draw the cubes without locking ujp everything else would be a big help.

Any ideas on my system/threading?

I am in a situation that I don’t know the best way to do things since I don’t really know 3D programming at all (it’s like starting computer programming from scratch).

I attached a pic for visual concept..


Thanks,
WB

 

 

   

Avatar
80prozent, Sr. Member
Posted: 13 September 2012 06:43 AM   Total Posts: 430   [ # 4 ]

hi
i do not have to many experience with something like this either, but here are my thoughs:

merge all your cubes into a big mesh. store the start index for each cubes triangle and verticle index, so you can access individual cubes inside the big mesh buffers.

what you trying to do (only mouseevents on surrounding cubes) looks like a good option at first glance, but you would still have to create some referencing logic between your mouseenabled cubes and the cubes in the big mesh.

i believe the best way to do this is to listen for mouseevent on the big mesh.
this way you will get the sceneposition-vector3d where the event took place.

using this vector3d you should be able to calculate (compare) on which original cube the event took place. if you know which cube you know which verticles of the big mesh you need to update.

i assume finding the original cube using the vector3d is the part where a octree could help, but this far i never used them.

if you are that far and you experience major fps drops, you can implement a worker, for using the multithreading.
my first impression about workers are that they process data not only while keeping your application running at normal speed, but that they seam to process it faster too.

hope that helps

 

 Signature 

sorry…i hope my actionscript is better than my english…

   
   

X

Away3D Forum

Member Login

Username

Password

Remember_me



X