Thread: mergine multiple .3ds into one

  1. #1
    Registered User
    Join Date
    Oct 2001
    Posts
    224

    Lightbulb mergine multiple .3ds into one

    ok say im making a game or a program were the user can select what the character is wearing(eg. armour, helmet, shield, sword). the end result would look something like this (use your imagination )

    Code:
               OOO
              O   O
               OOO
                O       I
               OOO      I
         SSS  O O O     I
         SSSOO  O    OOO
         SSS    O        
          S     O
                O
                O
               OOO
              O   O
            O       O
           O          O
    rather than making a different model for each possible combination of helmet shield sword boots armour and legging(which would equal 15625 possible combinations if there were 5 of each type of equipment) would it be possible just to make 5 of each in a model of there own (eg.a model of just the head or just the shield) and then in the game or application merge all the selected models into one, like you would if you were using 3ds max... "weld" the points together. if you could would it be possible to "un-weld" the points while in the app and then change the combination of models?

    it would look somthing like this

    Code:
                   
                         OOO
                        O   O              <----------- head
                         OOO
                          O 
                       ------   | I  
                         OOO    | I    <-----sword
                SSS|   O  O O   | I  
    shield>     SSS|OO    O   OO|O  
                 SS|      O                     <--------body
                  S|      O
                          O
                          O
                        ----- 
                         OOO
                        O   O                 <--------legs
                      O       O
                     O          O
    and were the is a line of ------ or | it represents were one model connects to the other.

    i plan to be doing this in OpenGL with VC++ (if possible).

    hope you understood all that

    thanks for any advice

  2. #2
    Registered User
    Join Date
    May 2004
    Posts
    19
    it is possible, you just need to define the relative position of the center of the shield model (for example) from the center of you body model. then use something like:

    Code:
    glPushMatrix();
      glTranslated(body_x, body_y, body_z);
      glRotated, glScaled, ..., whatever transformations you want to do to the MODELVIEW matrix.
      glCallList(body);
    
      glPushMatrix();
        glTranslated(shield_to_body_x, shield_to_body_y, shield_to_body_z);
        glRotated, glScaled, ..., again, relative position, orientation and size, relative to the body.
        glCallList(shield);
      glPopMatrix();
    
      glPushMatrix();
        glTranslated(sword_to_body_x, sword_to_body_y, sword_to_body_z);
        glRotated, glScaled, ..., again, relative position, orientation and size, relative to the body.
        glCallList(sword);
      glPopMatrix;
    
      and so on for the rest of the objects (armour, shoes, sunglasses, whatever...)
    
    glPopMatrix();
    This is assuming you are using display lists (hopefully), you can give continuous list id numbers to every object and then you just have to select an integer.

  3. #3
    Registered User
    Join Date
    Oct 2001
    Posts
    224
    on a slower computer if there was alot going on at once in the game and it started to lag would each body part move at the same time or would one part move to the new position and then the next...

  4. #4
    Registered User
    Join Date
    May 2004
    Posts
    19
    OpenGL only draws the scene when you teel it to, so you don't have that problem.

    You can user gultSwapBuffers(); if you are working with GLUT or SwapBuffers(hdc); to render the scene (assuming you are using double buffering). However if you want to render something while the rest of the scene is not done yet, use glFlush() to force a partial render.

  5. #5
    Registered User
    Join Date
    Oct 2001
    Posts
    224
    im just starting to learn OpenGL and this idea is for alot later in life... but what are the advantages/disadvantages to using glut or not using?

  6. #6
    Registered User
    Join Date
    May 2004
    Posts
    19
    Quote Originally Posted by opengl.org
    GLUT (pronounced like the glut in gluttony) is the OpenGL Utility Toolkit, a window system independent toolkit for writing OpenGL programs. It implements a simple windowing application programming interface (API) for OpenGL. GLUT makes it considerably easier to learn about and explore OpenGL programming. GLUT provides a portable API so you can write a single OpenGL program that works on across all PC and workstation OS platforms.

    GLUT is designed for constructing small to medium sized OpenGL programs. While GLUT is well-suited to learning OpenGL and developing simple OpenGL applications, GLUT is not a full-featured toolkit so large applications requiring sophisticated user interfaces are better off using native window system toolkits. GLUT is simple, easy, and small.

    The GLUT library has both C, C++ (same as C), FORTRAN, and Ada programming bindings. The GLUT source code distribution is portable to nearly all OpenGL implementations and platforms. The current version is 3.7. Additional releases of the library are not anticipated.

    GLUT wraps up a lot of windows functions, you don't need to set up windows, rendering contexts, drawing contexts, call back functions etc... It does that for you. for example:

    Code:
    #include <windows.h>
    #include <GL\gl.h>
    #include <GL\glu.h>
    #include <GL\glut.h>
    
    void display()
    {
    	glClearColor(0.0, 0.0, 1.0, 0.0);
    	glClear(GL_COLOR_BUFFER_BIT);
    	glColor3f(1.0, 1.0, 0.0);
    	glBegin(GL_POLYGON);
    		glVertex2f(-0.5, -0.5);
    		glVertex2f(-0.5, 0.5);
    		glVertex2f(0.5, 0.5);
    		glVertex2f(0.5, -0.5);
    	glEnd();
    	glFlush();
    }
    
    int main(int argc, char* argv[])
    {
    	glutInit(&argc, argv);
    	glutCreateWindow("square");
    	glutDisplayFunc(display);
    	glutMainLoop();
    	return 0;
    }
    This is actually all the code you need to draw a square.

    You can check out *almost* all GLUT functions here:
    http://www.opengl.org/resources/libr...ec3/spec3.html

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 16
    Last Post: 06-08-2009, 03:03 PM
  2. why Multiple define error ...
    By nilathinesh in forum C Programming
    Replies: 2
    Last Post: 10-19-2006, 06:31 AM
  3. Phantom redefinition
    By CodeMonkey in forum C++ Programming
    Replies: 6
    Last Post: 06-12-2005, 05:42 PM
  4. Linker errors - Multiple Source files
    By nkhambal in forum C Programming
    Replies: 3
    Last Post: 04-24-2005, 02:41 AM
  5. Replies: 1
    Last Post: 05-01-2003, 02:52 PM