JNIEXPORT void JNICALL JNIFUNCTION_DEMO(demoInitialise(JNIEnv* env, jobject object)) {
	
	const char *model0file = "Data/models/Porsche_911_GT3.obj";
	const char *model1file = "Data/models/Ferrari_Modena_Spider.obj";

	models[0].patternID = arwAddMarker("single;Data/patt.hiro;80");
	arwSetMarkerOptionBool(models[0].patternID, ARW_MARKER_OPTION_SQUARE_USE_CONT_POSE_ESTIMATION, false);
	arwSetMarkerOptionBool(models[0].patternID, ARW_MARKER_OPTION_FILTERED, true);

	models[0].obj = glmReadOBJ2(model0file, 0, 0); // context 0, don't read textures yet.
	if (!models[0].obj) {
		LOGE("Error loading model from file '%s'.", model0file);
		exit(-1);
	}
	glmScale(models[0].obj, 0.035f);
	//glmRotate(models[0].obj, 3.14159f / 2.0f, 1.0f, 0.0f, 0.0f);
	glmCreateArrays(models[0].obj, GLM_SMOOTH | GLM_MATERIAL | GLM_TEXTURE);
	models[0].visible = false;
	
	models[1].patternID = arwAddMarker("single;Data/patt.kanji;80");
	arwSetMarkerOptionBool(models[1].patternID, ARW_MARKER_OPTION_SQUARE_USE_CONT_POSE_ESTIMATION, false);
	arwSetMarkerOptionBool(models[1].patternID, ARW_MARKER_OPTION_FILTERED, true);

	models[1].obj = glmReadOBJ2(model1file, 0, 0); // context 0, don't read textures yet.
	if (!models[1].obj) {
		LOGE("Error loading model from file '%s'.", model1file);
		exit(-1);
	}
	glmScale(models[1].obj, 0.035f);
	//glmRotate(models[1].obj, 3.14159f / 2.0f, 1.0f, 0.0f, 0.0f);
	glmCreateArrays(models[1].obj, GLM_SMOOTH | GLM_MATERIAL | GLM_TEXTURE);
	models[1].visible = false;
}
Пример #2
0
bool ARTApp::init(const char *cparamName, const char *pattName, const char *objModelFile, float pattWidth, float modelScale)
{
	if (arHandle) //has initialized
		return false;

	if (!setupCamera(cparamName, "", &cParam, &arHandle, &ar3DHandle)) {
		return false;
	}

	if (!setupMarker(pattName, &pattID, arHandle, &pattHandle)) {
		return false;
	}

	{
		objModel = glmReadOBJ((char*)objModelFile);
		if (!objModel)
		{
			ARLOGe("Unable to load obj model file.\n");
			return false;
		}
		glmUnitize(objModel);
		glmScale(objModel, pattWidth*modelScale);
	}
	this->pattWidth = pattWidth;

	return true;
}
Пример #3
0
void drawBunny(const char * objname)
{
	GLMmodel* pModel = NULL;
	// The obj file will be loaded
	char FileName[128];
	sprintf(FileName, "%smodels/%s.obj", root, objname);

	// Center of the model
	float modelCenter[] = { 0.0f, 0.0f, 0.0f };

	// Load the new obj model
	pModel = glmReadOBJ(FileName);

	// Scale the model to fit the screen
	glmUnitize(pModel, modelCenter);

	// Generate normal for the model
	glmFacetNormals(pModel);
	
	glmScale(pModel, 1.5);
	glmVertexNormals(pModel, 90.0f);

	if (pModel)
	{
		glmDraw(pModel, GLM_SMOOTH);
	}
}
Пример #4
0
void
Robot::setRobotParameters(carmen_vector_3D_t robot_size)
{
	this->robot_size_  = robot_size;

	if(this->robot_model_ != NULL)
		glmScale(this->robot_model_, this->robot_size_.x / 1.7);
}
Пример #5
0
CarDrawer* createCarDrawer(int argc, char** argv)
{	
	CarDrawer* carDrawer = malloc(sizeof(CarDrawer));

	carDrawer->carModel = glmReadOBJ("ford_escape_model.obj");
	glmUnitize(carDrawer->carModel);

	int num_items;

	carmen_param_t param_list[] = {
	{"carmodel", "size_x", CARMEN_PARAM_DOUBLE, &(carDrawer->car_size.x), 0, NULL},
	{"carmodel", "size_y", CARMEN_PARAM_DOUBLE, &(carDrawer->car_size.y), 0, NULL},
	{"carmodel", "size_z", CARMEN_PARAM_DOUBLE, &(carDrawer->car_size.z), 0, NULL},
	{"carmodel", "x", CARMEN_PARAM_DOUBLE, &(carDrawer->car_pose.position.x), 0, NULL},
	{"carmodel", "y", CARMEN_PARAM_DOUBLE, &(carDrawer->car_pose.position.y), 0, NULL},
	{"carmodel", "z", CARMEN_PARAM_DOUBLE, &(carDrawer->car_pose.position.z), 0, NULL},
	{"carmodel", "roll", CARMEN_PARAM_DOUBLE, &(carDrawer->car_pose.orientation.roll), 0, NULL},
	{"carmodel", "pitch", CARMEN_PARAM_DOUBLE, &(carDrawer->car_pose.orientation.pitch), 0, NULL},
	{"carmodel", "yaw", CARMEN_PARAM_DOUBLE, &(carDrawer->car_pose.orientation.yaw), 0, NULL},
	{"car", "axis_distance", CARMEN_PARAM_DOUBLE, &(carDrawer->car_axis_distance), 0, NULL},
	{"car", "wheel_diameter", CARMEN_PARAM_DOUBLE, &(carDrawer->car_wheel_diameter), 0, NULL},

	{"sensor_board_1", "x", CARMEN_PARAM_DOUBLE, &(carDrawer->sensor_board_1_pose.position.x), 0, NULL},
	{"sensor_board_1", "y", CARMEN_PARAM_DOUBLE, &(carDrawer->sensor_board_1_pose.position.y), 0, NULL},
	{"sensor_board_1", "z", CARMEN_PARAM_DOUBLE, &(carDrawer->sensor_board_1_pose.position.z), 0, NULL},
	{"sensor_board_1", "roll", CARMEN_PARAM_DOUBLE, &(carDrawer->sensor_board_1_pose.orientation.roll), 0, NULL},
	{"sensor_board_1", "pitch", CARMEN_PARAM_DOUBLE, &(carDrawer->sensor_board_1_pose.orientation.pitch), 0, NULL},
	{"sensor_board_1", "yaw", CARMEN_PARAM_DOUBLE, &(carDrawer->sensor_board_1_pose.orientation.yaw), 0, NULL},

	{"xsens", "size_x", CARMEN_PARAM_DOUBLE, &(carDrawer->xsens_size.x), 0, NULL},
	{"xsens", "size_y", CARMEN_PARAM_DOUBLE, &(carDrawer->xsens_size.y), 0, NULL},
	{"xsens", "size_z", CARMEN_PARAM_DOUBLE, &(carDrawer->xsens_size.z), 0, NULL},
	{"xsens", "x", CARMEN_PARAM_DOUBLE, &(carDrawer->xsens_pose.position.x), 0, NULL},
	{"xsens", "y", CARMEN_PARAM_DOUBLE, &(carDrawer->xsens_pose.position.y), 0, NULL},
	{"xsens", "z", CARMEN_PARAM_DOUBLE, &(carDrawer->xsens_pose.position.z), 0, NULL},
	{"xsens", "roll", CARMEN_PARAM_DOUBLE, &(carDrawer->xsens_pose.orientation.roll), 0, NULL},
	{"xsens", "pitch", CARMEN_PARAM_DOUBLE, &(carDrawer->xsens_pose.orientation.pitch), 0, NULL},
	{"xsens", "yaw", CARMEN_PARAM_DOUBLE, &(carDrawer->xsens_pose.orientation.yaw), 0, NULL},	

	{"laser", "size_x", CARMEN_PARAM_DOUBLE, &(carDrawer->laser_size.x), 0, NULL},
	{"laser", "size_y", CARMEN_PARAM_DOUBLE, &(carDrawer->laser_size.y), 0, NULL},
	{"laser", "size_z", CARMEN_PARAM_DOUBLE, &(carDrawer->laser_size.z), 0, NULL},
	{"velodyne", "x", CARMEN_PARAM_DOUBLE, &(carDrawer->laser_pose.position.x), 0, NULL},
	{"velodyne", "y", CARMEN_PARAM_DOUBLE, &(carDrawer->laser_pose.position.y), 0, NULL},
	{"velodyne", "z", CARMEN_PARAM_DOUBLE, &(carDrawer->laser_pose.position.z), 0, NULL},
	{"velodyne", "roll", CARMEN_PARAM_DOUBLE, &(carDrawer->laser_pose.orientation.roll), 0, NULL},
	{"velodyne", "pitch", CARMEN_PARAM_DOUBLE, &(carDrawer->laser_pose.orientation.pitch), 0, NULL},
	{"velodyne", "yaw", CARMEN_PARAM_DOUBLE, &(carDrawer->laser_pose.orientation.yaw), 0, NULL}
	};
	
	num_items = sizeof(param_list)/sizeof(param_list[0]);
	carmen_param_install_params(argc, argv, param_list, num_items);

	glmScale(carDrawer->carModel, carDrawer->car_size.x/2.0);

	return carDrawer;
}
Пример #6
0
void init(void)
{
	glEnable(GL_DEPTH_TEST);
	glClearColor(0.6, 0.6, 0.6, 1);
	glPixelStorei(GL_UNPACK_ALIGNMENT, 1);

	pngLoadRaw("terrain5.png", &info);
	setheight();
	move[1] = bilinear(move[0], move[2]);
	tri[0] = Vec3(0, bilinear(0, 0.5), 0.5);
	tri[1] = Vec3(2.5, bilinear(2.5, 0), 0);
	tri[2] = Vec3(0, bilinear(0, -0.5), -0.5);

	car = glmReadOBJ("porsche.obj");
	glmUnitize(car);
	glmScale(car, 15);
	glmFacetNormals(car);
	glmVertexNormals(car, 90);

	glEnable(GL_TEXTURE_2D);
}
Пример #7
0
/*******************************************************************************
 Initialize the 3d Model for tool .  This involves reading 3ds file, calculating normals,
 calculating tangent space and bounding box.
*******************************************************************************/
void initToolOBJModel()
{
    if (!toolObjmodel)
    {
        toolObjmodel = glmReadOBJ(model2Path);

        if (!toolObjmodel)
        {
            printf("OBJ file does not exist \n");
            exit(0);
        }

        glmUnitize(toolObjmodel);
        glmScale(toolObjmodel, 0.250);
        glmFacetNormals(toolObjmodel);
        glmVertexNormals(toolObjmodel, 90.0);
    }

    toolObjList = glGenLists(1);
    glNewList( toolObjList, GL_COMPILE );
    glmDraw(toolObjmodel, GLM_SMOOTH);
    glEndList();
}
Пример #8
0
void
keyboard(unsigned char key, int x, int y)
{
    GLint params[2];
    
    switch (key) {
    case 'h':
        printf("help\n\n");
        printf("w         -  Toggle wireframe/filled\n");
        printf("c         -  Toggle culling\n");
        printf("n         -  Toggle facet/smooth normal\n");
        printf("b         -  Toggle bounding box\n");
        printf("r         -  Reverse polygon winding\n");
        printf("m         -  Toggle color/material/none mode\n");
        printf("p         -  Toggle performance indicator\n");
        printf("s/S       -  Scale model smaller/larger\n");
        printf("t         -  Show model stats\n");
        printf("o         -  Weld vertices in model\n");
        printf("+/-       -  Increase/decrease smoothing angle\n");
        printf("W         -  Write model to file (out.obj)\n");
        printf("q/escape  -  Quit\n\n");
        break;
        
    case 't':
        stats = !stats;
        break;
        
    case 'p':
        performance = !performance;
        break;
        
    case 'm':
        material_mode++;
        if (material_mode > 2)
            material_mode = 0;
        printf("material_mode = %d\n", material_mode);
        lists();
        break;
        
    case 'd':
        glmDelete(model);
        init();
        lists();
        break;
        
    case 'w':
        glGetIntegerv(GL_POLYGON_MODE, params);
        if (params[0] == GL_FILL)
            glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
        else
            glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
        break;
        
    case 'c':
        if (glIsEnabled(GL_CULL_FACE))
            glDisable(GL_CULL_FACE);
        else
            glEnable(GL_CULL_FACE);
        break;
        
    case 'b':
        bounding_box = !bounding_box;
        break;
        
    case 'n':
        facet_normal = !facet_normal;
        lists();
        break;
        
    case 'r':
        glmReverseWinding(model);
        lists();
        break;
        
    case 's':
        glmScale(model, 0.8);
        lists();
        break;
        
    case 'S':
        glmScale(model, 1.25);
        lists();
        break;
        
    case 'o':
        //printf("Welded %d\n", glmWeld(model, weld_distance));
        glmVertexNormals(model, smoothing_angle);
        lists();
        break;
        
    case 'O':
        weld_distance += 0.01;
        printf("Weld distance: %.2f\n", weld_distance);
        glmWeld(model, weld_distance);
        glmFacetNormals(model);
        glmVertexNormals(model, smoothing_angle);
        lists();
        break;
        
    case '-':
        smoothing_angle -= 1.0;
        printf("Smoothing angle: %.1f\n", smoothing_angle);
        glmVertexNormals(model, smoothing_angle);
        lists();
        break;
        
    case '+':
        smoothing_angle += 1.0;
        printf("Smoothing angle: %.1f\n", smoothing_angle);
        glmVertexNormals(model, smoothing_angle);
        lists();
        break;
        
    case 'W':
        glmScale(model, 1.0/scale);
        glmWriteOBJ(model, "out.obj", GLM_SMOOTH | GLM_MATERIAL);
        break;
        
    case 'R':
        {
            GLuint i;
            GLfloat swap;
            for (i = 1; i <= model->numvertices; i++) {
                swap = model->vertices[3 * i + 1];
                model->vertices[3 * i + 1] = model->vertices[3 * i + 2];
                model->vertices[3 * i + 2] = -swap;
            }
            glmFacetNormals(model);
            lists();
            break;
        }
        
    case 27:
        exit(0);
        break;
    }
    
    glutPostRedisplay();
}
Пример #9
0
void init(void) {
    glLightfv(GL_LIGHT0, GL_AMBIENT, light_ambient);
    glLightfv(GL_LIGHT0, GL_DIFFUSE, light_diffuse);
    glLightfv(GL_LIGHT0, GL_SPECULAR, light_specular);
    glLightfv(GL_LIGHT0, GL_POSITION, light_position);

    glEnable(GL_LIGHTING);
    glEnable(GL_LIGHT0);

    glDepthFunc(GL_LESS);
    glEnable(GL_DEPTH_TEST);
    glEnable(GL_NORMALIZE);
    glEnable(GL_TEXTURE_2D);
    glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
    glHint(GL_LINE_SMOOTH_HINT,GL_DONT_CARE);

    /* load up the model */

    pmodel = glmReadOBJ(FICHIER_OBJ);
    glmUnitize(pmodel);	//glmVertexNormals(obj, 90.0, GL_TRUE);

    glmScale(pmodel,1.6);

    GLfloat dimensions[3];
    glmDimensions(pmodel,  dimensions);
    pmodel->position[2]=dimensions[1]/2;


    for(int i=0; i<8; i++) {
        place[i+1]=place[i+1]*(echelle/8);
    }

    int n=0,m=0;
    for(int id=0; id<64; id++) {
        lesCases[id+1].id=id+1;
        lesCases[id+1].idPion=-1;

        if((id)%8==0) {
            n+=1;
            m=1;
            // printf("\n");
        }
        lesCases[id+1].nl=n;
        lesCases[id+1].nc=m++;
        // printf("%d(%d,%d) pion=%d\n",lesCases[id+1].id,lesCases[id+1].nl,lesCases[id+1].nc,lesCases[id+1].idPion);


        // int j= lesCases[id+1].nc;  int k=lesCases[id+1].nl;

    }
    // printf("\n");

    GLMmaterial* mm=pmodel->materials ;
    group = pmodel->groups;
    int k=1;
    while(group) {
        group->position[0]=0.0;
        group->position[1]=0.0;
        for(int i=0; i<32; i++)  {
            if(strstr(group->name,lesNoms[i])) {
                if(i<16) {
                    k=1;
                    lesPions[i].camp=2;
                }
                else {
                    k=33;
                    lesPions[i].camp=1;
                }
                strcpy(lesPions[i].nom,lesNoms[i]);
                lesPions[i].nombrePosibilite=0;
                lesPions[i].ix=place[lesCases[i+k].nc];
                lesPions[i].iy=place[lesCases[i+k].nl];
                lesCases[i+k].idPion=i;
                lesPions[i].idCase=i+k;
                //printf("--group %s : %d(%d,%d)\n",group->name,lesCases[i+k].id,lesCases[i+k].nl,lesCases[i+k].nc);
            }
        }
        group = group->next;
    }



}
Пример #10
0
int main(int argc, char** argv)
{
	//
	// load: 
	// intrinsice camera parameters, video configuration, pattern configuration and model file
	//
	char glutGamemode[32];
	char cparam_name[] = "Data/camera_para.dat";
	char vconf[] = "";
	char patt_name[] = "Data/patt.irc";
	char obj_name[] = "Data/bunny.obj";

	gObj = glmReadOBJ(obj_name);
	if (gObj == NULL)
	{
		ARLOGe("main(): Unable to load obj model file.\n");
		exit(-1);
	}
	glmUnitize(gObj);
	glmScale(gObj, 1.5*markerSize);

	//
	// Library inits.
	//

	glutInit(&argc, argv);

	//
	// Video setup.
	//

	if (!setupCamera(cparam_name, vconf, &gCparamLT, &gARHandle, &gAR3DHandle)) {
		ARLOGe("main(): Unable to set up AR camera.\n");
		exit(-1);
	}

	// Load marker(s).
	if (!setupMarker(patt_name, &gPatt_id, gARHandle, &gARPattHandle)) {
		ARLOGe("main(): Unable to set up AR marker.\n");
		cleanup();
		exit(-1);
	}

	//
	// Graphics setup.
	//

	// Set up GL context(s) for OpenGL to draw into.
	glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGBA | GLUT_DEPTH);
	if (!windowed) {
		if (windowRefresh) sprintf(glutGamemode, "%ix%i:%i@%i", windowWidth, windowHeight, windowDepth, windowRefresh);
		else sprintf(glutGamemode, "%ix%i:%i", windowWidth, windowHeight, windowDepth);
		glutGameModeString(glutGamemode);
		glutEnterGameMode();
	}
	else {
		glutInitWindowSize(windowWidth, windowHeight);
		glutCreateWindow(argv[0]);
	}

	// Setup ARgsub_lite library for current OpenGL context.
	if ((gArglSettings = arglSetupForCurrentContext(&(gCparamLT->param), arVideoGetPixelFormat())) == NULL) {
		ARLOGe("main(): arglSetupForCurrentContext() returned error.\n");
		cleanup();
		exit(-1);
	}
	arglSetupDebugMode(gArglSettings, gARHandle);
	arUtilTimerReset();


	// Register GLUT event-handling callbacks.
	// NB: mainLoop() is registered by Visibility.
	glutDisplayFunc(Display);
	glutVisibilityFunc(Visibility);
	glutReshapeFunc(Reshape);
	glutKeyboardFunc(Keyboard);

	glutMainLoop();

	return (0);
}
Пример #11
0
SilverGeneral::SilverGeneral(void): Piece("silver_general","silver")//"ginsho")//"letters/s")//
{
	glmScale(this->model,0.5);
	this->RotateZ(3.14);
}
Пример #12
0
void MyGLCloudViewer::setOBJScale(float* scale)
{
	glmScale(ARModel, scale);
}
void Object::scale(GLfloat factor) 
{
    glmScale(model, factor);
}
Пример #14
0
void ModelOBJ::Scale(float factor)
{
	glmScale(model,factor);	
	UpdateTriangleBuffer();
}
Пример #15
0
Horse::Horse(void): Piece("horse","horse")//"ryuma")//"letters/r")//
{
	glmScale(this->model,0.025);
	this->TranslateY(0.5);
	this->RotateZ(-3.14/2);
}
Пример #16
0
ofxGLM& ofxGLM::scale(float nScale) {
	glmScale(model, nScale);
	return *this;
}