void dibujar_objetos(){ glEnable(GL_LIGHTING); //Dibujamos glPushMatrix(); glTranslatef(objetos[1].x,objetos[1].y,objetos[1].z); glColor3f(2,8,3); //modelo = glmReadOBJ(path_archivo); //if (!modelo) exit (0); //si no existe, exit glmUnitize(modelo_CARRO); glmFacetNormals(modelo_CARRO); glmVertexNormals(modelo_CARRO, 90.0); glEnable(GL_COLOR_MATERIAL); glmDraw(modelo_CARRO, GLM_SMOOTH | GLM_MATERIAL); glDisable(GL_COLOR_MATERIAL); glPopMatrix(); glPushMatrix(); glTranslatef(objetos[2].x,objetos[2].y,objetos[2].z); glColor3f(2,8,3); glmUnitize(modelo_AVION); glmFacetNormals(modelo_AVION); glmVertexNormals(modelo_AVION, 90.0); glEnable(GL_COLOR_MATERIAL); glmDraw(modelo_AVION, GLM_SMOOTH | GLM_MATERIAL); glDisable(GL_COLOR_MATERIAL); glPopMatrix(); glDisable(GL_LIGHTING); }
void loadObjects() { eagle = glmReadOBJ("resources/models/eagle.obj"); glmVertexNormals(eagle, 180.0, false); glmUnitize(eagle); airplane = glmReadOBJ("resources/models/airplane.obj"); glmVertexNormals(airplane, 180.0, false); glmUnitize(airplane); }
void init(void) { gltbInit(GLUT_LEFT_BUTTON); /* read in the model */ model = glmReadOBJ(model_file); scale = glmUnitize(model); glmFacetNormals(model); glmVertexNormals(model, smoothing_angle); if (model->nummaterials > 0) material_mode = 2; /* create new display lists */ lists(); glEnable(GL_LIGHTING); glEnable(GL_LIGHT0); glLightModeli(GL_LIGHT_MODEL_TWO_SIDE, GL_TRUE); glEnable(GL_DEPTH_TEST); glEnable(GL_CULL_FACE); }
bool COBJNode::Load(char* filename) { #if CAVEMOD /*init DLarr */ for (int i=0; i<10; i++){ DLarr[i]=-1; } #endif if ( _model_p == NULL ) { // model still not loaded // read model from file _model_p = glmReadOBJ(filename); if(_model_p == NULL) return false; // translate model to the origin and scale it // to fit in a unit cube around the origin = "unitize" glmUnitize(_model_p); // precompute normal vectors glmFacetNormals(_model_p); glmVertexNormals(_model_p, 90.0); #if CAVEMOD // do not create DL... create on first update instead //_modelDL = glmList(_model_p, GLM_SMOOTH | GLM_MATERIAL | GLM_TEXTURE); #else // create display list _modelDL = glmList(_model_p, GLM_SMOOTH | GLM_MATERIAL | GLM_TEXTURE); #endif } return true; }
IndoorModel::IndoorModel(char* fileName, stack<mat4> *mvStack, GLuint program, vec4 transVec, vec3 rotVec, vec3 scalVec, bool texFlag, char* fileTextrue, int txWidth, int txHeight ) { _model = glmReadOBJ(fileName); //Loading the model if (!_model) exit(0); // See if it success glmUnitize(_model); // Normalize vertices glmFacetNormals(_model); // Compute facet normals glmVertexNormals(_model, 90.0); // Compute vertex normals glmLinearTexture(_model); //Map the texture to Model glmLoadGroupsInVBO(_model); // Load the model (vertices and normals) into a vertex buffer //World Coordinates Information _mvStack = mvStack; _program = program; _transVec = transVec; _rotVec = rotVec; _scalVec = scalVec; //Textures Information _texFlag = texFlag; _alphaFlag = false; if(texFlag){ _textures = glmReadPPM(fileTextrue, txWidth, txHeight); _txWidth = txWidth; _txHeight = txHeight; } }
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); } }
Model::Model (string mod, char prolog[2],float normal) { //Model model = NULL; char* path = (char*)malloc(sizeof(char)*mod.length()*10); sprintf(path, "../obj/%s",mod.c_str ()); if (!model) { // this is the call that actualy reads the OBJ and creates the model object model = glmReadOBJ (path); if (!model) exit (0); // This will rescale the object to fit into the unity matrix // Depending on your project you might want to keep the original size and positions you had in 3DS Max or GMAX so you may have to comment this. glmUnitize (model); // These 2 functions calculate triangle and vertex normals from the geometry data. // To be honest I had some problem with very complex models that didn't look to good because of how vertex normals were calculated // So if you can export these directly from you modeling tool do it and comment these line // 3DS Max can calculate these for you and GLM is perfectly capable of loading them glmFacetNormals (model); glmVertexNormals (model, normal); } pos[0] = 0.0; pos[1] = 0.0; pos[2] = 0.0; isPicked = false; name = 10; strcpy (prologRep,prolog); checked= false; }
//Loads the model with a given file name and no texture. void cModelLoader::loadModel(const char* mdlFilename) { m_model = glmReadOBJ(mdlFilename); glmUnitize(m_model); glmFacetNormals(m_model); glmVertexNormals(m_model, 180.0,false); }
void init() { glewInit(); glEnable (GL_DEPTH_TEST); glEnable(GL_LIGHTING); glEnable(GL_LIGHT0); glClearColor(.4, .4, .4, 1); initFBO(fbo1, depthBuffer1, img1); initFBO(fbo2, depthBuffer2, img2); checkboard = pngBind("checkboard.png", PNG_NOMIPMAP, PNG_ALPHA, NULL, GL_REPEAT, GL_NEAREST, GL_NEAREST); glBindTexture(GL_TEXTURE_2D, checkboard); glEnable(GL_TEXTURE_2D); extern GLuint setShaders(char* vert_file, char* frag_file); greyFilter = setShaders("greyFilter.vert", "greyFilter.frag"); mosaicFilter = setShaders("mosaicFilter.vert", "mosaicFilter.frag"); // load OBJ model m1 = glmReadOBJ ("al.obj"); glmUnitize (m1); glmFacetNormals (m1); glmVertexNormals (m1, 90); }
//GLuint resol = 50; void init_object(void) { GLfloat mat_specular[] = { 1.0, 1.0, 1.0, 1.0 }; GLfloat mat_shininess[] = { 50.0 }; //GLfloat light_position[] = { 1.0, 1.0, 1.0, 0.0 }; glClearColor (0.0, 0.0, 0.0, 0.0); glShadeModel (GL_SMOOTH); glMaterialfv(GL_FRONT, GL_SPECULAR, mat_specular); glMaterialfv(GL_FRONT, GL_SHININESS, mat_shininess); //glLightfv(GL_LIGHT, GL_POSITION, light_position); glEnable(GL_LIGHTING); glEnable(GL_LIGHT1); //glEnable(GL_DEPTH_TEST); { pmodel = glmReadOBJ("soccerball.obj"); if (!pmodel) exit(0); glmUnitize(pmodel); glmFacetNormals(pmodel); glmVertexNormals(pmodel, 90.0); } }
/******************************************************************************* Initialize the OBJ Model and create display list. *******************************************************************************/ void initOBJModel() { if (!objmodel) { objmodel = glmReadOBJ(model1Path); if (!objmodel) { printf("OBJ file does not exist \n"); exit(0); } glmUnitize(objmodel); glmFacetNormals(objmodel); glmVertexNormals(objmodel, 90.0); } //Create display for the OBJ model objList = glGenLists(1); glNewList( objList, GL_COMPILE ); glmDraw(objmodel, GLM_SMOOTH | GLM_TEXTURE ); glEndList(); //Create the display list for the modified // displacement mapped OBJ Model bumpList = glGenLists(1); glNewList( bumpList, GL_COMPILE ); drawGLMbump(); glEndList(); }
void init(void) { glEnable(GL_DEPTH_TEST); glClearColor(.4, .4, .4, 1); glewInit(); if(GLEW_ARB_vertex_shader && GLEW_ARB_fragment_shader) printf("Ready for GLSL\n"); else { printf("No GLSL support\n"); exit(1); } char vsh[20], fsh[20]; sprintf (vsh, "%s.vert", MAIN); sprintf (fsh, "%s.frag", MAIN); extern GLuint setShaders(char*,char*); p = setShaders(vsh, fsh); glUseProgram(p); glUniform4fv(glGetUniformLocation(p, "color_positive"), 1, ColorArray[c1%3]); glUniform4fv(glGetUniformLocation(p, "color_negative"), 1, ColorArray[c2%3]); glUniform1i(glGetUniformLocation(p, "type"), selection); m1 = glmReadOBJ(obj_name[0]); glmUnitize(m1); }
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; }
void Object::loadOBJ(string filename) { if(filename.size() == 0) { cerr << "OBJ filename is empty."; exit(1); } char * OBJFilename = new char[filename.size() + 1]; strcpy(OBJFilename, filename.c_str()); model = glmReadOBJ(OBJFilename); if (!model) { cerr << "Unable to load the model " << OBJFilename; exit(1); } glmUnitize(model); // These 2 functions calculate triangle and vertex normals from the geometry data. // To be honest I had some problem with very complex models that didn't look to good because of how vertex normals were calculated // So if you can export these directly from you modeling tool do it and comment these line // 3DS Max can calculate these for you and GLM is perfectly capable of loading them glmFacetNormals(model); glmVertexNormals(model, 90.0, GL_TRUE); }
void init(void) { renderShaderID = loadShaders("shaders/vShader.c", "shaders/fShader.c"); shadowShaderID = loadShaders("shaders/shadowVShader.c", "shaders/shadowFShader.c"); //initShadowMap(); gltbInit(GLUT_LEFT_BUTTON); /* read in the model */ model = glmReadOBJ(model_file); scale = glmUnitize(model); glmFacetNormals(model); glmVertexNormals(model, smoothing_angle); if (model->nummaterials > 0) material_mode = 2; /* create new display lists */ lists(); glEnable(GL_LIGHTING); glEnable(GL_LIGHT0); glLightModeli(GL_LIGHT_MODEL_TWO_SIDE, GL_TRUE); //glEnable(GL_DEPTH_TEST); //glEnable(GL_CULL_FACE); }
/** Loads an OBJ models from a file **/ Model ResourceLoader::loadObjModel(QString filePath) { Model m; m.model = glmReadOBJ(filePath.toStdString().c_str()); glmUnitize(m.model); m.idx = glmList(m.model, GLM_SMOOTH); return m; }
// ----------------------------------------------- // void init_model() { model = glmReadOBJ("../data/al.obj"); if (!model) exit(0); glmUnitize(model); glmFacetNormals(model); glmVertexNormals(model, 90.0); glmDimensions(model, model_dimensions); }
Robot::Robot(char* model_name) { this->robot_model_ = glmReadOBJ(model_name); this->robot_pose_length = 0; this->neural_pose_length = 0; this->localize_pose_length = 0; glmUnitize(this->robot_model_); }
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; }
//Loads a model with a given file name and texture ID. void cModelLoader::loadModel(const char* mdlFilename, GLuint textureID) { m_model = glmReadOBJ(mdlFilename); glmUnitize(m_model); glmFacetNormals(m_model); glmVertexNormals(m_model, 180.0,false); m_TextureID = textureID; m_model->textures[m_model->numtextures - 1].id = m_TextureID; }
void drawModel () { if (!testModel) { testModel = glmReadOBJ("weapon.obj"); if (!testModel) exit(0); glmUnitize(testModel); glmFacetNormals(testModel); glmVertexNormals(testModel, 90.0); } glmDraw (testModel, GLM_SMOOTH); }
void MyGLCloudViewer::loadARModel(char *fileName) { ARModel = glmReadOBJ(fileName); if (!ARModel) exit(0); glmUnitize(ARModel); glmFacetNormals(ARModel); glmVertexNormals(ARModel, 90.0); }
void Canhao::carregaOBJ(char* p_base, char* p_canhao){ if(!_baseTanque) { _baseTanque = glmReadOBJ(p_base); if(!_baseTanque) std::cerr << "Não foi possível carregar o arquivo .OBJ da base do tanque" << std::endl; glmUnitize(_baseTanque); glmFacetNormals(_baseTanque); glmVertexNormals(_baseTanque,180.0); } if(!_canhaoTanque) { _canhaoTanque = glmReadOBJ(p_canhao); if(!_canhaoTanque) std::cerr << "Não foi possível carregar o arquivo .OBJ do canhao do tanque" << std::endl; glmUnitize(_canhaoTanque); glmFacetNormals(_canhaoTanque); glmVertexNormals(_canhaoTanque,180.0); } }
House::House(char *filename, float x, float z, float scal) { posX = x; posZ = z; hmodel = glmReadOBJ(filename); glmUnitize(hmodel); glmVertexNormals(hmodel, 90.0, GL_TRUE); makeHouseDispList(); scalef = scal; }
Wheel::Wheel(char *tyreFile) { rad = 7; //getTextures(); wheel_model = glmReadOBJ(tyreFile); glmUnitize(wheel_model); glmVertexNormals(wheel_model, 90.0, GL_TRUE); angle = 0; }
void drawmodel_box4(void) { if (!pmodel4) { pmodel4 = glmReadOBJ("bike4.obj"); if (!pmodel4) exit(0); glmUnitize(pmodel4); glmFacetNormals(pmodel4); glmVertexNormals(pmodel4, 90.0); } glmDraw(pmodel4, GLM_SMOOTH| GLM_TEXTURE); }
void drawmodel_box3(void) { if (!pmodel3) { pmodel3 = glmReadOBJ("bike3.obj"); if (!pmodel3) exit(0); glmUnitize(pmodel3); glmFacetNormals(pmodel3); glmVertexNormals(pmodel3, 90.0); } glmDraw(pmodel3, GLM_SMOOTH| GLM_TEXTURE); }
void drawmodel_box(void) { if (!pmodel1) { pmodel1 = glmReadOBJ("bike1.obj"); if (!pmodel1) exit(0); glmUnitize(pmodel1); glmFacetNormals(pmodel1); glmVertexNormals(pmodel1, 90.0); } glmDraw(pmodel1, GLM_SMOOTH| GLM_TEXTURE); }
void drawmodel_box5(void) { if (!pmodel5) { pmodel5 = glmReadOBJ("bike5.obj"); if (!pmodel5) exit(0); glmUnitize(pmodel5); glmFacetNormals(pmodel5); glmVertexNormals(pmodel5, 90.0); } glmDraw(pmodel5, GLM_SMOOTH| GLM_TEXTURE); }
//Loads a model with a given file name and texture. void cModelLoader::loadModel(const char* mdlFilename, cTexture mdlTexture) { m_model = glmReadOBJ(mdlFilename); glmUnitize(m_model); glmFacetNormals(m_model); glmVertexNormals(m_model, 180.0f,false); m_TextureID = mdlTexture.getTexture(); m_model->textures[m_model->numtextures - 1].id = m_TextureID; m_model->textures[m_model->numtextures - 1].width = mdlTexture.getTWidth(); m_model->textures[m_model->numtextures - 1].height = mdlTexture.getTHeight(); }