Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

weasalmongler

Rendering Bezier Patches from Quake 3 bsp levels

This topic is 5968 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Right, the time has come for me to render the patches section of the Quake3 level. I imaging this is done with functions like : glMap2f(...); glMapGrid2f(...); glEvalMesh2(...); How do I now render the patches section, does anybody have a code example or pseudocode or something, as I am finding it very complicated. I am not sure how to use the vertices from the level to generate a proper sized curved surface. Can anybody help? -Weasalmongler

Share this post


Link to post
Share on other sites
Advertisement
You use the vertices as control points on a quadratic bezier surface.

Quadratic bezier surfaces are 3x3, so if you have a greater size in a patch, you can divide it up into 3x3 patches and render those. Remember that they have to share a set of control points to be continuous, though. A 3x5 patch, for example, is really a pair of 3x3 patches.

I can''t help you out with any code examples for EvalMesh, unfortunately. I tesselate my patches at load time to save on CPU resources. With EvalMesh you''re stuck tesselating at run time unless you are willing to use display lists.

Share this post


Link to post
Share on other sites
Thanks, your information has helped.

I still feel that I need more help though, could anybody else go into more detail and maybe give some pseudocode examples.

-Weasalmongler

Share this post


Link to post
Share on other sites
If you''re going to use OpenGL evaluators, the Red Book has code examples for drawing bezier surfaces.

If you want to tesslate the bezier patches yourself, then read over the articles about bezier curves and patches here on gamedev, which are pretty decent.

There really isn''t anything special about quake3''s bezier patches, so any tutorials you find (like the one at Nehe''s site) are going to apply.

Share this post


Link to post
Share on other sites
Sorry, I know how to use the OpenGL evaluators, I have some information on it already from books, what I don''t understand is how to use the Quake3 format of faces and meshes etc, with the evaluators to draw the surface, How do I only pass the proper vertices to the functions?

-Weasalmongler

Share this post


Link to post
Share on other sites
Well, the Red Book uses a [4][4][3] array for a cubic surface. Cubic''s have 4x4 control points, and quake uses quadratics, which have 3x3 control points. Copy the vertex positions pointed to by the face into a [3][3][3] array of floats.

Then just follow the existing example. The only other change ought to be knocking down the ''order'' argument of the evaluator by one.

Share this post


Link to post
Share on other sites
Could you post the section of code here?

I don''t have the Red Book and I cannot get access to the online version (can''t get there for some reason).

Thx.

Weasalmongler

Share this post


Link to post
Share on other sites
Guest Anonymous Poster

Ok. You can download all the source code to the red book from
ftp://sgigate.sgi.com/pub/opengl/opengl1_1.tar.Z

If you can''t get there either, here is the relevant section:

Example 12-2 : Bézier Surface: bezsurf.c


#include <GL/gl.h>
#include <GL/glu.h>
#include <stdlib.h>
#include <GL/glut.h>

GLfloat ctrlpoints[4][4][3] = {
{{-1.5, -1.5, 4.0}, {-0.5, -1.5, 2.0},
{0.5, -1.5, -1.0}, {1.5, -1.5, 2.0}},
{{-1.5, -0.5, 1.0}, {-0.5, -0.5, 3.0},
{0.5, -0.5, 0.0}, {1.5, -0.5, -1.0}},
{{-1.5, 0.5, 4.0}, {-0.5, 0.5, 0.0},
{0.5, 0.5, 3.0}, {1.5, 0.5, 4.0}},
{{-1.5, 1.5, -2.0}, {-0.5, 1.5, -2.0},
{0.5, 1.5, 0.0}, {1.5, 1.5, -1.0}}
};

void display(void)
{
int i, j;

glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glColor3f(1.0, 1.0, 1.0);
glPushMatrix ();
glRotatef(85.0, 1.0, 1.0, 1.0);
for (j = 0; j <= 8; j++) {
glBegin(GL_LINE_STRIP);
for (i = 0; i <= 30; i++)
glEvalCoord2f((GLfloat)i/30.0, (GLfloat)j/8.0);
glEnd();
glBegin(GL_LINE_STRIP);
for (i = 0; i <= 30; i++)
glEvalCoord2f((GLfloat)j/8.0, (GLfloat)i/30.0);
glEnd();
}
glPopMatrix ();
glFlush();
}

void init(void)
{
glClearColor (0.0, 0.0, 0.0, 0.0);
glMap2f(GL_MAP2_VERTEX_3, 0, 1, 3, 4,
0, 1, 12, 4, &ctrlpoints[0][0][0]);
glEnable(GL_MAP2_VERTEX_3);
glMapGrid2f(20, 0.0, 1.0, 20, 0.0, 1.0);
glEnable(GL_DEPTH_TEST);
glShadeModel(GL_FLAT);
}

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!