• Create Account

Banner advertising on our site currently available from just \$5!

# Torath

Member Since 24 May 2012
Offline Last Active Nov 04 2012 03:00 PM

### Quaternion rotation

03 November 2012 - 02:47 PM

Hi, I'm working on a 3D space game built with C++ and DirectX. I've got a question about using quaternions for object rotation and I'm hoping someone might have an idea.

Currently, the player ship's rotation is represented by a quaternion. The ship starts off level and facing directly straight forward (towards the positive Z axis). I create a quaternion based on the 3 axes (positive X to the right, Y is up, and Z is forward).

If I want to apply a rotation to the ship, for example 90 degrees to the right, I can call D3DXQuaternionRotationAxis() to get a rotation quaternion. I then multiply that against the original rotation using D3DXQuaternionMultiply() and I get a new updated rotation where the ship is facing forward along the X axis (perfect!).

The problem I have is in the next step:

If I then want to make a second rotation of pitching the nose of the ship up (based on the current direction it's facing along the X axis), when I try to use the method described above I don't get the intended result. What happens instead is the ship indeed rotates, but as if it were still facing in it's original direction towards the Z axis. So instead of seeing the nose of the ship rotate up, I see the ship roll. Or to be more clear, I see a rotation around the X axis, rather than seeing a rotation around the Z axis.

This is probably a very simple mistake, but for some reason I always have trouble wrapping my head around quaternion math.

Any help is appreciated!

### Rendering a space skybox

20 July 2012 - 01:40 AM

Hi. I'm currently working on a small 3D space game built using C++ and DirectX 11.

I've added in a skybox that has a nice mixture of stars for my background. Howevever, when I see it in game it never looks as sharp as the actual textures I've got. For example, the stars end up looking blocky instead of nice and crisp.

Does anyone have tips for rendering a nice looking skybox?

Oh, for reference, the sampler state I've set up for the pixel shader uses the D3D11_FILTER_MIN_MAG_MIP_LINEAR filter. Is this a good choice? Is there a better alternative?

Thanks for any help!

### Sleep() not reliable?

24 May 2012 - 10:35 PM

Hi everyone,

I'm building a game engine from the ground up using C++ and DirectX. In my main game loop I am calling the function Sleep() each frame, but it doesn't consistently sleep for the time I specify. Instead of sleeping for 16ms for example, it will sleep for roughly 30ms.

I tried a different implementation using a waitable timer (using the functions SetWaitableTimer() and WaitForSingleObject()) and I see similar behavior.

The strange thing (and this might be a red herring) is I saw it work properly once while debugging the game in Visual Studio. However, when I run outside the debugger I get the behavior described above.

Any ideas?

Thanks for any help!

PARTNERS