Crystal Space
Welcome, Guest. Please login or register.
April 21, 2014, 09:17:02 am

Login with username, password and session length
Search:     Advanced search
8990 Posts in 2037 Topics by 7601 Members
Latest Member: Ariel1eeschimize
* Home Help Search Login Register
+  Crystal Space
|-+  Crystal Space Development
| |-+  Support
| | |-+  Problem about Camera and his movement ( local and world )
« previous next »
Pages: [1] Print
Author Topic: Problem about Camera and his movement ( local and world )  (Read 2788 times)
ArKangeL
Newbie
*
Posts: 11


View Profile
« on: September 27, 2005, 05:48:36 pm »

Hi all

Now i have a little application that can write and move arround with a freelook mouse movement... yuhuuuuu Smiley

But now im interested in one question about camera and his movment, i see that my camera are moving with a local vector movement because he always move forward in the direction he look at, its like a flying type of movement, but if i want to do some type of 'human' movement like in any FPS game, what can i change in this code:

Code:
// In framesetup function

...

if (kbd->GetKeyState (CSKEY_UP))
{
c->Move (CS_VEC_FORWARD * 4 * speed);
}

...

 csMatrix3 rot = csXRotMatrix3 (rotX) * csYRotMatrix3 (rotY);
  csOrthoTransform ot (rot, c->GetTransform().GetOrigin ());
  c->SetTransform (ot);

As you can see, the last transformation its like a local transformation to the camera, so what can i change to make movement ( Forward, Backward, strafe.... ) like a FPS, i dont know if i explain it clearly, im trying to make a movement that camera strafe, move forward, move backward but without moving in local mode, i think that implementing a collision sistem will avoid the problem but, first i need to learn who to do this movement to optimize later.

Thx in advance Devteam

See you

ARKANGEL

Edit: Now i have this aproximation of the code:

Code:
  iCamera* c = view->GetCamera();

if (kbd->GetKeyState (CSKEY_RIGHT))
{
csYRotMatrix3 cXM3((2*PI)-rotY);
cV3 = cXM3 * cV3;
c->MoveWorld (cV3 * 4 * speed);
}
else if (kbd->GetKeyState (CSKEY_LEFT))
{
csYRotMatrix3 cXM3((PI)-rotY);
cV3 = cXM3 * cV3;
c->MoveWorld (cV3 * 4 * speed);
}
if (kbd->GetKeyState (CSKEY_UP))
{
csYRotMatrix3 cXM3((PI/2)-rotY);
cV3 = cXM3 * cV3;
c->MoveWorld (cV3 * 4 * speed);
}
else if (kbd->GetKeyState (CSKEY_DOWN))
{
csYRotMatrix3 cXM3((3*(PI/2))-rotY);
cV3 = cXM3 * cV3;
c->MoveWorld (cV3 * 4 * speed);
}


This is not the final code, iit have a little bug while you press forward_key at the same time you press strafe_key, but anyway, know you a better way to do this ?

Thx in advance
« Last Edit: September 28, 2005, 03:20:43 pm by ArKangeL » Logged
ArKangeL
Newbie
*
Posts: 11


View Profile
« Reply #1 on: September 28, 2005, 05:07:07 pm »

Hi

See my edit note please

ARKANGEL
Logged
jorrit
Administrator
Hero Member
*****
Posts: 1704


View Profile
« Reply #2 on: September 29, 2005, 05:31:43 am »

Hmm... I'm a bit confused by your question. What exactly is the problem with the MoveWorld() solution?

Greetings,
Logged
ArKangeL
Newbie
*
Posts: 11


View Profile
« Reply #3 on: September 29, 2005, 09:57:52 am »

Hi

Well, first of all, im not english, so my english may be poor.

About the 'movement world' i think the problem is solved now, i use this code to do a FPS movement type:

Code:

iCamera* c = view->GetCamera();
[b]csVector3 cV3(1.0f, 0.0f, 0.0f);[/b]


if (kbd->GetKeyState (CSKEY_RIGHT))
{
   csYRotMatrix3 cXM3((2*PI)-rotY);
   cV3 = cXM3 * cV3;
   c->MoveWorld (cV3 * 4 * speed);
}
else if (kbd->GetKeyState (CSKEY_LEFT))
{
   csYRotMatrix3 cXM3((PI)-rotY);
   cV3 = cXM3 * cV3;
   c->MoveWorld (cV3 * 4 * speed);
}

[b]cV3.Set(1.0f, 0.0f, 0.0f);[/b]

if (kbd->GetKeyState (CSKEY_UP))
{
   csYRotMatrix3 cXM3((PI/2)-rotY);
   cV3 = cXM3 * cV3;
   c->MoveWorld (cV3 * 4 * speed);
}
else if (kbd->GetKeyState (CSKEY_DOWN))
{
   csYRotMatrix3 cXM3((3*(PI/2))-rotY);
   cV3 = cXM3 * cV3;
   c->MoveWorld (cV3 * 4 * speed);
}
 

Now i want to known if there is another way to make this type of movement more efficiently

Thx in advance

ARKANGEL
Logged
jorrit
Administrator
Hero Member
*****
Posts: 1704


View Profile
« Reply #4 on: September 29, 2005, 10:05:17 am »

Why are you worried about efficiency there? Why do you think it wouldn't be efficient?

Greetings,
Logged
ArKangeL
Newbie
*
Posts: 11


View Profile
« Reply #5 on: September 29, 2005, 12:32:03 pm »

Hi

Im worried because the movement that i coded only moves at same Z, or in other words, you can only move in X Y plane ( i think ), so, whats happen if i want to walk over a non uniform terrain like a bumped floor or other type of surface ? I need to implement a collision system ? It need to i re-do the movement code ?

Thx for all

ARKANGEL
Logged
jorrit
Administrator
Hero Member
*****
Posts: 1704


View Profile
« Reply #6 on: September 29, 2005, 12:45:50 pm »

Hi

Im worried because the movement that i coded only moves at same Z, or in other words, you can only move in X Y plane ( i think ), so, whats happen if i want to walk over a non uniform terrain like a bumped floor or other type of surface ? I need to implement a collision system ? It need to i re-do the movement code ?

Thx for all

ARKANGEL

Why not use csColliderActor class? That one will handle all this automatically for you. Walktest also uses that. It is very easy to use and it is documented.

Greetings,
Logged
ArKangeL
Newbie
*
Posts: 11


View Profile
« Reply #7 on: September 29, 2005, 01:55:45 pm »

Hi

I will try it soon, first im undestanding the basics of movement in this engine, so in a little time i will check csCollider and i will do some test with it.

P.D: The documentation of the csCollider is on the CS manual or in the API manual ??

Thx for all

ARKANGEL
Logged
jorrit
Administrator
Hero Member
*****
Posts: 1704


View Profile
« Reply #8 on: September 29, 2005, 01:58:15 pm »

Hi

I will try it soon, first im undestanding the basics of movement in this engine, so in a little time i will check csCollider and i will do some test with it.

P.D: The documentation of the csCollider is on the CS manual or in the API manual ??

Thx for all

ARKANGEL

I mean csColliderActor. Not csCollider. And it is documented in both the API and user manual.

Greetings,
Logged
sunshine
Administrator
Sr. Member
*****
Posts: 294


View Profile
« Reply #9 on: September 29, 2005, 04:50:26 pm »

The online documentation (both user and api manuals) is now searchable, so you should be able to find this in both locations.
Logged
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 5.283 seconds with 15 queries.