コード例 #1
0
        public override void LoadContent(Microsoft.Xna.Framework.Content.ContentManager c, Microsoft.Xna.Framework.Graphics.GraphicsDevice g)
        {
            base.LoadContent(c, g);

            primBatch = new PrimitiveBatch(Device);
            cam = new FirstPersonCamera(0.5f, 10);
            cam.Pos = new Vector3(3, 3, 13);

            balls = new List<Ball>();

            for (int i = 0; i < 50; i++)
            {
                balls.Add(new Ball(new Vector3(i * 2, 2, 2), new Vector3(i + 1, -i, i % 2) * 0.1f, 0.5f));
            }

            planes = new List<Plane>();

            planes.Add(new Plane(Vector3.Right, 0));
            planes.Add(new Plane(Vector3.Up, 0));
            planes.Add(new Plane(new Vector3(0, 0, 1), 0));
            planes.Add(new Plane(Vector3.Left, -10));
            planes.Add(new Plane(Vector3.Down, -10));
            planes.Add(new Plane(new Vector3(0, 0, -1), -10));

            MeshBuilder mb = new MeshBuilder(g);
            sphere = mb.CreateSphere(1f, 10, 10);
        }
コード例 #2
0
ファイル: MapEditorPanel.cs プロジェクト: bschwind/Sky-Slider
        public override void LoadContent(Microsoft.Xna.Framework.Content.ContentManager content)
        {
            base.LoadContent(content);

            BlockData.Initialize(Device, content);

            cam = new FirstPersonCamera(0.5f, 10);
            cam.Pos = new Vector3(3, 3, 13);


            map = new Map(Device);

            partition = new MapPartition(map);
            engine = new PhysicsEngine3D(partition);

            MeshBuilder mb = new MeshBuilder(Device);
            sphere = mb.CreateSphere(0.1f, 10, 10);
            marker = new MeshNode(sphere);

            placeType = 1;

            primBatch = new PrimitiveBatch(Device);


        }
コード例 #3
0
        public override void LoadContent(ContentManager c, GraphicsDevice g)
        {
            base.LoadContent(c, g);

            cam = new FirstPersonCamera(0.5f, 5f);
            cam.Pos = new Vector3(5, 1, 10);
            primBatch = new PrimitiveBatch(g);
        }
コード例 #4
0
ファイル: RobotDemo.cs プロジェクト: bschwind/Graphics-Demos
        //A scenegraph is composed of SceneNodes
        public override void LoadContent(ContentManager content, GraphicsDevice g)
        {
            base.LoadContent(content, g);

            //Set up our camera and primitive renderer
            cam = new FirstPersonCamera(0.5f, 5f);        //0.5f is the turn speed for the camera, and 5f is the translational speed
            cam.Pos = new Vector3(3, 3, 13);              //Move our camera to the point (3, 3, 13)
            primBatch = new PrimitiveBatch(g);            //Initialize our PrimitiveBatch

            //Define the objects in our scene
            Mesh sphere, cylinder, box;                   //Define the meshes we will use for the robot arm
                                                          //A mesh holds a list of vertices, and a list of indices which represent triangles

            MeshNode arm, elbow, forearm, wrist, hand;    //Define all the parts of the robot arm we will use

            MeshBuilder mb = new MeshBuilder(g);          //MeshBuilder is a helper class for generating 3D geometry
                                                          //It has some built in functions to create primitives, as well as
                                                          //functions to create your own arbitrary meshes

            //Genererate our geometry
            //All geometry created is centered around the origin in its local coordinate system
            sphere = mb.CreateSphere(0.5f, 15, 15);       //Create a sphere mesh, with radius 0.5 and with 15 subdivisions
            cylinder = mb.CreateCylinder(0.3f, 2.0f, 15); //Create a cylinder with radius 0.3, a height of 2, and 15 subdivisions
            box = mb.CreateBox(0.8f, 1.4f, 0.1f);         //Create a box with width 0.8, height of 1.4, and depth of 0.1

            shoulder = new MeshNode(sphere);              //Assign the sphere mesh to our shoulder node

            arm = new MeshNode(cylinder);                 //Assign the cylinder mesh to our arm node
            arm.SetPos(new Vector3(0, -1, 0));            //Translate the arm down 1 on the y axis

            elbow = new MeshNode(sphere);                 //Assign a sphere to our elbow node
            elbow.SetPos(new Vector3(0, -2, 0));          //Translate the elbow down 2 on the y axis

            forearm = new MeshNode(cylinder);             //Assign a cylinder to our forearm node
            forearm.SetPos(new Vector3(0, -1, 0));        //Translate the forearm down 1 on the y axis

            wrist = new MeshNode(sphere);                 //Assign a sphere for the wrist node
            wrist.SetPos(new Vector3(0, -2, 0));          //Translate the wrist down 2 on the y axis

            hand = new MeshNode(box);                     //Assign the box to the hand node
            hand.SetPos(new Vector3(0, -0.7f, 0));        //Translate the hand down 0.7 (half the height of the box) on the y axis

            shoulder.AddChild(arm);                       //The shoulder is the root of this scene, in our case. It is the parent
            shoulder.AddChild(elbow);                     //of both the arm and the elbow

            elbow.AddChild(forearm);                      //The elbow is the parent of the forearm and wrist
            elbow.AddChild(wrist);

            wrist.AddChild(hand);                         //The wrist is the parent of the hand

            shoulder.SetPos(new Vector3(0, 5, 0));        //This call effectively translates the entire arm up 5 on the y axis
        }
