public override void OnInteract() { base.OnInteract(); PlayerScreen playerScreen = PlayerScreen.GetInst(); if (playerScreen.HasFuel) { if (trex == null) { new Sound3D("PlaneEngine", scene.FindEntity("Plane").Transformation.GetPosition()); playerScreen.AddJournalEntry("It won't start. Search outside for a tool."); playerScreen.RemoveMarker(scene.FindEntity("Plane").Transformation); trex = (AnimatedModel)scene.FindEntity("TRex"); trex.SetVisible(true); trex.Model.GetAnimationLayer().SetActiveAnimation("TRexIdle", false); trexSound = new Sound3D("TRexIdle", trex.Transformation.GetPosition()); trexSound.Looped = true; //cameraLerpTime = -0.25f; } } else { playerScreen.AddJournalEntry("It's out of fuel. If only there were a gas station here."); if (!playerScreen.HasAlertedGasStation) { playerScreen.RemoveMarker(scene.FindEntity("Plane").Transformation); playerScreen.AddMarker(scene.FindEntity("GasStation").Transformation); playerScreen.HasAlertedGasStation = true; } } }
void CreateHangar() { Model hangar = new Model("Hangar"); (MainTerrain as TerrainVoxel).GetLandmarkTransform(MapLandmark.Hangar, hangar.Transformation, hangar.GetMesh().GetBounds()); AddEntity("Hangar", hangar); SafeTrigger campTrigger = new SafeTrigger(); campTrigger.Transformation.SetPosition(hangar.Transformation.GetPosition()); campTrigger.Transformation.SetScale(Vector3.One * 30); AddEntity("SafeTrigger", campTrigger); AnimationNode[] nodes = hangar.GetMesh().GetNodes(); Matrix worldMatrix = hangar.Transformation.GetTransform(); Vector3 rot = hangar.Transformation.GetRotation(); Vector3 camNodePos = Vector3.Zero; for (int i = 0; i < nodes.Length; i++) { Vector3 nodePos = Vector3.Transform(nodes[i].Translation, worldMatrix); switch (nodes[i].Name) { case "Plane": InteractObject plane = new InteractObject(new AirplaneNode(this), "Plane"); plane.Transformation.SetPosition(nodePos); plane.Transformation.SetRotation(rot); AddEntity("Plane", plane); break; case "Door": InteractObject door = new InteractObject(null, "HangarDoor", true); Vector3 dispVec = Vector3.TransformNormal(Vector3.Right, worldMatrix)*-4f; door.Transformation.SetPosition(nodePos); door.Transformation.SetRotation(rot); door.SetInteractNode(new HangarDoorNode(door, Vector3.Zero, dispVec)); AddEntity("HangarDoor", door); break; case "Garage": InteractObject garage = new InteractObject(null, "HangarGarage", true); garage.Transformation.SetPosition(nodePos); garage.Transformation.SetRotation(rot); garage.SetInteractNode(new HangarDoorNode(garage, new Vector3(0, 0, -MathHelper.PiOver2), Vector3.Zero)); AddEntity("HangarGarage", garage); break; case "DinoSpawn": AnimatedModel trex = new AnimatedModel("TRex"); trex.SetCulling(false); trex.Transformation.SetPosition(nodePos); trex.Model.GetAnimationLayer().SetActiveAnimation("TRexIdle", true);//.SetAnimationLayer("AlphaRaptorIdle", 1.0f); trex.Model.SetCustomMatrix(Matrix.CreateScale(0.1f) * Matrix.CreateRotationX(-MathHelper.PiOver2) * Matrix.CreateRotationY(-MathHelper.PiOver2)); //model.UpdateAnimation(); AddEntity("TRex", trex); trex.SetVisible(false); break; case "CameraNode": camNodePos = nodePos; break; } InteractObject tempPlane = (InteractObject)FindEntity("Plane"); AirplaneNode planeNode = (AirplaneNode)tempPlane.GetInteractNode(); planeNode.SetEndCameraPosition(camNodePos, Vector3.TransformNormal(Vector3.Forward, worldMatrix)); //InteractObject gasTank = new InteractObject(null, "GasTank"); //gasTank.SetInteractNode(new GasTankNode(gasTank)); } }
void InitializeScene() { ResetScene(); Entities.Add("Sky", new Sky()); MainLight = new Sunlight(); MainTerrain = new TerrainVoxel(); /* MainTerrain = new TerrainHeightmap("Textures/level1_hm.png", 0, 100.0f); float width = (MainTerrain as TerrainHeightmap).GetWidth(); float height = (MainTerrain as TerrainHeightmap).MaximumHeight; MainTerrain.Transformation.SetScale(new Vector3(1, height / width, 1) * width); */ MainPlayer = new Camera(); Entities.Add("MainCamera", MainPlayer); Entities.Add("Terrain", MainTerrain); Entities.Add("Light", MainLight); Entities.Add("Plane", new Model("Plane")); Entities.Add("AmbientLight", new Light(LightType.Ambient, new Vector3(0.15f, 0.35f, 0.55f), Vector3.Zero, false)); Entities.Add("TestTree", new Model("Palm02")); Entities["TestTree"].Transformation.SetPosition(Vector3.Forward * 10.0f); Entities.Add("TestTree2", new Model("JungleOverhang")); Entities["TestTree2"].Transformation.SetPosition(Vector3.Forward * 10.0f + Vector3.Right * 7.6f); //AddEntity("Grass", new GrassPlacement()); AddEntity("Forest", new ForestManager()); //CreateForest(); //Entities.Add("Grass", new ShapePlacement()); /* Model testGeom = new Model("test_level"); testGeom.Transformation.SetPosition(Vector3.Up*20.0f); Entities.Add("scene_geom1", testGeom); Model testGeom2 = new Model("cgWarehouse002story"); testGeom2.Transformation.SetPosition(Vector3.Up * 21.0f); Entities.Add("scene_geom2", testGeom2); */ AnimatedModel model = new AnimatedModel("Allosaurus"); model.Transformation.SetPosition(Vector3.Forward*10+Vector3.Up*68); model.Model.GetAnimationLayer().SetActiveAnimation("AllosaurusIdle", true);//.SetAnimationLayer("AllosaurusIdle", 1.0f); model.Model.SetCustomMatrix(Matrix.CreateScale(0.09f)*Matrix.CreateRotationX(-MathHelper.PiOver2)); //model.UpdateAnimation(); Entities.Add("TestCharacter", model); AnimatedModel model2 = new AnimatedModel("AlphaRaptor"); model2.Transformation.SetPosition(Vector3.Forward * -5 + Vector3.Up * 62); model2.Model.GetAnimationLayer().SetActiveAnimation("AlphaRaptorIdle", true);//.SetAnimationLayer("AlphaRaptorIdle", 1.0f); model2.Model.SetCustomMatrix(Matrix.CreateScale(0.12f) * Matrix.CreateRotationX(-MathHelper.PiOver2)); //model.UpdateAnimation(); Entities.Add("TestCharacter2", model2); Raptor raptor = new Raptor(ResourceManager.Inst.GetDinosaurDatablock("Coelophysis")); Entities.Add("Raptor", raptor); Chest weaponCrate = new Chest("Weapon Box", "WeaponBox"); weaponCrate.Transformation.SetPosition(Vector3.Up * 30.0f); Entities.Add("weaponCrate", weaponCrate); CreateTeams(); //Entities.Add("Light2", new Light(LightType.Directional, new Vector3(0.2797f, 0.344f, 0.43f), Vector3.Up, false)); Initialize(); }