Getting Offset Position

Grab your favourite IDE and tinker with the innards of game engines

Getting Offset Position

Postby Spike on Wed Jul 14, 2010 4:09 pm

Hello. In my code I've saved an offset position of a cube (RED POINT). It works fine when the angles are (0,0,0). But how can I get the current point when the angles are different??? (Using Valve Angles and vectors)

Image
User avatar
Spike
May Contain Skills
May Contain Skills
 
Joined: Wed Sep 17, 2008 7:10 pm

Re: Getting Offset Position

Postby -=Biohazard=- on Wed Jul 14, 2010 4:23 pm

I guess the better way would be to use some kind of matrix multiplication, but here's one that should work as well:

Code: Select all
AngleVectors( cubeangles, &fwd, &right, &up );
Vector worldspaceOffset = Point - Cube;
Vector RelativeOffset( DotProduct( fwd, worldspaceOffset ), DotProduct( right, worldspaceOffset ), DotProduct( up, worldspaceOffset ) );

[...]

AngleVectors( cubeangles, &fwd, &right, &up );
Vector CurrentPointPosition( fwd * RelativeOffset.x, right * RelativeOffset.y, up * RelativeOffset.z );
User avatar
-=Biohazard=-
Regular
Regular
 
Joined: Mon Apr 07, 2008 11:15 am

Re: Getting Offset Position

Postby Spike on Thu Jul 15, 2010 5:37 pm

Thanks :)
User avatar
Spike
May Contain Skills
May Contain Skills
 
Joined: Wed Sep 17, 2008 7:10 pm

Return to Programming

Who is online

Users browsing this forum: No registered users

cron