Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

DarkBASIC Professional Discussion / 3D Rotaion (Edit this code, smart guy)

Author
Message
Armitage
22
Years of Service
User Offline
Joined: 18th Nov 2002
Location: Canada
Posted: 19th Nov 2002 00:03
Hello. The snippet below is my attempt at 3D rotation.

The blue ball is the origin. The red ball rotates about the Z axis. This is fine.

What I'm missing is the ability to rotate the ball about the X axis at the same time. I'm not sure how to do this.



Leftkey and rightkey rotate the ball about the Z axis. Upkey and downkey make the ball do silly things. That's what I want to change.

If someone could show me how to do this, I'd really appreciate it.
The Darthster
22
Years of Service
User Offline
Joined: 25th Sep 2002
Location: United Kingdom
Posted: 19th Nov 2002 00:26
You'll need to include this function, this will allow you to rotate an object around 3d coordinates based on the 3d polar coordinates of the start of the orbit.



This is TGWDNGHN's code, I lost my own function which did the same thing (I think)
Armitage
22
Years of Service
User Offline
Joined: 18th Nov 2002
Location: Canada
Posted: 19th Nov 2002 01:15
Thanks for that function! That was timely and completely effective. It seemed like you were swatting a fly (WHAP!) from any angle you choose.

For those interested in seeing this work, here's the same thing with the Polar_Object function implemented, and a wireframe sphere that proves that this works.



Cheers!

I suppose this could help me with my little (atmospheric) space flight game. My little spaceship has some difficulty climbing (or falling) at angles greater than ~45 degrees. Soon, you'll be able to do a mayday nose-dive into Planet X.

ICQ: 92636554
brittd
22
Years of Service
User Offline
Joined: 28th Oct 2002
Location:
Posted: 19th Nov 2002 05:05
cool code, where were you guys a month ago.
Armitage
22
Years of Service
User Offline
Joined: 18th Nov 2002
Location: Canada
Posted: 19th Nov 2002 06:19
Well, this has spawned some more goodness. Using the Polar_Object function, I've perfected my MouseLook routines! RAWK! I've been waiting so damn long to make a descent Mouselook.

I've also added Mouse Smoothing, which is fun.

Check this out, for your #including pleasure:



I'm sure this has been done before, but it has not come to my attention.

Cheers, again!

Now, for that space-buggie nose-dive...

ICQ: 92636554
Armitage
22
Years of Service
User Offline
Joined: 18th Nov 2002
Location: Canada
Posted: 19th Nov 2002 06:25
Oh, yeah... about that mouselook function:

Use WASD to advance and strafe (or whatever keys are in that position on your keyboard; I type Dvorak, so it's ",aoe", but this should work for all as it looks at scancodes). Use the right mouse button to move the camera up, the space bar to move the camera down. And use the mouse to look (duh!).

ICQ: 92636554

Login to post a reply

Server time is: 2025-06-30 08:22:56
Your offset time is: 2025-06-30 08:22:56