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


C++ Spatial::Update方法代码示例

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


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

示例1: lightGray

//----------------------------------------------------------------------------
void Delaunay3D::DoSearch ()
{
    // Make all tetra wireframe.
    const int numSimplices = mDelaunay->GetNumSimplices();
    Float4 lightGray(0.75f, 0.75f, 0.75f, 1.0f);
    int i;
    for (i = 0; i < numSimplices; ++i)
    {
        ChangeTetraStatus(i, lightGray, true);
    }

    // Generate random point in AABB of data set.
    Vector3f random;
    random.X() = Mathf::IntervalRandom(mMin.X(), mMax.X());
    random.Y() = Mathf::IntervalRandom(mMin.Y(), mMax.Y());
    random.Z() = Mathf::IntervalRandom(mMin.Z(), mMax.Z());

    // Move sphere to this location.
    Spatial* sphere = mScene->GetChild(0);
    sphere->Culling = Spatial::CULL_DYNAMIC;
    sphere->LocalTransform.SetTranslate(random);
    sphere->Update();

    if (mDelaunay->GetContainingTetrahedron(random) >= 0)
    {
        // Make all tetra on the path solid.
        const int pathLast = mDelaunay->GetPathLast();
        for (i = 0; i <= pathLast; ++i)
        {
            int index = mDelaunay->GetPath()[i];
            float red, blue;
            if (pathLast > 0)
            {
                red = i/(float)pathLast;
                blue = 1.0f - red;
            }
            else
            {
                red = 1.0f;
                blue = 0.0f;
            }
            ChangeTetraStatus(index, Float4(red, 0.0f, blue, 0.5f), false);
        }
    }
    else
    {
        // The point is outside the convex hull.  Change the wireframe
        // color for the last visited face in the search path.
        int index = mDelaunay->GetPath()[mDelaunay->GetPathLast()];
        int v0, v1, v2, v3;
        int vOpposite = mDelaunay->GetLastFace(v0, v1, v2, v3);
        ChangeLastTetraStatus(index, vOpposite,
            Float4(0.0f, 1.0f, 0.0f, 0.5f),
            Float4(0.0f, 0.25f, 0.0f, 0.5f));
    }

    mCuller.ComputeVisibleSet(mScene);
}
开发者ID:rasslingcats,项目名称:calico,代码行数:59,代码来源:Delaunay3D.cpp

示例2: UpdateWorldData

//----------------------------------------------------------------------------
void BillboardNode::UpdateWorldData (double applicationTime)
{
    // Compute the billboard's world transforms based on its parent's world
    // transform and its local transforms.  Notice that you should not call
    // Node::UpdateWorldData since that function updates its children.  The
    // children of a BillboardNode cannot be updated until the billboard is
    // aligned with the camera.
    Spatial::UpdateWorldData(applicationTime);

    if (mCamera)
    {
        // Inverse-transform the camera to the model space of the billboard.
        APoint modelPos = WorldTransform.Inverse()*mCamera->GetPosition();

        // To align the billboard, the projection of the camera to the
        // xz-plane of the billboard's model space determines the angle of
        // rotation about the billboard's model y-axis.  If the projected
        // camera is on the model axis (x = 0 and z = 0), ATan2 returns zero
        // (rather than NaN), so there is no need to trap this degenerate
        // case and handle it separately.
        float angle = Mathf::ATan2(modelPos[0], modelPos[2]);
        HMatrix orient(AVector::UNIT_Y, angle);
        WorldTransform.SetRotate(WorldTransform.GetRotate()*orient);
    }

    // Update the children now that the billboard orientation is known.
    std::vector<SpatialPtr>::iterator iter = mChild.begin();
    std::vector<SpatialPtr>::iterator end = mChild.end();
    for (/**/; iter != end; ++iter)
    {
        Spatial* child = *iter;
        if (child)
        {
            child->Update(applicationTime, false);
        }
    }
}
开发者ID:2asoft,项目名称:GeometricTools,代码行数:38,代码来源:Wm5BillboardNode.cpp


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