Allow to draw bezier curve (only the points)
This commit is contained in:
parent
cbbffc247b
commit
1a107b455b
@ -66,6 +66,7 @@ bool shademodel = true;
|
|||||||
/*
|
/*
|
||||||
* static function declaration
|
* static function declaration
|
||||||
*/
|
*/
|
||||||
|
static void draw_bez(HE_obj const * const obj);
|
||||||
static void draw_obj(int32_t const myxrot,
|
static void draw_obj(int32_t const myxrot,
|
||||||
int32_t const myyrot,
|
int32_t const myyrot,
|
||||||
int32_t const myzrot);
|
int32_t const myzrot);
|
||||||
@ -188,6 +189,31 @@ static void draw_vertices(HE_obj const * const obj,
|
|||||||
glPopMatrix();
|
glPopMatrix();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void draw_bez(HE_obj const * const obj)
|
||||||
|
{
|
||||||
|
uint32_t i = 0;
|
||||||
|
static float line_width = 2;
|
||||||
|
|
||||||
|
glPushMatrix();
|
||||||
|
|
||||||
|
glLineWidth(line_width);
|
||||||
|
glColor3f(1.0, 0.0, 0.0);
|
||||||
|
|
||||||
|
|
||||||
|
while (i < obj->bzc) {
|
||||||
|
glBegin(GL_LINE_STRIP);
|
||||||
|
for (uint32_t j = 0; j <= obj->bez_curves[i].deg; j++) {
|
||||||
|
glVertex3f(obj->bez_curves[i].vec[j].x,
|
||||||
|
obj->bez_curves[i].vec[j].y,
|
||||||
|
obj->bez_curves[i].vec[j].z);
|
||||||
|
}
|
||||||
|
glEnd();
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
|
||||||
|
glPopMatrix();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Draws an object.
|
* Draws an object.
|
||||||
@ -234,7 +260,10 @@ static void draw_obj(int32_t const myxrot,
|
|||||||
if (show_normals)
|
if (show_normals)
|
||||||
draw_normals(obj, 0);
|
draw_normals(obj, 0);
|
||||||
|
|
||||||
draw_vertices(obj, false);
|
if (obj->ec != 0)
|
||||||
|
draw_vertices(obj, false);
|
||||||
|
|
||||||
|
draw_bez(obj);
|
||||||
|
|
||||||
glPopMatrix();
|
glPopMatrix();
|
||||||
}
|
}
|
||||||
|
@ -273,6 +273,15 @@ bool normalize_object(HE_obj *obj)
|
|||||||
obj->vertices[i].vec->z = obj->vertices[i].vec->z * scale_factor;
|
obj->vertices[i].vec->z = obj->vertices[i].vec->z * scale_factor;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for (uint32_t i = 0; i < obj->bzc; i++) {
|
||||||
|
for (uint32_t j = 0; j <= obj->bez_curves[i].deg; j++) {
|
||||||
|
obj->bez_curves[i].vec[j].x *= scale_factor;
|
||||||
|
obj->bez_curves[i].vec[j].y *= scale_factor;
|
||||||
|
obj->bez_curves[i].vec[j].z *= scale_factor;
|
||||||
|
}
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -535,6 +535,9 @@ HE_obj *parse_obj(char const * const obj_string)
|
|||||||
*/
|
*/
|
||||||
static void delete_accel_struct(HE_obj *he_obj)
|
static void delete_accel_struct(HE_obj *he_obj)
|
||||||
{
|
{
|
||||||
|
if (he_obj->ec == 0)
|
||||||
|
return; /* probably only a bezier curve */
|
||||||
|
|
||||||
for (uint32_t i = 0; i < he_obj->vc; i++) {
|
for (uint32_t i = 0; i < he_obj->vc; i++) {
|
||||||
free(he_obj->vertices[i].acc->dummys);
|
free(he_obj->vertices[i].acc->dummys);
|
||||||
free(he_obj->vertices[i].acc->edge_array);
|
free(he_obj->vertices[i].acc->edge_array);
|
||||||
|
Loading…
Reference in New Issue
Block a user