Original Post
Hi, I have made a simple model viewer with c# and mdx and I would like a button that makes whatever object is being displayed spin. Here is what I tried but it didn''t work
//Globals
static int iTime = Environment.TickCount % 1000;
static float fAngle = iTime * (2.0f * (float)Math.PI) / 1000.0f;
static Matrix ident = Matrix.Identity;
static Matrix spin = Matrix.RotationY( fAngle );
Matrix crnt = ident;
//Main loop
static void Main()
{
using (WinForm frm = new WinForm())
{
if (!frm.InitializeGraphics()) // Initialize Direct3D
{
MessageBox.Show("Could not initialize Direct3D. This tutorial will exit.");
return;
}
frm.Show();
// While the form is still valid, render and process messages
while(frm.Created)
{
frm.Render();
Application.DoEvents();
}
}
}
The Render() meathod has a call to SetupMatrices() just after beginscene()
//Setup matrices
private void SetupMatrices()
{
device.Transform.World = crnt;
device.Transform.View = Matrix.LookAtLH( new Vector3( 0.0f, 3.0f,-5.0f ), new Vector3( 0.0f, 0.0f, 0.0f ), new Vector3( 0.0f, 1.0f, 0.0f ) );
device.Transform.Projection = Matrix.PerspectiveFovLH( (float)Math.PI / 4, 1.0f, 1.0f, 100.0f );
}
and finally the buttons event
private void button1_Click(object sender, System.EventArgs e)
{
curnt = spin;
}
it compiles but the button does nothing. Any ideas?
Thanks for this, it is greatly appreciated