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


C++ Facet::GetNode方法代码示例

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


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

示例1: _ApplyInternalForces

Void SoftBody::_ApplyInternalForces( Scalar fTimeStep )
{
    Node * pNode;
    Facet * pFacet;

    Bool bLift = ( m_fLift > 0.0f );
    Bool bDrag = ( m_fDrag > 0.0f );
    Bool bPressure = ( m_fPressure != 0.0f );
    Bool bVolumeConversation = ( m_fVolumeConversation > 0.0f );

    Bool bAeroDynamics = ( bLift || bDrag );
    Bool bAeroDynamicsV = bAeroDynamics && ( m_iAeroDynamicsModel <= SOFTBODY_AERODYNAMICS_V_TwoSided );
    Bool bAeroDynamicsF = bAeroDynamics && ( m_iAeroDynamicsModel > SOFTBODY_AERODYNAMICS_V_TwoSided );

    Bool bUseMedium = bAeroDynamics;
    Bool bUseVolume = ( bPressure || bVolumeConversation );

    Scalar fVolume = 0.0f;
    Scalar fIVolumeTP = 0.0f;
    Scalar fDVolumeTV = 0.0f;

    Medium curMedium;

    if ( bUseVolume ) {
        fVolume = _ComputeVolume();
        fIVolumeTP = MathFn->Invert( fVolume ) * m_fPressure;
        fDVolumeTV = ( m_hPose.fVolume - fVolume ) * m_fVolumeConversation;
    }

    // Link forces (??!)
    //////////////////////////////////////////

    // Node forces
    Vector3 vRelVelocity, vNormal, vRelVelNormalized, vForce;
    Scalar fSqrRelVelocity, fDot, fAmplitude;

    EnumNodes();
    pNode = EnumNextNode();
    while( pNode != NULL ) {
        if ( pNode->InvMass == 0.0f ) {
            pNode = EnumNextNode();
            continue;
        }

        if ( bUseMedium ) {
            _EvaluateMedium( &curMedium, pNode->Position );
            if ( bAeroDynamicsV ) {
                vRelVelocity = ( pNode->Velocity - curMedium.vVelocity );
                fSqrRelVelocity = vRelVelocity.NormSqr();
                if ( fSqrRelVelocity > SCALAR_ERROR ) {
                    switch( m_iAeroDynamicsModel ) {
                        case SOFTBODY_AERODYNAMICS_V_Point:
                            vNormal = vRelVelocity;
                            vNormal.Normalize();
                            break;
                        case SOFTBODY_AERODYNAMICS_V_OneSided:
                            vNormal = pNode->Normal;
                            break;
                        case SOFTBODY_AERODYNAMICS_V_TwoSided:
                            vNormal = pNode->Normal;
                            vNormal *= ( (vRelVelocity*vNormal) < 0.0f ) ? -1.0f : +1.0f;
                            break;
                        default: Assert(false); break;
                    }
                    fDot = ( vRelVelocity * vNormal );
                    if ( fDot > 0.0f ) {
                        vRelVelNormalized = vRelVelocity;
                        vRelVelNormalized.Normalize();

                        vForce = Vector3::Null;
                        fAmplitude = ( pNode->Area * fDot * fSqrRelVelocity * 0.5f );
                        fAmplitude *= curMedium.fDensity;
                        vForce += ( vNormal * (-fAmplitude * m_fLift) );
                        vForce += ( vRelVelNormalized * (-fAmplitude * m_fDrag) );
                        pNode->ApplyClampedForce( vForce, fTimeStep );
                    }
                }
            }
        }
        if ( bPressure )
            pNode->ForceBuffer += ( pNode->Normal * (pNode->Area * fIVolumeTP) );
        if ( bVolumeConversation )
            pNode->ForceBuffer += ( pNode->Normal * (pNode->Area * fDVolumeTV) );

        pNode = EnumNextNode();
    }

    // Facet forces
    static const Scalar fInv3 = MathFn->Invert( 3.0f );

    Vector3 vFacetVelocity;
    Vertex3 vFacetPosition;
    Node *pA, *pB, *pC;

    EnumFacets();
    pFacet = EnumNextFacet();
    while( pFacet != NULL ) {
        if ( bAeroDynamicsF ) {
            pA = pFacet->GetNode( 0 );
            pB = pFacet->GetNode( 1 );
//.........这里部分代码省略.........
开发者ID:Shikifuyin,项目名称:Scarab-Engine,代码行数:101,代码来源:SoftBody.cpp


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