http://7dfps.org/?projects=you-are-falling
Anyway, I was inspired to revisit this when Kj posted and answer to someone about launching an object the way the launcher is facing, as trig problems seem to limit my game development,. this little code snip makes shooting easy (thanks Kjell!);
Code: Select all
float X, Y, Z, SX, CX, SY, CY, SZ, CZ;
// Some caching to speed things up :-)
X = CurrentModel.Rotation.X*PI*2;
Y = CurrentModel.Rotation.Y*PI*2;
Z = CurrentModel.Rotation.Z*PI*2;
SX = sin(X); CX = cos(X);
SY = sin(Y); CY = cos(Y);
SZ = sin(Z); CZ = cos(Z);
// Set velocity relative to rotation ( 8 is the actual velocity )
CurrentModel.Velocity.X = (CX*SY*CZ+SX*SZ)*55;
CurrentModel.Velocity.Y = (CX*SY*SZ-SX*CZ)*55;
CurrentModel.Velocity.Z = (CX*CY)*55;
Currently my terrain 'physics' consists of adding speed if last-z-on-ground-hight is higher than previous and vise-versa,. more to come. Would like to do something like vector locust gameplay wise,. more turret building and base construction stuff anyway.., need ray casting vs terrain for AI of any use to work though. (line of sight)