View Full Version : helpe me with this, please
04-19-2003, 08:31 PM
Actually i want to dig down a hole or a river on a plane, i want to texture the rest part of the plane without having the digged part textured or covered. Is there a better solution than the one below which i posted a fews days ago but no anwser?
There are a number of polygons (which could be of any shape, may not be the polygon of openGl definition) on a plane(a rectangle), now i want to fill the rest of the plane with QUADS or TRIANGLE or any valid openGL polygon.
Anyone has any idea? or are there any existing algorithms that just fix this?
Thanks in advance!
04-20-2003, 12:24 AM
You can use the glu tesselators. Search for them, I think there should be plenty of tutorials. Basically you feed the tesselator your polygons and the plane and it spits out the opengl primitives.
04-21-2003, 01:43 AM
Thanks. I remember it was you that helped with my prevoius problem(finding the lost point).
I really should thank you a lot!
I did some try on tesselator, below is the code copied from a book, but nothing appeared on screen.
04-22-2003, 12:11 AM
You have to specify the callbacks. The tesselation object uses these to output geometry. Easiest way is to bind them directly to the opengl drawing commands, like this:
gluTessCallback(tess, GLU_TESS_BEGIN, glBegin);
gluTessCallback(tess, GLU_TESS_VERTEX, glVertex3dv);
gluTessCallback(tess, GLU_TESS_END, glEnd);
You could also create your own callbacks to collect the geometry to your own data structures, but that's a little harder, I suggest you start with these. You can draw it in a display list once so you don't have to use the tesselation object every frame.
04-22-2003, 01:40 AM
I got the error message below for gluTessCallback(tess, GLU_TESS_BEGIN, glBegin); (but not for glEnd)
Strange, the exactly same code used in an example has no problem. Maybe i missed something.Frankly i don't quite understand the way Callback working.
Regards and looking forward to your reply
error C2664: 'gluTessCallback' : cannot convert parameter 3 from 'void (unsigned int)' to 'void (__stdcall *)(void)'
04-22-2003, 02:07 AM
Looks like some c/c++ weirdness. I don't know, I've never done it in c. It doesn't seem to allow glBegin as an argument, since it's not of the right type. Some typecast could help. I really don't know, maybe somebody who knows c a little better could help. In the meantime, you can search for other tutorials, I'm sure somebody has solved that already.
Visual C++ is telling you that the argument you passed for the callback (glBegin) is not of the correct type. It appears that the callback is supposed to be a function which takes no arguments (like glEnd) not a function which takes an integer argument (like glBegin).
04-22-2003, 07:04 AM
But the callback function can be of several types. It's arguments are specified by the second argument of the tessCallback call. The function you pass is ultimately just a pointer, I'm sure it's just a matter of typecasting it. I think the easiest fix would be to check the type the tessCallback expects in your glu.h, and cast the glBegin to whatever that is.
04-22-2003, 07:05 AM
i fixed the compilation error by searching some old messages here. But That pice of code still does nothing. Now i am also worried about the texture of the generated triangle or anything since i don't have or don't know how to have texturecoord.
04-22-2003, 05:15 PM
Sorry, I made a mistake, the arry for 2 contours should be seperated. It's working now.
But as i worried, i need to know how many triangles and which 3 vertexs make each of these triangles in order to do proper texture, could you give me more help?
Thanks a lot
04-22-2003, 08:34 PM
Now it seems i made some kind of progress. I am gussing the way to find out the number of triangle and its vertex is to do some coding for my own callback Begin/vertex/End by using the parameters and the order calling the functions as the inputs. Is that the idea?
If so now the problem comes to a basic C question:
The code now steps to my own callback"gluTessCallback(tess,GLU_TESS_VERTEX_DATA,myvertex tdata)". As some book says the prototype of this callback looks like:
void myvertexdata(void *vertex_data,void *polygon_data),
but how can i access vertex data(double vv which was declared as some kind of global) through the parameter "vertex_data" (even i can see the the pointer is pointing to where it is supposed to)
Anyone be so nice as to show me how in detail?
04-22-2003, 10:18 PM
I think you can insert it into a vector like this:
double * v;
v = (double *)vertex_data;
But I'm no c expert so forgive me if it doesn't work. An alternative way to apply a texture would be using the automatic texture coordinate generation, here are the istructions for that: http://www.opengl.org/discussion_boards/ubb/Forum2/HTML/011409.html
04-23-2003, 01:36 AM
Hi Dear Ilkka:
You are great! I got the data i want! I will stick to this solution.
I am a chinese, I'd like to make friend with you, if you have a chance to visit china(but don't come at this moment, we have some horrible disease spread out), I will be happy to treat you. My e mail is email@example.com
Best regards, Liuya
Powered by vBulletin® Version 4.2.3 Copyright © 2016 vBulletin Solutions, Inc. All rights reserved.