示例#1
0
        public GasStation(Scene scene)
        {
            Model gasStation = new Model("GasStation");

            (scene.MainTerrain as TerrainVoxel).GetLandmarkTransform(MapLandmark.GasStation, gasStation.Transformation, gasStation.GetMesh().GetBounds());
            //powerPlant.Transformation.SetPosition(powerPlant.Transformation.GetPosition()-Vector3.Up*94);
            Vector3 pos = gasStation.Transformation.GetPosition();
            gasStationTransform = gasStation.Transformation;
            AnimationNode[] nodes = gasStation.GetMesh().GetNodes();
            Matrix worldMatrix = gasStation.Transformation.GetTransform();

            SafeTrigger campTrigger = new SafeTrigger();
            campTrigger.Transformation.SetPosition(gasStation.Transformation.GetPosition());
            campTrigger.Transformation.SetScale(Vector3.One * 30);
            scene.AddEntity("SafeTrigger", campTrigger);

            //Vector3 meshCenter = 0.5f * (gasStation.GetMesh().GetBounds().Max + gasStation.GetMesh().GetBounds().Min);
            for (int i = 0; i < nodes.Length; i++)
            {
                InteractObject gasTank = new InteractObject(null, "GasTank");
                gasTank.SetInteractNode(new GasTankNode(gasTank));
                Vector3 gasTankPos = Vector3.Transform(nodes[i].Translation, worldMatrix);
                gasTank.Transformation.SetPosition(gasTankPos);
                gasTank.Transformation.SetRotation(gasStation.Transformation.GetRotation());
                scene.AddEntity("GasTank", gasTank);
            }
            scene.AddEntity("GasStation", gasStation);
        }
 public static Matrix ToXNA(Body body, Transform transform)
 {
     Vector3 rot = transform.GetRotation();
     Matrix mat = body.Orientation * Matrix.CreateRotationY(rot.Y);
     mat.Translation = body.Position;
     return mat;
 }
示例#3
0
        public VoxelCollision(VoxelGeometry voxel, Transform transform, BoundingBox bounds)
        {
            geometry = voxel;
            transformation = transform;

            boundsWorldSpaceCollision = bounds;
            boundsWorldSpaceCollision.Min = bounds.Min * 1.5f;
            boundsWorldSpaceCollision.Max = bounds.Max * 1.5f;
        }
示例#4
0
 public Weapon(string modelName, Body body, Transform transform, Scene scene)
 {
     this.ignorePred = new IgnoreSkinPredicate(body);
     this.scene = scene;
     this.fpsModel = new ViewModel(modelName);
     fpsModel.SetTransform(transform);
     Matrix weaponTransform = Matrix.CreateScale(0.1f) * Matrix.CreateRotationX(-MathHelper.PiOver2) * Matrix.CreateRotationY(MathHelper.PiOver2);
     fpsModel.SetCustomMatrix(weaponTransform);
     fpsModel.GetAnimationLayer().SetActiveAnimation("Pistol_Idle", true);//.SetAnimationLayer("Pistol_Idle", 1);
 }
示例#5
0
 public Weapon(string datablockName, Body body, Transform transform, Scene scene)
 {
     this.ignorePred = new IgnoreSkinPredicate(body);
     this.scene = scene;
     this.datablock = ResourceManager.Inst.GetWeaponDatablock(datablockName);
     this.fpsModel = new ViewModel(datablock.MeshName);
     this.fpsModel.SetRenderAlways(true, scene);
     this.ammo = datablock.AmmoPerClip;
     this.ReserveAmmo = datablock.DefaultAmmo;
     fpsModel.SetTransform(transform);
     fpsModel.SetCustomMatrix(datablock.CustomMatrix);
     fpsModel.GetAnimationLayer().SetActiveAnimation(datablock.GetAnimation(WeaponAnimations.Idle), true);
 }
        public VoxelCollision(VoxelGeometry voxel, Transform transform, BoundingBox bounds, Scene scene)
        {
            geometry = voxel;
            transformation = transform;
            this.scene = scene;

            boundsWorldSpaceCollision = bounds;
            boundsWorldSpaceCollision.Min = bounds.Min * 1.5f;
            boundsWorldSpaceCollision.Max = bounds.Max * 1.5f;
            if (geometry.CanRender)
            {
                //GenerateCollisionMesh();
            }
        }
