This code allows a user to select a meshwrapper that they click on using the 
mouse.  It is very useful code.  The following code is above my head. Peter 
Amstutz wrote it for me back in 2003.

I have since updated to the latest version of CrystalSpace, Hitbeam is 
different, and I do not know how to update my code.

Here is the code:

    csVector3 v; 
    int FrameWidth, FrameHeight; 
  iGraphics2D* g2d = g3d->GetDriver2D (); 
  FrameWidth = g2d->GetWidth (); 
  FrameHeight = g2d->GetHeight (); 

//M.x = Mouse's coordinates x , M.y = Mouse's coordinates y
  csVector2 p (M.x, FrameHeight-M.y); 

/*This next line gives the error:  error: no matching function for call to 
‘iCamera::InvPerspective(csVector2&, int, csVector3&)’
*/
 view->GetCamera ()->InvPerspective (p, 1, v); 

  csVector3 vw = view->GetCamera ()->GetTransform ().This2Other (v); 
  iSector* sector = view->GetCamera ()->GetSector (); 
  csVector3 origin = view->GetCamera ()->GetTransform ().GetO2TTranslation (); 
  csVector3 isect; 

//Now for the old code that no longer works:
iPolygon3D **sel=NULL; 
iMeshWrapper *temp_wrap= sector->HitBeam (origin, origin + (vw-origin) * 20, 
isect,sel); 

----------------------------------------------------------------------------------------------
Here is another look at my code. I tried changing stuff by reading the docs and 
help from IRC, but I think I messed up stuff.



csVector3 v;
 
    int FrameWidth, FrameHeight;
 
  iGraphics2D* g2d = g3d->GetDriver2D ();
 
  FrameWidth = g2d->GetWidth ();
 
  FrameHeight = g2d->GetHeight ();
 
 
 
 
 
  csVector2 p (M.x, FrameHeight-M.y);
 
 
//OLD CODE  view->GetCamera ()->InvPerspective (p, 1, v);
//NEXT LINE = NEW CODE: Is this the problem?
  view->GetCamera ()->InvPerspective (p, 1.0);
 
  csVector3 vw = view->GetCamera ()->GetTransform ().This2Other (v);
 
  iSector* sector = view->GetCamera ()->GetSector ();
 
  csVector3 origin = view->GetCamera ()->GetTransform ().GetO2TTranslation ();
 
  csVector3 isect;
 
 
//OLD CODE iPolygon3D **sel=NULL;
 
//OLD CODE iMeshWrapper *temp_wrap= sector->HitBeam (origin, origin + 
(vw-origin) * 20, isect,sel);
 
//NEXT LINE = NEW CODE: Is this the problem?
iMeshWrapper *temp_wrap=sector->HitBeam(origin, 
origin+(vw-origin)*20,true).mesh;






       
-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
Crystal-main mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/crystal-main
Unsubscribe: mailto:[EMAIL PROTECTED]

Reply via email to