Results 1 to 3 of 3

Thread: assign names and colour to premade object

  1. #1
    Member Newbie
    Join Date
    May 2001
    Location
    bogota, colombia
    Posts
    42

    assign names and colour to premade object

    Ive got a file from which I load a figure of a head. Id like to assign names and colours to each polygon in this head.

    I use a operation in my C++ program that reads all the vertexes, normals and textures and put it into a DisplayList that is being called when I want to display the figure. But how do I do to assign names and colours at the same time??

    my operation where I load all the data:
    unsigned int C3DPaintCanvas::GenerateDisplayList()
    {
    int i;
    int j;
    GLint lid=glGenLists(1);
    int mcount=0;
    int mindex=0;
    glNewList(lid, GL_COMPILE);
    glBegin(GL_TRIANGLES);
    // sizeof(face_indicies) = 151488
    // sizeof(face_indicies[0]) = 18
    // => for loop 8416 times
    for(i=0;i<sizeof(face_indicies)/sizeof(face_indicies[0]);i++)
    {
    // choose material - enters first time
    if(!mcount)
    {
    SelectMaterial(material_ref[mindex][0]);
    mcount=material_ref[mindex][1];
    mindex++;
    }
    mcount--;
    // set name ??????
    // set colour ???????
    ////////////////////////////////
    //glLoadName (i);
    //glPushName (i);
    // set the colour
    // glColor3f(0.0,1.0,0.0);
    //glPopName ();
    ///////////////////////////////

    for(j=0;j<3;j++)
    {
    int vi=face_indicies[i][j];
    // Vertex
    int ni=face_indicies[i][j+3];
    //Normal index
    int ti=face_indicies[i][j+6];
    //Texture index
    glNormal3f (normals[ni][0],normals[ni][1],normals[ni][2]);
    glTexCoord2f(textures[ti][0],textures[ti][1]);
    glVertex3f (vertices[vi][0],vertices[vi][1],vertices[vi][2]);
    }
    }
    glEnd();
    glEndList();
    return lid;
    }
    // end of GenerateDisplayList()

  2. #2
    Senior Member OpenGL Guru
    Join Date
    Mar 2001
    Posts
    3,574

    Re: assign names and colour to premade object

    OpenGL doesn't have the concept of a triangle having a name, so you're going to have to store that information somewhere yourself.

    As to colors, how do you want to select colors? I mean, for a given triangle, how do you want to determine what color it is? Once you figure that out, stick that into the loading code.

  3. #3
    Member Newbie
    Join Date
    May 2001
    Location
    bogota, colombia
    Posts
    42

    Re: assign names and colour to premade object

    But is it not possible to use naming??
    or does the namestack has a limited depth??

    I thought for a while that I could store the polygons in a namestack and then use picking to figure out which polygon I want to draw. But if I dont understand wrong, picking is
    only for figure out which polygon or object is choosed by the mouse. But how can I do if I have coordinates for the object i.e Id like to draw polygons I cant see from the screen until I rotate my figure... mouse coordinates are not intresting...

    /grodslukaren

Similar Threads

  1. delete object or change the colour
    By macsam in forum OpenGL: Basic Coding
    Replies: 1
    Last Post: 05-23-2018, 01:46 PM
  2. Assign to uniform from shader
    By Kopelrativ in forum OpenGL: Basic Coding
    Replies: 1
    Last Post: 04-11-2011, 10:50 PM
  3. OpenGL colour not able to render colour
    By mundrapiyush in forum OpenGL: Linux
    Replies: 3
    Last Post: 05-16-2010, 03:15 AM
  4. may i assign a data exceed [0,1] to the rgb value?
    By Louvie in forum OpenGL: Basic Coding
    Replies: 1
    Last Post: 08-15-2006, 04:57 AM
  5. Replies: 2
    Last Post: 01-01-2003, 01:51 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Proudly hosted by Digital Ocean