コード例 #1
0
ファイル: Agent.cs プロジェクト: houstonhuffman/XNA_project3
 /// <summary>
 /// Create an Agent.
 /// All Agents are collidable and have a single instance Object3D named agentObject.
 /// Set StepSize, create first, follow and above cameras.
 /// Set first as agentCamera
 /// <param name="stage"></param>
 /// <param name="label"></param>
 /// <param name="position"></param>
 /// <param name="orientAxis"></param>
 /// <param name="radians"></param>
 /// <param name="meshFile"></param>
 /// </summary>
 public Agent(Stage stage, string label, Vector3 position, Vector3 orientAxis,
    float radians, string meshFile)
     : base(stage, label, meshFile)
 {
     addObject(position, orientAxis, radians);
     agentObject = instance.First<Object3D>();
     first = new Camera(stage, agentObject, Camera.CameraEnum.FirstCamera);
     follow = new Camera(stage, agentObject, Camera.CameraEnum.FollowCamera);
     above = new Camera(stage, agentObject, Camera.CameraEnum.AboveCamera);
     stage.addCamera(first);
     stage.addCamera(follow);
     stage.addCamera(above);
     agentCamera = first;
 }
コード例 #2
0
ファイル: Stage.cs プロジェクト: houstonhuffman/XNA_project3
        /// <summary>
        /// Set GraphicDevice display and rendering BasicEffect effect.  
        /// Create SpriteBatch, font, and font positions.
        /// Creates the traceViewport to display information and the sceneViewport
        /// to render the environment.
        /// Create and add all DrawableGameComponents and Cameras.
        /// </summary>
        protected override void LoadContent()
        {
            display = graphics.GraphicsDevice;
            effect = new BasicEffect(display);
            // Set up Inspector display
            spriteBatch = new SpriteBatch(display);      // Create a new SpriteBatch
            inspectorFont = Content.Load<SpriteFont>("Courier New");  // load font
            // viewports
            defaultViewport = GraphicsDevice.Viewport;
            inspectorViewport = defaultViewport;
            sceneViewport = defaultViewport;
            inspectorViewport.Height = InfoPaneSize * inspectorFont.LineSpacing;
            inspectorProjection = Matrix.CreatePerspectiveFieldOfView((float)Math.PI / 4.0f,
               inspectorViewport.Width / inspectorViewport.Height, 1.0f, 200.0f);
            sceneViewport.Height = defaultViewport.Height - inspectorViewport.Height;
            sceneViewport.Y = inspectorViewport.Height;
            sceneProjection = Matrix.CreatePerspectiveFieldOfView((float)Math.PI / 4.0f,
               sceneViewport.Width / sceneViewport.Height, 1.0f, 1000.0f);
            // create Inspector display
            Texture2D inspectorBackground = Content.Load<Texture2D>("inspectorBackground");
            inspector = new Inspector(display, inspectorViewport, inspectorFont, Color.Black, inspectorBackground);
            // create information display strings
            // help strings
            inspector.setInfo(0, "AGXNASKv4 -- Academic Graphics XNA Starter Kit for CSUN Comp 565 assignments.");
            inspector.setInfo(1, "Press keyboard for input (not case sensitive 'H'  'h')");
            inspector.setInfo(2, "Inspector toggles:  'H' help or info   'M'  matrix or info   'I'  displays next info pane.");
            inspector.setInfo(3, "Arrow keys move the player in, out, left, or right.  'R' resets player to initial orientation.");
            inspector.setInfo(4, "Stage toggles:  'B' bounding spheres, 'C' cameras, 'F' fog, 'T' updates, 'Y' yon");
            // initialize empty info strings
            for (int i = 5; i < 20; i++) inspector.setInfo(i, "  ");
            inspector.setInfo(5, "matrics info pane, initially empty");
            inspector.setInfo(10, "first info pane, initially empty");
            inspector.setInfo(15, "second info pane, initially empty");
            // set blending for bounding sphere drawing
            blending = new BlendState();
            blending.ColorSourceBlend = Blend.SourceAlpha;
            blending.ColorDestinationBlend = Blend.InverseSourceAlpha;
            blending.ColorBlendFunction = BlendFunction.Add;
            notBlending = new BlendState();
            notBlending = display.BlendState;

            // Create and add stage components
            // Create a top-down "Whole stage" camera view, make it first camera in collection.
            topDownCamera = new Camera(this, Camera.CameraEnum.TopDownCamera);
            camera.Add(topDownCamera);
            boundingSphere3D = Content.Load<Model>("boundingSphereV3");
            wayPoint3D = Content.Load<Model>("100x50x100Marker"); //treasure_chest100x50x100Marker

            // Create required entities:
            collidable = new List<Object3D>();
            terrain = new Terrain(this, "terrain", "heightTexture1", "colorTexture1");
            Components.Add(terrain);
            // Load Avatar mesh objects, Avatar meshes do not have textures

            player = new Player(this, "Chaser",
               new Vector3(510 * spacing, terrain.surfaceHeight(510, 507), 507 * spacing),
               new Vector3(0, 1, 0), 0.80f, "redAvatarV3");  // face looking diagonally across stage
            Components.Add(player);
        }
コード例 #3
0
ファイル: Stage.cs プロジェクト: houstonhuffman/XNA_project3
 /// <summary>
 /// Changing camera view for Agents will always set YonFlag false
 /// and provide a clipped view.
 /// </summary>
 public void nextCamera()
 {
     cameraIndex = (cameraIndex + 1) % camera.Count;
     currentCamera = camera[cameraIndex];
     // set the appropriate projection matrix
     YonFlag = false;
     setProjection(farYon);
 }
コード例 #4
0
ファイル: Stage.cs プロジェクト: houstonhuffman/XNA_project3
 public void addCamera(Camera aCamera)
 {
     camera.Add(aCamera);
     cameraIndex++;
 }