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


C++ AVector类代码示例

本文整理汇总了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);
}
开发者ID:cyecp,项目名称:Phoenix3D_2.1,代码行数:27,代码来源:PX2CurveCtrl.cpp

示例2: Flee

//----------------------------------------------------------------------------
AVector SteeringBehavior::Flee (APoint fromPosition)
{
	AVector desiredVelocity = mActor->GetPosition() - fromPosition;
	desiredVelocity.Normalize();

	return (desiredVelocity - mActor->GetVelocity());
}
开发者ID:ascetic85,项目名称:Phoenix3d,代码行数:8,代码来源:SteeringBehavior.cpp

示例3: IsSmallTransScope

//----------------------------------------------------------------------------
bool InputPushTransformController::IsSmallTransScope()
{
	AVector smallScope = mMaxPosSmall - mMinPosSmall;
	float lengthSquare = smallScope.SquaredLength();

	return 0.0f != lengthSquare;
}
开发者ID:PhoenixSteam,项目名称:Phoenix3D,代码行数:8,代码来源:PX2InputPushTransformController.cpp

示例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);
	}
}
开发者ID:JamShan,项目名称:Phoenix3D_2.1,代码行数:27,代码来源:PX2SceneNodeCtrl.cpp

示例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;
    }
}
开发者ID:vijaynerella,项目名称:GeometricTools,代码行数:32,代码来源:ClodMeshes.cpp

示例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;
}
开发者ID:JamShan,项目名称:Phoenix3D_2.1,代码行数:34,代码来源:PX2Bound.cpp

示例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;
}
开发者ID:PhoenixSteam,项目名称:Phoenix3D,代码行数:29,代码来源:PX2Camera.cpp

示例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);
}
开发者ID:SylviaTanenbaum,项目名称:3d-simulation-and-game,代码行数:33,代码来源:PX2TerrainPage.cpp

示例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));
	}
}
开发者ID:zhangf911,项目名称:Phoenix3D,代码行数:35,代码来源:PX2EditRenderView_Scene.cpp

示例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);
}
开发者ID:2asoft,项目名称:GeometricTools,代码行数:36,代码来源:PhysicsModule.cpp

示例11: Seek

AVector SteeringBehavior::Seek (APoint toPosition)
{
	AVector desiredVelocity = mActor->GetPosition() - actorPosition;
	desiredVelocity.Normalize();

	desiredVelocity *= mActor->GetMaxSpeed();

	return (desiredVelocity - mActor->GetVelocity());
}
开发者ID:ascetic85,项目名称:Phoenix3d,代码行数:9,代码来源:SteeringBehavior.cpp

示例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;
}
开发者ID:fishxz,项目名称:omni-bot,代码行数:10,代码来源:Wm5SurfacePatch.cpp

示例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);
}
开发者ID:whztt07,项目名称:Phoenix3D_2.0,代码行数:11,代码来源:PX2SoundSystemFMOD.cpp

示例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;
}
开发者ID:Kiichi77,项目名称:WildMagic,代码行数:11,代码来源:Wm5CurveSegment.cpp

示例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;
}
开发者ID:2asoft,项目名称:GeometricTools,代码行数:11,代码来源:HelixTubeSurface.cpp


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