示例#1
0
文件: main.cpp 项目: darxsys/IRG
void animateSceneCenterMovement() {
	calculateBezier(points);
	for(int i = 0; i < bezierPoints.size(); ++i) {
		center.i = bezierPoints[i].x;
		center.j = bezierPoints[i].y;
		center.k = bezierPoints[i].z;

		ObjectModel* n = removePolygons(original);

		//pronadji matricu transformacije za postojece ociste i glediste
		float* MatrixViewT;
		float* MatrixProjectionT;
		MakeTransform(eye, center, &MatrixViewT, &MatrixProjectionT);
		float* Matrix;
		MatrixMultiply(MatrixViewT, 4, 4, MatrixProjectionT, 4, 4, &Matrix);
		ObjectModel* o = TransformCopy(n, Matrix);
		o->normalize();	
		free(MatrixViewT); free(MatrixProjectionT); free(Matrix);

		drawBody(o);		
		delete n; delete o;
		sleep(1);
	}
	//glutSwapBuffers();
	printf("Animacija gotova.\n");
}
示例#2
0
ObjectModel *SUROpener::openSUR(QString fileName)
{
    Parser parser(fileName);
    ObjectModel *om = new ObjectModel();
    for (int i=0; i<parser.getCoordinates().size(); i++)
    {
        Parser::Coordinate c = parser.getCoordinates().at(i);
        om->addVertex(c.x, c.y, c.z);
    }
    for (int i=0; i<parser.getIncidences().size(); i++)
    {
        Parser::Incidence in= parser.getIncidences().at(i);
        om->addTriangle(in.a-1, in.b-1, in.c-1);
    }
    om->normalize();
    return om;
}
示例#3
0
文件: main.cpp 项目: darxsys/IRG
void renderScene() {
	// ObjectModel* n = new ObjectModel(original);
	ObjectModel* n = removePolygons(original);

	//pronadji matricu transformacije za postojece ociste i glediste
	float* MatrixViewT;
	float* MatrixProjectionT;
	MakeTransform(eye, center, &MatrixViewT, &MatrixProjectionT);
	float* Matrix;
	MatrixMultiply(MatrixViewT, 4, 4, MatrixProjectionT, 4, 4, &Matrix);
	ObjectModel* o = TransformCopy(n, Matrix);
	o->normalize();	

	free(MatrixViewT); free(MatrixProjectionT); free(Matrix);

	drawBody(o);
	delete n; delete o; //delete original;
}
示例#4
0
文件: main.cpp 项目: darxsys/IRG
int main(int argc, char** argv) {
    if (argc != 2) {
        printf("Trebam ulaznu .obj datoteku kao prvi i jedini argument komandne linije.\n");
        exit(1);
    }

    char* filename = argv[1];
    ObjectModel* obj = new ObjectModel(filename);

    printf("Unosite naredbe\n");
    float x, y, z;
    int status;
    char prompt[100];
    while(1) {
        fgets(prompt, sizeof(prompt), stdin);
        if (!strcmp(prompt, "normiraj\n")) {
            obj->normalize();
            std::cout << obj->dumpToObj();
            //getchar();
            continue;
        } else if (!strcmp(prompt, "quit\n")) {
            break;
        } else {
            sscanf(prompt, "%f %f %f", &x, &y, &z);
            obj->checkPoint(x, y, z, &status);
            if (!status) {
                printf("Tocka nije unutar tijela!\n");
            } else if (status == 1) {
                printf("Tocka je na rubu tijela\n");
            } else {
                printf("Tocka je unutar tijela\n");
            }
        }
    }

    return 0;
}