Beispiel #1
0
static void DrawPointSet(PointSetNode *pointSet)
{
	CoordinateNode *coordinate = pointSet->getCoordinateNodes();
	if (!coordinate)
		return;

	NormalNode	*normal = pointSet->getNormalNodes();
	ColorNode	*color = pointSet->getColorNodes();

	float	vpoint[3];
	float	pcolor[3];

	glColor3f(1.0f, 1.0f, 1.0f);

	glBegin(GL_POINTS);

	int nCoordinatePoint = coordinate->getNPoints();
	for (int n=0; n<nCoordinatePoint; n++) {

		if (color) {
			color->getColor(n, pcolor);
			glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE, pcolor);
//			glColor3fv(pcolor);
		}

		coordinate->getPoint(n, vpoint);
		glVertex3fv(vpoint);
	}

	glEnd();
}
Beispiel #2
0
void PointSetNode::recomputeBoundingBox() 
{
	CoordinateNode *coordinate = getCoordinateNodes();
	if (!coordinate) {
		setBoundingBoxCenter(0.0f, 0.0f, 0.0f);
		setBoundingBoxSize(-1.0f, -1.0f, -1.0f);
		return;
	}

	BoundingBox bbox;
	float		point[3];

	int nCoordinatePoints = coordinate->getNPoints();
	for (int n=0; n<nCoordinatePoints; n++) {
		coordinate->getPoint(n, point);
		bbox.addPoint(point);
	}

	setBoundingBox(&bbox);
}
Beispiel #3
0
int ColModel::add_triangles_face(TransformNode* tnode, IndexedFaceSetNode* inode)
{
    CoordinateNode* cnode = inode->getCoordinateNodes();
    if(!cnode) return -1;
    int n_my_vertex = cnode->getNPoints();
    int n_index = inode->getNCoordIndexes();
    if(n_my_vertex == 0 || n_index == 0) return 0;
    int i;
    int vertex_id_base = n_vertex;
    n_vertex += n_my_vertex;
    // reallocate memory for saving vertices and save current vertices
#if 1
    fVec3* tmp_vertices = vertices;
    vertices = new fVec3 [n_vertex];
    if(tmp_vertices)
    {
        for(i=0; i<vertex_id_base; i++)
            vertices[i].set(tmp_vertices[i]);
        delete[] tmp_vertices;
    }
#else
    fVec3* tmp_vertices = 0;
    if(vertices)
    {
        tmp_vertices = new fVec3 [vertex_id_base];
        for(i=0; i<vertex_id_base; i++)
            tmp_vertices[i].set(vertices[i]);
        delete[] vertices;
    }
    vertices = new fVec3 [n_vertex];
    for(i=0; i<vertex_id_base; i++)
        vertices[i].set(tmp_vertices[i]);
    if(tmp_vertices) delete[] tmp_vertices;
#endif
    float fp[3];
    for(i=0; i<n_my_vertex; i++)
    {
        cnode->getPoint(i, fp);
        vertices[i+vertex_id_base](0) = fp[0];
        vertices[i+vertex_id_base](1) = fp[1];
        vertices[i+vertex_id_base](2) = fp[2];
        apply_all_transforms(tnode, (Node*)cnode, vertices[i+vertex_id_base]);
    }
    // process polygons (all changed to ccw)
    int ccw = inode->getCCW();
    for(i=0; i<n_index; i++)
    {
        int c1, c2, c3;
        c1 = inode->getCoordIndex(i);
        i++;
        while( (c2 = inode->getCoordIndex(i)) != -1 &&
                (c3 = inode->getCoordIndex(i+1)) != -1 )
        {
            TriangleInfo* ti = 0;
            if(ccw) ti = new TriangleInfo(c1+vertex_id_base, c2+vertex_id_base, c3+vertex_id_base);
            else ti = new TriangleInfo(c1+vertex_id_base, c3+vertex_id_base, c2+vertex_id_base);
            triangles.append(ti);
            n_triangle++;
            i++;
        }
        i += 1;
    }
    return 0;
}