Search Home Members Contacts
About Us
Products
Downloads
Community
Support
Pages: [1]
  Print  
Author Topic: A08 - A complete Landscape C# mesh rotation help!  (Read 653 times)
jimmer24
Community Member
*
Posts: 2


« on: January 23, 2008, 07:47:02 PM »

Hi all.  Im just tryin to rotate a mesh centerd on my viewpoint.  Is ATan2 the right way to do this?  im not that good at math so i guess its basicly a math question.  Any help?


   // Update the vectors using the angles and positions.
   sngPositionX = sngPositionX + (float)(System.Math.Cos((double)sngAngleY) * sngWalk / 5 * TV8.TimeElapsed()) + (float)(System.Math.Cos((double)sngAngleY + 3.141596 / 2) * sngStrafe / 5 * TV8.TimeElapsed());
   sngPositionZ = sngPositionZ + (float)(System.Math.Sin((double)sngAngleY) * sngWalk / 5 * TV8.TimeElapsed()) + (float)(System.Math.Sin((double)sngAngleY + 3.141596 / 2) * sngStrafe / 5 * TV8.TimeElapsed());
     
   // New : because we are using a landscape with up and down, we
   // can't let the camera at the same height. We want the camera to
   // follow the height of the map, so we use the "get height". Also,
   // because we want to have the effect that we are not a mouse,
   // we will add some height to the height returned...
         sngPositionY = Land.GetHeight(sngPositionX, sngPositionZ) + 10;
       
   // We update the look at position.
   snglookatX = sngPositionX + (float)System.Math.Cos((double)sngAngleY);
   snglookatY = sngPositionY + (float)System.Math.Tan((double)sngAngleX);
   snglookatZ = sngPositionZ + (float)System.Math.Sin((double)sngAngleY);

   // With the new values of the camera vectors (position and
   // look at), we update the scene's camera.
   Scene.SetCamera (sngPositionX, sngPositionY, sngPositionZ, snglookatX, snglookatY, snglookatZ);


>>   //put a mesh where im standing
>>        mesh.SetPosition(sngPositionX, sngPositionY , sngPositionZ);
>>   //find angle???
>>       xangle = tvmath.ATan2(sngPositionX - snglookatX, snglookatY - sngPositionY) * 180                        / tvmath.PI_;
>>   //rotate
>>      mesh.SetRotation((float)xangel, 0, 0);
     }


Jim
Logged
vsleepy
Customers
Community Member
*****
Posts: 245


« Reply #1 on: January 25, 2008, 11:35:13 PM »

do you actually want to rotate the landscape, or do you want to rotate the camera around the landscape?
Logged
jimmer24
Community Member
*
Posts: 2


« Reply #2 on: January 31, 2008, 04:52:14 PM »

Hi vsleepy.  Thx for responding.  Sry it took so long to reply.

I just want to rotate a mesh to the same direction Im facing.  If I look up, the mesh rotates up in sync with me. If I turn the mesh turns with me. The mesh can either be centered at my postion.. or translated somewhere else(sorta like a remote gun turrent).  Its not for a game, so much as it is just to learn the math so I can apply it to whatever I decide to do. Thx
Logged
Pages: [1]
  Print  
 
Jump to:  

Powered by SMF 1.1.3 | SMF © 2006-2007, Simple Machines LLC
Seo4Smf v0.2 © Webmaster's Talks