示例#7
0
 public void GetLandmarkTransform(MapLandmark marker, Transform transform, BoundingBox meshBounds)
 {
     Vector4 param = landmarks[(int)marker];
     Vector3 pos = new Vector3(param.X, param.Y, param.Z);
     transform.SetPosition(pos);
     Vector3 rotation = transform.GetRotation();
     rotation.Y = param.W;
     transform.SetRotation(rotation);
     List<TriangleGraph> triangles;
     BoundingBox region = meshBounds;
     Vector3 sides = (meshBounds.Max - meshBounds.Min)*0.5f;
     region.Min = pos - sides;
     region.Max = pos + sides;
     region.Min.Y = this.Transformation.GetBounds().Min.Y;
     region.Max.Y = this.Transformation.GetBounds().Max.Y;
     if (GetTrianglesInRegion(RandomHelper.RandomGen, out triangles, region, true))
     {
         TriangleGraph bestTri = triangles[0];
         float bestDist = Vector3.DistanceSquared(bestTri.Centroid, pos);
         for (int i = 1; i < triangles.Count; i++)
         {
             float dist = Vector3.DistanceSquared(triangles[i].Centroid, pos);
             if (dist < bestDist)
             {
                 bestTri = triangles[i];
                 bestDist = dist;
             }
         }
         transform.SetPosition(bestTri.GeneratePointInTriangle(RandomHelper.RandomGen));
         BoundingBox newRegion = transform.TransformBounds(meshBounds);
         Vector3 offsetVector = Vector3.One * 5.0f;
         newRegion.Min = newRegion.Min - offsetVector;
         newRegion.Max = newRegion.Max + offsetVector;
         triangles = null;
         if (GetTrianglesInRegion(RandomHelper.RandomGen, out triangles, newRegion, true))
         {
             for (int i = 0; i < triangles.Count; i++)
             {
                 if(!usedLandmarkTriangles.ContainsKey(triangles[i].ID))
                     usedLandmarkTriangles.Add(triangles[i].ID, (char)1);
             }
         }
     }
 }
示例#8
0
 public void SetTransformation(Transform transform)
 {
     currTransform = transform;
 }
示例#9
0
 public void RemoveMarker(Transform transform)
 {
     markers.Remove(transform);
 }
示例#10
0
        public override void OnAdd(Scene scene)
        {
            base.OnAdd(scene);

            scene.AddActor(this);

            PhysicsSystem world = scene.GetPhysicsEngine();

            Vector3 pos = Vector3.Up * 256 + 15*(new Vector3((float)RandomHelper.RandomGen.NextDouble(), (float)RandomHelper.RandomGen.NextDouble(), (float)RandomHelper.RandomGen.NextDouble())*2-Vector3.One);
            //pos.X += (scene.MainTerrain as TerrainHeightmap).GetWidth()*0.5f;
            //pos.Z += (scene.MainTerrain as TerrainHeightmap).GetDepth() * 0.5f;
            Vector3 normal = Vector3.Up;
            //scene.MainTerrain.GenerateRandomTransform(RandomHelper.RandomGen, out pos, out normal);
            //pos = pos + Vector3.Up * 5;

            body = new CharacterBody();
            collision = new CollisionSkin(body);

            standCapsule = new Capsule(Vector3.Zero, Matrix.CreateRotationX(MathHelper.PiOver2), 1.0f, 1.778f);
            crouchCapsule = new Capsule(Vector3.Zero, Matrix.CreateRotationX(MathHelper.PiOver2), 1.0f, 1.0f);
            SetupPosture(false);
            collision.AddPrimitive(standCapsule, (int)MaterialTable.MaterialID.NormalRough);
            body.CollisionSkin = collision;
            Vector3 com = PhysicsHelper.SetMass(75.0f, body, collision);

            body.MoveTo(pos + com, Matrix.Identity);
            collision.ApplyLocalTransform(new JigLibX.Math.Transform(-com, Matrix.Identity));

            body.SetBodyInvInertia(0.0f, 0.0f, 0.0f);

            body.AllowFreezing = false;
            body.EnableBody();
            Transformation = new Transform(body);

            ResetState();
        }
