Crystal Space
Welcome,
Guest
. Please
login
or
register
.
May 24, 2013, 06:36:26 am
1 Hour
1 Day
1 Week
1 Month
Forever
Login with username, password and session length
Search:
Advanced search
9224
Posts in
2230
Topics by
5386
Members
Latest Member:
Salamutuu
Crystal Space
Crystal Space Development
General Crystal Space Discussion
Orientation vector
« previous
next »
Pages:
[
1
]
Author
Topic: Orientation vector (Read 3945 times)
koocake
Jr. Member
Posts: 54
Orientation vector
«
on:
April 28, 2006, 11:46:59 pm »
Hi there,
I want to know how I can get the vector which points in the direction that an object is pointing, so that
I can apply a force in that direction.
I have tried :
car->GetTransform()*CS_VEC_FORWARD;
and
car->GetOrientation()*CS_VEC_FORWARD;
and
car->GetTransform().Other2This(CS_VEC_FORWARD);
but none of these seem to work, the force seems to be applied along the world axes, not in the direction that the car faces!
can you help?
regards, Kate Mallichan
Logged
jorrit
Administrator
Hero Member
Posts: 1703
Re: Orientation vector
«
Reply #1 on:
April 30, 2006, 09:30:17 pm »
Quote from: koocake on April 28, 2006, 11:46:59 pm
Hi there,
I want to know how I can get the vector which points in the direction that an object is pointing, so that
I can apply a force in that direction.
I have tried :
car->GetTransform()*CS_VEC_FORWARD;
and
car->GetOrientation()*CS_VEC_FORWARD;
and
car->GetTransform().Other2This(CS_VEC_FORWARD);
but none of these seem to work, the force seems to be applied along the world axes, not in the direction that the car faces!
can you help?
regards, Kate Mallichan
I need to see a bit more code. How exactly are you using that vector?
Greetings,
Logged
koocake
Jr. Member
Posts: 54
Re: Orientation vector
«
Reply #2 on:
May 01, 2006, 01:12:34 pm »
I am applying the force as follows:
car->AddForce(vector*force);
I have also tried car->AddRelForce(vector*force);
but the car either moves in funny directions, or towards the axes.
regards, Kate
Logged
jorrit
Administrator
Hero Member
Posts: 1703
Re: Orientation vector
«
Reply #3 on:
May 01, 2006, 03:26:55 pm »
The functions AddForce() is in world space and AddRelForce() is in local space. So AddRelForce() should work. What do you mean by 'funny' directions? Also perhaps show me the exact code you're using.
Greetings,
Logged
koocake
Jr. Member
Posts: 54
Re: Orientation vector
«
Reply #4 on:
May 01, 2006, 03:40:48 pm »
I am using the following code:
car->AddRelForce(CS_VEC_FORWARD*acceleration_force);
car->Update();
The problem is that the force seems to be applied along the nearest world axis, so that the car veers towards the axes
when it is supposed to be moving forwards in the direction is is pointing. I think I may have to do something with car->GetOrientation() but I am not sure what. I would appreciate any help you can give as this is becoming an urgent situation with a project deadline coming up!
thankyou for your help,
Kate Mallichan
Logged
jorrit
Administrator
Hero Member
Posts: 1703
Re: Orientation vector
«
Reply #5 on:
May 01, 2006, 08:14:21 pm »
How is the force vector calculated? I don't have sufficient information to really know what is going on here.
Greetings,
Logged
koocake
Jr. Member
Posts: 54
Re: Orientation vector
«
Reply #6 on:
May 01, 2006, 08:25:52 pm »
the force is simply an int value, not a vector. is this where i am going wrong?
Logged
jorrit
Administrator
Hero Member
Posts: 1703
Re: Orientation vector
«
Reply #7 on:
May 01, 2006, 09:01:13 pm »
Quote from: koocake on May 01, 2006, 08:25:52 pm
the force is simply an int value, not a vector. is this where i am going wrong?
Hmm... Perhaps you should at least make it a float. An int sounds a bit weird. Otherwise I have no clue without seeing more code.
Greetings,
Logged
Lak Moore
Guest
Re: Orientation vector
«
Reply #8 on:
May 17, 2006, 07:41:53 pm »
Is this what you are after?
Code:
csVector3 currPos;
float yRot;
iSector* sector;
csRef<iPcLinearMovement> lm = celQueryPropertyClassEntity<iPcLinearMovement> (entity);
lm->GetLastPosition(current, yRot, sector);
csVector3 delta(0);
theta = yRot + PI;
cosTH = cos(theta);
sinTH = sin(theta);
//rotate delta by yRot
delta.x = cosTH + sinTH;
delta.z = -sinTH + cosTH;
delta = delta.Unit() * FORCE //FORCE is your force and it can be an int if you want
Logged
Pages:
[
1
]
« previous
next »
Jump to:
Please select a destination:
-----------------------------
Crystal Space Development
-----------------------------
=> General Crystal Space Discussion
=> Support
-----------------------------
Crystal Space Project Development
-----------------------------
=> Feature Requests
=> Plugins
=> Bug Reports
-----------------------------
Crystal Space Development
-----------------------------
=> Game Content Creation
-----------------------------
Miscellaneous
-----------------------------
=> Article/Tutorial Requests
=> Article/Tutorial Discussion
-----------------------------
Crystal Space Project Development
-----------------------------
=> Development Discussion
-----------------------------
Crystal Space Projects
-----------------------------
=> Project Discussion
=> WIP Projects
=> Finished Projects
-----------------------------
Associate Projects
-----------------------------
=> CEL Discussion
=> Crystal Core Discussion
=> CrystalBlend Discussion
-----------------------------
Crystal Space Project Development
-----------------------------
=> Google Summer of Code
-----------------------------
Associate Projects
-----------------------------
=> Apricot (Open Game)
=> Ares Project
Loading...