Results 1 to 4 of 4

Thread: Rotating a GLXMilkshape3D model

  1. #1
    Legendary Member cairnswm's Avatar
    Join Date
    Nov 2002
    Location
    Randburg, South Africa
    Posts
    1,537

    Rotating a GLXMilkshape3D model

    How do I rotate a Milkshape 3D model? I have the following code from the 'Sprites' demo:

    [pascal] glPushMatrix;
    glTranslatef(-X,0,-Y);
    glScalef(5,5,5);
    glRotatef(Anim / 4, 0, 1, 0);
    glRotatef(Anim / 5, 1, 0, 0);

    Texture.Bind;
    Model.Draw;
    glPopMatrix;[/pascal]

    But I have no idea what it is trying to do

    I have tried to use this same code in the Startrek Enterprise Milkshape demo to turn the ship without moving the camera but it doesn;t work and quite honestly I dont know what I'm doing let alone what I'm doing wrong

    Why does the GLXMilkshape3D component not have a Rotate method? I would have thought this would be a common function that everyone would use?
    William Cairns
    My Games: http://www.cairnsgames.co.za (Currently very inactive)
    MyOnline Games: http://TheGameDeveloper.co.za (Currently very inactive)

  2. #2

    Rotating a GLXMilkshape3D model

    To rotate milkshape 3D models (as any other bunch of polygons ), there's no other way but to use pure OpenGL. To do so, you have to include opengl if your use clause.
    Then the key to rotating is the function glRotate (or glRotatef which uses the single type parameter instead of double...). This function's parameters are the angle of the rotation (in degrees), and the x,y, and z component.
    For example if you use glRotatef(90, 0, 0.5, 0) it will execute a 45A¬? rotation around the y axis. Easy, as you see

    Ok now you're able to rotate, i think the translation (glTranslatef) and the scaling (glScale) are not a problem !

    Just remeber some tips :
    - Always start by glPushMatrix and end by glPopmatrix : the first function "saves" the matrix used to draw and the second one restores the old matrix to get back your good ol' coordinates :lol:

    - Never use Model.Draw(X,Y,Z) when rotating or scaling because the coordinates where the model will be drawn are modified by the previous instructions so your model won't be where expected (at all )

    - Always start by tranlating, then scaling and rotating (do not forget to draw your model nevetheless ). The trick is that translating doesnt affect coordinates, but the other 2 do, so if you use translate after rotating or scaling the result will be... hazardous (i'm not sure there's an order between scaling and rotation though).

    - Always have fun making games and exploring the beautiful world of OpengGL and GLXTreem !

    Abened, in an inspired day lol (pardon my english i cannot write so much without making mistakes :roll: )

  3. #3
    Legendary Member cairnswm's Avatar
    Join Date
    Nov 2002
    Location
    Randburg, South Africa
    Posts
    1,537

    Rotating a GLXMilkshape3D model

    OK! It all makes sense now (sort of )

    How does OpenGL know which model I'm trying to rotate? If I look at the example I used it doesn't refer to any specific model. If I want to rotate only a single model how would I do it in a game using 3 or 4 models.
    William Cairns
    My Games: http://www.cairnsgames.co.za (Currently very inactive)
    MyOnline Games: http://TheGameDeveloper.co.za (Currently very inactive)

  4. #4

    Rotating a GLXMilkshape3D model

    OpenGL rotates the whole scene, so it doesn't know what object you are rotating and don't need to either, all commands you are sending to opengl is executed in the oposite order as you sended them, that's why it works as it does.
    Amnoxx

    Oh, and this code appears to be an approximate replacement for return(random() & 0x01);

    Phoenix Wiki
    http://www.phoenixlib.net/

    Phoenix Forum
    http://www.pascalgamedevelopment.com/viewforum.php?f=71

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •