Ejemplo n.º 1
0
        public PathCamera(String ID,Path targetPath,Vector3 cameraStartPosition)
            : base(ID, Vector3.Zero, Vector3.Zero)
        {
            targetPath.SetTangents();

            this.cameraCurveLookat = targetPath;

            time = 0;
        }
Ejemplo n.º 2
0
        public void RegisterActors()
        {
            #region 3D Stuff

            SceneGraphManager.CullingActive = false;

            float testTimeOffset = 6000;

            //ship-position path
            Path path = new Path("targetPath",ID);
            path.LoadContent();
            path.AddPoint(new Vector3(0, -100, 0), 0);
            path.AddPoint(new Vector3(0, -300, -8000), testTimeOffset+2000);
            path.AddPoint(new Vector3(500, -100, -16000), 2*testTimeOffset+4000);
            path.AddPoint(new Vector3(000, 500, -24000), 3*testTimeOffset+6000);
            path.AddPoint(new Vector3(0, 0, -30000), 4*testTimeOffset+8000);

            //camera-position path
            Path path2 = new Path("positionPath", ID,Color.Green);
            path2.LoadContent();
            path2.AddPoint(new Vector3(0, 200, 500), 0);
            path2.AddPoint(new Vector3(0, 300, -8000), testTimeOffset+2400);
            path2.AddPoint(new Vector3(500, 100, -16000), 2*testTimeOffset+4400);
            path2.AddPoint(new Vector3(000, 500, -24000), 3*testTimeOffset+6400);
            path2.AddPoint(new Vector3(0, 0, -29000), 4*testTimeOffset+8000);

            path.SetTangents();
            path2.SetTangents();

            SceneGraphManager.RootNode.Children.Add(path);
            SceneGraphManager.RootNode.Children.Add(path2);

            //create a ship
            Ship ship = new Ship("SpaceShip", ID,path);
            ship.LoadContent();
            ship.Updateable = true;

            Planet p = new Planet("testplanet", 1000);
            p.Position = new Vector3(-1000,-1000,-10000);
            p.Visible = true;
            p.LoadContent();

            SceneGraphManager.RootNode.Children.Add(p);

            Laser laser = new Laser("testlaser","laser", 5);
            laser.Visible = false;
            laser.LoadContent();
            SceneGraphManager.RootNode.Children.Add(laser);

            SceneGraphManager.RootNode.Children.Add(ship);

            //cameras
            ChaseCamera chaseCamera = new ChaseCamera("chaseCamera", new Vector3(0, 50, 700), ship);
            chaseCamera.LoadContent();

            FPSCamera fpsCamera = new FPSCamera("fpsCamera", Vector3.Zero, Vector3.UnitZ,500);
            fpsCamera.LoadContent();

            PathCamera pathCamera = new PathCamera("pathCamera",path,path2);
            pathCamera.LoadContent();

            CameraManager.Instance.CurrentCamera = "pathCamera";

            //create a skySphere
            SkySphere skySphere = new SkySphere("skySphere", "level1_skymap", 30000f);
            skySphere.Position = Vector3.Zero;
            skySphere.Visible = true;
            skySphere.LoadContent();

            SceneGraphManager.RootNode.Children.Add(skySphere);

            //100 asteroids with random position, scale and rotation
            Random random = new Random();

            /*
            for (int i = 0; i < 100; i++)
            {
                EffectProperty effectProp = new EffectProperty("TextureMappingEffect");
                effectProp.Effect = ResourceManager.Instance.GetResource<Effect>("TextureMappingEffect");

                MeshObject asteroid01 = new MeshObject("asteroid" + i, "asteroid", 1f);
                //asteroid01.Properties.Add(ActorPropertyType.EFFECT, effectProp);

                CollideableProperty collidable = new CollideableProperty();
                asteroid01.Properties.Add(ActorPropertyType.COLLIDEABLE, collidable);

                asteroid01.Scale = new Vector3(random.Next(15, 100), random.Next(15, 100), random.Next(15, 100));
                asteroid01.Rotation = Quaternion.CreateFromYawPitchRoll(random.Next(20,100),random.Next(20,100),random.Next(20,100));
                asteroid01.Position = new Vector3(random.Next(-1000, 1000), random.Next(-500, 500), random.Next(-100, 0) - i * 300);
                asteroid01.LoadContent();
                asteroid01.SetModelEffect(ResourceManager.Instance.GetResource<Effect>("PPModel"),true);

                SceneGraphManager.RootNode.Children.Add(asteroid01);
            }
             * */

            MeshObject obj = new MeshObject("tea", "teapot", 1.0f);
            obj.LoadContent();
            obj.Position = new Vector3(0,-100,0);
            obj.SetModelEffect(ResourceManager.Instance.GetResource<Effect>("PPModel"), true);
            SceneGraphManager.RootNode.Children.Add(obj);

            #endregion

            #region UI Stuff
            TextElement headline = new TextElement("TextElementHeadline2", new Vector2(500, 20), Color.Yellow, "GamePlayView", ResourceManager.Instance.GetResource<SpriteFont>("Arial"));
            headline.Scale = 1f;
            headline.Visible = false;
            UIManager.Instance.AddActor(headline);

            TextElement TextPositionShip = new TextElement("TextPositionShip", new Vector2(500, 40), Color.Yellow, "GamePlayView", ResourceManager.Instance.GetResource<SpriteFont>("Arial"));
            TextPositionShip.Scale = 1f;
            TextPositionShip.Visible = true;
            UIManager.Instance.AddActor(TextPositionShip);

            //create crossfade
            CrossHair crosshair_near = new CrossHair("crosshair_near", "SpaceShip", "crosshair_near", 1500);
            crosshair_near.LoadContent();
            UIManager.Instance.AddActor(crosshair_near);
            #endregion
        }