本文整理汇总了C++中ModelLoader类的典型用法代码示例。如果您正苦于以下问题:C++ ModelLoader类的具体用法?C++ ModelLoader怎么用?C++ ModelLoader使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了ModelLoader类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: solidShapesFromURDFString
bool solidShapesFromURDFString(const std::string & urdf_string,
const std::string & urdf_filename,
const Model & model,
const std::string urdfGeometryType,
iDynTree::ModelSolidShapes & output)
{
if (urdfGeometryType != "visual" && urdfGeometryType != "collision")
{
std::cerr << "[ERROR] unknown urdfGeometryType " << urdfGeometryType << std::endl;
return false;
}
ModelLoader loader;
ModelParserOptions options;
options.originalFilename = urdf_filename;
loader.setParsingOptions(options);
bool ok = loader.loadModelFromString(urdf_string);
if (ok && urdfGeometryType == "visual")
{
output = loader.model().visualSolidShapes();
}
if (ok && urdfGeometryType == "collision")
{
output = loader.model().collisionSolidShapes();
}
return ok;
}
示例2: solidShapesFromURDF
bool solidShapesFromURDF(const std::string & urdf_filename,
const Model & model,
const std::string urdfGeometryType,
ModelSolidShapes & output)
{
if (urdfGeometryType != "visual" && urdfGeometryType != "collision")
{
std::cerr << "[ERROR] unknown urdfGeometryType " << urdfGeometryType << std::endl;
return false;
}
ModelLoader loader;
bool ok = loader.loadModelFromFile(urdf_filename);
if (ok && urdfGeometryType == "visual")
{
output = loader.model().visualSolidShapes();
}
if (ok && urdfGeometryType == "collision")
{
output = loader.model().collisionSolidShapes();
}
return ok;
}
示例3: load
void Obj::load(string filename)
{
this->name = filename;
ModelLoader m;
m.load_obj(filename, this);
}
示例4: getSensors
SensorsList getSensors(const std::string& fileName)
{
ModelLoader loader;
bool ok = loader.loadModelFromFile(fileName);
// Load model
ASSERT_IS_TRUE(ok);
SensorsList sensorList = loader.sensors();
return sensorList;
}
示例5: getModel
Model getModel(const std::string& fileName)
{
ModelLoader loader;
bool ok = loader.loadModelFromFile(fileName);
// Load model
ASSERT_IS_TRUE(ok);
Model model = loader.model();
return model;
}
示例6: ModelLoader
void Object::readFromFile(const char *filename) {
ModelLoader loader = *new ModelLoader();
loader.read_from_file(filename);
vertices_counter = loader.vertexs_counter;
indices_counter = loader.indexes_counter;
vertices_array = loader.vertexes_out;
indices_array = loader.indexes;
}
示例7: sizeof
Object::Object()
{
try
{
position = { { 0., 0., 0. }, 0., 0., -1, 0, 0, false };
scale = .1f;
ModelLoader modelLoader;
model = modelLoader.ReadModel("resources\\objects\\Captain America.obj", "resources\\objects\\Captain America.mtl");
if (!model)
{
throw "Can't load player's geometry";
}
else
{
boundingBox.isShowing = false;
calculateSizes();
glGenBuffers(1, &tid);
glBindBuffer(GL_ARRAY_BUFFER, tid);
glBufferData(GL_ARRAY_BUFFER, model->UV_vertices.size()*sizeof(float), NULL, GL_STATIC_DRAW);
glBufferSubData(GL_ARRAY_BUFFER, 0, model->UV_vertices.size()*sizeof(float), &model->UV_vertices[0]);
glBindBuffer(GL_ARRAY_BUFFER, 0);
glGenBuffers(1, &nid);
glBindBuffer(GL_ARRAY_BUFFER, nid);
glBufferData(GL_ARRAY_BUFFER, model->normals.size()*sizeof(float), NULL, GL_STATIC_DRAW);
glBufferSubData(GL_ARRAY_BUFFER, 0, model->normals.size()*sizeof(float), &model->normals[0]);
glBindBuffer(GL_ARRAY_BUFFER, 0);
glGenBuffers(1, &vid);
glBindBuffer(GL_ARRAY_BUFFER, vid);
glBufferData(GL_ARRAY_BUFFER, model->vertices.size()*sizeof(float), NULL, GL_STATIC_DRAW);
glBufferSubData(GL_ARRAY_BUFFER, 0, model->vertices.size()*sizeof(float), &model->vertices[0]);
glBindBuffer(GL_ARRAY_BUFFER, 0);
glGenBuffers(1, &bbvid);
glBindBuffer(GL_ARRAY_BUFFER, bbvid);
glBufferData(GL_ARRAY_BUFFER, 72 * sizeof(float), NULL, GL_STATIC_DRAW);
glBufferSubData(GL_ARRAY_BUFFER, 0, 72 * sizeof(float), &boundingBox.coords[0]);
glBindBuffer(GL_ARRAY_BUFFER, 0);
}
}
catch (const char* error)
{
model = NULL;
std::cout << error << std::endl;
}
}
示例8: Load
bool Model :: Load(std :: string name,ModelLoader &loader,Texture &tex)
{
// attempt to load the file
if(!loader.Load(name))
return false;
// do we have to clean up?
if(frames)
this->Clear();
// get the model information
int modelframes=loader.GetNumFrames();
int nummeshes=loader.GetNumMeshes();
float modelfps=(float)loader.GetFPS();
// tidy up the values
if(modelframes<=0)
return false;
if(modelfps==0.0f)
modelfps=1.0f;
// and setup our model
if(!this->Setup(modelframes,modelfps))
return false;
// now set up the frames
for(int ct=0; ct<numframes; ct++)
{
// setup the frame
if(!frames[ct].Setup(nummeshes))
{
this->Clear();
return false;
}
// add the meshes
for(int ct2=0; ct2<nummeshes; ct2++)
{
Mesh msh; // temporary mesh
// get the mesh
if(!loader.Get(ct,ct2,&tex,&msh))
return false;
// and set it to the frame
frames[ct].SetMesh(ct2,msh);
}
}
// success
return true;
}
示例9: makeScene
Scene* makeScene(){
ModelLoader loader;
Object* o = loader.load("teapot.obj", true);
o->setDrawMode( GL_TRIANGLES );// Render mode: triangluar mesh
o->glSetTexture(0, "test0.png");// Texture
o->glSetTexture(1, pSkyTech->getTexture() ); // Environment map.
o->glSetTexture(2, pShadowTarget->getColorTexture() ); // Blurred shadows-only image. for soft-shadows.
o->glSetTexture(3, pShadowsHV->getColorTexture() );
o->glSetTexture(0, new Texture( GL_TEXTURE_2D, pCube->getTexture() ) );
Scene* sc = new Scene();
sc->addObject(o);
return sc;
}
示例10: GetSetting
//----------------------------------------------------------------------------------
//
//----------------------------------------------------------------------------------
void EffectImplemented::UnloadResources()
{
Setting* loader = GetSetting();
TextureLoader* textureLoader = loader->GetTextureLoader();
if( textureLoader != NULL )
{
for( int32_t ind = 0; ind < m_ImageCount; ind++ )
{
textureLoader->Unload( m_pImages[ind] );
m_pImages[ind] = NULL;
}
for (int32_t ind = 0; ind < m_normalImageCount; ind++)
{
textureLoader->Unload(m_normalImages[ind]);
m_normalImages[ind] = NULL;
}
for (int32_t ind = 0; ind < m_distortionImageCount; ind++)
{
textureLoader->Unload(m_distortionImages[ind]);
m_distortionImages[ind] = NULL;
}
}
SoundLoader* soundLoader = loader->GetSoundLoader();
if( soundLoader != NULL )
{
for( int32_t ind = 0; ind < m_WaveCount; ind++ )
{
soundLoader->Unload( m_pWaves[ind] );
m_pWaves[ind] = NULL;
}
}
{
ModelLoader* modelLoader = loader->GetModelLoader();
if( modelLoader != NULL )
{
for( int32_t ind = 0; ind < m_modelCount; ind++ )
{
modelLoader->Unload( m_pModels[ind] );
m_pModels[ind] = NULL;
}
}
}
}
示例11: ModelLoader
// Carga un ResourceMesh y guarda una referencia a este
ResourceMesh* ResourceManager::loadMesh(const char* filePath)
{
ResourceMesh* mesh = NULL;
ModelLoader* modelLoader = new ModelLoader();
mesh = modelLoader->loadOBJ(filePath);
// Si hay algun problema con el modelo cargamos uno de error por defecto
if (mesh == NULL)
{
mesh = modelLoader->loadOBJ(Resources::MESH_ERROR);
}
mesh->fileName = filePath; //guardamos el filePath
return mesh;
}
示例12: InitModels
void MyGLWindow::InitModels()
{
Chrono chrono;
// load models
ModelLoader modelLoader;
chrono.start();
_actorLib["Tank"] = modelLoader.LoadFromFile("./data/model/stankbot/models/stankbot.dae");
_actorLib["Tank"]->SetShaderProgram(_shaderProgLib["defaultShader"]);
std::cout << "Load stankbot (ms) : " << chrono.ellapsed() << std::endl;
chrono.start();
_actorLib["Dragon"] = modelLoader.LoadFromFile("./data/model/dragon_vrip_res3.ply");
_actorLib["Dragon"]->SetShaderProgram(_shaderProgLib["defaultShader"]);
std::cout << "Load dragon (ms) : " << chrono.ellapsed() << std::endl;
}
示例13: ModelLoader
TexturedModel::TexturedModel(Model model, std::vector<glm::vec2> uvs, GLuint textureID) {
this->setVaoID(model.getVaoID());
this->setVerticesVboID(model.getVerticesVboID());
this->setVertexCount(model.getVertexCount());
this->setScale(model.getScale());
this->setPosition(model.getPosition());
this->setTextured(true);
ModelLoader modelLoader = ModelLoader();
GLfloat *uvsTemp = &uvs[0].x;
int uvsSize = uvs.size() * 2 * sizeof(GLfloat);
this->uvVboID = modelLoader.storeData(2, uvsTemp, uvsSize);
this->setColor(false);
this->setColorsVboID(model.getColorsVboID());
}
示例14: saveResults
/* Asking user if he would like to save his model */
void saveResults(NNModel* model){
cout << endl << "Would you like to save this model? (Press y/n)";
/* Wait for y or n click*/
char key = ' ';
do{
key = _getch();
} while ((key != 'n') && (key != 'y'));
/* Saving model if needed */
if (key == 'y'){
cout << endl << endl << endl;
string fileName;
cout << "--Enter file name: "; cin >> fileName;
ModelLoader m;
m.saveModel(model, (char*)fileName.c_str());
}
示例15: QGLWidget
GLWidget::GLWidget(const QGLFormat & format, QWidget * parent) : QGLWidget(format, parent),
mShaderProgram(this),
mViewMatrix(),
mProjectionMatrix(){
float ratio = float(geometry().width())/float(geometry().height());
mProjectionMatrix.perspective(60, ratio, .1, 100); // ortho(-5,5,-5,5,-5,5);//Orthogonal projection
mViewMatrix.translate(0.0,0.0,-10.0);
ModelLoader* loader = ModelFactory::getModelLoader("models/monkey.obj");
if(loader != NULL){
objTest = (StaticModel*)loader->loadModel();
}
objTest->mModelMatrix.translate(0,0,0);
delete loader;
manip = new SphereManipulator("cube manipulator", objTest);
this->grabKeyboard();
}