Re: [hlcoders] How to Vectors work?

2007-01-19 Thread Jeremy
--
[ Picked text/plain from multipart/alternative ]
Vectors hold a position x,y,z or a direction x,y,z. Although they could also
use them to store yaw pitch and roll valve created a seperate class for that
I believe, QAngle.

What they hold depends on where you get the value from.

CBaseEntity::GetAbsOrigin() will give you back a vector with an absolute
world position.
There is also GetLocalOrigin which will give you a local positional offset
from something you are parented to. I've not used this much, but I  would
assume that might be an offset from a vehicle you are in, maybe an elevator
or moving platform or something, though I could be wrong.

CBaseEntity::GetAbsVelocity: Velocity is often expressed as a direction
vector as well, with the length of the vector representing the speed. As a
simple example, an entities position will be updated by some code like
position += velocity * deltaTime; In this case the length of the velocity
vector is significant. To get just the direction without the 'speed'
component you would normalize the vector.

Some purely directional attributes of entities operate from a normalized
vector. HL2 stores many of its directions in the QAngle class. For example,
CBaseEntity::EyeAngles() returns a QAngle, which I normally convert to a
directional vector because I find them easier to work with.

Vector vFwd, vRight, vUp;
QAngle viewAngles = pEntity->EyeAngles();
AngleVectors(viewAngles, &vFwd, &vRight, &vUp);

Most useful in this case is the vFwd vector, so you can optionally pass null
to the right and up parameters to save a bit of work.

Vectors are overall pretty nice and easy to work with, though if you are
brand new to them it will probably take more than this to start getting
comfortable with them. If you have specific questions about things feel free
to post them but(and I don't mean this rudely), it's unlikely someone is
going to go very in depth explaining a basic mathematical tool like vectors.

J

On 1/19/07, Mukkan Yhtiö <[EMAIL PROTECTED]> wrote:
>
> Hi,
>
> Could some one explain how Vector Vatriables work? As far as I know they
> hold (x, y and z) coordinates?
>
> If I wanted to manually manipulate a Vector Variable in game I need to
> know
> how they work mathimatically? What they hold entirely and how to
> manipulate
> them in a 3D environment.
>
> I assume when manipulating 3D objects in a 3D environment you use yaw,
> pitch
> and roll as well as x, y and z?
>
> If anyone could briefly explain all this to me I would be eternally
> greatfull.
>
> Thanks.
>
> _
> Express yourself instantly with MSN Messenger! Download today it's FREE!
> http://messenger.msn.click-url.com/go/onm00200471ave/direct/01/
>
>
> ___
> To unsubscribe, edit your list preferences, or view the list archives,
> please visit:
> http://list.valvesoftware.com/mailman/listinfo/hlcoders
>
>
--

___
To unsubscribe, edit your list preferences, or view the list archives, please 
visit:
http://list.valvesoftware.com/mailman/listinfo/hlcoders



Re: [hlcoders] How to Vectors work?

2007-01-19 Thread Jeffrey \"botman\" Broome

Chris Harris wrote:

--
[ Picked text/plain from multipart/alternative ]
I suggest to get a book dealing with Linear Algebra... Though be warned it
is Calculus 2 and 3 topics so it may be hard or not (depends). Linear
Algebra is the math of vectors and it basically an invaluable tool for doing
3d engine work. Many natural phenomena that you may need to do are possible
with some simple equations from the book.


GameDev.net has some excellent articles on Math and Physics...

http://www.gamedev.net/reference/list.asp?categoryid=28

...see the "Subcategory: Vectors" section

--
Jeffrey "botman" Broome

___
To unsubscribe, edit your list preferences, or view the list archives, please 
visit:
http://list.valvesoftware.com/mailman/listinfo/hlcoders



Re: [hlcoders] How to Vectors work?

2007-01-19 Thread Chris Harris
--
[ Picked text/plain from multipart/alternative ]
I suggest to get a book dealing with Linear Algebra... Though be warned it
is Calculus 2 and 3 topics so it may be hard or not (depends). Linear
Algebra is the math of vectors and it basically an invaluable tool for doing
3d engine work. Many natural phenomena that you may need to do are possible
with some simple equations from the book.

On 1/19/07, Joel R. <[EMAIL PROTECTED]> wrote:
>
> --
> [ Picked text/plain from multipart/alternative ]
> In math vectors are used to define "direction".  But in c++ theres a class
> called Vector which holds 3 points.  [0],[1],[2] or .x,.y,.z or
> [PITCH],[YAW],[ROLL]  All the same exact thing, just 3 different ways of
> setting the variables, usually whatever comes easier to the coder.  I like
> using .x/.y/.z myself.
>
> First you have origins, the point in the world 3D grid that something is
> located at.
> Lets say i have a guy at point ( 0, 0, 10 ).  Our guy is on the z axis
> (up)
> 10 units. Simple.
> Velocity uses the same Vector class but is used as a direction.  The
> amount
> given is how many units it will move in one second according to the values
> in each axis.
> Lets say I'm at (0,0,0) and I want to move to our guy in 2 seconds. Our
> velocity would be (0,0,5).
>
> In the code they do soemthing like this.
>
> Vector origin = pEntity->GetAbsOrigin();
> Vector velocity = Vector(0,0,5);
>
> origin += velocity * gpGlobals->frametime;
>
> pEntity->SetAbsOrigin( origin );
>
> This is basically what the movement system does.  Velocity is just a
> helper
> to know your movement speed and direction.
> Origin is what really counts as thats where your model will be located at.
>
> Hope that helps =)
>
>
> On 1/19/07, Mukkan Yhtiö <[EMAIL PROTECTED]> wrote:
> >
> > Hi,
> >
> > Could some one explain how Vector Vatriables work? As far as I know they
> > hold (x, y and z) coordinates?
> >
> > If I wanted to manually manipulate a Vector Variable in game I need to
> > know
> > how they work mathimatically? What they hold entirely and how to
> > manipulate
> > them in a 3D environment.
> >
> > I assume when manipulating 3D objects in a 3D environment you use yaw,
> > pitch
> > and roll as well as x, y and z?
> >
> > If anyone could briefly explain all this to me I would be eternally
> > greatfull.
> >
> > Thanks.
> >
> > _
> > Express yourself instantly with MSN Messenger! Download today it's FREE!
> > http://messenger.msn.click-url.com/go/onm00200471ave/direct/01/
> >
> >
> > ___
> > To unsubscribe, edit your list preferences, or view the list archives,
> > please visit:
> > http://list.valvesoftware.com/mailman/listinfo/hlcoders
> >
> >
> --
>
> ___
> To unsubscribe, edit your list preferences, or view the list archives,
> please visit:
> http://list.valvesoftware.com/mailman/listinfo/hlcoders
>
>
--

