Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. Troubles Drawing a Rubik Cube to windows form.

Troubles Drawing a Rubik Cube to windows form.

Scheduled Pinned Locked Moved C#
helpcomgraphicsdiscussionannouncement
1 Posts 1 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    Are Jay
    wrote on last edited by
    #1

    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[^]. 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.

    1 Reply Last reply
    0
    Reply
    • Reply as topic
    Log in to reply
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes


    • Login

    • Don't have an account? Register

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • World
    • Users
    • Groups