Away3D Coords to 2D Coords

Software: Away3D 4.x

Marc Abbink, Newbie
Posted: 22 August 2012 09:51 AM   Total Posts: 2

Hi guys,

I am using Away3D 4.0 for my new project and I don’t have a lot of experience with it yet.

I want to make a shooter game with a 3D gun, so I imported a max file using your tutorial with awd files (works like a charm).

Then I used your Starling, Away3D, Starling layer tutorial to make the right layers in one Stage3D instance. Also works fine.

Then I wanted to do the movement of the gun, so I placed the gun inside a container which is inside of another container (away3D containers). Until so far, no problem.

But than I wanted to make some gun smoke once you have shot. So I need to know the position of the end of the gun in 2D coords. I placed a simple cube on that position, so I can try to track that position.

Then I looked on the internet for all kinds of solutions, but none works for me. Does anyone here has a clue of what to do?

Cheers,
Marc from Holland

   

Richard Olsson, Administrator
Posted: 22 August 2012 01:46 PM   Total Posts: 1192   [ # 1 ]

Just use the project() method of your camera to project the scenePosition of your cube (or whatever you have at the end of the gun’s barrel.) The X and Y components of the returned vector will be the screen position.

screenPos myView.camera.project(myCube.scenePosition); 
   
   

X

Away3D Forum

Member Login

Username

Password

Remember_me



X