
本站地址:http://www.bajiao123.com

托管的 Direct3D之 使用 Frame Hierarchy 创建动画(翻译)
让我们看看我们刚才创建的类是怎么建立一个坦克模形专用的类来。我们定义了一个 Tank 类,还给它增加了一此关于它的位置,方向,斜率等属性。还有炮塔的角度。
我们重写了GraphicsObject类的Initialize方法。增加了一个事件处理程序给SetupCustomTransform 事件。这让我们在宣染对象前有设置自定义变换的机会。Tank_SetupCustomTransform 事件处理程序找到body帧并从它的bearing、pitch、roll、position属性计算出CustomTransform 。然后找到turret 帧计算出炮台的自义角度。
public class Tank : GraphicsObject{ ... public override void Initialize() { base.Initialize(); this.SetupCustomTransform += new EventHandler(this.Tank_SetupCustomTransform); } public void Tank_SetupCustomTransform(object sender, EventArgs e) { // Apply the transformation on the whole tank. this.GetFrame("Body").CustomTransform = Matrix.RotationYawPitchRoll(this.bearing, this.pitch, this.roll)* Matrix.Translation(this.position); // Apply this transformation on the turret only. this.GetFrame("Turret").CustomTransform = Matrix.RotationY(this.turretAngle); } ...}
<< 上一页 [11] [12] [13] [14] [15] [16] [17] [18] [19] [20] ... 下一页 >>
本站地址:http://www.bajiao123.com

