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


C++ CModel::GetMesh方法代码示例

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


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

示例1: WriteTextModel

void ModelOutput::WriteTextModel(const CModel& model, std::ostream &stream)
{
    ModelHeaderV3 header;
    header.version = 3;
    header.totalCrashSpheres = model.GetCrashSphereCount();
    header.hasShadowSpot = model.HasShadowSpot();
    header.hasCameraCollisionSphere = model.HasCameraCollisionSphere();
    header.totalMeshes = model.GetMeshCount();
    WriteTextHeader(header, stream);

    stream << "# MODEL PROPERTIES" << std::endl;

    for (const auto& crashSphere : model.GetCrashSpheres())
        WriteCrashSphere(crashSphere, stream);

    if (model.HasShadowSpot())
        WriteShadowSpot(model.GetShadowSpot(), stream);

    if (model.HasCameraCollisionSphere())
        WriteCameraCollisionSphere(model.GetCameraCollisionSphere(), stream);

    stream << std::endl;

    for (const std::string& meshName : model.GetMeshNames())
    {
        const CModelMesh* mesh = model.GetMesh(meshName);
        assert(mesh != nullptr);
        WriteTextMesh(mesh, meshName, stream);
    }
}
开发者ID:BTML,项目名称:colobot,代码行数:30,代码来源:model_output.cpp

示例2: DumpInfo

void DumpInfo(const CModel& model)
{
    const CModelMesh* mesh = model.GetMesh("main");
    if (mesh == nullptr)
    {
        std::cerr << "Main mesh not found!" << std::endl;
        return;
    }

    Math::Vector bboxMin( Math::HUGE_NUM,  Math::HUGE_NUM,  Math::HUGE_NUM);
    Math::Vector bboxMax(-Math::HUGE_NUM, -Math::HUGE_NUM, -Math::HUGE_NUM);

    std::map<std::string, int> texs1, texs2;
    std::map<int, int> states;
    int variableTexs2 = 0;

    for (const ModelTriangle& t : mesh->GetTriangles())
    {
        bboxMin.x = Math::Min(t.p1.coord.x, t.p2.coord.x, t.p3.coord.x, bboxMin.x);
        bboxMin.y = Math::Min(t.p1.coord.y, t.p2.coord.y, t.p3.coord.y, bboxMin.y);
        bboxMin.z = Math::Min(t.p1.coord.z, t.p2.coord.z, t.p3.coord.z, bboxMin.z);

        bboxMax.x = Math::Max(t.p1.coord.x, t.p2.coord.x, t.p3.coord.x, bboxMax.x);
        bboxMax.y = Math::Max(t.p1.coord.y, t.p2.coord.y, t.p3.coord.y, bboxMax.y);
        bboxMax.z = Math::Max(t.p1.coord.z, t.p2.coord.z, t.p3.coord.z, bboxMax.z);

        texs1[t.tex1Name] += 1;
        if (! t.tex2Name.empty())
            texs2[t.tex2Name] += 1;
        if (t.variableTex2)
            variableTexs2 += 1;
    }

    int total = mesh->GetTriangleCount();

    std::cerr << "---- Info ----" << std::endl;
    std::cerr << "Total triangles: " << total;
    std::cerr << std::endl;
    std::cerr << "Bounding box:" << std::endl;
    std::cerr << " bboxMin: [" << bboxMin.x << ", " << bboxMin.y << ", " << bboxMin.z << "]" << std::endl;
    std::cerr << " bboxMax: [" << bboxMax.x << ", " << bboxMax.y << ", " << bboxMax.z << "]" << std::endl;
    std::cerr << std::endl;
    std::cerr << "Textures:" << std::endl;
    std::cerr << " tex1:" << std::endl;
    PrintStats(texs1, total);
    std::cerr << " tex2:" << std::endl;
    PrintStats(texs2, total);
    std::cerr << " variable tex2: " << variableTexs2 << " / " << total << std::endl;
    std::cerr << std::endl;
}
开发者ID:BTML,项目名称:colobot,代码行数:50,代码来源:convert_model.cpp

