当前位置: 首页>>代码示例>>C++>>正文


C++ SimObject::AddMesh方法代码示例

本文整理汇总了C++中SimObject::AddMesh方法的典型用法代码示例。如果您正苦于以下问题:C++ SimObject::AddMesh方法的具体用法?C++ SimObject::AddMesh怎么用?C++ SimObject::AddMesh使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在SimObject的用法示例。


在下文中一共展示了SimObject::AddMesh方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: Initialize

unsigned int SceneTest::Initialize()
{
    ////////////////////////
    //////////// Ground Level

    m_groundLevel = 0.0f;

    ////////////////////////
    /////////// Objects

    glm::vec3 tPos, tRot, tScl, tPosMin, tPosMax;
    glm::vec4 tCol;


    SimObject* ground = new SimObject();
    ground->Initialize("Ground");

    tPos = (glm::vec3(0.0f, m_groundLevel - 0.1f, 0.0f));
    tRot = (glm::vec3(-3.14f / 2.0f, 0.0f, 0.0f));
    tScl = (glm::vec3(100.0f, 100.0f, 100.0f));
    tCol = (glm::vec4(0.8f, 0.8f, 0.9f, 1.0f));

    Transform* groundTransform = new Transform(ground);
    groundTransform->Initialize();
    groundTransform->SetPosition(&tPos);
    groundTransform->SetRotation(&tRot);
    groundTransform->SetScale(&tScl);
    ground->SetTransform(groundTransform);
    MeshGLRect* triangle = new MeshGLRect(ground, &tCol);
    triangle->Initialize();
    triangle->SetGloss(100.0f);
    triangle->SetSpecular(0.8f);
    triangle->SetTextureID(ResourceManager::GetInstance()->GetTextureWhite());
    ground->AddMesh(triangle);

    tPosMin = glm::vec3(-0.5f, -100000.0f, -0.5f);
    tPosMax = glm::vec3(0.5f, 0.001f, 0.5f);
    BoxAACollider* gCollider = PhysicsManager::GetInstance()->CreateBoxAACollider(ground, &tPosMin, &tPosMax);
    ground->AddCollider(gCollider);

    AddObject(ground);


    SimObject* testObj = new SimObject();
    testObj->Initialize("testObj");

    tPos = (glm::vec3(0.0f, 2.5f, 0.0f));
    tScl = (glm::vec3(1.0f, 1.0f, 1.0f));
    tCol = (glm::vec4(0.4f, 0.7f, 0.9f, 1.0f));

    Transform* testObjTransform = new Transform(testObj);
    testObjTransform->Initialize();
    testObjTransform->SetPosition(&tPos);
    testObjTransform->SetScale(&tScl);
    testObj->SetTransform(testObjTransform);

    MeshGLSphere* sph = new MeshGLSphere(testObj, 2.0f, 16, 16, &tCol);
    sph->Initialize();
    sph->SetGloss(20.0f);
    sph->SetSpecular(0.6f);
    sph->SetTextureID(ResourceManager::GetInstance()->GetTextureWhite());
    testObj->AddMesh(sph);


    tPosMin = (glm::vec3(0.0f, 0.0f, 0.0f));
    SphereCollider* tObjCollider = PhysicsManager::GetInstance()->CreateSphereCollider(testObj, &tPosMin, 2.0f);
    testObj->AddCollider(tObjCollider);



    AddObject(testObj);

    // and here goes box
    SimObject* testObjBox = new SimObject();
    testObjBox->Initialize("testObjBox");

    tPos = (glm::vec3(0.0f, 999.0f, 0.0f));
    tScl = (glm::vec3(1.0f, 1.0f, 1.0f));
    tCol = (glm::vec4(0.4f, 0.7f, 0.9f, 1.0f));

    Transform* testObjBoxTransform = new Transform(testObjBox);
    testObjBoxTransform->Initialize();
    testObjBoxTransform->SetPosition(&tPos);
    testObjBoxTransform->SetScale(&tScl);
    testObjBox->SetTransform(testObjBoxTransform);

    tCol = glm::vec4(0.2f, 0.2f, 0.8f, 1.0f);
    MeshGLBox* box = new MeshGLBox(testObjBox, 4.0f, 3.0f, 3.0f, &tCol);
    box->Initialize();
    box->SetGloss(100.0f);
    box->SetSpecular(0.5f);
    box->SetTextureID(ResourceManager::GetInstance()->GetTextureWhite());
    testObjBox->AddMesh(box);

    tPosMin = glm::vec3(-2.0f, -1.5f, -1.5f);
    tPosMax = glm::vec3(2.0f, 1.5f, 1.5f);
    BoxAACollider* tObjBoxCollider = PhysicsManager::GetInstance()->CreateBoxAACollider(testObjBox, &tPosMin, &tPosMax);
    testObjBox->AddCollider(tObjBoxCollider);

    AddObject(testObjBox);
//.........这里部分代码省略.........
开发者ID:ACPLMaverick,项目名称:MAVNET,代码行数:101,代码来源:SceneTest.cpp


注:本文中的SimObject::AddMesh方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。