public Treasure(Stage theStage, string label, string fileOfModel, Vector3 position, Vector3 up, float scale)
            : base(theStage, label, fileOfModel)
        {
            AddObject(position, up, scale);
            treasureObject = instance.First<Object3D>();
            isOpen = false;

            closeStateModel = stage.Content.Load<Model>(HIDDEN_TREASURE_FILENAME);
            openStateModel = stage.Content.Load<Model>(FOUND_TREASURE_FILENAME);
        }
Exemplo n.º 2
0
        /// <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
        /// 
        /// </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>();

            // create 3 cameras
            first = new Camera(stage, agentObject, Camera.CameraEnum.FirstCamera);
            follow = new Camera(stage, agentObject, Camera.CameraEnum.FollowCamera);
            above = new Camera(stage, agentObject, Camera.CameraEnum.AboveCamera);

            // add 3 cameras to Stage
            stage.AddCamera(first);
            stage.AddCamera(follow);
            stage.AddCamera(above);

            // initialize the first camera
            agentCamera = first;
            taggedTreasures = 0;
        }
Exemplo n.º 3
0
        /// <summary>
        /// Set surface height base on X-Z 
        /// </summary>
        public void SetSurfaceHeight(Object3D anObject3D)
        {
            int spacing = Spacing;
            // Using Lerp
            int Ax = (int)anObject3D.Translation.X / spacing;
            int Az = (int)anObject3D.Translation.Z / spacing;

            int Bx = Ax + 1;
            int Bz = Az;

            int Cx = Ax;
            int Cz = Az + 1;

            int Dx = Ax + 1;
            int Dz = Az + 1;

            float Yx = anObject3D.Translation.X;
            float Yz = anObject3D.Translation.Z;

            Vector3 vector3A = new Vector3(Ax * spacing, terrain.SurfaceHeight(Ax, Az), Az * spacing);
            Vector3 vector3B = new Vector3(Bx * spacing, terrain.SurfaceHeight(Bx, Bz), Bz * spacing);
            Vector3 vector3C = new Vector3(Cx * spacing, terrain.SurfaceHeight(Cx, Cz), Cz * spacing);
            Vector3 vector3D = new Vector3(Dx * spacing, terrain.SurfaceHeight(Dx, Dz), Dz * spacing);

            float deltaYx;
            float deltaYz;
            float terrainHeight;
            if ((Yx - Ax * spacing + Yz - Az * spacing) <= spacing)  {
                deltaYx = Vector3.Lerp(vector3A, vector3B, (Yx - Ax * spacing) / (Bx * spacing - Ax * spacing)).Y;
                deltaYz = Vector3.Lerp(vector3A, vector3C, (Yz - Az * spacing) / (Cz * spacing - Az * spacing)).Y;
                terrainHeight = deltaYx + deltaYz - terrain.SurfaceHeight(Ax, Az);
            }
            else  {
                deltaYx = Vector3.Lerp(vector3C, vector3D, (Yx - Cx * spacing) / (Dx * spacing - Cx * spacing)).Y;
                deltaYz = Vector3.Lerp(vector3B, vector3D, (Yz - Bz * spacing) / (Dz * spacing - Bz * spacing)).Y;
                terrainHeight = deltaYx + deltaYz - terrain.SurfaceHeight(Dx, Dz);
            }

            anObject3D.Translation = new Vector3(anObject3D.Translation.X,
                                                  terrainHeight, anObject3D.Translation.Z);
        }
Exemplo n.º 4
0
 /// <summary>
 /// Set correct surface height base on its plane
 /// </summary>
 /// <param name="anObject3D">A movable object</param>
 public void SetSmoothSurfaceHeight(Object3D anObject3D)
 {
     float terrainHeight = terrain.GetExactTerrainHeight(anObject3D.Translation.X, anObject3D.Translation.Z, 150);
     anObject3D.Translation = new Vector3(anObject3D.Translation.X, terrainHeight, anObject3D.Translation.Z);
 }
Exemplo n.º 5
0
 // Methods
 public bool IsCollidable(Object3D obj3d)
 {
     if (collidable.Contains(obj3d))
         return true;
     return false;
 }
        public void AddObject(Vector3 position, Vector3 orientAxis, float radians)
        {
            Object3D obj3d = new Object3D(stage, this, String.Format("{0}.{1}", name, instance.Count), position, orientAxis, radians, Vector3.One);

            // need to do only once for Model3D
            obj3d.UpdateBoundingSphere();
            instance.Add(obj3d);

            if (IsCollidable)
                stage.Collidable.Add(obj3d);
        }
Exemplo n.º 7
0
 public Camera(Stage aScene, Object3D anAgentObject, CameraEnum whichCameraType)
 {
     scene = aScene;
     agent = anAgentObject;
     whichCamera = whichCameraType;
 }
Exemplo n.º 8
0
        /// <summary>
        /// Construct a leaderless pack.
        /// </summary>
        /// <param name="theStage"> the scene</param>
        /// <param name="label"> name of pack</param>
        /// <param name="meshFile"> model of pack instance</param>
        public Pack(Stage theStage, string label, string meshFile)
            : base(theStage, label, meshFile)
        {
            random = new Random();
            isCollidable = true;
            leader = null;
            flockMode = FlockEnum.FLOCK_0_PERCENT;

            InitializeFlocing();
        }