Exemplo n.º 1
0
Keyframe::Keyframe(map<Vector3f, SharkVertex*, compareVect3> *rawVerts, vector<Quad*> *rawFaces)
{
	//deep copy verts over.
	map<Vector3f, SharkVertex*, compareVect3>::iterator im;
	for(im = rawVerts->begin(); im != rawVerts->end(); im++)
	{
		pair<Vector3f, SharkVertex*> serk = *im;
		SharkVertex * d = new SharkVertex();
		d->sNormal(serk.second->gNormal());
		d->sTransformed(serk.second->gTransformed());
		d->sLocal(serk.second->gLocal());
		uVertices.insert(pair<Vector3f, SharkVertex*>(serk.first, d));
	}

	//create faces.
	vector<Quad*>::iterator iq;
        for(iq = rawFaces->begin(); iq != rawFaces->end(); iq++)
        {
		Quad * nRect = new Quad();
		for(int i = 0; i < 4; i++)
		{
			nRect->sVert(i, uVertices.find((*iq)->gLocalVert(i))->second);
		}
		faces.push_back(nRect);
	}

	//setNormals
	createQuads();
}
Exemplo n.º 2
0
void BOP_Merge2::mergeFaces(BOP_Mesh *m, BOP_Index v)
{
	m_mesh = m;

#ifdef BOP_DEBUG
	cout << "##############################" << endl;
#endif
	cleanup( );

	m_firstVertex = v;
	bool cont = false;

	// Merge faces
	mergeFaces();	

	do {
		// Add quads ...
		cont = createQuads();
		// ... and merge new faces
		if( cont ) cont = mergeFaces();

#ifdef BOP_DEBUG
		cout << "called mergeFaces " << cont << endl;
#endif
		// ... until the merge is not succesful
	} while(cont);
}
int main( int argc, char** argv )
{
    osgViewer::Viewer viewer;
    viewer.setSceneData( createQuads(20, 20) );
    viewer.addEventHandler( new osgViewer::StatsHandler );
    return viewer.run();
}
Exemplo n.º 4
0
/* Parse raw rotation data into new keyframes for the shark. Locations of points and quads that make up the shark 
* will be set with this method
* Requires infomation in Shark class with the same names to be passed in. 
 */
void Keyframe::gatherTransformData(GLfloat segmentRot[], GLfloat segLength[], Mesh *mesh, int segments, glQuaternion *glQuat )
{
	int startingPoint = 3;

	float start = mesh->lengthMax, end = mesh->lengthMax;//, length =0;
	for(int i = 0; i <= startingPoint; i++)
	{
		end = start; 
		start -= segLength[i];
		//length += start;
	}
	MyMat stackMatrix = MyMat();
	stackMatrix.makeTranslate(Vector3f(-segLength[startingPoint], 0, 0));

	transformHeirarchy(startingPoint, 0, segmentRot, segLength, mesh, segments, 
			glQuat, startingPoint, stackMatrix, start, end);
	 
	createQuads();                    
}
Exemplo n.º 5
0
/**
    \brief triangulate the scrap data
  */
void cwTriangulateTask::triangulateScrap(int index) {
    cwTriangulateInData& scrapData = Scraps[index];
    QRectF bounds = scrapData.outline().boundingRect();
    cwImage croppedImage = TriangulatedScraps[index].croppedImage();

    //Create the regualar mesh that covers the croppedImage
    PointGrid pointGrid = createPointGrid(bounds, scrapData);

    //Find all the points in the regualar mesh that are in the scrap's polygon
    QSet<int> gridPointsInScrap = pointsInPolygon(pointGrid, scrapData.outline());

    //Creates list of quads that are on the edges or in the scrap
    QuadDatabase quads = createQuads(pointGrid, scrapData.outline());

    //Triangulate the quads (this will update the outputs data)
    cwTriangulatedData triangleData = createTriangles(pointGrid, gridPointsInScrap, quads, scrapData);

    //Create the matrix that converts the normalized coords to the normalized coords
    QMatrix4x4 toLocal = localNormalizedCoordinates(bounds);

    //Convert the normalized points to local note points
    QVector<QVector3D> localNotePoints = mapToLocalNoteCoordinates(toLocal, triangleData.points());

    //Create the texture coordinates
    QVector<QVector2D> texCoords = mapTexCoordinates(localNotePoints);

    //Morph the points for the scrap
    QVector<QVector3D> points = morphPoints(triangleData.points(), scrapData, toLocal, croppedImage);

    //Morph the lead points for the scrap
    QVector<QVector3D> leadPoints = morphPoints(leadPositionToVector3D(scrapData.leads()),
                                                 scrapData,
                                                 toLocal,
                                                 croppedImage);

    //For testing
    cwTriangulatedData& outScrapData = TriangulatedScraps[index];
    outScrapData.setIndices(triangleData.indices());
    outScrapData.setPoints(points);
    outScrapData.setTexCoords(texCoords);
    outScrapData.setLeadPoints(leadPoints);
}
Exemplo n.º 6
0
/**
 * Simplifies a mesh, merging its faces.
 * @param m mesh
 * @param v index of the first mergeable vertex (can be removed by merge) 
 */
void BOP_Merge::mergeFaces(BOP_Mesh *m, BOP_Index v)
{
	m_mesh = m;
	m_firstVertex = v;

	bool cont = false;

	// Merge faces
	mergeFaces();

	do {
		// Add quads ...
		cont = createQuads();
		if (cont) {
			// ... and merge new faces
			cont = mergeFaces();
		}
		// ... until the merge is not succesful
	} while(cont);
}
Exemplo n.º 7
0
void initRenderer(int argc, char** argv, int w, int h) {

    screenWidth = w;
    screenHeight = h;

    glutInit(&argc, argv);

    glutInitWindowSize(screenWidth, screenHeight);
    glutInitDisplayMode(GLUT_RGBA | GLUT_DOUBLE | GLUT_ALPHA | GLUT_DEPTH);



    if (useEffects) {

        window = glutCreateWindow("RGBD - Waiting for Kinect...");
        glewInit();

        colourTexture = createTexture();
        depthTexture = createTexture();
        normalTexture = createTexture();
    


        createQuads();

        fogEffect = new FogEffect();
        dofEffect = new DOFEffect();
        relightingEffect = new RelightingEffect();
        cartoonEffect = new CartoonEffect();
        mapEffect = new MapEffect();

        createInterface();


    } else {



        window = glutCreateWindow("RGBD - Test Maps");
        glewInit();

        glGenTextures(1, &depthTexture);
        glBindTexture(GL_TEXTURE_2D, depthTexture);
        glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_BASE_LEVEL, 0);
        glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LEVEL, 0);
        glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
        glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
        glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
        glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);

        glGenTextures(1, &colourTexture);
        glBindTexture(GL_TEXTURE_2D, colourTexture);
        glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_BASE_LEVEL, 0);
        glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LEVEL, 0);
        glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
        glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
        glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
        glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);

        glGenTextures(1, &normalTexture);
        glBindTexture(GL_TEXTURE_2D, normalTexture);
        glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_BASE_LEVEL, 0);
        glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LEVEL, 0);
        glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
        glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
        glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
        glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);

        currentMap = colourTexture;
    }




}