示例#11
0
        public override void OnUpdate(float timeDT)
        {
            scene.Update();
            Entity camera = scene.FindEntity("MainCamera");

            if (camera != null)
            {
                playerTransform = camera.Transformation;
                compass.SetTransformation(playerTransform);
                if(isGameRunning)
                    PerformInteraction();
            }
            /*
            MainRenderView view = (MainRenderView)scene.MainCamera;
            Entity enemy = scene.FindEntity("Amulet");
            if (enemy != null)
            {
                view.SetBlurTarget(enemy.Transformation.GetPosition(), Vector3.Normalize(camera.Transformation.GetTransform().Forward));
            }
            */
            if(journalEntryAdded)
                DisplayJournalStatus(timeDT);

            if (ActivatedPower && !HasAlertedHangar && !journalEntryAdded)
            {
                AddJournalEntry("Find a way off the island", -4);
                HasAlertedHangar = true;
                AddMarker(scene.FindEntity("Plane").Transformation);
            }

            UpdateBlinkTime();

            if (!isGameRunning)
            {
                fadeOutTime += timeDT;
                if (fadeOutTime < timeTilCredits)
                {
                    Vector4 color = Vector4.Zero;
                    color.W = fadeOutTime / timeTilCredits;
                    blackFade.SetButtonColor(color);
                }
                else
                {
                    creditsLabel.SetVisible(true);
                    float alpha = MathHelper.Clamp((fadeOutTime - timeTilCredits) / 3.0f, 0.0f, 1.0f);
                    creditsLabel.SetTextColor(Vector4.One * alpha);
                }
            }

            base.OnUpdate(timeDT);
        }
示例#12
0
        public override void OnUpdate(float timeDT)
        {
            scene.Update();
            Entity camera = scene.FindEntity("MainCamera");

            if (camera != null)
            {
                playerTransform = camera.Transformation;
                compass.SetTransformation(playerTransform);
                scoreLabel.SetText(camera.Transformation.GetPosition().ToString());
                PerformInteraction();
            }

            Entity testEnt = scene.FindEntity("scene_geom2");
            if (testEnt != null && !addedMarker)
            {
                compass.AddMarker(testEnt.Transformation);
                addedMarker = true;
            }

            if (Input.InputManager.Inst.IsKeyDown(Gaia.Input.GameKey.Interact))
            {
                journalFadeTime = 0;
                journalEntryAdded = true;
            }

            if(journalEntryAdded)
                DisplayJournalStatus(timeDT);

            base.OnUpdate(timeDT);
        }
示例#13
0
 public void RemoveMarker(Transform transform)
 {
     int index = markers.IndexOf(transform);
     if (index >= 0 && index < markers.Count)
         markers.RemoveAt(index);
 }
示例#14
0
 public void AddCustomMarker(Transform transform, TextureResource texture)
 {
     customMarkers.Add(new CustomMarker(transform, texture.GetTexture() as Texture2D));
 }
示例#15
0
 public CustomMarker(Transform transform, Texture2D texture)
 {
     this.transform = transform;
     this.markerImage = texture;
 }
示例#16
0
 public void SetTransform(Transform transform)
 {
     this.transform = transform;
 }
示例#17
0
 public void AddMarker(Transform transform)
 {
     compass.AddMarker(transform);
 }
示例#18
0
 public void AddMarker(Transform transform)
 {
     markers.Add(transform);
 }
示例#19
0
 public void RemoveMarker(Transform transform)
 {
     compass.RemoveMarker(transform);
 }
