3d Modeller (AGAIN PLEASE HeLp!!)

This message is c++ based.

Here is a bit of my source code

typedef struct{
float x,y,z;

typedef struct{
int a,b,c;

typedef struct {
vertex_type vertex[MAX_VERTICES];
polygon_type polygon[MAX_POLYGONS];

} obj_type, *obj_type_ptr;

All this means that instead of the regular types of identifiers(int,float)
I can now call obj_type!!

Here is code to say what vertexes the object has and where they are-

obj_type name =
-10, -10, 10, // vertex v0
10, -10, 10, // vertex v1
10, -10, -10, // vertex v2
-10, -10, -10, // vertex v3
-10, 10, 10, // vertex v4
10, 10, 10, // vertex v5
10, 10, -10, // vertex v6
-10, 10, -10 // vertex v7
this is the vertecies and there position in 3d space.
0, 1, 4, // polygon v0,v1,v4
1, 5, 4, // polygon v1,v5,v4
1, 2, 5, // polygon v1,v2,v5
2, 6, 5, // polygon v2,v6,v5
2, 3, 6, // polygon v2,v3,v6
3, 7, 6, // polygon v3,v7,v6
3, 0, 7, // polygon v3,v0,v7
0, 4, 7, // polygon v0,v4,v7
4, 5, 7, // polygon v4,v5,v7
5, 6, 7, // polygon v5,v6,v7
3, 2, 0, // polygon v3,v2,v0
2, 1, 0, // polygon v2,v1,v0
This code continues from the other one and says which verticies join to form the face.
Anyway my question is how can I later add new verticies and polgons if I use plus won’t I just edit the currently existing vertexies!!

Had you posted this in a beginner C++ forum, you might have gotten a response like this:


struct Vert {
float x, y, z;
struct Triangle {
int ix[3];
struct Object {
vector verts;
vector tris;
void draw() {
glEnableClientState( GL_VERTEX_ARRAY );
glVertexPointer( 3, GL_FLOAT, 0, &verts[0] );
glDrawElements( GL_TRIANGLES, tris.size()*3, GL_UNSIGNED_INT, &tris[0] );
glDisableClientState( GL_VERTEX_ARRAY );

void addVert( Vert const & v ) {
verts.push_back( v );
void addTriangle( Triangle const & t ) {
tris.push_back( t );

But, since you didn’t ask in a beginner C++ forum, you get this answer, plus the additional, FREE!, recommendation to post language-related questions in a language-related forum.

I prefer this way,
GLfloat *myarray = glnew[somevalue];


gldelete [] myarray;

Simply create a new definition for new[] and delete[].


Thanks jwatte I haven’t done it yet but I completly understand it.
I was just wondering with the way you have done it there how would you implement names to select from and identify say a cube from a triangle etc.

Help jwatte do you think you could send me an example souce code to Shanedudddy2@hotmail.com
Because when I try to do what you said to do it comes up with errors to do with calling vector wrong or something!!

[This message has been edited by shanedudddy2 (edited 01-06-2003).]

Please send me a working example to
Also what does push_back command do??

shaneduddy2, like said before you will really have to learn the basics of C/C++ first before you can actually create something usefull and none is going to send you a working example (would you spoonfeed someone yourself?).

push_back is a very well known method from the STL.
If you do not know what the STL is, use Google, type ‘STL’, press ENTER, and find out what it is.

Found out all about stl and stuff.
From your example in the
structures for adding verts and triangles you
make references to v & t.
What do they mean?
I know you declared
v as a vert type
t as a triangle type
,but how do I define the position of the vert
in which case how do I declare v and 3 numbers

What does the v & the t stand for.
Please explain

Please help me jwatte!!

v and t are of type Vert and Triangle, defined a few lines above in that same file.

Jwatte I know they are of vert and triangle types but how do I declare what position the v should be the x,y,z of the vertex please help

ohh please shut up now. i even explained you in the first post of you to use vector. get a c++ book, read www.gametutorials.com till you understand them, read nehe.gamedev.net till you understand them, and then you have no problem…

and most of all, that was (actually more or less working, but still not complete) pseudocode. please learn to understand to read such code…

you’re here in the advanced opengl forum. that means you have a quite a good knowledge of the language you use, and a quite a good knowledge of opengl, you have questions about some newer features/extensions, or about complex problems. they are not questions about basic language problems.

and NO ONE, NEVER IN ANY CHANCE gives you working code, except in tutorials or books. FORGET IT. we are not here to do your job. thats your task. we are here to help you in questions, to discuss problems, etc. about advanced opengl topics.


ps.:thats not ment to offend, its ****ing early in the morning here, thats all…

shaneduddy2 has gained the status of ‘Frequent Contributor’. sigh I’m not gonna try to answer this guy’s question (what was it again?), but I am gonna gripe about how much this forum needs moderating. I mean, someone who pollutes the forum with posts begging for free code has no right to have a status of ‘frequent contributer’. I know it’s based on the number of posts a person has made, but this is rediculous. And I have to agree totally with Dave. Shane, PLEASE, PLEASE, PLEASE do yourself a favour and actually learn the friggn’ language you intend to program with. I am a firm believer in “only helping those that help themselves.” Take some initiative, make some friggn’ effort and quit expecting others to do it for you. PLEASE!!! PLEASE!!! PLEASE!!!

p.s. My post wasn’t meant to be offensive either. It was however, Shane, meant to make you feel bad about your forum abuse This forum is not moderated and viral posts like yours only encourage future problems.

[This message has been edited by fenris (edited 01-10-2003).]


have you check the link I’ve posted in another thread :

It could really be useful to you; besides, it has a forum where you’ll get much friendlier answers than here.

This piece comes to mind: http://www.tuxedo.org/~esr/faqs/smart-questions.html