المساعد الشخصي الرقمي

مشاهدة النسخة كاملة : Troubles Drawing a Rubik Cube to windows form.



C# Programming
01-14-2010, 02:15 AM
First - The code used to create my version of a rubik cube was created by Peter Szilagyi; Arcus Applet - Rubik's Cube Simulator Applet. His code is not the problem it's the way I have implemented it into a windows form.

Second - It is entirely to hard to copy and paste code snippets of the code to show what and where it is doing the re-draw of the cube and it's cubie's so I have posted a .rar file with the entire window's project and I will reference methods within this project. RubikCube Project (http://www.robertfidler.com/win/articles/downloads/RubikCube.rar)[^ (http://www.robertfidler.com/win/articles/downloads/RubikCube.rar)].

Basic layout of the application uses RubikCube : Control. Within the RubikCube I am overriding the mouse events to move the cube and on paint event to draw the cube.

In the Mouse Move Event I call:
rbx_mouse_X, rbx_mouse_Y are where the mouse was and _event.X, _event.Y is where the mouse current is.
axisRotX(Math.PI * (rbx_mouse_Y - _event.Y) / rbx_dimension.Height);
axisRotY(Math.PI * (_event.X - rbx_mouse_X) / rbx_dimension.Width);

axisRotX then calls:
_vector[rbx_Y] = _vector[rbx_Y] * Math.Cos(_angle) - _vector[rbx_Z] * Math.Sin(_angle);
_vector[rbx_Z] = _vector[rbx_Z] * Math.Cos(_angle) + _vector[rbx_Y] * Math.Sin(_angle);

and so on...

I the issue occurs when the mouse movements are quick the cube begins to decrease in size and distorts. I have a series of static values that the cubie's ( a sub class of Rubik Cube ) access during their paint method. I am not sure on the best way to architect the class layout to get the desired results but it seems the mouse move events are happening out of sequence and causing the cube to disfigure.

Any thoughts, constructive criticism, or suggested reference materials to help would be appreciated.

I'm listening but I only speak GEEK.