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


C++ SceneNode::convertWorldToLocalPosition方法代码示例

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


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

示例1: tree

TerrainPatchData::TerrainPatchData(TerrainQuadtree* tree) :
        tree(tree),
        tessellation(tree->getPlanetarySurface()->getTessellation()),
        vertices(tessellation + 3, std::vector<Ogre::Vector3>(tessellation + 3)),
        normals(tessellation + 3, std::vector<Ogre::Vector3>(tessellation + 3)),
        heights(tessellation + 3, std::vector<Ogre::Real>(tessellation + 3, 0.0)) {
    int patchSize = tree->getSize();
    Ogre::Real halfPatchSize = Ogre::Real(patchSize / 2);
    Ogre::Real delta = (Ogre::Real)patchSize * (1.0 / (Ogre::Real)tessellation);

    Ogre::SceneNode* patchSceneNode = tree->getSceneNode();
    Ogre::SceneNode* planetarySceneNode = tree->getPlanetarySurface()->getSceneNode();

    Ogre::Real planetaryRadius = (Ogre::Real)tree->getPlanetarySurface()->getRadius();

    for (int z = -1; z < tessellation + 2; ++z) {
        for (int x = -1; x < tessellation + 2; ++x) {
            Ogre::Vector3 position(-halfPatchSize + delta * x, 0.0, -halfPatchSize + delta * z);
            Ogre::Vector3 planetaryPosition = planetarySceneNode->convertWorldToLocalPosition(patchSceneNode->convertLocalToWorldPosition(position));
            planetaryPosition = mapToSphere(planetaryPosition, planetaryRadius);
            Ogre::Vector3 normal = planetaryPosition.normalisedCopy();
            Ogre::Real height = tree->getPlanetarySurface()->getNoiseFunction()->getValue(planetaryPosition);

            planetaryPosition = planetarySceneNode->convertLocalToWorldPosition(planetaryPosition);
            position = patchSceneNode->convertWorldToLocalPosition(planetaryPosition);

            normal = (tree->getRootSceneNode()->getOrientation().Inverse() * normal).normalisedCopy();

            vertices[z + 1][x + 1] = position;
            normals[z + 1][x + 1] = normal;
            heights[z + 1][x + 1] = height;
        }
    }

    for (int z = 0; z < tessellation + 1; ++z) {
        for (int x = 0; x < tessellation + 1; ++x) {
            processedPositions.push_back(getVertex(x, z));
            processedNormals.push_back(getVertexNormal(x, z));
            processedTextureCoords.push_back(getNormal(x, z));
        }
    }

    // Add triangles.
    for (int z = 0; z < tessellation; ++z) {
        int zOffset = z * (tessellation + 1);
        for (int x = 0; x < tessellation; ++x) {
            int indices[4] = {
                zOffset + x,
                zOffset + x + 1,
                zOffset + tessellation + 1 + x,
                zOffset + tessellation + 1 + x + 1
            };

            processedIndices.push_back(indices[0]);
            processedIndices.push_back(indices[2]);
            processedIndices.push_back(indices[1]);
            processedIndices.push_back(indices[2]);
            processedIndices.push_back(indices[3]);
            processedIndices.push_back(indices[1]);
        }
    }
}
开发者ID:summerbreezeex,项目名称:SolidBlack,代码行数:62,代码来源:TerrainPatchData.cpp


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