コード例 #5
0
        public override void LoadContent(ContentManager content, GraphicsDevice g)
        {
            base.LoadContent(content, g);

            primBatch = new PrimitiveBatch(Device);
            cam = new FirstPersonCamera(0.5f, 10);
            cam.Pos = new Vector3(3, 3, 13);

            MeshBuilder mb = new MeshBuilder(g);
            sphere = mb.CreateSphere(1f, 10, 10);

            setupEngine();
        }
コード例 #6
0
        public override void LoadContent(ContentManager c, GraphicsDevice g)
        {
            base.LoadContent(c, g);

            currentMesh = createCube(c);
            effect = new BasicEffect(g);
            effect.PreferPerPixelLighting = true;
            effect.TextureEnabled = true;
            effect.Texture = currentMesh.Texture;
            effect.EnableDefaultLighting();

            cam = new FirstPersonCamera(0.5f, 5f);
            cam.Pos = new Vector3(0, 2, 4);
        }
コード例 #7
0
ファイル: GameHost.cs プロジェクト: kekraft/XNAProject
        /// <summary>
        /// LoadContent will be called once per game and is the place to load
        /// all of your content.
        /// </summary>
        protected override void LoadContent()
        {
            camera = new FirstPersonCamera(0.5f, 10);
            camera.Pos = new Vector3(3, 3, 13);

            Texture2D heightMap = Content.Load<Texture2D>("heightmap");

            primitiveBatch = new PrimitiveBatch(GraphicsDevice);

            sceneRoot = new SceneNode();
            terrainNode = new TerrainNode(GraphicsDevice, heightMap);

            sceneRoot.AddChild(terrainNode);
        }
コード例 #8
0
        public override void LoadContent(ContentManager content, GraphicsDevice g)
        {
            base.LoadContent(content, g);

            //Set up our camera and primitive renderer
            cam = new FirstPersonCamera(0.5f, 5f);
            cam.Pos = new Vector3(5, 1, 10);
            primBatch = new PrimitiveBatch(g);

            //Set up our triangle
            a = new Vector3(4, 1, 5);
            b = new Vector3(6, 1.5f, 3);
            c = new Vector3(6, 1, 5);

            triangleCenter = (a + b + c) / 3f;

            n = Vector3.Normalize(Vector3.Cross(c - a, b - a));
        }
コード例 #9
0
        public override void LoadContent(ContentManager content, GraphicsDevice g)
        {
            base.LoadContent(content, g);

            //Set up our camera and primitive renderer
            cam = new FirstPersonCamera(0.5f, 5f);
            cam.Pos = new Vector3(5, 1, 10);
            primBatch = new PrimitiveBatch(g);

            animation = Animation.Parse("Content/MotionCaptures/BriskWalk1_All.tsv");

            spheres = new List<MeshNode>();
            MeshBuilder mb = new MeshBuilder(Device);

            for (int i = 0; i < animation.GetNumMarkers(); i++)
            {
                spheres.Add(new MeshNode(mb.CreateSphere(0.06f, 10, 10)));
            }
        }
