Jump to content
  • Advertisement
Sign in to follow this  
Stowelly

Crystal Space - Mouse Movement

This topic is 5049 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

im trying to make objects selectable in my program, the crystal space manual shows you how to pick the object based on the camera and the co-ordinates of the mouse but i have no idea what function to call to get this, thanks alot (also if anyone knew the api references for input capture id be very greatfull)

Share this post


Link to post
Share on other sites
Advertisement
Here's a bit of our camera class that figures out what mesh is at the current mouse coords:


iCamera *psCamera::GetICamera()
{
return view->GetCamera();
}

iMeshWrapper* psCamera::FindMeshUnder2D(int x, int y)
{
if (!GetICamera())
return NULL;

csVector3 vc, vo, vw;

csVector2 perspective( x, GetICamera()->GetShiftY() * 2 - y );
GetICamera()->InvPerspective( perspective, 1, vc );
vw = GetICamera()->GetTransform().This2Other( vc );

iSector* sector = GetICamera()->GetSector();

if ( sector )
{
vo = GetICamera()->GetTransform().GetO2TTranslation();
csVector3 isect;
csVector3 end = vo + (vw-vo)*600;

iMeshWrapper* sel = sector->HitBeamPortals(vo, end, isect, NULL);
return sel;
}
return NULL;
}

Share this post


Link to post
Share on other sites
Ah if you want to capture input you need to create your own event handler and check for stuff like:


bool PawsManager::HandleEvent( iEvent &event )
{
switch ( event.Type )
{
case csevMouseMove: return HandleMouseMove( event );
case csevMouseDown: return HandleMouseDown( event );

case csevMouseUp : return HandleMouseUp( event );
}

//Mouse is at:
// event.Mouse.x, event.Mouse.y



Share this post


Link to post
Share on other sites
Quote:
Original post by Stowelly
thanks alot, are there any other sites apart from the actual crystal space one that are good for information about it


The CS-Main mailing list ( check for actualy address on Crystal's site ) is pretty active as well as the #crystalspace on irc.freenode.net

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!