示例#1
0
 /// <summary>
 /// The main entry point for the application.
 /// </summary>
 static void Main(string[] args)
 {
     using (Game1 game = new Game1())
     {
         game.Run();
     }
 }
示例#2
0
        protected Matrix worldTranslationMatrix; //location of model in the world

        #endregion Fields

        #region Constructors

        public PrimitiveModel(Game1 g)
        {
            game = g;

            worldTranslationMatrix = Matrix.Identity;
            worldScaleMatrix = Matrix.Identity;
        }
示例#3
0
        public void draw(Game1 game, BasicEffect effect)
        {
            effect.VertexColorEnabled = false;  //because we are about to render textures not color
            effect.TextureEnabled = true;  //because we are about to render textures not colors
            VertexPositionTexture[] vertexTextures;
            foreach (Node sourceNode in nodes.Values)
            {
                foreach (Node destNode in sourceNode.neighbours.Values)
                {
                    Matrix world = Matrix.Identity;

                    vertexTextures = new VertexPositionTexture[2 * 3];

                    float width = 0.01f;
                    float length = (destNode.position-sourceNode.position).Length();
                    float angle = (float)Math.Atan2(destNode.position.X - sourceNode.position.X, destNode.position.Z - sourceNode.position.Z);
                    Matrix rotate = Matrix.CreateRotationY(angle-(float)MathHelper.PiOver2);
                    Matrix translate = Matrix.CreateTranslation(sourceNode.position);

                    Vector3 vertex1 = new Vector3(0, 0, width);
                    Vector3 vertex2 = new Vector3(0, 0, -width);
                    Vector3 vertex3 = new Vector3(length, 0, width);
                    Vector3 vertex4 = new Vector3(length, 0, -width);

                    vertexTextures[0] = new VertexPositionTexture(vertex3, new Vector2(0, 1));
                    vertexTextures[1] = new VertexPositionTexture(vertex1, new Vector2(0, 0));
                    vertexTextures[2] = new VertexPositionTexture(vertex2, new Vector2(1, 0));
                    vertexTextures[3] = new VertexPositionTexture(vertex3, new Vector2(0, 1));
                    vertexTextures[4] = new VertexPositionTexture(vertex2, new Vector2(1, 0));
                    vertexTextures[5] = new VertexPositionTexture(vertex4, new Vector2(1, 1));
                    world *= rotate * translate;
                    effect.World = world;
                    effect.Texture = Game1.textures["line"];
                    effect.CurrentTechnique.Passes[0].Apply();
                    game.GraphicsDevice.DrawUserPrimitives<VertexPositionTexture>(PrimitiveType.TriangleList, vertexTextures, 0, 2);

                    //effect.Texture = Game1.textures["line"];
                    //effect.CurrentTechnique.Passes[0].Apply();
                    //GraphicsDevice.DrawUserPrimitives<VertexPositionTexture>(PrimitiveType.TriangleList, vertexTextures, 0, 2);
                   // batch.Draw(Game1.textures["line"], new Rectangle((int)sourceNode.x, (int)sourceNode.z, (int)Math.Sqrt(Math.Pow((sourceNode.x - destNode.x), 2) + Math.Pow((sourceNode.z - destNode.z), 2)), 5),
                   //     null, color, (float)Math.Atan2((destNode.z - sourceNode.z), (destNode.x - sourceNode.x)), new Vector2(0, 0), SpriteEffects.None, 0.0f);
                }
            }
            foreach (Node sourceNode in nodes.Values)
            {
                effect.World = Matrix.Identity;
                effect.Texture = Game1.textures["circle"];
                effect.CurrentTechnique.Passes[0].Apply();
                game.GraphicsDevice.DrawUserPrimitives<VertexPositionTexture>(PrimitiveType.TriangleList, sourceNode.vertexTextures, 0, 2);
                //batch.Draw(Game1.textures["circle"], new Rectangle((int)sourceNode.x - Node.rad, (int)sourceNode.z - Node.rad, Node.rad * 2, Node.rad * 2), sourceNode.color);
            }
        }
示例#4
0
文件: Cube.cs 项目: Will2817/COMP3004
 public CubeModel(Game1 theGame)
     : base(theGame)
 {
     initializeCube();
 }
示例#5
0
文件: Cube.cs 项目: Will2817/COMP3004
 public CubeModel(Game1 theGame, float w, float h, float d)
     : base(theGame)
 {
     initializeCube();
     dimensionScaleMatrix = Matrix.CreateScale(w / width, h / height, d / depth);
 }