示例3: WriteBinaryModel

void ModelOutput::WriteBinaryModel(const CModel& model, std::ostream &stream)
{
    const CModelMesh* mesh = model.GetMesh("main");
    if (mesh == nullptr)
        throw CModelIOException("No main mesh found in model");

    ModelHeaderV1AndV2 header;

    header.version = 2;
    header.totalTriangles = mesh->GetTriangleCount();

    WriteBinary<4, int>(header.version, stream);
    WriteBinary<4, int>(header.totalTriangles, stream);

    for (const ModelTriangle& triangle : mesh->GetTriangles())
    {
        ModelTriangleV1AndV2 t;

        t.p1 = triangle.p1;
        t.p2 = triangle.p2;
        t.p3 = triangle.p3;
        t.material.ambient = triangle.ambient;
        t.material.diffuse = triangle.diffuse;
        t.material.specular = triangle.specular;
        t.tex1Name = triangle.tex1Name;
        t.tex2Name = triangle.tex2Name;
        t.variableTex2 = triangle.variableTex2;
        t.state = ConvertToOldState(triangle);

        WriteBinaryVertexTex2(t.p1, stream);
        WriteBinaryVertexTex2(t.p2, stream);
        WriteBinaryVertexTex2(t.p3, stream);
        WriteBinaryMaterial(t.material, stream);
        WriteBinaryString<1>(t.tex1Name, stream);
        WriteBinaryString<1>(t.tex2Name, stream);
        WriteBinaryBool(t.variableTex2, stream);
        WriteBinary<4, int>(t.state, stream);
    }
}
开发者ID:BTML,项目名称:colobot,代码行数:39,代码来源:model_output.cpp

示例4: WriteOldModel

void ModelOutput::WriteOldModel(const CModel& model, std::ostream &stream)
{
    const CModelMesh* mesh = model.GetMesh("main");
    if (mesh == nullptr)
        throw CModelIOException("No main mesh found in model");

    OldModelHeader header;
    header.revision = 1;
    header.version = 2;
    header.totalTriangles = mesh->GetTriangleCount();

    WriteBinary<4, int>(header.revision, stream);
    WriteBinary<4, int>(header.version, stream);
    WriteBinary<4, int>(header.totalTriangles, stream);
    for (int i = 0; i < 10; ++i)
        WriteBinary<4, int>(header.reserved[i], stream);

    for (const ModelTriangle& triangle : mesh->GetTriangles())
    {
        OldModelTriangleV3 t;

        t.used = true;

        t.p1 = triangle.p1;
        t.p2 = triangle.p2;
        t.p3 = triangle.p3;

        t.material.ambient = triangle.ambient;
        t.material.diffuse = triangle.diffuse;
        t.material.specular = triangle.specular;
        strncpy(t.texName, triangle.tex1Name.c_str(), 20);
        t.min = 0.0f;
        t.max = 1000000.0f;
        t.state = ConvertToOldState(triangle);

        int no = 0;
        if (triangle.variableTex2)
            no = 1;
        else
            std::sscanf(triangle.tex2Name.c_str(), "dirty%d.png", &no);

        t.texNum2 = no;


        WriteBinary<1, char>(t.used,     stream);
        WriteBinary<1, char>(t.selected, stream);

        /* padding */ WriteBinary<2, unsigned int>(0, stream);

        WriteBinaryVertexTex2(t.p1, stream);
        WriteBinaryVertexTex2(t.p2, stream);
        WriteBinaryVertexTex2(t.p3, stream);

        WriteBinaryMaterial(t.material, stream);
        stream.write(t.texName, 20);
        WriteBinaryFloat(t.min, stream);
        WriteBinaryFloat(t.max, stream);
        WriteBinary<4, long>(t.state, stream);
        WriteBinary<2, short>(t.texNum2, stream);

        WriteBinary<2, short>(t.reserved2, stream);
        WriteBinary<2, short>(t.reserved3, stream);
        WriteBinary<2, short>(t.reserved4, stream);
    }
}
开发者ID:BTML,项目名称:colobot,代码行数:65,代码来源:model_output.cpp


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