3D Rotating Objects Demo

This demo show how to do transformations on, solid and wire-frame, 3d objects.

Image 1

The class file does all the grunt work for you. the only calls the user makes to the class is to "LoadObject", if the user wants to move or rotate it then they call the "SetRotations" and "SetTranslations" functions. There are also properties that allow the user to get the current translations and rotations for each axis. After the user has done all that, simply call the "RenderObject" routine and bamm!

In the "LoadObject" function you must supply a file path and an device context (picture box) along with initial values you would like set, such as the rotation, scale factor and it's world position.

In the "SetRotations" function there is three parameters. One for the X, Y and Z values. Only supply the one that you want to change. The same goes for the "SetTranslations" function.

There are no parameters for "RenderObject". Enjoy :-)

Download Zipped Project File (16k)



Comments

  • great

    Posted by edoov5153 on 03/06/2006 08:24pm

    excellent work

    Reply
  • is there a odf file format description out?

    Posted by Legacy on 08/08/2000 12:00am

    Originally posted by: Andr�

    Hello

    I want to create a grid of rectangles using odf files so that your wonderful app can display it. (the wireframe only)

    But on the net I could not find any documentation about the format of such an odf file.

    So my question is: Is there any documentation about odf files?


    Thank you!


    Andr�

    • odf description

      Posted by chams on 09/14/2004 09:02pm

      odf is not a standard file system. But it works in this way : #1 Header #2 Version #3 Object #4 <-Empty line-> separator #5 to n the next n lines are the points drawing the object (Called vertices by the author). One line per point, (x,y,z). In this sample : 1,1,-1 'point A 1,-1,-1 'point B -1,-1,-1 'point C -1,1,-1 'point D 1,1,1 'point E 1,-1,1 'point F -1,-1,1 'point G -1,1,1 'point H <-Empty line-> separator the following lines ares in fact triangles, refering to the index of the points, follow by the triangle's color. Each triangle must be connect to the previous with two points. In the sample : 0,1,2,255 'refer to points index 0, 1 and 2 ie : A,B,C,colorValue(Long) 2,3,0,255 'refer to C,D,A connect to the previous by A and C, etc... 3,2,6,16776960 6,7,3,16776960 7,6,5,16711935 5,4,7,16711935 4,5,1,65280 1,0,4,65280 4,0,3,0 3,7,4,0 1,5,6,16777215 6,2,1,16777215 With a total of 12 triangles forming the 6 faces of the cube (each face of the cube is draw by 2 triangles) Last Line : END : Quit the loading loop. I think it's possible to do a object converter from Povray's raw-triangles output, because it is a list of triangles connect to the other by to points ;-)) chams

      Reply
    Reply
  • email changed

    Posted by Legacy on 07/31/2000 12:00am

    Originally posted by: Chris

    My email has changed for those who care... :-)

    Chris Abbott

    Reply
  • 3D Rotating Objects Demo

    Posted by Legacy on 05/03/2000 12:00am

    Originally posted by: mor

    I treid to load in VB5, but I got the Msg:
    Retained is an invalid key
    Project1.vbp cant be loaded.
    Please help
    thanks
    mor

    Reply
  • Note from Author...

    Posted by Legacy on 03/03/2000 12:00am

    Originally posted by: Chris Abbott

    I add new version and other interesting stuff Here: alccentral.cjb.net

    Reply
  • Fantastic & Really superb chris

    Posted by Legacy on 02/28/2000 12:00am

    Originally posted by: Sathish Balasubramaniam

    Good Show & Great Mind

    Reply
  • What a wonderfull creation

    Posted by Legacy on 01/21/2000 12:00am

    Originally posted by: Rick

    I think that the author is an increadibly tallented progrmer
    and deserves praise for their work

    Reply
  • 1815.shtml

    Posted by Legacy on 12/27/1999 12:00am

    Originally posted by: Magnus G�venal

    Very smooth ....

    Reply
  • Rendering multiple cubes that overlap.

    Posted by Legacy on 11/26/1999 12:00am

    Originally posted by: Pino Carafa

    The sample project is amazing, but alas, there is a problem if you're rendering multiple cubes that could obscure each other.
    
    

    The following sample code is an adaptation from the original form code and shows how you have to change the rendering order so that two cubes that are side by side are always displayed correctly.

    It would be nice if the sample program were improved so that it calculates the correct rendering order for a collection of cubes?

    Let me know if and how you're thinking of tackling this problem.

    Many thanks for your help

    Pino

    Sample code follows:
    Option Explicit

    Private Const PI = 3.141593

    'declare new objects
    Dim obj1 As New cls3dObject
    Dim obj2 As New cls3dObject
    Sub RunDemo()

    Dim dblNewX As Double
    Dim dblNewZ As Double

    Dim lngCounter As Long
    Do
    'Rotate both cubes for the correct amount
    obj1.SetRotations obj1.RotateX, _
    obj1.RotateY - 3, _
    obj1.RotateZ
    obj2.SetRotations obj2.RotateX, _
    obj2.RotateY - 3, _
    obj2.RotateZ

    'The "outer" cube must be translated to give _
    the impression that both cubes are _
    rotating around a common axis
    dblNewX = 16 * Cos(PI * obj1.RotateY / 180)
    dblNewZ = -75 - 16 * Sin(PI * obj1.RotateY / 180)
    obj2.SetTranslations dblNewX, _
    obj1.TranslateY, _
    dblNewZ

    'clear picture box, render objects _
    and pause for moment.
    'The sample is indeed amazing. _
    In fact it's so fast I had to slow it down!
    For lngCounter = 1 To 10000
    DoEvents
    Next

    pic3d.Cls
    'But here's the problem. Depending on the amount _
    of rotation, you have to render one cube before _
    the other.
    'where does the value 9 come from? _
    (189 = 180 + 9, 351 = 360 - 9)
    'Would it be possible to create a routine that _
    accepts a collection of cube objects, _
    and performs a calculation to determine the _
    order in which they should be rendered?
    If obj1.RotateY < 189 Or obj1.RotateY > 351 Then
    obj2.RenderObject
    obj1.RenderObject
    Else
    obj1.RenderObject
    obj2.RenderObject
    End If
    DoEvents
    Loop

    End Sub
    Private Sub Form_Load()

    Me.Show
    'load each object
    obj1.LoadObject App.Path & "\cube.odf", _
    pic3d, 0, 0, -75, 2, 0, 0, 0
    obj2.LoadObject App.Path & "\cube.odf", _
    pic3d, 16, 0, -75, 2, 0, 0, 0
    RunDemo

    End Sub

    Private Sub Form_Unload(Cancel As Integer)

    End

    End Sub


    Many thanks

    Pino

    • 3D program using c++

      Posted by em_1031609 on 03/12/2008 07:38am

      can you help me write a code in c++ for 3D objects... A code for rotating 3D objects in x, y, and z axes... thanks...!

      Reply
    Reply
  • :-)

    Posted by Legacy on 11/25/1999 12:00am

    Originally posted by: Faris

    OPPPSSSSsss :o)

    Reply
  • Loading, Please Wait ...

Leave a Comment
  • Your email address will not be published. All fields are required.

Top White Papers and Webcasts

  • Live Event Date: November 20, 2014 @ 2:00 p.m. ET / 11:00 a.m. PT Are you wanting to target two or more platforms such as iOS, Android, and/or Windows? You are not alone. 90% of enterprises today are targeting two or more platforms. Attend this eSeminar to discover how mobile app developers can rely on one IDE to create applications across platforms and approaches (web, native, and/or hybrid), saving time, money, and effort and introducing apps to market faster. You'll learn the trade-offs for gaining long …

  • IBM Worklight is a mobile application development platform that lets you extend your business to mobile devices. It is designed to provide an open, comprehensive platform to build, run and manage HTML5, hybrid and native mobile apps.

Most Popular Programming Stories

More for Developers

Latest Developer Headlines

RSS Feeds