Results 1 to 10 of 10

Thread: dealing individual objects

  1. #1
    Join Date
    Aug 2006
    Location
    Germany
    Posts
    33
    Thanks
    8
    Qt products
    Qt4
    Platforms
    Windows

    Default dealing individual objects

    hello,

    I draw 4 individual objects stic together(4 cubes to form a square in blender)and export it to VRML2 format. In that i have points and coordindex for each object.so I create array list(glnewlist()) for each and print on the screen.

    but the objects are not as before, it merged or in unordered manner
    is there something to do with transformations?

    any idea about dealing this ,please?
    thanks

    Qt Code:
    1. glNewList(2, GL_COMPILE);
    2.  
    3. for (int i=0; i<6; i++)
    4. {
    5. glBegin(GL_POLYGON);
    6. x=Friend2[faceRefs2[i][0]][0];
    7. y=Friend2[faceRefs2[i][0]][1];
    8. z=Friend2[faceRefs2[i][0]][2];
    9. glVertex3f(x, y, z);
    10. x=Friend2[faceRefs2[i][1]][0];
    11. y=Friend2[faceRefs2[i][1]][1];
    12. z=Friend2[faceRefs2[i][1]][2];
    13. glVertex3f(x, y, z);
    14. x=Friend2[faceRefs2[i][2]][0];
    15. y=Friend2[faceRefs2[i][2]][1];
    16. z=Friend2[faceRefs2[i][2]][2];
    17. glVertex3f(x, y, z);
    18. x=Friend2[faceRefs2[i][3]][0];
    19. y=Friend2[faceRefs2[i][3]][1];
    20. z=Friend2[faceRefs2[i][3]][2];
    21. glVertex3f(x, y, z);
    22. if(faceRefs2[i][4] != -1)
    23. {
    24. x=Friend2[faceRefs2[i][4]][0];
    25. y=Friend2[faceRefs2[i][4]][1];
    26. z=Friend2[faceRefs2[i][4]][2];
    27. glVertex3f(x, y, z);
    28. }
    29. glEnd();
    30. }
    31. glColor3f(1.0f,0.0f,1.0f);
    32. glBegin(GL_QUADS);
    33. x=Friend2[4][0];
    34. y=Friend2[4][1];
    35. z=Friend2[4][2];
    36. glVertex3f(x,y,z);
    37. x=Friend2[5][0];
    38. y=Friend2[5][1];
    39. z=Friend2[5][2];
    40. glVertex3f(x,y,z);
    41. x=Friend2[6][0];
    42. y=Friend2[6][1];
    43. z=Friend2[6][2];
    44. glVertex3f(x,y,z);
    45. x=Friend2[7][0];
    46. y=Friend2[7][1];
    47. z=Friend2[7][2];
    48. glVertex3f(x,y,z);
    49. glEnd();
    50.  
    51. glEndList();
    To copy to clipboard, switch view to plain text mode 

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 976 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: dealing individual objects

    Could you post the contents of Friend2 and faceRefs2 arrays for such crippled object?

  3. #3
    Join Date
    Aug 2006
    Location
    Germany
    Posts
    33
    Thanks
    8
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: dealing individual objects

    these are the array list for the 3 objects and I make the list and print
    Friend are points and facreRefs are coordIndex

    Qt Code:
    1. GLfloat Friend[8][3]={
    2. {0.163, -1.0, -1.262},
    3. {0.163, -1.0, 0.738},
    4. {-0.032, -1.0, 0.738},
    5. {-0.032, -1.0, -1.262},
    6. {0.163, 1.0, -1.262},
    7. {0.163, 1.0, 0.738},
    8. {-0.032, 1.0, 0.738},
    9. {-0.032, 1.0, -1.262}
    10. };
    11. int faceRefs[6][5]={
    12. {0, 1, 2, 3, -1},
    13. {4, 7, 6, 5, -1},
    14. {0, 4, 5, 1, -1},
    15. {1, 5, 6, 2, -1},
    16. {2, 6, 7, 3, -1},
    17. {4, 0, 3, 7, -1}
    18. };
    19.  
    20.  
    21.  
    22.  
    23. GLfloat Friend2[8][3]={ {1.962, -1.0, -0.156},
    24. { 1.962, -1.0, 0.113},
    25. { -2.312, -1.0, 0.113},
    26. {-2.312, -1.0, -0.156},
    27. {1.962, 1.0, -0.156},
    28. {1.962, 1.0, 0.113},
    29. {-2.312, 1.0, 0.113},
    30. {-2.312, 1.0, -0.1562}
    31. };
    32. int faceRefs2[6][5]={
    33. {0, 1, 2, 3, -1},
    34. {4, 7, 6, 5, -1},
    35. {0, 4, 5, 1, -1},
    36. {1, 5, 6, 2, -1},
    37. {2, 6, 7, 3, -1},
    38. {4, 0, 3, 7, -1}
    39. };
    40.  
    41.  
    42.  
    43.  
    44. GLfloat Friend3[8][3]={
    45. {-1.846, -1.0, -0.891},
    46. {-1.846, -1.0, 1.109},
    47. {-2.046, -1.0, 1.109},
    48. {-2.046, -1.0, -0.891},
    49. {-1.846, 1.0, -0.891},
    50. {-1.846, 1.0, 1.109},
    51. {-2.046, 1.0, 1.109},
    52. {-2.046, 1.0, -0.891}
    53. };
    54.  
    55. int faceRefs3[6][5]={
    56. {0, 1, 2, 3, -1},
    57. {4, 7, 6, 5, -1},
    58. {0, 4, 5, 1, -1},
    59. {1, 5, 6, 2, -1},
    60. {2, 6, 7, 3, -1},
    61. {4, 0, 3, 7, -1}
    62. };
    To copy to clipboard, switch view to plain text mode 

  4. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 976 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: dealing individual objects

    Quote Originally Posted by kingslee View Post
    these are the array list for the 3 objects and I make the list and print
    How should these objects look like?

    So far I see only one problem: the normals are assigned in a wrong way, because you draw vertices of some faces in reverse order.

  5. #5
    Join Date
    Aug 2006
    Location
    Germany
    Posts
    33
    Thanks
    8
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: dealing individual objects

    Thank you jacek for your reply.
    I here by attach the screen schots - top view and bit tilted top view and the vrml file.
    i changed the extension of vrml to txt for uploading (check11.txt)
    Attached Images Attached Images
    Attached Files Attached Files

  6. #6
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 976 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: dealing individual objects

    It looks like your VRML file is corrupted. If you open it in a VRML viewer, you'll get the same object as in OpenGL.

  7. The following user says thank you to jacek for this useful post:

    kingslee (14th November 2006)

  8. #7
    Join Date
    Aug 2006
    Location
    Germany
    Posts
    33
    Thanks
    8
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: dealing individual objects

    thansk jacek !
    Is there something to do with the world cordinates .. as I get it from otehr forum

    the explanation.

    This seems to be a problem of moving the coordinate system to the correct position. I don't know blender that well, but if it works like other 3D modellers it's likely that the object's vertices are stored in object space along with a world space transform of the object.

    Example: You have two boxes (axis aligned, coords in world space):
    1) min = (0/0/0), max = (1/1/1)
    2) min = (2/2/2), max = (3/3/3)

    Storing the verts in object space (centers at (0.5/0.5/0.5) and (2.5/2.5/2.5) in world space) gives :

    min = (-0.5/-0.5/-0.5) and max = (0.5/0.5/0.5) for BOTH boxes.

    Rendering them without moving box2's coordinate system to (2.5/2.5/2.5) in world space results in box2 drawn on top of box1.

    /
    Qt Code:
    1. /draw box1
    2. glPushMatrix();
    3. glTranslatef(box1.pos.x, box1.pos.y, box1.pos.z);
    4. box1.draw();
    5. glPopMatrix();
    6.  
    7. //draw box2
    8. glPushMatrix();
    9. glTranslatef(box2.pos.x, box2.pos.y, box2.pos.z);
    10. box2.draw();
    11. glPopMatrix();
    To copy to clipboard, switch view to plain text mode 


    But the problem is I dont know how to get the position of x yz from the array list.

    is that possible?

  9. #8
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 976 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: dealing individual objects

    Maybe you should just try a more recent version? I have Blender 2.27a and there are two VRML97 exporters. Both seem to work correctly.

  10. The following user says thank you to jacek for this useful post:

    kingslee (15th November 2006)

  11. #9
    Join Date
    Aug 2006
    Location
    Germany
    Posts
    33
    Thanks
    8
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: dealing individual objects

    thanks jacek for ur reply.
    I use blender 2.42a and vrml 2.

    then I will try with vrml97 export and get back to you.

    thanks

  12. #10
    Join Date
    Aug 2006
    Location
    Germany
    Posts
    33
    Thanks
    8
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: dealing individual objects

    OMG
    It works perfectly with the vrml viewer


    the thing is, in the vrml2 export, there is no translation information of each objects.


    regards
    kings
    Last edited by kingslee; 15th November 2006 at 02:49. Reason: updated contents

Similar Threads

  1. Replies: 7
    Last Post: 18th July 2006, 22:33
  2. Help me to use QtSharedMemory to share the data objects
    By gtthang in forum Qt Programming
    Replies: 3
    Last Post: 17th February 2006, 12:50

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
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.