___
To unsubscribe, edit your list preferences, or view the list archives, please 
visit:
http://list.valvesoftware.com/mailman/listinfo/hlcoders



Re: [hlcoders] How to Vectors work?

2007-01-19 Thread Joel R.
--
[ Picked text/plain from multipart/alternative ]
In math vectors are used to define "direction".  But in c++ theres a class
called Vector which holds 3 points.  [0],[1],[2] or .x,.y,.z or
[PITCH],[YAW],[ROLL]  All the same exact thing, just 3 different ways of
setting the variables, usually whatever comes easier to the coder.  I like
using .x/.y/.z myself.

First you have origins, the point in the world 3D grid that something is
located at.
Lets say i have a guy at point ( 0, 0, 10 ).  Our guy is on the z axis (up)
10 units. Simple.
Velocity uses the same Vector class but is used as a direction.  The amount
given is how many units it will move in one second according to the values
in each axis.
Lets say I'm at (0,0,0) and I want to move to our guy in 2 seconds. Our
velocity would be (0,0,5).

In the code they do soemthing like this.

Vector origin = pEntity->GetAbsOrigin();
Vector velocity = Vector(0,0,5);

origin += velocity * gpGlobals->frametime;

pEntity->SetAbsOrigin( origin );

This is basically what the movement system does.  Velocity is just a helper
to know your movement speed and direction.
Origin is what really counts as thats where your model will be located at.

Hope that helps =)


On 1/19/07, Mukkan Yhtiö <[EMAIL PROTECTED]> wrote:
>
> Hi,
>
> Could some one explain how Vector Vatriables work? As far as I know they
> hold (x, y and z) coordinates?
>
> If I wanted to manually manipulate a Vector Variable in game I need to
> know
> how they work mathimatically? What they hold entirely and how to
> manipulate
> them in a 3D environment.
>
> I assume when manipulating 3D objects in a 3D environment you use yaw,
> pitch
> and roll as well as x, y and z?
>
> If anyone could briefly explain all this to me I would be eternally
> greatfull.
>
> Thanks.
>
> _
> Express yourself instantly with MSN Messenger! Download today it's FREE!
> http://messenger.msn.click-url.com/go/onm00200471ave/direct/01/
>
>
> ___
> To unsubscribe, edit your list preferences, or view the list archives,
> please visit:
> http://list.valvesoftware.com/mailman/listinfo/hlcoders
>
>
--

___
To unsubscribe, edit your list preferences, or view the list archives, please 
visit:
http://list.valvesoftware.com/mailman/listinfo/hlcoders



[hlcoders] How to Vectors work?

2007-01-19 Thread Mukkan Yhti

Hi,

Could some one explain how Vector Vatriables work? As far as I know they
hold (x, y and z) coordinates?

If I wanted to manually manipulate a Vector Variable in game I need to know
how they work mathimatically? What they hold entirely and how to manipulate
them in a 3D environment.

I assume when manipulating 3D objects in a 3D environment you use yaw, pitch
and roll as well as x, y and z?

If anyone could briefly explain all this to me I would be eternally
greatfull.

Thanks.

_
Express yourself instantly with MSN Messenger! Download today it's FREE!
http://messenger.msn.click-url.com/go/onm00200471ave/direct/01/


___
To unsubscribe, edit your list preferences, or view the list archives, please 
visit:
http://list.valvesoftware.com/mailman/listinfo/hlcoders