示例#20
0
        public PowerPlant(Scene scene)
        {
            Model powerPlant = new Model("PowerPlant");
            Model powerPlantFence = new Model("PowerPlantFence");
            InteractObject switchA = new InteractObject(new SwitchNode(this, 0x1), "PowerPlantSwitchA");
            InteractObject switchB = new InteractObject(new SwitchNode(this, 0x2), "PowerPlantSwitchB");
            InteractObject switchC = new InteractObject(new SwitchNode(this, 0x4), "PowerPlantSwitchC");
            InteractObject switchD = new InteractObject(new SwitchNode(this, 0x8), "PowerPlantSwitchD");

            (scene.MainTerrain as TerrainVoxel).GetLandmarkTransform(MapLandmark.PowerPlant, powerPlant.Transformation, powerPlantFence.GetMesh().GetBounds());
            //powerPlant.Transformation.SetPosition(powerPlant.Transformation.GetPosition()-Vector3.Up*94);
            Vector3 pos = powerPlant.Transformation.GetPosition();
            Vector3 rot = powerPlant.Transformation.GetRotation();
            powerPlantTransform = powerPlant.Transformation;
            (switchA.GetInteractNode() as SwitchNode).SetInteractObject(switchA);
            (switchB.GetInteractNode() as SwitchNode).SetInteractObject(switchB);
            (switchC.GetInteractNode() as SwitchNode).SetInteractObject(switchC);
            (switchD.GetInteractNode() as SwitchNode).SetInteractObject(switchD);

            powerPlantFence.Transformation = powerPlant.Transformation;

            SafeTrigger campTrigger = new SafeTrigger();
            campTrigger.Transformation.SetPosition(powerPlantTransform.GetPosition());
            campTrigger.Transformation.SetScale(Vector3.One * 30);
            scene.AddEntity("SafeTrigger", campTrigger);

            switchA.Transformation.SetPosition(pos);
            switchA.Transformation.SetRotation(rot);

            switchB.Transformation.SetPosition(pos);
            switchB.Transformation.SetRotation(rot);

            switchC.Transformation.SetPosition(pos);
            switchC.Transformation.SetRotation(rot);

            switchD.Transformation.SetPosition(pos);
            switchD.Transformation.SetRotation(rot);

            AnimationNode[] nodes = powerPlantFence.GetMesh().GetNodes();
            Matrix worldMatrix = powerPlantFence.Transformation.GetTransform();
            //Vector3 meshCenter = 0.5f * (gasStation.GetMesh().GetBounds().Max + gasStation.GetMesh().GetBounds().Min);
            for (int i = 0; i < nodes.Length; i++)
            {
                if (nodes[i].Name == "DoorHinge")
                {
                    InteractObject door = new InteractObject(null, "PowerPlantDoor", true);
                    Vector3 doorPos = Vector3.Transform(nodes[i].Translation, worldMatrix);
                    door.Transformation.SetPosition(doorPos);
                    door.Transformation.SetRotation(powerPlantFence.Transformation.GetRotation());
                    door.SetInteractNode(new PowerPlantDoorNode(door, new Vector3(0, MathHelper.PiOver2, 0), Vector3.Zero));
                    scene.AddEntity("PowerPlantDoor", door);
                }
            }

            //switchA.interactNode.OnInteract();
            //switchD.interactNode.OnInteract();

            scene.AddEntity("PowerPlant", powerPlant);
            scene.AddEntity("PowerPlantFence", powerPlantFence);

            scene.AddEntity("SwitchA", switchA);
            scene.AddEntity("SwitchB", switchB);
            scene.AddEntity("SwitchC", switchC);
            scene.AddEntity("SwitchD", switchD);

            List<int> potentialPuzzles = new List<int>();
            for (int i = 0; i < (1 << 7); i++)
            {
                if (IsValidPuzzle(i))
                {
                    potentialPuzzles.Add(i);
                }
            }
            Puzzle = potentialPuzzles[RandomHelper.RandomGen.Next(potentialPuzzles.Count)];
            int randInput = RandomHelper.RandomGen.Next(16);
            while (AttemptPuzzle(Puzzle, randInput))
                randInput = RandomHelper.RandomGen.Next(16);
            IsEnabled = false;
            if ((randInput & 0x01) > 0)
                switchA.GetInteractNode().OnInteract();
            if ((randInput & 0x02) > 0)
                switchB.GetInteractNode().OnInteract();
            if ((randInput & 0x04) > 0)
                switchC.GetInteractNode().OnInteract();
            if ((randInput & 0x08) > 0)
                switchD.GetInteractNode().OnInteract();
            IsEnabled = true;
        }