SICALLBACK aaOcean_BeginEvaluate( ICENodeContext& in_ctxt ) { // get ocean pointer from user-data aaOcean *pOcean = (aaOcean *)(CValue::siPtrType)in_ctxt.GetUserData(); // get ICE node input port arrays CDataArrayLong PointID( in_ctxt, ID_IN_PointID); CDataArrayLong resolution( in_ctxt, ID_IN_RESOLUTION); CDataArrayLong seed( in_ctxt, ID_IN_SEED); CDataArrayFloat waveHeight( in_ctxt, ID_IN_WAVE_HEIGHT); CDataArrayFloat waveSpeed( in_ctxt, ID_IN_WAVESPEED); CDataArrayFloat chop( in_ctxt, ID_IN_CHOP); CDataArrayFloat oceanScale( in_ctxt, ID_IN_OCEAN_SCALE ); CDataArrayFloat oceanDepth( in_ctxt, ID_IN_OCEAN_DEPTH ); CDataArrayFloat windDir( in_ctxt, ID_IN_WINDDIR ); CDataArrayFloat cutoff( in_ctxt, ID_IN_CUTOFF); CDataArrayFloat velocity( in_ctxt, ID_IN_WINDVELOCITY); CDataArrayLong windAlign( in_ctxt, ID_IN_WINDALIGN ); CDataArrayFloat damp( in_ctxt, ID_IN_DAMP); CDataArrayBool enableFoam( in_ctxt, ID_IN_ENABLEFOAM); CDataArrayFloat time( in_ctxt, ID_IN_TIME); CDataArrayFloat loopTime( in_ctxt, ID_IN_REPEAT_TIME); CDataArrayFloat surfaceTension( in_ctxt, ID_IN_SURFACE_TENSION); CDataArrayFloat randWeight( in_ctxt, ID_IN_RAND_WEIGHT); pOcean->input(resolution[0], seed[0], oceanScale[0], oceanDepth[0], surfaceTension[0], velocity[0], cutoff[0], windDir[0], windAlign[0], damp[0], waveSpeed[0], waveHeight[0], chop[0], time[0], loopTime[0], enableFoam[0], randWeight[0]); return CStatus::OK; }
void ForestWind::processTick() { PROFILE_SCOPE( ForestWind_ProcessTick ); const F32 deltaTime = 0.032f; const U32 simTime = Sim::getCurrentTime(); Point2F finalVec( 0, 0 ); Point2F windDir( mParent->mWindDirection.x, mParent->mWindDirection.y ); if ( mLastGustTime < simTime ) { Point2F turbVec( 0, 0 ); if ( mLastGustTime < simTime + (mParent->mWindTurbulenceFrequency * 1000.0f) ) turbVec = (mRandom.randF() * mParent->mWindTurbulenceStrength) * windDir; mLastGustTime = simTime + (mParent->mWindGustFrequency * 1000.0f); Point2F gustVec = (mRandom.randF() * mParent->mWindGustStrength + mRandom.randF() * mParent->mWindGustWobbleStrength) * windDir; finalVec += gustVec + turbVec; //finalVec.normalizeSafe(); } //bool rotationChange = false; if ( mLastYawTime < simTime ) { mLastYawTime = simTime + (mParent->mWindGustYawFrequency * 1000.0f); F32 rotateAmt = mRandom.randF() * mParent->mWindGustYawAngle + mRandom.randF() * mParent->mWindGustWobbleStrength; if ( mRandom.randF() <= 0.5f ) rotateAmt = -rotateAmt; rotateAmt = mDegToRad( rotateAmt ); if ( rotateAmt > M_2PI_F ) rotateAmt -= M_2PI_F; else if ( rotateAmt < -M_2PI_F ) rotateAmt += M_2PI_F; mTargetYawAngle = rotateAmt; //finalVec.rotate( rotateAmt ); mCurrentTarget.rotate( rotateAmt ); } //mCurrentTarget.normalizeSafe(); if ( mCurrentTarget.isZero() || mCurrentInterp >= 1.0f ) { mCurrentInterp = 0; mCurrentTarget.set( 0, 0 ); Point2F windDir( mDirection.x, mDirection.y ); windDir.normalizeSafe(); mCurrentTarget = finalVec + windDir; } else { mCurrentInterp += deltaTime; mCurrentInterp = mClampF( mCurrentInterp, 0.0f, 1.0f ); mDirection.interpolate( mDirection, Point3F( mCurrentTarget.x, mCurrentTarget.y, 0 ), mCurrentInterp ); //F32 rotateAmt = mLerp( 0, mTargetYawAngle, mCurrentInterp ); //mTargetYawAngle -= rotateAmt; //Point2F dir( mDirection.x, mDirection.y ); //if ( mTargetYawAngle > 0.0f ) // dir.rotate( rotateAmt ); //mDirection.set( dir.x, dir.y, 0 ); } }