Crystal Space
Welcome, Guest. Please login or register.
July 30, 2014, 02:34:44 am

Login with username, password and session length
Search:     Advanced search
9005 Posts in 2043 Topics by 8255 Members
Latest Member: Mslenacarleen0303
* Home Help Search Login Register
+  Crystal Space
|-+  Associate Projects
| |-+  CEL Discussion
| | |-+  CEL Mouselook - 1st Person
« previous next »
Pages: [1] Print
Author Topic: CEL Mouselook - 1st Person  (Read 3431 times)
bernardofd
Jr. Member
**
Posts: 74


59948732 bernardofd@click21.com.br
View Profile WWW
« on: January 30, 2006, 05:34:28 pm »

Hello;

It's been a while I've trying to implement mouselook in CEL. I took the code made by muffinpeddler (http://community.crystalspace3d.org/forum/index.php/topic,335.0.html) with some changes. It worked, but I didn't like the movement of the screen when I moved the mouse. I mean, I don't know how to explain it right but, it seems that the camera rotation it's accelerated. I want that the camera rotates with constant velocity, and only move to an certain angle correspondent at the offset of the mouse pointer to the center (as I did in my code without CEL).

I mean, muffinpeddler's code's rotation is based in the velocity of the mouse movement in a frame space. I want that my rotation is based by how much the mouse moved in a frame space, so, what a want is how to get the offset through celData structure...

Is this possible?

Greetings;
« Last Edit: January 30, 2006, 05:37:39 pm by bernardofd » Logged

__________________________
Bernardo Figuerêdo Domingues
Computer Science - UFMG - Brazil
allpowerful32
Jr. Member
**
Posts: 62


View Profile
« Reply #1 on: February 03, 2006, 03:03:44 am »

Of course its possible.  without more information, however, I can't comment on the dificulty of the coding and or changes.
Logged
Dr_Ompaa
Newbie
*
Posts: 4


142382436
View Profile WWW
« Reply #2 on: February 05, 2006, 11:01:42 pm »

Hm ... constant velocity could maybe be achieved like

Fetch Some StringID ...
Code:
id_paramvalue = pl->FetchStringID ("cel.parameter.value");


"camera_rotate" is bound to "mousex_centered"
Code:
pcinput->Bind ("mousex_centered", "camera_rotate");


If the mouse moves away from the center the offset is a float you can get as shown below
(The code comes into the SendMessage Function of your Behaviour Type of course)

Code:
  else if (msg_id == id_pccommandinput_camera_rotate)
  {
    if(params->GetParameter(id_paramvalue)->value.f > 0)
    {
      pccamera->MoveYaw(0.0175f);
    }
    else if(params->GetParameter(id_paramvalue)->value.f < 0)
    {
      pccamera->MoveYaw(-0.0175f);
    }
  }

So the idea is that if the offset of the mouse to the center is positive we rotate into one direction with constant velocity and the other way round.

Hope this helps somehow ... or is at least understandable Wink

to see the code in action you can get the oOC code
Code:
cvs -d:pserver:anonymous@cvs.sf.net:/cvsroot/ocmod checkout ooc

our solution to this problem can be found in src/ooc.cpp and src/behaviour/be_player.cpp
Logged

oOC Project: Coding Leader
visit www.openoutcast.de
muffinpeddler
Full Member
***
Posts: 122


View Profile Email
« Reply #3 on: February 06, 2006, 09:25:11 pm »

I don't believe the MoveYaw function on the default camera works...That's the problem I was having, as it would be much easier to use these functions, but the yaw seems to be constrained to the camera mode.
Logged
Dr_Ompaa
Newbie
*
Posts: 4


142382436
View Profile WWW
« Reply #4 on: February 06, 2006, 09:48:19 pm »

well at least in Freelook mode the Yaw of the camera is independent from the character

Code:
void CAFreeLook::DoCameraCalculations (const csTicks elapsedTicks,
  const csVector3& actor_pos, const csVector3& actor_eye,
  const float actor_yrot)
{
  parent->SetTarget (actor_eye);
  parent->EnsureCameraDistance ();
  parent->CalculatePositionFromYawPitchRoll ();
}

By commenting out some line you can unlink Camera Yaw from the player in other modes as well
Code:
void CAThirdPerson::DoCameraCalculations (const csTicks elapsedTicks,
  const csVector3& actor_pos, const csVector3& actor_eye,
  const float actor_yrot)
{
  parent->SetTarget (actor_eye);
  // Comment out line below
  // parent->SetYaw (actor_yrot);
  parent->CalculatePositionFromYawPitchRoll ();
}

so this parent->SetYaw (actor_yrot); connects the camera with the player mesh why MoveYaw doesn't work on all modes

(all things referring to cel/plugins/propclass/defcam/defcam.cpp)
« Last Edit: February 06, 2006, 09:50:48 pm by Dr_Ompaa » Logged

oOC Project: Coding Leader
visit www.openoutcast.de
Pages: [1] Print 
« previous next »
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.2 | SMF © 2006-2007, Simple Machines LLC Valid XHTML 1.0! Valid CSS!
Page created in 7.233 seconds with 15 queries.