コード例 #10
0
        public override void LoadContent(ContentManager content, GraphicsDevice g)
        {
            base.LoadContent(content, g);

            primBatch = new PrimitiveBatch(Device);
            cam = new FirstPersonCamera(0.5f, 10);
            cam.Pos = new Vector3(3, 3, 13);

            renderer = new DeferredRenderer(g, content);

            MeshBuilder mb = new MeshBuilder(g);
            Mesh box = mb.CreateBox(1, 1, 1);
            mb.Begin();
            mb.AddQuad(new Vector3(-100, 0, -100), new Vector3(100, 0, -100), new Vector3(100, 0, 100), new Vector3(-100, 0, 100), false, Vector2.Zero, Vector2.One);
            Mesh floor = mb.End();
            box.Texture = content.Load<Texture2D>("Cube");
            floor.Texture = content.Load<Texture2D>("Cube");
            meshes.Add(box);
            meshes.Add(floor);
        }
コード例 #11
0
ファイル: BallDemo.cs プロジェクト: bschwind/Graphics-Demos
        public override void LoadContent(ContentManager content, GraphicsDevice g)
        {
            base.LoadContent(content, g);

            primBatch = new PrimitiveBatch(Device);
            cam = new FirstPersonCamera(0.5f, 10);
            cam.Pos = new Vector3(3, 3, 13);

            MeshBuilder mb = new MeshBuilder(Device);
            mb.Begin();
            mb.AddSphere(radius, 20, 20);
            Mesh sphereMesh = mb.End();

            sphere = new MeshNode(sphereMesh);
            sphere.SetPos(new Vector3(5, 5, 5));

            planes = new List<Plane>();
            planes.Add(new Plane(Vector3.Right, 0));
            planes.Add(new Plane(Vector3.Up, 0));
            planes.Add(new Plane(new Vector3(0, 0, 1), 0));
            planes.Add(new Plane(Vector3.Left, -10));
            planes.Add(new Plane(Vector3.Down, -10));
            planes.Add(new Plane(new Vector3(0, 0, -1), -10));
        }
コード例 #12
0
        public override void LoadContent(ContentManager content, GraphicsDevice g)
        {
            base.LoadContent(content, g);

            primBatch = new PrimitiveBatch(Device);
            cam = new FirstPersonCamera(0.5f, 10);
            //cam.Pos = new Vector3(3, 3, 13);

            Model bodyModel = content.Load<Model>("Models/Body");
            Model handleModel = content.Load<Model>("Models/Handle");
            Model triggerModel = content.Load<Model>("Models/Trigger");
            crosshair = content.Load<Texture2D>("Crosshair");
            fire = content.Load<SoundEffect>("fire_silenced");
            batch = new SpriteBatch(Device);

            Mesh bodyMesh = new Mesh();
            bodyMesh.Indices = bodyModel.Meshes[0].MeshParts[0].IndexBuffer;
            bodyMesh.Vertices = bodyModel.Meshes[0].MeshParts[0].VertexBuffer;
            body = new MeshNode(bodyMesh);

            Mesh handleMesh = new Mesh();
            handleMesh.Indices = handleModel.Meshes[0].MeshParts[0].IndexBuffer;
            handleMesh.Vertices = handleModel.Meshes[0].MeshParts[0].VertexBuffer;
            handle = new MeshNode(handleMesh);
            handle.SetPos(new Vector3(0, 0.13f, 0.477f));

            Mesh triggerMesh = new Mesh();
            triggerMesh.Indices = triggerModel.Meshes[0].MeshParts[0].IndexBuffer;
            triggerMesh.Vertices = triggerModel.Meshes[0].MeshParts[0].VertexBuffer;
            trigger = new MeshNode(triggerMesh);
            trigger.SetPos(new Vector3(0, 0.033f, -1.561f));

            body.AddChild(handle);
            body.AddChild(trigger);
            body.SetPos(new Vector3(0, 5, 0));

            pickableObjects = new List<MeshNode>();
            pickableObjects.Add(body);
            pickableObjects.Add(handle);
            pickableObjects.Add(trigger);

            //Extract triangles
            bodyTris = GetTriangles(bodyMesh);
            handleTris = GetTriangles(handleMesh);
            triggerTris = GetTriangles(triggerMesh);
        }
コード例 #13
0
ファイル: MapViewerPanel.cs プロジェクト: bschwind/Sky-Slider
 public MapViewerPanel(Vector2 upLeft, Vector2 botRight)
     : base(upLeft, botRight)
 {
     cam = new FirstPersonCamera(0.5f, 10f);
     cam.Pos = new Vector3(0, 3, 13);
 }