camera

hi all, i have dx rendering a ballmesh with a texture at the origin, and i want it to rotate when i press up, dx is already reading my keyboard... but wat do i do? any help would be appreciated
[193 byte] By [hello0101011] at [2007-12-23]
# 1

Not sure how you have this implemented, can you post any code?

Assuming your using either, RotateX or RotateY or RotateAxix just provide accessors to them where defined.

For instance:

private float m_rotateX = 0.0f;

public float GetRotateX
{
Get
{
return m_rotateX;
}

Set
{
m_rotateX = value;
}
}

In your render method:

m_matrix = new Matrix();
m_matrix = Matrix.Identity;

m_matrix.RotateX = GetRotateX;

Then in your keyboard handler... again not sure how this is setup.

public void Keydown(Micorosft.DirectX.DirectInput.Device m_keyboardDevice)
{
foreach (Key k in m_keyboardDevice.GetPressedKeys())
{
if (k == Key.UpArrow)
{
GetRotateX = GetRotateX += 0.01f;
}
}
}

Oh yea sorry, this code is in C# not sure what language your using?

UsingBytes at 2007-8-30 > top of Msdn Tech,Game Technologies: DirectX, XNA, XACT, etc.,Game Technologies: DirectX 101...
# 2

ok, i will explain clearer, and yes im using c#

using directx meshs i have a sphere, which is 1st placed at the origin (0,0,0)

i also have a texture which is applied to the mesh

when i press up i want the sphere to spin, not move, just spin in a forward direction

currently, i read the keyboad like so:

private void ReadUserInput()

{

di.KeyboardState keys = keyb.GetCurrentKeyboardState();

if (keys[di.Key.Up])

{

}

and i render the ball like so:

dev.SetTexture(0, ball.Texture);

dev.Transform.World = Matrix.Translation(new Vector3(ball.X, ball.Y, ball.Z));

ball.Mesh.DrawSubset(0);

now i applied the code u gave above, but it made the ball move round in a circle, not just spin round.

can u help me now

hello0101011 at 2007-8-30 > top of Msdn Tech,Game Technologies: DirectX, XNA, XACT, etc.,Game Technologies: DirectX 101...
# 3

Hello again,

Seeing what you want to do, you should be able to accomplish the output your looking for using either:

dev.Transform.World = Matrix.RotationZ(your variable to rotate here);
or
dev.Transform.World = Matrix.RotationY(variable to rotate);

There are a couple other's in there that use rotation.

Please let me know if this gets your closer to what your trying to do or not.

UsingBytes at 2007-8-30 > top of Msdn Tech,Game Technologies: DirectX, XNA, XACT, etc.,Game Technologies: DirectX 101...
# 4
nope thats it thank you!
hello0101011 at 2007-8-30 > top of Msdn Tech,Game Technologies: DirectX, XNA, XACT, etc.,Game Technologies: DirectX 101...
# 5
Not a problem at all, glad I could help.
UsingBytes at 2007-8-30 > top of Msdn Tech,Game Technologies: DirectX, XNA, XACT, etc.,Game Technologies: DirectX 101...