Archived

This topic is now archived and is closed to further replies.

Samith

wtf!?!? stupid thing

Recommended Posts

ok, im making a small 3d engine thing, right now you just kinda fly around. i got the rotations to work out right, but lets say you rotate to the left 90 degrees, then hit the up button, you excpect to go forward right? well, you go to the right, is there a way i can fix this? thanks if you need more detail or need to see my code just tell me

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
This has nothing to do with rotations nor with the gimbal lock, that''s something totally different.

All you need to do is update your camera translation depending on your flight direction.

- AH

Share this post


Link to post
Share on other sites
Wow, these forums are short on help aren''t they?

I think, Samith, that you need to (as mr. Anonymous Poster stated) change the translation you do when going ''forward''.

Picture this: If you''re facing North and you walk forward, you''ll move North. But if you''re facing West and you walk forward, which way do you think you''ll move?

Your program says North.

How to make it say West?

Your rotation should be calculated from the positive x direction, with the left-rotation as positive to work.

So use this: (steplength is how far you''ll move)
translation for x = cos(rotation) * steplength
translation for z = sin(rotation) * steplength

Make sure you convert to radians first (rotation * 3.141592653589793238462643383279502884197169399375105820974944 / 180) so the sines and cosines work right.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
quote:

Make sure you convert to radians first (rotation * 3.141592653589793238462643383279502884197169399375105820974944 / 180) so the sines and cosines work right.



LOL This is sick, you have a PI-mania...

- AH

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
Shit, you learned that stuff 8 years ago and still know it ?!

Things like that are deleted by my brains garbage collector after 2 weeks... What a waste of (neural-) memory...

- AH

Share this post


Link to post
Share on other sites
I bet knowing pi to 61 decimal places would come in handy a lot . Maybe a party trick for a *really* boring party?

And with double prescision floating point storage, you get the whole thing taken back to 3.14159265358979 : 14 digits.

Why not memorise some other useful things, like Sqr(2), or the first page of your phone directory... you''d be famous

Trying is the first step towards failure.

Share this post


Link to post
Share on other sites
you see that is what ur computers clip board is for ... ctrl-c ... ctrl-v lol ... works great sept when u copy a few digits too many and vc++ freaks out but what can you expect ;-)

Share this post


Link to post
Share on other sites
Can I just demonstrate something here please?

When I decided to memorise pi I got to around

here
|
v
3.141592653589793238462643383279502884197169399375105820974944

And some people I knew were quite impressed I''d done that! Because you see, just because pi is a really complex number doesn''t mean you have to memorise it, did your calculator at school not have a pi button? *g*

*lol*

Sorry mate - that is actually quite impressive! I know for a fact that I couldn''t memorise it to 20 places, let alone 100!!! Though the question has to be asked - why???

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
Samith there is another way to do it.

CVector mView; //Crank the view and position in those
CVector mPosition;

void MoveCamera(float speed)
{
CVector vector={0};



vector.x = mView.x - mPosition.x;
vector.y = mView.y - mPosition.y;
vector.z = mView.z - mPosition.z;

mPosition.x += vector.x * speed;
mPosition.z += vector.z * speed;
mView.x += vector.x * speed;
mView.z += vector.z * speed;
mView.y += vector.z * speed;
mPosition.y += vector.z * speed;
gluLookAt(mPositon.x,mPosition.y,mPosition.z,mView.x,mView.y,mView.z,0,0,0);
}

//it suppose to work. Just MoveCamera(-X)to move back and //MoveCamera(X) to move forward.

Share this post


Link to post
Share on other sites
loop through this a few times
{
yy = a;
a = (a + b) / 2;
b = sqrt(b*yy);
c = c - xx * pow((a - yy),2.0);
xx = 2.0 * xx;
pi = pow((a + b),2) / (4.0*c) );
}

Share this post


Link to post
Share on other sites
You didn''t round the last digit correctly (since the next digit is a 5).

And double precision actually stores 15 digits, I believe.

"Don''t be afraid to dream, for out of such fragile things come miracles."

Share this post


Link to post
Share on other sites