本文整理汇总了C++中Model3D类的典型用法代码示例。如果您正苦于以下问题:C++ Model3D类的具体用法?C++ Model3D怎么用?C++ Model3D使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Model3D类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: DrawSolidTexturedNormalMapped
// Draws the given model with texturing, shading and a normal map.
void Rasterizer::DrawSolidTexturedNormalMapped(Model3D& model, std::vector<DirectionalLight*> directionalLights, std::vector<AmbientLight*> ambientLights, std::vector<PointLight*> pointLights)
{
std::vector<Polygon3D> _polygonList = model.GetPolygonList();
std::vector<Vertex> _vertexList = model.GetTransformedVertexList();
std::vector<UVCoordinate> _uvCoordList = model.GetUVCoordinateList();
for (unsigned int i = 0; i < _polygonList.size(); i++)
{
Polygon3D poly = _polygonList[i];
if (poly.GetBackfacing() == true)
continue;
Vertex v1 = _vertexList[poly.GetVertexIndex(0)];
Vertex v2 = _vertexList[poly.GetVertexIndex(1)];
Vertex v3 = _vertexList[poly.GetVertexIndex(2)];
// Set the uv coordinates of each vertex temporarily to the coordinates in the
// uv coordinate list.
v1.SetUVCoordinate(_uvCoordList[poly.GetUVIndex(0)]);
v2.SetUVCoordinate(_uvCoordList[poly.GetUVIndex(1)]);
v3.SetUVCoordinate(_uvCoordList[poly.GetUVIndex(2)]);
// Fill the polygon using the models texture.
if (model.GetNormalMapOn() == true)
FillPolygonTexturedNormalMapped(v1, v2, v3, v1.GetColor(), model, directionalLights, ambientLights, pointLights);
else
FillPolygonTextured(v1, v2, v3, v1.GetColor(), model);
}
}
示例2: filtersAll
void MainWindow::OnOpenModel()
{
const QString filtersAll(QString::fromUtf8(
"Model files (*.mff);;All files (*.*)"));
QString filterSel(QString::fromUtf8(
"Model files (*.mff)"));
const QString sFilePath = QFileDialog::getOpenFileName(this,
QString::fromUtf8("Open 3D model"),
qApp->applicationDirPath(),
filtersAll, &filterSel);
if(sFilePath.isEmpty())
{
return;
}
Model3D model;
if(model.Load(sFilePath))
{
OnCloseModel();
m_sFilePath = sFilePath;
setWindowTitle(m_sFilePath);
ui->openGLWidget->SetModel(model);
}
}
示例3: Init
void Init()
{
Super::Init();
mWorld = GD_NEW(World, this, "Launch::Gamedesk");
mWorld->Init(&mOctree);
Model3D* pModel = Cast<Model3D>(mWorld->SpawnEntity(Model3D::StaticClass()));
pModel->SetMesh("link's house.ase");
pModel->Select(true);
Keyboard& keyboard = InputSubsystem::GetKeyboard();
keyboard.AddKeyListener(this, Keyboard::Key_W, Keyboard::Key_Down);
keyboard.AddKeyListener(this, Keyboard::Key_S, Keyboard::Key_Down);
keyboard.AddKeyListener(this, Keyboard::Key_A, Keyboard::Key_Down);
keyboard.AddKeyListener(this, Keyboard::Key_D, Keyboard::Key_Down);
keyboard.AddKeyListener(this, Keyboard::Key_Escape, Keyboard::Key_Down);
Mouse& mouse = InputSubsystem::GetMouse();
mouse.AddMoveListener(this);
mMainWindow->AddListener(this);
mFont.GetFont( "Data/Fonts/tahoma.ttf", 14 );
}
示例4: InsertModelInWorld
void ModelBrowserUI::InsertModelInWorld( Q3ListBoxItem* pItem )
{
Camera* camera = mTool->GetEditor()->GetWorldManager().GetCurrentCamera();
Vector3f pos = camera->GetPosition() + (camera->GetView() * 2.0f);
Model3D* newModel = Cast<Model3D>( mTool->GetEditor()->GetWorldManager().SpawnEntity( Model3D::StaticClass(), pos ) );
newModel->SetMesh( String("Data/Meshes/") + String(pItem->text().ascii()) );
}
示例5: sizeof
bool OpenGLRenderer::renderModel3DWireframe(Model3D &model3D, const glm::vec4 &color, Camera &camera, RenderTarget &renderTarget)
{
__(glDepthRangef(camera.getNear(), camera.getFar()));
/* Enable wireframe mode */
__(glPolygonMode(GL_FRONT_AND_BACK, GL_LINE));
__(glEnable(GL_LINE_SMOOTH));
__(glDisable(GL_CULL_FACE));
/* Calculate MVP matrix */
glm::mat4 MVP = camera.getPerspectiveMatrix() * camera.getViewMatrix() * model3D.getModelMatrix();
/* Cast the model into an internal type */
OpenGLAsset3D *glObject = static_cast<OpenGLAsset3D *>(model3D.getAsset3D());
/* Set the color for the wireframe shader */
_wireframeShader->setColor(color);
/* Bind the render target */
renderTarget.bind();
{
__(glEnable(GL_MULTISAMPLE));
__(glEnable(GL_DEPTH_TEST));
__(glDepthFunc(GL_LEQUAL));
__(glBlendEquation(GL_FUNC_ADD));
__(glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA));
__(glEnable(GL_BLEND));
/* Bind program to upload the uniform */
_wireframeShader->attach();
/* Send our transformation to the currently bound shader, in the "MVP" uniform */
_wireframeShader->setUniformMat4("u_MVPMatrix", &MVP);
/* Set the shader custom parameters */
_wireframeShader->setCustomParams();
/* Draw the model */
__(glBindVertexArray(glObject->getVertexArrayID()));
{
std::vector<uint32_t> offset = glObject->getIndicesOffsets();
std::vector<uint32_t> count = glObject->getIndicesCount();
for (size_t i = 0; i < offset.size(); ++i) {
__(glDrawElements(GL_TRIANGLES, count[i], GL_UNSIGNED_INT, (void *)(offset[i] * sizeof(GLuint))));
}
}
__(glBindVertexArray(0));
/* Unbind */
_wireframeShader->detach();
}
renderTarget.unbind();
return true;
}
示例6: LoadModel_Studio
bool LoadModel_Studio(FileSpecifier& Spec, Model3D& Model)
{
ModelPtr = &Model;
Model.Clear();
if (DBOut)
{
// Name buffer
const int BufferSize = 256;
char Buffer[BufferSize];
Spec.GetName(Buffer);
fprintf(DBOut,"Loading 3D Studio Max model file %s\n",Buffer);
}
OpenedFile OFile;
if (!Spec.Open(OFile))
{
if (DBOut) fprintf(DBOut,"ERROR opening the file\n");
return false;
}
ChunkHeaderData ChunkHeader;
if (!ReadChunkHeader(OFile,ChunkHeader)) return false;
if (ChunkHeader.ID != MASTER)
{
if (DBOut) fprintf(DBOut,"ERROR: not a 3DS Max model file\n");
return false;
}
if (!ReadContainer(OFile,ChunkHeader,ReadMaster)) return false;
return (!Model.Positions.empty() && !Model.VertIndices.empty());
}
示例7: removeModelFromList
/**
Remove the argument model from the argument list
*/
bool ShadowableScene::removeModelFromList(string modelName, vector<Model3D*> &list)
{
/// \todo loop through all the display lists and try to find the modelName
Model3D *aModel;
for (int index = 0; index < list.size(); index++)
{
aModel = list[index];
if (aModel->getName() == modelName)
{
shadowCasterList.erase(&list[index]);
return true;
}
}
return false;
}
示例8: AddModel
bool ModelDatabase::AddModel(Model3D model, string id)
{
bool added;
unsigned int size = mModels.size();
Model3D temp;
temp.Copy(model);
mModels.insert(pair<string, Model3D>(id, temp));
if(size > mModels.size())
added = true;
else
added = false;
return added;
}
示例9: renderModelList
/**
Render the model list to the screen
*/
void ShadowableScene::renderModelList(const vector<Model3D*> &modelList)
{
Model3D *aModel;
for (int index = 0; index < modelList.size(); index++)
{
aModel = modelList[index];
glPushMatrix();
// Position the model
Vector3D position(aModel->getPosition());
glTranslatef(position.x, position.y, position.z);
// Orient the model
FTM rotations(aModel->getFTM());
float tempMatrix[] =
{
rotations._00,rotations._01,rotations._02,rotations._03,
rotations._10,rotations._11,rotations._12,rotations._13,
rotations._20,rotations._21,rotations._22,rotations._23,
rotations._30,rotations._31,rotations._32,rotations._33,
};
glMultMatrixf(tempMatrix);
if (!aModel->isLit())
{
// Set the color (for non lit scenes)
glColor3f(aModel->getRed(),aModel->getGreen(),aModel->getBlue());
glDisable(GL_LIGHTING);
}
else
{
// Set the material props (for lit scenes)
Material tempMaterial = aModel->getMaterial();
float matSpecular[] = {tempMaterial.specularRed, tempMaterial.specularGreen, tempMaterial.specularBlue, tempMaterial.specularAlpha};
glMaterialfv(GL_FRONT, GL_SPECULAR, matSpecular);
float matShininess[] = {tempMaterial.shininess};
glMaterialfv(GL_FRONT, GL_SHININESS, matShininess);
float matAmbDiff[] = { tempMaterial.ambientDiffuseRed, tempMaterial.ambientDiffuseGreen, tempMaterial.ambientDiffuseBlue, tempMaterial.ambientDiffuseAlpha };
glMaterialfv(GL_FRONT, GL_AMBIENT_AND_DIFFUSE, matAmbDiff);
glEnable(GL_LIGHTING);
}
// draw the model
glCallList(aModel->getCallListId());
glPopMatrix();
}
}
示例10: renderToShadowMap
bool OpenGLRenderer::renderToShadowMap(Model3D &model3D, Light &light, NormalShadowMapShader &shader)
{
/* Calculate MVP matrix */
glm::mat4 MVP = light.getProjectionMatrix() * light.getViewMatrix() * model3D.getModelMatrix();
/* Calculate normal matrix */
glm::mat3 normalMatrix = glm::transpose(glm::inverse(glm::mat3(model3D.getModelMatrix())));
/* Cast the model into an internal type */
OpenGLAsset3D *glObject = static_cast<OpenGLAsset3D *>(model3D.getAsset3D());
glEnable(GL_DEPTH_TEST);
glDepthFunc(GL_LESS);
/* Bind the render target */
light.getShadowMap()->bind();
{
/* Bind program to upload the uniform */
shader.attach();
/* Send our transformation to the currently bound shader, in the "MVP" uniform */
shader.setUniformMat4("u_MVPMatrix", &MVP);
/* Draw the model */
__(glBindVertexArray(glObject->getVertexArrayID()));
{
std::vector<uint32_t> offset = glObject->getIndicesOffsets();
std::vector<uint32_t> count = glObject->getIndicesCount();
for (size_t i = 0; i < count.size(); ++i) {
__(glDrawElements(GL_TRIANGLES, count[i], GL_UNSIGNED_INT, (void *)(offset[i] * sizeof(GLuint))));
}
}
__(glBindVertexArray(0));
/* Unbind */
shader.detach();
}
light.getShadowMap()->unbind();
return true;
}
示例11: DrawSolidShaded
// Draws the given model with gouraud shading.
void Rasterizer::DrawSolidShaded(Model3D& model)
{
std::vector<Polygon3D> _polygonList = model.GetPolygonList();
std::vector<Vertex> _vertexList = model.GetTransformedVertexList();
// Iterate over and render each of the polygons in the list.
for (unsigned int i = 0; i < _polygonList.size(); i++)
{
Polygon3D poly = _polygonList[i];
if (poly.GetBackfacing() == true)
continue;
Vertex v1 = _vertexList[poly.GetVertexIndex(0)];
Vertex v2 = _vertexList[poly.GetVertexIndex(1)];
Vertex v3 = _vertexList[poly.GetVertexIndex(2)];
// Fill the polygon using the polygons colour.
FillPolygonShaded(v1, v2, v3, poly.GetColor());
}
}
示例12:
Galerkin::Galerkin(Model3D &_m,clVector &_uSol,
clVector &_vSol,
clVector &_wSol,
clVector &_cSol,
clMatrix &_gx,
clMatrix &_gy,
clMatrix &_gz)
{
outflow = _m.getOutflow();
numVerts = _m.getNumVerts();
numNodes = _m.getNumNodes();
numElems = _m.getNumElems();
uSol = _uSol;
vSol = _vSol;
wSol = _wSol;
cSol = _cSol;
gx = _gx;
gy = _gy;
gz = _gz;
}
示例13: glEnable
void ViewportWidget::paintGL(QGLPainter *painter) {
if (!_models) return;
glEnable(GL_BLEND);
glEnable (GL_LINE_SMOOTH);
glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glHint (GL_LINE_SMOOTH_HINT, GL_DONT_CARE);
/* Draw the background video */
drawVideoFrame(painter);
/* Draw the models on top of the video */
glEnable(GL_DEPTH_TEST);
QListIterator<Model3D*> i(*_models);
while(i.hasNext()) {
Model3D *model = i.next();
model->draw(painter);
}
glDisable(GL_DEPTH_TEST);
glDisable (GL_LINE_SMOOTH);
glDisable(GL_BLEND);
}
示例14: renderModelNormals
bool OpenGLRenderer::renderModelNormals(Model3D &model3D, Camera &camera, RenderTarget &renderTarget, float normalSize)
{
/* Calculate MVP matrix */
glm::mat4 MVP = camera.getPerspectiveMatrix() * camera.getViewMatrix() * model3D.getModelMatrix();
/* Calculate normal matrix */
glm::mat3 normalMatrix = glm::transpose(glm::inverse(glm::mat3(model3D.getModelMatrix())));
/* Cast the model into an internal type */
OpenGLAsset3D *glObject = static_cast<OpenGLAsset3D *>(model3D.getAsset3D());
/* Bind the render target */
renderTarget.bind();
{
/* Bind program to upload the uniform */
_renderNormals.attach();
_renderNormals.setUniformMat4("u_MVPMatrix", &MVP);
_renderNormals.setUniformFloat("u_normalSize", normalSize);
/* Draw the model */
__(glBindVertexArray(glObject->getVertexArrayID()));
{
std::vector<uint32_t> offset = glObject->getIndicesOffsets();
std::vector<uint32_t> count = glObject->getIndicesCount();
for (size_t i = 0; i < offset.size(); ++i) {
__(glDrawElements(GL_TRIANGLES, count[i], GL_UNSIGNED_INT, (void *)(offset[i] * sizeof(GLuint))));
}
}
__(glBindVertexArray(0));
/* Unbind */
_renderNormals.detach();
}
renderTarget.unbind();
return true;
}
示例15: DrawWireFrame
// Draws the given model in wireframe mode.
void Rasterizer::DrawWireFrame(Model3D& model)
{
std::vector<Polygon3D> _polygonList = model.GetPolygonList();
std::vector<Vertex> _vertexList = model.GetTransformedVertexList();
// Iterate over and render each of the polygons in the list.
for (unsigned int i = 0; i < _polygonList.size(); i++)
{
Polygon3D poly = _polygonList[i];
if (poly.GetBackfacing() == true)
continue;
Vertex v1 = _vertexList[poly.GetVertexIndex(0)];
Vertex v2 = _vertexList[poly.GetVertexIndex(1)];
Vertex v3 = _vertexList[poly.GetVertexIndex(2)];
// Draw a line between each of the vertexs in the polygon.
DrawLine(v1.GetX(), v1.GetY(), v2.GetX(), v2.GetY());
DrawLine(v2.GetX(), v2.GetY(), v3.GetX(), v3.GetY());
DrawLine(v1.GetX(), v1.GetY(), v3.GetX(), v3.GetY());
_polygonsRendered++;
}
}