About Store Forum Documentation Contact
Donations:
140$/mo



Post Reply 
camera.setSpherical rotation limit
Author Message
eric99 Offline
Member

Post: #1
camera.setSpherical rotation limit
Hi,

I use VIEW_TPP camera mode and i can't override the +/-180 degrees limit of the plr.angle.y parameter (there is no such limitation for the angle.x).

Here is the line code
Cam.setSpherical(plr.ctrl_pos+Vec(0,1,0),plr.angle.x,plr.angle.y,0,Cam.dist*Scal​eFactor(Ms.wheel()*-0.2));

Could you help me ?

thks.
07-17-2010 10:54 PM
Find all posts by this user Quote this message in a reply
Dampire Offline
Member

Post: #2
RE: camera.setSpherical rotation limit
This is my old code. I wrote it 1 year ago.

Code:
Cam.yaw  -=Ms.ds.x; // update camera yaw   angle according to mouse smooth delta x
Cam.pitch+=Ms.ds.y; // update camera pitch angle according to mouse smooth delta y
Clamp(Cam.pitch,Players[0].cskel.getPoint("head").dir.y-PI_4,Players[0].cskel.getPoint("head").dir.y + PI_2); // clamp to possible camera pitch angle
Clamp(Cam.yaw, Players[0].angle.x-PI_2,Players[0].angle.x+PI_2); //clamp to possible camera yaw angle
Cam.setSpherical(Players[0].cskel.getPoint("head").pos,Cam.yaw, Cam.pitch, 0, 5);

You just need to replace PI_4, PI_2, etc with your limits.
(This post was last modified: 07-18-2010 09:23 AM by Dampire.)
07-18-2010 09:22 AM
Find all posts by this user Quote this message in a reply
eric99 Offline
Member

Post: #3
RE: camera.setSpherical rotation limit
That's OK, i found the clamping line in the Camera Modes tutorial :
Clamp(Cam.pitch,-PI_2,0); // clamp to possible camera pitch angle

In fact, I tried to modify Bloody Massacre but I can't see anything in the source code though the pitch is limited to +/-PI in the TPP mode.
07-18-2010 01:47 PM
Find all posts by this user Quote this message in a reply
eric99 Offline
Member

Post: #4
RE: camera.setSpherical rotation limit
OK solved
I finally solved the problem :
You must write the angle definition in your player.h to have totally freedom in camera rotation.

Code:
/******************************************************************************/
struct SpacePlayer : Chr
{
   Vec2 angle;
.
.
.
}

May be, there is a default clamping limit for angle.y in the engine itself ?
07-18-2010 10:24 PM
Find all posts by this user Quote this message in a reply
Esenthel Offline
Administrator

Post: #5
RE: camera.setSpherical rotation limit
for Game::Chr it is possible that angle.y may get clamped to -PI_2 .. PI_2
07-19-2010 12:11 PM
Find all posts by this user Quote this message in a reply
eric99 Offline
Member

Post: #6
RE: camera.setSpherical rotation limit
Sorry but...

My redefinition of Chr::Player angle has some indesirable effects :
The player movement don't care of the angle's value anymore.
Is there a better way to do ?

Maybe the clamp limit could be disabled when the player is in flying mode ?
07-20-2010 12:54 AM
Find all posts by this user Quote this message in a reply
eric99 Offline
Member

Post: #7
RE: camera.setSpherical rotation limit
Finally, I've got a correct solution with :

Code:
input.diri.z = 0;
      Cam.yaw  -=Ms.dir_d.x; // update camera yaw   angle according to mouse smooth delta x
      Cam.pitch+=Ms.dir_d.y; // update camera pitch angle according to mouse smooth delta y
          Int d  = Kb.b(KB_W)-Kb.b(KB_S);
      Flt dx = -d*Sin(Cam.yaw)*Cos(Cam.pitch);
      Flt dy = d*Sin(Cam.pitch);
      Flt dz = d*Cos(Cam.yaw)*Cos(Cam.pitch);


      plr.pos(Vec(plr.pos().x+ dx,plr.pos().y+dy,plr.pos().z+dz)); // update player position
     Cam.dist=Max(1.0f,Cam.dist*ScaleFactor(Ms.wheel()*-0.1));
     Cam.setSpherical(plr.pos(),plr.angle2.x,plr.angle2.y,0,Cam.dist);
07-28-2010 10:23 PM
Find all posts by this user Quote this message in a reply
Post Reply