本文整理汇总了C++中AVector类的典型用法代码示例。如果您正苦于以下问题:C++ AVector类的具体用法?C++ AVector怎么用?C++ AVector使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了AVector类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Float3
//----------------------------------------------------------------------------
void CurveCtrlFloat::OnCtrlChanged (bool updateCurve)
{
if (mIndex >= (int)(mCurveFloat->mCurve->Points.size()))
return;
float inVal = mCurveFloat->mCurve->Points[mIndex].InVal;
float outVal = mCurveFloat->mCurve->Points[mIndex].OutVal;
float arriveTangent = mCurveFloat->mCurve->Points[mIndex].ArriveTangent;
float leaveTangent = mCurveFloat->mCurve->Points[mIndex].LeaveTangent;
InterpCurveMode mode = mCurveFloat->mCurve->Points[mIndex].InterpMode;
mInVal = inVal;
mOutVal = Float3(inVal, 0.0f, outVal);
AVector at(1.0f, 0.0f, arriveTangent);
at.Normalize();
mArriveTangent = at;
AVector lt (1.0f, 0.0f, leaveTangent);
lt.Normalize();
mLeaveTangent = lt;
mInterpCurveMode = mode;
CurveCtrl::OnCtrlChanged(updateCurve);
}
示例2: Flee
//----------------------------------------------------------------------------
AVector SteeringBehavior::Flee (APoint fromPosition)
{
AVector desiredVelocity = mActor->GetPosition() - fromPosition;
desiredVelocity.Normalize();
return (desiredVelocity - mActor->GetVelocity());
}
示例3: IsSmallTransScope
//----------------------------------------------------------------------------
bool InputPushTransformController::IsSmallTransScope()
{
AVector smallScope = mMaxPosSmall - mMinPosSmall;
float lengthSquare = smallScope.SquaredLength();
return 0.0f != lengthSquare;
}
示例4: GetPosition
//----------------------------------------------------------------------------
void SceneNodeCtrl::OnMouseWheel(RenderStep *renderStep, float wheelDelta)
{
Camera *camera = renderStep->GetCamera();
float rmax = camera->GetRMax();
APoint camPosition = camera->GetPosition();
APoint ctrlPosition = GetPosition();
AVector diff = ctrlPosition - camPosition;
float diffLength = diff.Length();
if (mLookType != LT_PERSPECTIVE)
{
if (0.0f != rmax)
{
mCtrlsGroup->WorldTransform.SetUniformScale(rmax*0.11f);
mCtrlsGroup->Update(Time::GetTimeInSeconds(), false);
}
}
else
{
float scale = diffLength*0.04f;
if (scale == 0.0f) scale = 0.0001f;
if (scale < 1.0f) scale = 1.0f;
mCtrlsGroup->WorldTransform.SetUniformScale(scale);
mCtrlsGroup->Update(Time::GetTimeInSeconds(), false);
}
}
示例5: UpdateClods
//----------------------------------------------------------------------------
void ClodMeshes::UpdateClods ()
{
// Adjust the triangle quantities for the clod meshes. The distance along
// the camera direction controls the triangle quantities. A nonlinear
// drop-off is used.
for (int i = 0; i < 2; ++i)
{
AVector diff =
mClod[i]->WorldBound.GetCenter() - mCamera->GetPosition();
float depth = diff.Dot(mCamera->GetDVector());
int targetRecord;
if (depth <= mCamera->GetDMin())
{
targetRecord = 0;
}
else if (depth >= mCamera->GetDMax())
{
targetRecord = mClod[i]->GetNumRecords() - 1;
}
else
{
float dmin = mCamera->GetDMin();
float dmax = mCamera->GetDMax();
float ratio = Mathf::Pow((depth - dmin)/(dmax - dmin), 0.5f);
targetRecord = (int)((mClod[i]->GetNumRecords() - 1)*ratio);
}
mClod[i]->TargetRecord() = targetRecord;
}
}
示例6: TestIntersection
//----------------------------------------------------------------------------
bool Bound::TestIntersection (const Bound& bound, float tmax,
const AVector& velocity0, const AVector& velocity1) const
{
if (bound.GetRadius() == 0.0f || GetRadius() == 0.0f)
{
return false;
}
AVector relVelocity = velocity1 - velocity0; // 相对速度
AVector cenDiff = bound.mCenter - mCenter; // 相对位移
float a = relVelocity.SquaredLength();
float c = cenDiff.SquaredLength();
float rSum = bound.mRadius + mRadius;
float rSumSqr = rSum*rSum;
if (a > 0.0f)
{
float b = cenDiff.Dot(relVelocity);
if (b <= 0.0f)
{
if (-tmax*a <= b)
{
return a*c - b*b <= a*rSumSqr;
}
else
{
return tmax*(tmax*a + 2.0f*b) + c <= rSumSqr;
}
}
}
return c <= rSumSqr;
}
示例7: GetPickRay
//----------------------------------------------------------------------------
bool Camera::GetPickRay(float posSizePercentWdith, float posSizePercentHeight,
APoint& origin, AVector& direction)
{
// Get the [0,1]^2-normalized coordinates of (x,y).
float r = posSizePercentWdith;
float u = posSizePercentHeight;
// Get the relative coordinates in [rmin,rmax]x[umin,umax].
float rBlend = (1.0f - r)*GetRMin() + r*GetRMax();
float uBlend = (1.0f - u)*GetUMin() + u*GetUMax();
if (IsPerspective())
{
origin = GetPosition();
direction = GetDMin()*GetDVector() +
rBlend*GetRVector() + uBlend*GetUVector();
direction.Normalize();
}
else
{
origin = GetPosition() + rBlend*GetRVector() +
uBlend*GetUVector();
direction = GetDVector();
direction.Normalize();
}
return true;
}
示例8: RemoveJunglerPoints
//----------------------------------------------------------------------------
void TerrainPage::RemoveJunglerPoints (Jungler *jungler, APoint center, float radius,
int num)
{
if (!jungler)
return;
// 范围内个数
std::vector<int> indexs;
for (int i=0; i<jungler->GetNum(); i++)
{
const APoint &pos = jungler->GetPos(i);
AVector dir = pos - center;
if (dir.Length() < radius)
{
indexs.push_back(i);
}
}
std::vector<int> indexsRemoves;
for (int i=0; i<(int)indexs.size(); i++)
{
float fRand = (float)num/(float)indexsRemoves.size();
float fR = Mathf::IntervalRandom(0.0f, 1.0f);
if (fR <= fRand)
{
indexsRemoves.push_back(indexs[i]);
}
}
jungler->Remove(indexsRemoves);
}
示例9: incrH
//----------------------------------------------------------------------------
void EditRenderView_Scene::_RolateCamera(float horz, float vert)
{
Scene *scene = PX2_PROJ.GetScene();
CameraActor *camActor = scene->GetUseCameraActor();
if (VT_PERSPECTIVE == mViewType)
{
AVector rVector;
AVector dVector;
AVector uVector;
camActor->GetRDUVector(rVector, dVector, uVector);
// horz
HMatrix incrH(AVector::UNIT_Z, -horz*0.5f);
dVector = incrH * dVector;
uVector = incrH * uVector;
rVector = incrH * rVector;
// vert
Matrix3f kIncrV(rVector, -vert*0.5f);
dVector = kIncrV * dVector;
uVector = kIncrV * uVector;
dVector.Normalize();
float dVectorAdj = dVector.Dot(AVector::UNIT_Z);
float dVectorAdj1 = dVector.Dot(-AVector::UNIT_Z);
if (dVectorAdj > 0.9f || dVectorAdj1 > 0.9f)
return;
AVector::Orthonormalize(dVector, uVector, rVector);
camActor->LocalTransform.SetRotate(HMatrix(rVector, dVector,
uVector, AVector::ZERO, true));
}
}
示例10: GetData
//----------------------------------------------------------------------------
void PhysicsModule::GetData (APoint& center, HMatrix& incrRot) const
{
// Position is a point exactly on the hill.
APoint position;
position[0] = (float)(A1*mState[0]);
position[1] = (float)(A2*mState[2]);
position[2] = (float)(A3 - mState[0]*mState[0] - mState[2]*mState[2]);
// Lift this point off the hill in the normal direction by the radius of
// the ball so that the ball just touches the hill. The hill is
// implicitly specified by F(x,y,z) = z - [a3 - (x/a1)^2 - (y/a2)^2]
// where (x,y,z) is the position on the hill. The gradient of F is a
// normal vector, Grad(F) = (2*x/a1^2,2*y/a2^2,1).
AVector normal;
normal[0] = 2.0f*position[0]/(float)mAux[0];
normal[1] = 2.0f*position[1]/(float)mAux[1];
normal[2] = 1.0f;
normal.Normalize();
center = position + ((float)Radius)*normal;
// Let the ball rotate as it rolls down hill. The axis of rotation is
// the perpendicular to hill normal and ball velocity. The angle of
// rotation from the last position is A = speed*deltaTime/radius.
AVector velocity;
velocity[0] = (float)(A1*mState[1]);
velocity[1] = (float)(A1*mState[3]);
velocity[2] = -2.0f*(velocity[0]*(float)mState[0] +
velocity[1]*(float)mState[2]);
float speed = velocity.Normalize();
float angle = speed*((float)mDeltaTime)/((float)Radius);
AVector axis = normal.UnitCross(velocity);
incrRot = HMatrix(axis, angle);
}
示例11: Seek
AVector SteeringBehavior::Seek (APoint toPosition)
{
AVector desiredVelocity = mActor->GetPosition() - actorPosition;
desiredVelocity.Normalize();
desiredVelocity *= mActor->GetMaxSpeed();
return (desiredVelocity - mActor->GetVelocity());
}
示例12: PU
//----------------------------------------------------------------------------
AVector SurfacePatch::Tangent1 (float u, float v) const
{
AVector tangent0 = PU(u, v);
AVector tangent1 = PV(u, v);
tangent0.Normalize();
AVector normal = tangent0.UnitCross(tangent1);
tangent1 = normal.Cross(tangent0);
return tangent1;
}
示例13: SetVelocity
//----------------------------------------------------------------------------
void FMODSound::SetVelocity (const AVector &velocity)
{
FMOD_VECTOR vec;
vec.x = velocity.X();
vec.y = velocity.Y();
vec.z = velocity.Z();
if (mChannel)
mChannel->set3DAttributes(0, &vec);
}
示例14: PU
//----------------------------------------------------------------------------
AVector CurveSegment::Normal (float u) const
{
AVector velocity = PU(u);
AVector acceleration = PUU(u);
float VDotV = velocity.Dot(velocity);
float VDotA = velocity.Dot(acceleration);
AVector normal = VDotV*acceleration - VDotA*velocity;
normal.Normalize();
return normal;
}
示例15: MoveCamera
//----------------------------------------------------------------------------
bool HelixTubeSurface::MoveCamera ()
{
APoint position = mCurve->GetPosition(mCurveTime);
AVector tangent = mCurve->GetTangent(mCurveTime);
AVector binormal = tangent.UnitCross(AVector::UNIT_Z);
AVector normal = binormal.UnitCross(tangent);
mCamera->SetFrame(position, tangent, normal, binormal);
mCuller.ComputeVisibleSet(mScene);
return true;
}