3实现模型跟随地形的效果文档格式.docx
- 文档编号:13189601
- 上传时间:2022-10-08
- 格式:DOCX
- 页数:15
- 大小:32.82KB
3实现模型跟随地形的效果文档格式.docx
《3实现模型跟随地形的效果文档格式.docx》由会员分享,可在线阅读,更多相关《3实现模型跟随地形的效果文档格式.docx(15页珍藏版)》请在冰豆网上搜索。
#region成员变量、属性和构造函数
//需要跟随的地形
SimpleTerrainSceneNodeterrain;
//坦克各部件的Bone。
ModelBoneturretBone;
ModelBonecannonBone;
ModelBonelSteerEngineBone;
ModelBonerSteerEngineBone;
ModelBoneleftBackWheelBone;
ModelBonerightBackWheelBone;
ModelBoneleftFrontWheelBone;
ModelBonerightFrontWheelBone;
//坦克各部件Bone的转换矩阵
MatrixturretTransform;
MatrixcannonTransform;
MatrixlSteerEngineTransform;
MatrixrSteerEngineTransform;
MatrixleftBackWheelTransform;
MatrixrightBackWheelTransform;
MatrixleftFrontWheelTransform;
MatrixrightFrontWheelTransform;
//车轮自转的旋转矩阵
MatrixwheelRollMatrix;
//各部件的旋转量
floatturretRotationValue;
floatcannonRotationValue;
floatsteerRotationValue;
floatwheelRotationValue;
///炮管、炮塔旋转的最大角速度
publicconstfloatMaxCannonSpeed=1f;
///炮塔的旋转范围
privateconstfloatMaxTurretAngle=1.0f;
privateconstfloatMinTurretAngle=-1.0f;
///炮管的旋转范围
privateconstfloatMaxCannonAngle=0.0f;
privateconstfloatMinCannonAngle=-0.9f;
///获取或设置车轮的旋转量
publicfloatWheelRotationValue
get{returnwheelRotationValue;
}
set{wheelRotationValue=value;
///获取或设置前轮轴的旋转量
publicfloatSteerRotationValue
get{returnsteerRotationValue;
set{steerRotationValue=value;
///获取或设置炮塔旋转量
publicfloatTurretRotation
get{returnturretRotationValue;
set
if(value>
MaxTurretAngle)
turretRotationValue=MaxTurretAngle;
elseif(value<
MinTurretAngle)
turretRotationValue=MinTurretAngle;
else
turretRotationValue=value;
///获取或设置炮管旋转量
publicfloatCannonRotation
get{returncannonRotationValue;
MaxCannonAngle)
cannonRotationValue=MaxCannonAngle;
MinCannonAngle)
cannonRotationValue=MinCannonAngle;
cannonRotationValue=value;
///创建一个ModelSceneNode对象。
paramname="
engine"
>
引擎<
/param>
modelAssetName"
模型名称<
publictankModel(StunXnaGEengine,ScenesetScene,stringmodelAssetName,SimpleTerrainSceneNodeterrain)
:
base(engine,setScene,modelAssetName)
this.terrain=terrain;
#endregion
///初始化节点。
publicoverridevoidInitialize()
base.Initialize();
//获取坦克各部件的Bone。
turretBone=model.Bones["
turret_geo"
];
cannonBone=model.Bones["
canon_geo"
lSteerEngineBone=model.Bones["
l_steer_geo"
rSteerEngineBone=model.Bones["
r_steer_geo"
leftBackWheelBone=model.Bones["
l_back_wheel_geo"
rightBackWheelBone=model.Bones["
r_back_wheel_geo"
leftFrontWheelBone=model.Bones["
l_front_wheel_geo"
rightFrontWheelBone=model.Bones["
r_front_wheel_geo"
//获取坦克各部件的转换矩阵
turretTransform=turretBone.Transform;
cannonTransform=cannonBone.Transform;
lSteerEngineTransform=lSteerEngineBone.Transform;
rSteerEngineTransform=rSteerEngineBone.Transform;
leftBackWheelTransform=leftBackWheelBone.Transform;
rightBackWheelTransform=rightBackWheelBone.Transform;
leftFrontWheelTransform=leftFrontWheelBone.Transform;
rightFrontWheelTransform=rightFrontWheelBone.Transform;
publicoverridevoidUpdate(GameTimegameTime)
base.Update(gameTime);
//根据旋转量重新计算变换矩阵
turretBone.Transform=Matrix.CreateRotationY(turretRotationValue)*turretTransform;
cannonBone.Transform=Matrix.CreateRotationX(cannonRotationValue)*cannonTransform;
lSteerEngineBone.Transform=Matrix.CreateRotationY(steerRotationValue)*lSteerEngineTransform;
rSteerEngineBone.Transform=Matrix.CreateRotationY(steerRotationValue)*rSteerEngineTransform;
wheelRollMatrix*=Matrix.CreateRotationX(wheelRotationValue);
leftBackWheelBone.Transform=Matrix.CreateRotationX(wheelRotationValue)*leftBackWheelTransform;
rightBackWheelBone.Transform=Matrix.CreateRotationX(wheelRotationValue)*rightBackWheelTransform;
leftFrontWheelBone.Transform=Matrix.CreateRotationX(wheelRotationValue)*leftFrontWheelTransform;
rightFrontWheelBone.Transform=Matrix.CreateRotationX(wheelRotationValue)*rightFrontWheelTransform;
///绘制坦克。
gameTime"
<
publicoverrideintDraw(GameTimegameTime,booluseReflect)
model.CopyAbsoluteBoneTransformsTo(modelTransforms);
retur
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- 实现 模型 跟随 地形 效果
![提示](https://static.bdocx.com/images/bang_tan.gif)