CodeRecipe( );

one stop for all game coders..

Follow us on Twitter
Home >> FAQs >> Shockwave Faqs >> mouse in 3dWorld
Coderecipe Downloads

mouse in 3dWorld Print E-mail
User Rating: / 0
PoorBest 
Written by CR Team   
Saturday, 01 August 2009 08:27

How do you go about using mouse in 3d World ?

mouse

MoveCursor Xtra : Well one good spot to start looking for is the Move Cursor shockwave Xtra. This is a great help to get your cursor on sprite and 3d world aligned at the same point in the stage.

With the above xtra used. You can then make use of the following methods to move between the sprite and the 3d world:

1
2
3
4
5
6
--Get the location of the mouse using loc(locH,locV)
sprite("3dSprite").camera.spriteSpaceToWorldSpace(loc)

--similarly you can get the vector point in 3d world to the
-- sprite (x,z/y positions)
member("3d").camera("name").worldSpaceToSpriteSpace(vector)

ModelUnderLoc: Along with the above xtra you can also use the modelUnderLoc camera property to get the models in the direction vector w.r.t the 3d world camera.

1
2
3
4
5
6
7
--First model found in the ray shot from camera
member("3d").camera(#).modelUnderLoc(pointWithinSprite)
 
--List of all the models
member("3d").camera(#).modelsUnderLoc(ptWithinSprite,optionsList)
 
--look at the help doc for optionList parameters

 

If you want to speed up the process, try using the rayCastClosest() and rayCastAll() methods found within the physics engine. This will also allow you to sort rigidbodies/models by distance.