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


C++ Terrain::PatchHeight方法代码示例

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


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

示例1: Terrain_PatchHeight

static duk_ret_t Terrain_PatchHeight(duk_context* ctx)
{
    Terrain* thisObj = GetThisWeakObject<Terrain>(ctx);
    uint ret = thisObj->PatchHeight();
    duk_push_number(ctx, ret);
    return 1;
}
开发者ID:realXtend,项目名称:tundra-urho3d,代码行数:7,代码来源:TerrainBindings.cpp

示例2: CreateHeightFieldFromTerrain

void RigidBody::CreateHeightFieldFromTerrain()
{
    CheckForPlaceableAndTerrain();
    
    Terrain* terrain = impl->terrain;
    if (!terrain)
        return;
    
    uint width = terrain->PatchWidth() * Terrain::cPatchSize;
    uint height = terrain->PatchHeight() * Terrain::cPatchSize;
    if (!width || !height)
        return;
    
    impl->heightValues.Resize(width * height);
    
    float xzSpacing = 1.0f;
    float ySpacing = 1.0f;
    float minY = 1000000000;
    float maxY = -1000000000;
    for(uint z = 0; z < height; ++z)
        for(uint x = 0; x < width; ++x)
        {
            float value = terrain->GetPoint(x, z);
            if (value < minY)
                minY = value;
            if (value > maxY)
                maxY = value;
            impl->heightValues[z * width + x] = value;
        }

    float3 scale = terrain->nodeTransformation.Get().scale;
    float3 bbMin(0, minY, 0);
    float3 bbMax(xzSpacing * (width - 1), maxY, xzSpacing * (height - 1));
    float3 bbCenter = scale.Mul((bbMin + bbMax) * 0.5f);
    
    impl->heightField = new btHeightfieldTerrainShape(width, height, &impl->heightValues[0], ySpacing, minY, maxY, 1, PHY_FLOAT, false);
    
    /** \todo Terrain uses its own transform that is independent of the placeable. It is not nice to support, since rest of RigidBody assumes
        the transform is in the placeable. Right now, we only support position & scaling. Here, we also counteract Bullet's nasty habit to center 
        the heightfield on its own. Also, Bullet's collisionshapes generally do not support arbitrary transforms, so we must construct a "compound shape"
        and add the heightfield as its child, to be able to specify the transform.
     */
    impl->heightField->setLocalScaling(scale);
    
    float3 positionAdjust = terrain->nodeTransformation.Get().pos;
    positionAdjust += bbCenter;
    
    btCompoundShape* compound = new btCompoundShape();
    impl->shape = compound;
    compound->addChildShape(btTransform(btQuaternion(0,0,0,1), positionAdjust), impl->heightField);
}
开发者ID:realXtend,项目名称:tundra-urho3d,代码行数:51,代码来源:RigidBody.cpp


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