本文整理汇总了C++中Mesh函数的典型用法代码示例。如果您正苦于以下问题:C++ Mesh函数的具体用法?C++ Mesh怎么用?C++ Mesh使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了Mesh函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: switch
Shape Shape::createShape(
ShapeType type,
float size /* = 1.0f */,
float texturing /* = 2.0f */,
int resolution /* = 16 */,
float width /* = 0.0f */,
float height /* = 0.0f */,
float depth /* = 0.0f */)
{
this->setSize(size);
this->setResolution(resolution);
switch (type)
{
case SPHERE:
this->setVertices(createSphere(size, resolution, true));
break;
case PYRAMID:
this->setVertices(createPyramid(size, texturing));
break;
case TETRAHEDRON:
this->setVertices(createTetrahedron(size, texturing));
break;
case CUBOID:
this->setVertices(createCuboid(size, width, height, depth, texturing));
break;
default:
break;
}
this->setMesh(Mesh(this->m_vertices, this->m_vertices.size()));
return *(this);
}
示例2: Mesh
//-----------------------------------------------------------------------
Resource* MeshManager::createImpl(const String& name, ResourceHandle handle,
const String& group, bool isManual, ManualResourceLoader* loader,
const NameValuePairList* createParams)
{
// no use for createParams here
return OGRE_NEW Mesh(this, name, handle, group, isManual, loader);
}
示例3: Mesh
/** @brief Update memory using the Transfer object */
void TRMTransportAnalysis::UpdateMemory(){
Mesh()->LoadSolution(fX);
TPZBuildMultiphysicsMesh::TransferFromMultiPhysics(fmeshvec, Mesh());
// Volumetric update
if (fSimulationData->IsTwoPhaseQ()) {
fTransfer->s_To_Transport_Memory(fmeshvec[0], Mesh(),0);
}
// Volumetric update
if (fSimulationData->IsThreePhaseQ()) {
fTransfer->s_To_Transport_Memory(fmeshvec[0], Mesh(),0);
fTransfer->s_To_Transport_Memory(fmeshvec[1], Mesh(),1);
}
}
示例4: Attribute
// ------------------------------------
GeomAttr::GeomAttr() :
// ------------------------------------
Attribute(EATTR_GEOM),
m_shape(GEOM_SQUARE),
m_bound(Box(Vector2(-0.5, -0.5), Vector2(1, 1)))
{
m_mesh = Mesh(m_bound);
}
示例5: loadMeshIntoMeshGroup
bool loadMeshIntoMeshGroup(MeshGroup* meshgroup, const char* filename, const FMatrix3x3& transformation, SettingsBaseVirtual* object_parent_settings)
{
TimeKeeper load_timer;
const char* ext = strrchr(filename, '.');
if (ext && (strcmp(ext, ".stl") == 0 || strcmp(ext, ".STL") == 0))
{
Mesh mesh = object_parent_settings ? Mesh(object_parent_settings) : Mesh(meshgroup); //If we have object_parent_settings, use them as parent settings. Otherwise, just use meshgroup.
if(loadMeshSTL(&mesh,filename,transformation)) //Load it! If successful...
{
meshgroup->meshes.push_back(mesh);
log("loading '%s' took %.3f seconds\n",filename,load_timer.restart());
return true;
}
}
return false;
}
示例6: is
Scene Scene::load(const std::string &filename, const json11::Json &settings) {
std::ifstream is(filename);
std::stringstream ss;
ss << is.rdbuf();
std::string err;
Json jsonRoot = Json::parse(ss.str(), err);
if (jsonRoot.is_null()) {
throw Exception("Failed to load scene from '%s' (error: %s)", filename, err);
}
_resolver = filesystem::resolver();
_resolver.prepend(filesystem::path(filename).parent_path());
Scene scene;
// Patch settings
auto settingsValues = jsonRoot["settings"].object_items();
for (auto kv : settings.object_items()) {
settingsValues[kv.first] = kv.second;
}
scene.settings = Properties(json11::Json(settingsValues));
// Parse scene objects
Json jsonScene = jsonRoot["scene"];
if (jsonScene.is_object()) {
auto jsonCamera = jsonScene["camera"];
if (jsonCamera.is_object()) {
Properties props(jsonCamera);
scene.camera = Camera(jsonCamera);
}
auto jsonWorld = jsonScene["world"];
if (jsonWorld.is_object()) {
Properties props(jsonWorld);
scene.world = World(jsonWorld);
}
for (auto jsonBox : jsonScene["boxes"].array_items()) {
scene.boxes.emplace_back(Box(Properties(jsonBox)));
}
for (auto jsonSphere : jsonScene["spheres"].array_items()) {
scene.spheres.emplace_back(Sphere(Properties(jsonSphere)));
}
for (auto jsonMesh : jsonScene["meshes"].array_items()) {
scene.meshes.emplace_back(Mesh(Properties(jsonMesh)));
}
for (auto jsonCameraKeyframe : jsonScene["cameraKeyframes"].array_items()) {
scene.cameraKeyframes.emplace_back(Camera(Properties(jsonCameraKeyframe)));
}
// Set default camera
if (!jsonCamera.is_object()) {
Vector3f center = scene.world.bounds.center();
scene.camera.position += center;
scene.camera.target += center;
}
}
return scene;
}
示例7: Mesh
Mesh Model::processMesh(aiMesh * mesh, const aiScene * scene)
{
std::vector<Vertex> vertices;
std::vector<GLuint> indices;
std::vector<Texture> textures;
// process vertices
for (GLuint i = 0; i < mesh->mNumVertices; i++)
{
Vertex vertex;
vertex.position.x = mesh->mVertices[i].x;
vertex.position.y = mesh->mVertices[i].y;
vertex.position.z = mesh->mVertices[i].z;
vertex.normal.x = mesh->mNormals[i].x;
vertex.normal.y = mesh->mNormals[i].y;
vertex.normal.z = mesh->mNormals[i].z;
if (mesh->mTextureCoords[0])
{
vertex.texCoords.x = mesh->mTextureCoords[0][i].x;
vertex.texCoords.y = mesh->mTextureCoords[0][i].y;
}
else
{
vertex.texCoords = glm::vec2(0.0f, 0.0f);
}
vertices.push_back(vertex);
}
// process indices
for (GLuint i = 0; i < mesh->mNumFaces; i++)
{
aiFace face = mesh->mFaces[i];
for (GLuint j = 0; j < face.mNumIndices; j++)
{
indices.push_back(face.mIndices[j]);
}
}
// process material
if (mesh->mMaterialIndex >= 0)
{
aiMaterial* material = scene->mMaterials[mesh->mMaterialIndex];
std::vector<Texture> diffuseMaps = this->loadMaterialTextures(material,
aiTextureType_DIFFUSE, "texture_diffuse");
textures.insert(textures.end(), diffuseMaps.begin(), diffuseMaps.end());
std::vector<Texture> specularMaps = this->loadMaterialTextures(material,
aiTextureType_SPECULAR, "texture_specular");
textures.insert(textures.end(), specularMaps.begin(), specularMaps.end());
}
return Mesh(vertices, indices, textures);
}
示例8: bricks
void TestGame::Init(const Window& window)
{
Material bricks("bricks", Texture("bricks.jpg"), 0.0f, 0, Texture("bricks_normal.jpg"), Texture("bricks_disp.png"), 0.03f, -0.5f);
Material bricks2("bricks2", Texture("bricks2.jpg"), 0.0f, 0, Texture("bricks2_normal.png"), Texture("bricks2_disp.jpg"), 0.04f, -1.0f);
//Material skin("humanFace", Texture("human.jpg"), 0.0f, 0, Texture("human_normal_inv.jpg"));
//Material skin("humanFace", Texture("human.jpg"), 0.08f, 8, Texture("human_normal_inv.jpg"));
IndexedModel square;
{
square.AddVertex(1.0f, -1.0f, 0.0f); square.AddTexCoord(Vector2f(1.0f, 1.0f));
square.AddVertex(1.0f, 1.0f, 0.0f); square.AddTexCoord(Vector2f(1.0f, 0.0f));
square.AddVertex(-1.0f, -1.0f, 0.0f); square.AddTexCoord(Vector2f(0.0f, 1.0f));
square.AddVertex(-1.0f, 1.0f, 0.0f); square.AddTexCoord(Vector2f(0.0f, 0.0f));
square.AddFace(0, 1, 2); square.AddFace(2, 1, 3);
}
Mesh customMesh("square", square.Finalize());
AddToScene((new Entity(Vector3f(0, -1, 5), Quaternion(), 32.0f))
->AddComponent(new MeshRenderer(Mesh("terrain02.obj"), Material("bricks"))));
AddToScene((new Entity(Vector3f(7,0,7)))
->AddComponent(new PointLight(Vector3f(0,1,0), 0.4f, Attenuation(0,0,1))));
AddToScene((new Entity(Vector3f(20,-11.0f,5), Quaternion(Vector3f(1,0,0), ToRadians(-60.0f)) * Quaternion(Vector3f(0,1,0), ToRadians(90.0f))))
->AddComponent(new SpotLight(Vector3f(0,1,1), 0.4f, Attenuation(0,0,0.02f), ToRadians(91.1f), 7, 1.0f, 0.5f)));
AddToScene((new Entity(Vector3f(), Quaternion(Vector3f(1,0,0), ToRadians(-45))))
->AddComponent(new DirectionalLight(Vector3f(1,1,1), 0.4f, 10, 80.0f, 1.0f)));
AddToScene((new Entity(Vector3f(0, 2, 0), Quaternion(Vector3f(0,1,0), 0.4f), 1.0f))
->AddComponent(new MeshRenderer(Mesh("plane3.obj"), Material("bricks2")))
->AddChild((new Entity(Vector3f(0, 0, 25)))
->AddComponent(new MeshRenderer(Mesh("plane3.obj"), Material("bricks2")))
->AddChild((new Entity())
->AddComponent(new CameraComponent(Matrix4f().InitPerspective(ToRadians(70.0f), window.GetAspect(), 0.1f, 1000.0f)))
->AddComponent(new FreeLook(window.GetCenter()))
->AddComponent(new FreeMove(10.0f)))));
AddToScene((new Entity(Vector3f(24,-12,5), Quaternion(Vector3f(0,1,0), ToRadians(30.0f))))
->AddComponent(new MeshRenderer(Mesh("sphere.obj"), Material("bricks"))));
AddToScene((new Entity(Vector3f(0,0,7), Quaternion(), 1.0f))
->AddComponent(new MeshRenderer(Mesh("square"), Material("bricks2"))));
}
示例9: Measure
Size2F SpriteTemplate::Measure(const FileId& data, const Size2F& limitSize /*= Size2F::Zero*/) const
{
auto obj= RenderingObjectFactory::Instance().CreateFromTexture(data);
if (obj.IsValid())
{
return obj.Mesh()->Size().To2D();
}
return limitSize;
}
示例10: Mesh
Model Model::ConvertAssimpToDarknec(Model model, aiScene* scene) {
model.numMeshes_ = scene->mNumMeshes;
for (unsigned int mesh = 0; mesh < scene->mNumMeshes; mesh++) {
Mesh messh = Mesh();
int vertCount = scene->mMeshes[mesh]->mNumVertices;
int normCount = scene->mMeshes[mesh]->mNumVertices;
int indiCount = scene->mMeshes[mesh]->mNumFaces * 3; //All imported models must be comprised of tris.
int uvCount = scene->mMeshes[mesh]->mNumVertices;
messh.numIndices_ = indiCount;
messh.numNormals_ = normCount * 3;
messh.numVertices_ = vertCount * 3;
messh.numUVs_ = uvCount * 2;
messh.hasNormals_ = scene->mMeshes[mesh]->HasNormals();
messh.hasUVS_ = scene->mMeshes[mesh]->HasTextureCoords(0);
for (unsigned int face = 0; face < scene->mMeshes[mesh]->mNumFaces; face++) {
aiFace facce = scene->mMeshes[mesh]->mFaces[face];
messh.indices_.push_back(facce.mIndices[0]);
messh.indices_.push_back(facce.mIndices[1]);
messh.indices_.push_back(facce.mIndices[2]);
}
for (int vertex = 0; vertex < vertCount; vertex++) {
aiVector3D vector = scene->mMeshes[mesh]->mVertices[vertex];
messh.vertices_.push_back(vector.x);
messh.vertices_.push_back(vector.y);
messh.vertices_.push_back(vector.z);
}
if (messh.hasNormals_) {
for (int normal = 0; normal < normCount; normal++) {
aiVector3D vector = scene->mMeshes[mesh]->mNormals[normal];
messh.normals_.push_back(vector.x);
messh.normals_.push_back(vector.y);
messh.normals_.push_back(vector.z);
}
}
if (messh.hasUVS_) {
for (int uv = 0; uv < uvCount; uv++) {
aiVector3D vector = scene->mMeshes[mesh]->mTextureCoords[0][uv];
messh.UVs_.push_back(vector.x);
messh.UVs_.push_back(1- vector.y);
}
}
model.meshes_.push_back(messh);
}
return model;
}
示例11: Mesh
Mesh Generate::line(const vector<VectorF> &linePointsIn, TextureDescriptor texture, Color color,
float lineWidth)
{
if(linePointsIn.size() < 2) // if less than 2 points then we can't have a line
{
return Mesh(new Mesh_t());
}
vector<VectorF> linePoints;
linePoints.reserve(linePointsIn.size());
linePoints.push_back(linePointsIn[0]);
for(size_t i = 1; i < linePointsIn.size(); i++)
{
if(absSquared(linePointsIn[i] - linePoints.back()) >= eps * eps) // remove duplicates
linePoints.push_back(linePointsIn[i]);
}
if(linePoints.size() < 2) // if less than 2 points then we can't have a line
{
return Mesh(new Mesh_t());
}
vector<Edge> edges;
edges.reserve(linePoints.size());
float distance = 0;
edges.push_back(makeStartEdge(linePoints[0], linePoints[1], distance, lineWidth));
distance += abs(linePoints[1] - linePoints[0]);
for(size_t i = 2; i < linePoints.size(); i++)
{
edges.push_back(makeMiddleEdge(linePoints[i - 2], linePoints[i - 1], linePoints[i], distance, lineWidth));
distance += abs(linePoints[i - 1] - linePoints[i]);
}
edges.push_back(makeEndEdge(linePoints[linePoints.size() - 2], linePoints[linePoints.size() - 1], distance, lineWidth));
Mesh retval = nullptr;
for(size_t i = 1; i < edges.size(); i++)
{
TextureDescriptor currentTexture = texture.subTexture(edges[i - 1].distance / distance, edges[i].distance / distance, 0, 1);
Mesh mesh = Generate::quadrilateral(currentTexture, edges[i - 1].p2, color, edges[i].p2, color, edges[i].p1, color, edges[i - 1].p1, color);
if(retval == nullptr)
retval = mesh;
else
retval->add(mesh);
}
return retval;
}
示例12: InternalMessage
void TestDetector::detectMovingObject()
{
InternalMessage("Model","Model::TestDetector::detectMovingObject entering") ;
/*!
We create a ship with a detector and a second object to detect.
*/
std::auto_ptr<Kernel::Model> model(new Kernel::Model("TestDetector::detectMovingObject")) ;
model->init() ;
Kernel::Object* system = model->createObject() ;
Kernel::Object* ship = system->createObject() ;
ship->addTrait(new Positioned()) ;
ship->addTrait(new Oriented()) ;
ship->addTrait(new Mobile()) ;
ship->addTrait(new Solid(Mesh("test_ship.mesh"))) ;
ship->addTrait(new Massive(Mass::Kilogram(1000))) ;
ship->addTrait(new Computer()) ;
ship->addTrait(new Detector()) ;
Detector::connect(ship,ship) ;
Kernel::Object* ship2 = system->createObject() ;
ship2->addTrait(new Positioned(Position::Meter(0,0,500))) ;
ship2->addTrait(new Massive(Mass::Kilogram(1000))) ;
ship2->addTrait(new Oriented()) ;
ship2->addTrait(new Mobile()) ;
ship2->addTrait(new Solid(Mesh("test_ship.mesh"))) ;
// the second ship has been detected.
std::set<Kernel::Object*> detected(ship->getTrait<Computer>()->getDetectedObjects()) ;
CPPUNIT_ASSERT(!detected.empty()) ;
CPPUNIT_ASSERT(detected.find(ship2) != detected.end()) ;
ship2->getTrait<Positioned>()->setPosition(Position::Meter(0,100,0)) ;
// the second ship has been detected.
detected = ship->getTrait<Computer>()->getDetectedObjects() ;
CPPUNIT_ASSERT(!detected.empty()) ;
CPPUNIT_ASSERT(detected.find(ship2) != detected.end()) ;
InternalMessage("Model","Model::TestDetector::detectMovingObject leaving") ;
}
示例13: Mesh
void MeshBuilder::apply(Mesh& mesh) const {
if (!mesh.is_initialized()) {
mesh = Mesh(vertex_decl, index_type, DRAW_TRIANGLES);
} else {
COLD_DEBUG_ASSERT(mesh.get_vertex_declaration() == vertex_decl);
COLD_DEBUG_ASSERT(mesh.get_index_type() == index_type);
}
mesh.set_vertices(vertices.get_pointer(), vertices.get_count());
mesh.set_indices(indices.get_pointer(), indices.get_count());
}
示例14: m_plane
RenderingEngine::RenderingEngine(const Window& window) :
m_plane(Mesh("plane.obj")),
m_window(&window),
m_tempTarget(window.GetWidth(), window.GetHeight(), 0, GL_TEXTURE_2D, GL_NEAREST, GL_RGBA, GL_RGBA, false, GL_COLOR_ATTACHMENT0),
m_planeMaterial("renderingEngine_filterPlane", m_tempTarget, 1, 8),
m_defaultShader("forward-ambient"),
m_shadowMapShader("shadowMapGenerator"),
m_nullFilter("filter-null"),
m_gausBlurFilter("filter-gausBlur7x1"),
m_fxaaFilter("filter-fxaa"),
m_altCameraTransform(Vector3f(0,0,0), Quaternion(Vector3f(0,1,0),ToRadians(180.0f))),
m_altCamera(Matrix4f().InitIdentity(), &m_altCameraTransform)
{
SetSamplerSlot("diffuse", 0);
SetSamplerSlot("normalMap", 1);
SetSamplerSlot("dispMap", 2);
SetSamplerSlot("shadowMap", 3);
SetSamplerSlot("roughMap", 4);
SetSamplerSlot("filterTexture", 0);
SetVector3f("ambient", Vector3f(0.2f, 0.2f, 0.2f));
SetFloat("fxaaSpanMax", 8.0f);
SetFloat("fxaaReduceMin", 1.0f/128.0f);
SetFloat("fxaaReduceMul", 1.0f/8.0f);
SetFloat("fxaaAspectDistortion", 150.0f);
SetTexture("displayTexture", Texture(m_window->GetWidth(), m_window->GetHeight(), 0, GL_TEXTURE_2D, GL_LINEAR, GL_RGBA, GL_RGBA, true, GL_COLOR_ATTACHMENT0));
glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
glFrontFace(GL_CW);
glCullFace(GL_BACK);
glEnable(GL_CULL_FACE);
glEnable(GL_DEPTH_TEST);
//glEnable(GL_DEPTH_CLAMP);
//glEnable(GL_MULTISAMPLE);
//glEnable(GL_FRAMEBUFFER_SRGB);
//m_planeMaterial("renderingEngine_filterPlane", m_tempTarget, 1, 8);
m_planeTransform.SetScale(1.0f);
m_planeTransform.Rotate(Quaternion(Vector3f(1,0,0), ToRadians(90.0f)));
m_planeTransform.Rotate(Quaternion(Vector3f(0,0,1), ToRadians(180.0f)));
for(int i = 0; i < NUM_SHADOW_MAPS; i++)
{
int shadowMapSize = 1 << (i + 1);
m_shadowMaps[i] = Texture(shadowMapSize, shadowMapSize, 0, GL_TEXTURE_2D, GL_LINEAR, GL_RG32F, GL_RGBA, true, GL_COLOR_ATTACHMENT0);
m_shadowMapTempTargets[i] = Texture(shadowMapSize, shadowMapSize, 0, GL_TEXTURE_2D, GL_LINEAR, GL_RG32F, GL_RGBA, true, GL_COLOR_ATTACHMENT0);
}
m_lightMatrix = Matrix4f().InitScale(Vector3f(0,0,0));
}
示例15: RETURN_NULL_IF_NULL
Sprite* NodeFactory::CreateSpriteFromAtlasRegion(StringRef regionName, const FileIdRef& atlasFileId, TextureAtlasFileFormat fileFormat /*= TextureAtlasFileFormat::Spine*/, uint atlasPageCount /*= 1*/)
{
auto renderingObject = RenderingObjectFactory::Instance().CreateFromTextureAtlasRegion(regionName, atlasFileId, fileFormat, atlasPageCount);
RETURN_NULL_IF_NULL(renderingObject);
Sprite* sprite = new Sprite();
sprite->SetRenderingObject(renderingObject);
sprite->SetSize(renderingObject.Mesh()->Size());
sprite->Initialize();
return sprite;
}