//used to draw billboards that have a texture
 public BillboardPrimitiveObject(string id, ActorType actorType, Transform3D transform,
                                 Effect effect, IVertexData vertexData, Texture2D texture, Color color, float alpha, StatusType statusType, BillboardType billBoardType)
     : base(id, actorType, transform, effect, vertexData, texture, color, alpha, statusType)
 {
     this.billboardParameters = new BillboardParameters();
     this.BillboardType       = billBoardType;
 }
コード例 #2
0
        private void DrawObject(GameTime gameTime, BillboardPrimitiveObject billboardPrimitiveObject)
        {
            Effect effect = billboardPrimitiveObject.Effect as Effect;

            billboardParameters = billboardPrimitiveObject.BillboardParameters;

            //W, V, P, Apply, Draw
            effect.CurrentTechnique = effect.Techniques[billboardParameters.Technique];
            effect.Parameters["World"].SetValue(billboardPrimitiveObject.Transform3D.World);
            effect.Parameters["View"].SetValue((this.Game as Main).CameraManager.ActiveCamera.View);
            effect.Parameters["Projection"].SetValue((this.Game as Main).CameraManager.ActiveCamera.ProjectionParameters.Projection);
            effect.Parameters["Up"].SetValue(billboardPrimitiveObject.Transform3D.Up);
            effect.Parameters["DiffuseTexture"].SetValue(billboardPrimitiveObject.Texture);
            effect.Parameters["Alpha"].SetValue(billboardPrimitiveObject.Alpha);

            if (billboardParameters.BillboardType == BillboardType.Normal)
            {
                effect.Parameters["Right"].SetValue(billboardPrimitiveObject.Transform3D.Right);
            }

            if (billboardParameters.IsScrolling)
            {
                effect.Parameters["IsScrolling"].SetValue(billboardParameters.IsScrolling);
                effect.Parameters["scrollRate"].SetValue(billboardParameters.scrollValue);
            }
            else
            {
                effect.Parameters["IsScrolling"].SetValue(false);
            }

            if (billboardParameters.IsAnimated)
            {
                effect.Parameters["IsAnimated"].SetValue(billboardParameters.IsAnimated);
                effect.Parameters["InverseFrameCount"].SetValue(billboardParameters.inverseFrameCount);
                effect.Parameters["CurrentFrame"].SetValue(billboardParameters.currentFrame);
            }
            else
            {
                effect.Parameters["IsAnimated"].SetValue(false);
            }


            effect.CurrentTechnique.Passes[0].Apply();
            billboardPrimitiveObject.VertexData.Draw(gameTime, effect);
        }
 //used to draw billboards that have a texture
 public BillboardPrimitiveObject(string id, ObjectType objectType,
     Transform3D transform, IVertexData vertexData, Effect effect, Color color, float alpha, Texture2D texture, BillboardType billBoardType)
     : base(id, objectType, transform, vertexData, effect, color, alpha, texture)
 {
     this.billBoardType = billBoardType;
     this.billboardParameters = new BillboardParameters();
     if (billBoardType == BillboardType.Normal)
     {
         this.billboardParameters.Technique = "Normal";
         this.billboardParameters.BillboardType = BillboardType.Normal;
     }
     else if (billBoardType == BillboardType.Cylindrical)
     {
         this.billboardParameters.Technique = "Cylindrical";
         this.billboardParameters.BillboardType = BillboardType.Cylindrical;
         this.billboardParameters.Up = this.Transform3D.Up;
     }
     else
     {
         this.billboardParameters.Technique = "Spherical";
         this.billboardParameters.BillboardType = BillboardType.Spherical;
     }
 }