日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

Mango Teapot ② Teapot クラス

發布時間:2024/1/17 编程问答 25 豆豆
生活随笔 收集整理的這篇文章主要介紹了 Mango Teapot ② Teapot クラス 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

ソースコードは MangoTeapot.codeplex.com にあります。

  • Silverlight と XNA によるグラフィックス デバイスの共有
  • Teapot クラス
  • 加速度センサーと モーション
  • カメラ
  • 以前 Silverlight 5 (beta) で Teapot を描畫したとき、頂點バッファとインデックスバッファを基に Blinn-Phong シェーダーで描畫する Teapot クラスを作成しました。そのときの Teapot クラスに以下の変更を加えました。おもに XNA 4.0 への対応とシェーダーから固定機能(BasicEffect)への移行です。

    IVertexType

    XNA 4.0 ではカスタム頂點フォーマットを定義する際に IVertexType を継承しなければならないので、それに対応しました。

    private struct VertexPositionNormal : IVertexType

    {

    ? private Vector3 _vertexPosition;

    ? private Vector3 _vertexNormal;

    ?

    ? public Vector3 Position

    ? {

    ??? get { return _vertexPosition; }

    ??? set { _vertexPosition = value; }

    ? }

    ? public Vector3 Normal

    ? {

    ??? get { return _vertexNormal; }

    ??? set { _vertexNormal = value; }

    ? }

    ? public VertexPositionNormal(
    ??? float positionX, float positionY, float positionZ,?
    ??? float normalX, float normalY, float normalZ)

    ? {

    ??? _vertexPosition = new Vector3(positionX, positionY, positionZ);

    ??? _vertexNormal = new Vector3(normalX, normalY, normalZ);

    ? }

    ? public static readonly VertexDeclaration VertexDeclaration =
    ??? new VertexDeclaration(

    ????? new VertexElement(0, VertexElementFormat.Vector3,
    ??????? VertexElementUsage.Position, 0),

    ????? new VertexElement(12, VertexElementFormat.Vector3,
    ??????? VertexElementUsage.Normal, 0)
    );

    ? VertexDeclaration IVertexType.VertexDeclaration

    ? {

    ??? get { return VertexDeclaration; }

    ? }

    }

    ?

    BasicEffect

    Silverlight 5 では BasicEffect が使えずカスタム シェーダー エフェクトしか使えなかったのですが、逆に Windows Phone ではカスタム シェーダー エフェクトが使えず BasicEffect しか使えません。BasicEffect のデフォルト設定に(EnableDefaultLighting)、ピクセル単位のシェーディングを有効にしました(PreferPerPixelLighting)。いちばんマンゴー色に似ていたので、ディフューズ色を Color.Goldenrod にしました。

    private BasicEffect effect;

    // BasicEffect

    effect = new BasicEffect(device);

    effect.EnableDefaultLighting();

    effect.DiffuseColor = Color.Goldenrod.ToVector3();

    effect.PreferPerPixelLighting = true;

    もちろん World, View, Projection 行列はシェーダー レジスターではなく、BasicEffect オブジェクトの各プロパティに代入します。

    // Set BasicEffect parameters

    effect.World = this.World;

    effect.View = this.View;

    effect.Projection = this.Projection;

    effect.SpecularPower = this.Shininess;

    また、XNA 4.0 から描畫時のエフェクトの適用は、Begin(), End() ではなく Apply() メソッドになりました。

    foreach (EffectPass p in effect.CurrentTechnique.Passes)

    {

    ? p.Apply();

    ? device.DrawIndexedPrimitives(PrimitiveType.TriangleList,
    ?????????????????????????????? 0, 0, numVertices, 0, numElements);

    }

    abstract:ソースコードは MangoTeapot.codeplex.com にあります。 Silverlight と XNA によるグラフィックス デバイスの共有 Teapot クラス 加速度センサーと モーション カメラ 以前 Silverlight 5 (be

    轉載于:https://www.cnblogs.com/gdhm2/archive/2011/10/25/2223957.html

    總結

    以上是生活随笔為你收集整理的Mango Teapot ② Teapot クラス的全部內容,希望文章能夠幫你解決所遇到的問題。

    如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。