本文整理汇总了C++中MeshBuilder类的典型用法代码示例。如果您正苦于以下问题:C++ MeshBuilder类的具体用法?C++ MeshBuilder怎么用?C++ MeshBuilder使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了MeshBuilder类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
bool MeshBuilder::operator==( const MeshBuilder& other ) const
{
if ( vertices() != other.vertices() )
return false;
if ( polygons() != other.polygons() )
return false;
if ( vertexMaps() != other.vertexMaps() )
return false;
if ( discontinuousVertexMaps() != other.discontinuousVertexMaps() )
return false;
for ( int i = 0 ; i < m_this->vertices.size() ; ++i )
if ( *m_this->vertices[i] != *other.m_this->vertices[i] )
return false;
for ( int i = 0 ; i < m_this->polygons.size() ; ++i )
if ( *m_this->polygons[i] != *other.m_this->polygons[i] )
return false;
for ( int i = 0 ; i < m_this->vertexMaps.size() ; ++i )
if ( *m_this->vertexMaps[i] != *other.m_this->vertexMaps[i] )
return false;
for ( int i = 0 ; i < m_this->discontinuousVertexMaps.size() ; ++i )
if ( *m_this->discontinuousVertexMaps[i] != *other.m_this->discontinuousVertexMaps[i] )
return false;
return true;
}
示例2: m_pauseTexture
TheGame::TheGame()
: m_pauseTexture(Texture::CreateOrGetTexture("Data/Images/Test.png"))
, m_camera(new Camera3D())
, m_twahSFX(AudioSystem::instance->CreateOrGetSound("Data/SFX/Twah.wav"))
, m_renderAxisLines(false)
, m_showSkeleton(false)
{
SetUpShader();
#pragma TODO("Fix this blatant memory leak")
Texture* blankTex = new Texture(1600, 900, Texture::TextureFormat::RGBA8);
Texture* depthTex = new Texture(1600, 900, Texture::TextureFormat::D24S8);
m_fbo = Framebuffer::FramebufferCreate(1, &blankTex, depthTex);
Material* fboMaterial = new Material(new ShaderProgram("Data/Shaders/Post/post.vert", "Data/Shaders/Post/post.frag"), //post_pixelation
RenderState(RenderState::DepthTestingMode::ON, RenderState::FaceCullingMode::RENDER_BACK_FACES, RenderState::BlendMode::ALPHA_BLEND));
fboMaterial->SetDiffuseTexture(blankTex);
fboMaterial->SetNormalTexture(depthTex);
MeshBuilder builder;
builder.AddQuad(Vector3(-1, -1, 0), Vector3::UP, 2.0f, Vector3::RIGHT, 2.0f);
quadForFBO = new MeshRenderer(new Mesh(), fboMaterial);
builder.CopyToMesh(quadForFBO->m_mesh, &Vertex_PCUTB::Copy, sizeof(Vertex_PCUTB), &Vertex_PCUTB::BindMeshToVAO);
quadForFBO->m_material->SetFloatUniform("gPixelationFactor", 8.0f);
}
示例3: Scene
// Method to forge our junks
Scene* SceneBuilder::forge()
{
Scene* scene = new Scene();
// Grabbing all world settings
json11::Json* wsJson = new json11::Json((*this->json)["worldSettings"]);
json11::Json::object worldSettingsJson = wsJson->object_items();
WorldSettingsBuilder* wsBuilder = new WorldSettingsBuilder(wsJson);
scene->setWorldSettings(wsBuilder->forgeWorldSettings());
json11::Json* mJson = new json11::Json((*this->json)["meshes"]);
MeshBuilder* meshBuilder = new MeshBuilder();
meshBuilder->setJson(mJson);
scene->setMeshes(meshBuilder->forgeMeshes());
json11::Json* pJson = new json11::Json((*this->json)["camera"]);
PovBuilder* povBuilder = new PovBuilder();
povBuilder->setJson(pJson);
scene->setPov(povBuilder->forge());
// WorldSettingsBuilder deallocates the json so we will set it to null
wsJson = NULL;
return scene;
};
示例4: generateMesh
void generateMesh(Terrain* const t,const QString& obj,int echantillion){
MeshBuilder bu;
QString nom="terrain";
Mesh m =bu.terrain(*t,echantillion,nom);
bu.saveMesh(obj,m);
}
示例5: DrawVertexArray
//-----------------------------------------------------------------------------------
void Renderer::DrawVertexArray(const Vertex_PCT* vertexes, int numVertexes, DrawMode drawMode /*= DrawMode::QUADS*/)
{
if (numVertexes == 0)
{
return;
}
MeshBuilder builder;
builder.Begin();
for (int i = 0; i < numVertexes; ++i)
{
builder.SetColor(vertexes[i].color);
builder.SetUV(vertexes[i].texCoords);
builder.SetTBN(Vector3::ZERO, Vector3::ZERO, Vector3::ZERO);
builder.AddVertex(vertexes[i].pos);
builder.AddIndex(i);
}
builder.End();
Mesh* mesh = new Mesh();
builder.CopyToMesh(mesh, &Vertex_PCUTB::Copy, sizeof(Vertex_PCUTB), &Vertex_PCUTB::BindMeshToVAO);
mesh->m_drawMode = drawMode;
MeshRenderer* thingToRender = new MeshRenderer(mesh, m_defaultMaterial);
m_defaultMaterial->SetMatrices(Matrix4x4::IDENTITY, m_viewStack.GetTop(), m_projStack.GetTop());
GL_CHECK_ERROR();
thingToRender->Render();
delete mesh;
}
示例6: PolyangleHauteur
Mesh RezDeChaussee::generate() const
{
QVector<PolyangleHauteur> polyangles;
polyangles << PolyangleHauteur(base, hauteur)
<< PolyangleHauteur(base, hauteur + hauteurRDC);
MeshBuilder mb;
Mesh rdcMesh = mb.generationPolyanglesRelies(polyangles);
Etage etage = Etage(base, hauteur + hauteurRDC, hauteurRDC);
rdcMesh.merge(etage.generate());
return rdcMesh;
}
示例7: Render
//-----------------------------------------------------------------------------------
void Path::Render() const
{
MeshBuilder builder;
builder.Begin();
const float TILE_SIZE = 25.0f;
for (PathNode* node : m_openList)
{
Vector2 bottomLeft = Vector2(node->position) * TILE_SIZE;
builder.AddTexturedAABB(AABB2(bottomLeft, bottomLeft + (Vector2::ONE * TILE_SIZE)), Vector2::ZERO, Vector2::ONE, RGBA(0x0000FF7F));
Renderer::instance->DrawText2D(bottomLeft, std::to_string(node->f).substr(0, 4), 0.5f, RGBA::WHITE, false, BitmapFont::CreateOrGetFontFromGlyphSheet("Runescape"));
}
for (PathNode* node : m_closedList)
{
Vector2 bottomLeft = Vector2(node->position) * TILE_SIZE;
builder.AddTexturedAABB(AABB2(bottomLeft, bottomLeft + (Vector2::ONE * TILE_SIZE)), Vector2::ZERO, Vector2::ONE, RGBA(0xFF00007F));
Renderer::instance->DrawText2D(bottomLeft, std::to_string(node->f).substr(0, 4), 0.5f, RGBA::WHITE, false, BitmapFont::CreateOrGetFontFromGlyphSheet("Runescape"));
}
for (PathNode* node : m_resultantPath)
{
Vector2 bottomLeft = Vector2(node->position) * TILE_SIZE;
builder.AddTexturedAABB(AABB2(bottomLeft, bottomLeft + (Vector2::ONE * TILE_SIZE)), Vector2::ZERO, Vector2::ONE, RGBA(0x00FF007F));
}
Vector2 bottomLeft = (Vector2(m_currentGoal) * TILE_SIZE);
builder.AddTexturedAABB(AABB2(bottomLeft, bottomLeft + (Vector2::ONE * TILE_SIZE)), Vector2::ZERO, Vector2::ONE, RGBA(0x00FF007F));
builder.End();
Mesh* mesh = new Mesh();
builder.CopyToMesh(mesh, &Vertex_PCUTB::Copy, sizeof(Vertex_PCUTB), &Vertex_PCUTB::BindMeshToVAO);
MeshRenderer* renderer = new MeshRenderer(mesh, Renderer::instance->m_defaultMaterial);
renderer->Render();
delete mesh;
}
示例8: RenderMainMenu
//-----------------------------------------------------------------------------------
void TheGame::RenderMainMenu()
{
if (m_mainMenuText == nullptr)
{
MeshBuilder builder;
BitmapFont* bmFont = BitmapFont::CreateOrGetFontFromGlyphSheet("Runescape");
builder.AddText2D(Vector2(450, 600), "Picougelike", 7.0f, RGBA::VAPORWAVE, true, bmFont);
builder.AddText2D(Vector2(450, 300), "New Game (N)", 5.0f, RGBA::CYAN, true, bmFont);
builder.AddText2D(Vector2(450, 150), "Quit (Q)", 5.0f, RGBA::CYAN, true, bmFont);
m_mainMenuText = new MeshRenderer(new Mesh(), bmFont->GetMaterial());
builder.CopyToMesh(m_mainMenuText->m_mesh, &Vertex_TextPCT::Copy, sizeof(Vertex_TextPCT), &Vertex_TextPCT::BindMeshToVAO);
}
m_mainMenuText->Render();
}
示例9: generate
Mesh PetitEtageResidentiel::generate() const
{
MeshBuilder mb;
Mesh etageMesh = mb.generationEtage(this);
QVector<std::pair<Batiment*,int>> bats;
ToitResidentiel tr(base,hauteur+hauteurEtage,hauteurEtage,hMax-1,shrinkMax,aireMin);
EtageResidentiel er(base,hauteur+hauteurEtage,hauteurEtage,hMax-1,shrinkMax,aireMin);
bats << std::make_pair(&tr,5);
if(hMax>1){
bats << std::make_pair(&er,50);
}
etageMesh.merge(Batiment::getRandomBatiment(bats)->generate());
return etageMesh;
}
示例10: ImportVertex
//-----------------------------------------------------------------------------------
static void ImportVertex(MeshBuilder& builder, const Matrix4x4& transform, FbxMesh* mesh, int polyIndex, int vertIndex, std::vector<SkinWeight>& skinWeights)
{
Vector3 normal;
if (GetNormal(normal, transform, mesh, polyIndex, vertIndex))
{
builder.SetNormal(normal);
//Temporary hack to get around not supporting multiple vertex definitions
Vector3 bitangent = Vector3::UP;
if (normal == bitangent)
{
bitangent = Vector3::FORWARD;
}
Vector3 tangent = Vector3::Cross(bitangent, normal);
bitangent = Vector3::Cross(normal, tangent);
builder.SetTangent(tangent);
builder.SetBitangent(bitangent);
}
RGBA color;
if (GetColor(color, mesh, polyIndex, vertIndex))
{
builder.SetColor(color);
}
Vector2 uv;
if (GetUV(uv, mesh, polyIndex, vertIndex, 0))
{
builder.SetUV(uv);
}
//Set Skin Weights
int controlIndex = mesh->GetPolygonVertex(polyIndex, vertIndex);
if (controlIndex < skinWeights.size())
{
builder.SetBoneWeights(skinWeights[controlIndex].indices, skinWeights[controlIndex].weights);
builder.RenormalizeSkinWeights(); //Just to be safe.
}
else
{
builder.ClearBoneWeights();
}
Vector3 position;
if (GetPosition(&position, transform, mesh, polyIndex, vertIndex))
{
builder.AddVertex(position);
}
}
示例11: buildSquare
// Builds one square
void buildSquare(Object &object, const GLfloat side, MeshBuilder & builder) {
builder.addVertex(-side, -side, 0); // bottom left
builder.addVertex(side, -side, 0); // bottom right
builder.addVertex(-side, side, 0); // top left
builder.addVertex(side, side, 0); // top right
builder.addFace(0, 2, 3); // First triangle : top left
builder.addFace(0, 1, 3); // Second triangle : bottom right
vector<unsigned int> indices;
vector<Vector3f> vertices;
vector<Vector3f> normals;
vector<UV> uvs;
builder.unpack(indices, vertices, normals, uvs);
// Sends the data into buffers on the GPU
object.sendPrimitives(vertices, indices);
}
示例12: compute
bool TangentSpaceBuilder::compute(MeshBuilder& builder, int indexIdx, int posIdx, int normalIdx, int uvIdx, int tangentIdx)
{
const IndexArray idxPtr = builder.getAttributeAs<uint16_t>(indexIdx);
const Vec3fArray posPtr = builder.getAttributeAs<Vec3f>(posIdx);
const Vec3fArray nrmPtr = builder.getAttributeAs<Vec3f>(normalIdx);
const Vec2fArray uvPtr = builder.getAttributeAs<Vec2f>(uvIdx);
Vec3fArray tangentPtr = builder.getAttributeAs<Vec3f>(tangentIdx);
if(!idxPtr.data || !posPtr.data || !nrmPtr.data || !uvPtr.data || !tangentPtr.data)
return false;
if(idxPtr.size != builder.indexCount())
return false;
if(posPtr.size != builder.vertexCount())
return false;
compute(idxPtr, posPtr, nrmPtr, uvPtr, tangentPtr);
return true;
}
示例13: DrawVertexArray
//-----------------------------------------------------------------------------------
void Renderer::DrawVertexArray(const Vertex_PCT* vertexes, int numVertexes, DrawMode drawMode /*= QUADS*/, Texture* texture /*= nullptr*/)
{
// if (!texture)
// {
// texture = m_defaultTexture;
// }
// BindTexture(*texture);
// glEnableClientState(GL_VERTEX_ARRAY);
// glEnableClientState(GL_COLOR_ARRAY);
// glEnableClientState(GL_TEXTURE_COORD_ARRAY);
//
// glVertexPointer(3, GL_FLOAT, sizeof(Vertex_PCT), &vertexes[0].pos);
// glColorPointer(4, GL_UNSIGNED_BYTE, sizeof(Vertex_PCT), &vertexes[0].color);
// glTexCoordPointer(2, GL_FLOAT, sizeof(Vertex_PCT), &vertexes[0].texCoords);
//
// glDrawArrays(GetDrawMode(drawMode), 0, numVertexes);
//
// glDisableClientState(GL_VERTEX_ARRAY);
// glDisableClientState(GL_COLOR_ARRAY);
// glDisableClientState(GL_TEXTURE_COORD_ARRAY);
// UnbindTexture();
if (numVertexes == 0)
{
return;
}
MeshBuilder builder;
builder.Begin();
for (int i = 0; i < numVertexes; ++i)
{
builder.SetColor(vertexes[i].color);
builder.SetUV(vertexes[i].texCoords);
builder.SetTBN(Vector3::ZERO, Vector3::ZERO, Vector3::ZERO);
builder.AddVertex(vertexes[i].pos);
builder.AddIndex(i);
}
builder.End();
Mesh* mesh = new Mesh();
builder.CopyToMesh(mesh, &Vertex_PCUTB::Copy);
mesh->m_drawMode = drawMode;
MeshRenderer thingToRender = MeshRenderer(mesh, m_defaultMaterial);
m_defaultMaterial->SetMatrices(Matrix4x4::IDENTITY, m_viewStack.GetTop(), m_projStack.GetTop());
GL_CHECK_ERROR();
thingToRender.Render();
delete mesh;
}
示例14: MeshRenderer
//-----------------------------------------------------------------------------------
void Skeleton::Render() const
{
if (!m_joints)
{
MeshBuilder builder;
for (const Matrix4x4& modelSpaceMatrix : m_boneToModelSpace)
{
builder.AddIcoSphere(1.0f, RGBA::BLUE, 0, modelSpaceMatrix.GetTranslation());
}
m_joints = new MeshRenderer(new Mesh(), new Material(new ShaderProgram("Data/Shaders/fixedVertexFormat.vert", "Data/Shaders/fixedVertexFormat.frag"),
RenderState(RenderState::DepthTestingMode::OFF, RenderState::FaceCullingMode::RENDER_BACK_FACES, RenderState::BlendMode::ALPHA_BLEND)));
m_joints->m_material->SetDiffuseTexture(Renderer::instance->m_defaultTexture);
builder.CopyToMesh(m_joints->m_mesh, &Vertex_PCUTB::Copy, sizeof(Vertex_PCUTB), &Vertex_PCUTB::BindMeshToVAO);
}
if (!m_bones)
{
MeshBuilder builder;
for (unsigned int i = 0; i < m_parentIndices.size(); i++)
{
int parentIndex = m_parentIndices[i];
if (parentIndex >= 0)
{
builder.AddLine(m_boneToModelSpace[i].GetTranslation(), m_boneToModelSpace[parentIndex].GetTranslation(), RGBA::SEA_GREEN);
}
}
m_bones = new MeshRenderer(new Mesh(), new Material(new ShaderProgram("Data/Shaders/fixedVertexFormat.vert", "Data/Shaders/fixedVertexFormat.frag"),
RenderState(RenderState::DepthTestingMode::OFF, RenderState::FaceCullingMode::RENDER_BACK_FACES, RenderState::BlendMode::ALPHA_BLEND)));
m_bones->m_material->SetDiffuseTexture(Renderer::instance->m_defaultTexture);
builder.CopyToMesh(m_bones->m_mesh, &Vertex_PCUTB::Copy, sizeof(Vertex_PCUTB), &Vertex_PCUTB::BindMeshToVAO);
}
m_joints->Render();
m_bones->Render();
}
示例15: UNUSED
//-----------------------------------------------------------------------------------
void Renderer::DrawText2D(const Vector2& position, const std::string& asciiText, float scale, const RGBA& tint /*= RGBA::WHITE*/, bool drawShadow /*= false*/, const BitmapFont* font /*= nullptr*/, const Vector2& right /*= Vector3::UNIT_X*/, const Vector2& up /*= Vector3::UNIT_Z*/)
{
//To be used when I expand this method to 3D text
UNUSED(up);
UNUSED(right);
if (asciiText.empty())
{
return;
}
if (font == nullptr)
{
font = m_defaultFont;
}
int stringLength = asciiText.size();
Vector2 cursorPosition = position + (Vector2::UNIT_Y * (float)font->m_maxHeight * scale);
const Glyph* previousGlyph = nullptr;
MeshBuilder builder;
builder.Begin();
for (int i = 0; i < stringLength; i++)
{
unsigned char currentCharacter = asciiText[i];
const Glyph* glyph = font->GetGlyph(currentCharacter);
float glyphWidth = static_cast<float>(glyph->width) * scale;
float glyphHeight = static_cast<float>(glyph->height) * scale;
if (previousGlyph)
{
const Vector2 kerning = font->GetKerning(*previousGlyph, *glyph);
cursorPosition += (kerning * scale);
}
Vector2 offset = Vector2(glyph->xOffset * scale, -glyph->yOffset * scale);
Vector2 topRight = cursorPosition + offset + Vector2(glyphWidth, 0.0f);
Vector2 bottomLeft = cursorPosition + offset - Vector2(0.0f, glyphHeight);
AABB2 quadBounds = AABB2(bottomLeft, topRight);
AABB2 glyphBounds = font->GetTexCoordsForGlyph(*glyph);
if (drawShadow)
{
float shadowWidthOffset = glyphWidth / 10.0f;
float shadowHeightOffset = glyphHeight / -10.0f;
Vector2 shadowOffset = Vector2(shadowWidthOffset, shadowHeightOffset);
AABB2 shadowBounds = AABB2(bottomLeft + shadowOffset, topRight + shadowOffset);
builder.AddTexturedAABB(shadowBounds, glyphBounds.mins, glyphBounds.maxs, RGBA::BLACK);
}
builder.AddTexturedAABB(quadBounds, glyphBounds.mins, glyphBounds.maxs, tint);
cursorPosition.x += glyph->xAdvance * scale;
previousGlyph = glyph;
}
builder.End();
Mesh* mesh = new Mesh();
builder.CopyToMesh(mesh, &Vertex_PCUTB::Copy, sizeof(Vertex_PCUTB), &Vertex_PCUTB::BindMeshToVAO);
mesh->m_drawMode = DrawMode::TRIANGLES;
MeshRenderer* thingToRender = new MeshRenderer(mesh, font->GetMaterial());
m_defaultMaterial->SetMatrices(Matrix4x4::IDENTITY, m_viewStack.GetTop(), m_projStack.GetTop());
GL_CHECK_ERROR();
thingToRender->Render();
delete mesh;
delete thingToRender;
}