DIY Z Sorting SpriteSessions with MD2

Software: Away3D 3.x

FrankEnd, Newbie
Posted: 07 May 2013 04:06 PM   Total Posts: 9

Hello.

I am working on a roulette game and could really use some advice about z-sorting. (Away3D 3.6)

My scene is made up of the number wheel, 37 slot dividers and the ball. Due to the nature of the models and the animation, if I put them all in the same layer then loads of nasty intersecting happens which results in a bunch of missing triangle during the spin.

I think this is impossible to avoid so I have put the 3 components into their ownSession, which solves one problem, but obviously results in the ball being in front of the dividers all the time, which isn’t right.

I thought of changing the SpriteSession screenZ property on a timer or an onEnterFrame to ‘manually’ z-sort the ball and dividers - but don’t really know where to start. Is this a good idea or is there a better way? To make things more complex the ball animation is an MD2 import and I’m not sure how to get the z-position of the ball from this data.

A demo swf is attached.

Any advice would be warmly received!

Thanks.

 

File Attachments
RouletteDemo.swf  (File Size: 2045KB - Downloads: 211)
   

FrankEnd, Newbie
Posted: 08 May 2013 05:13 PM   Total Posts: 9   [ # 1 ]

Hello!

I ended up cheating and just making the slot dividers shorter - it looks better that way too. I also lightened the material. This now means that 99/100 times you can’t really tell that the ball in on a higher layer.

(sorry, file is now over 2mb so can’t attach)

Anyway, one thing that is bugging me is that the MD2 seems to import with everything mirrored. I fixed this in terms of rotational direction by removing the minus operator from the parseFrames function in the Md2 class: position.x = ((sx * md2.readUnsignedByte()) + tx) * scaling;

However, while this is ok for the motion, it still leaves something (perhaps the UV coords?) upside down, and you can see that the shadow on the shaded white ball material is the wrong way round (check the other attachment, it was also happening then).

Is there anything I can do to correct this?

   

FrankEnd, Newbie
Posted: 17 July 2013 12:09 PM   Total Posts: 9   [ # 2 ]

Just to say, in case it helps somebody, I solved the problem of the light being ‘upside down’ on my MD2 ball animation vs the Away3D sphere I use (I do half the animation with a sphere, then swap it out and play a pre-rendered MD2 for the bouncing/physics).

Just purely by chance I tried:

_ball = Md2.parse(Cast.bytearray( EmbeddedMD2 ));
_ball.geometry.invertFaces();

and it only worked first time!

Just love it when a complete guess pays off…

   
   

X

Away3D Forum

Member Login

Username

Password

Remember_me



X