public ItemLibrary(String filename) { int counter = 0; string line; items = new List<Item>(); itemMap = new Dictionary<string, Item>(); ModelLoader loader = new ModelLoader(); // Read the file and display it line by line. System.IO.StreamReader file = new System.IO.StreamReader(filename); while ((line = file.ReadLine()) != null) { //Allow comments in config file if (line.StartsWith("#")) continue; string[] tokens=line.Split(','); Console.WriteLine("Loading: "+tokens[Item.NAME]); /* Model m = (Model)loader.Load("", tokens[Item.NAME]); Material defaultMaterial = new Material(); defaultMaterial.Diffuse = new Vector4(0, 0.5f, 0, 1); defaultMaterial.Specular = Color.White.ToVector4(); defaultMaterial.SpecularPower = 10; Item item = new Item(m, tokens[Item.NAME], defaultMaterial); */ Item item = new Item(tokens); //item.Scale = new Vector3(float.Parse(tokens[Item.SCALE])); items.Add(item); itemMap.Add(tokens[Item.NAME], item); counter++; } file.Close(); }
/// <summary> /// To initializa external Components like GoblinsXna /// </summary> protected override void Initialize() { int idx; //Init Console Console.WriteLine("CarGame AR: " + Version()); Console.WriteLine(DateTime.Now.ToString() + " Loading game\n"); // To initialize Xna base.Initialize(); // Initialize the GoblinXNA framework State.InitGoblin(graphics, Content, ""); // Initialize the scene graph scene = new Scene(); /********* Init Content from Game *********/ //Instantiate the Markers HinderMarkeNodes = new MarkerNode[Max_Markers]; WeaponMarkeNodes = new MarkerNode[Max_palyer]; //One Weapon for Player //Instantiate Models Console.WriteLine(DateTime.Now.ToString() + " Loading Car´s Models\n"); CarModels = new GeometryNode[Max_Models]; ModelLoader loader = new ModelLoader(); for (idx = 0; idx < Max_Models; idx++) { CarModels[idx] = new GeometryNode("CarModel" + idx.ToString()); CarModels[idx].Model = (Model)loader.Load("Models", ModelsName[idx]); ((Model)CarModels[idx].Model).UseInternalMaterials = true; } //Instantiate the Logic Game GameLogic = new Game_Logic(Max_palyer); //Create Obj for Cars CarObjPhy = new RaceCar[Max_palyer]; //Instancio los Obj de los obstaculos ObstModels = new GeometryNode[Max_Markers]; //Instantiate the 2DManager My2Dmanager = new My2DSpriteManager(GameLogic); My2Dmanager.LoadContent(); //Load SoundEffects GameLogic.SoundGame.SoundLoad(); /******************************************/ // Use the newton physics engine scene.PhysicsEngine = new NewtonPhysics(); //Config Physics SetupPhysics(); #if USE_SOCKET_NETWORK //Init Network State.EnableNetworking = true; State.IsServer = true; ConfigServer(14242); #endif State.ThreadOption = (ushort)ThreadOptions.MarkerTracking; // Setup and Create optical marker tracking SetupMarkerTracking(); CreateMarkerTracking(); // Enable shadow mapping scene.ShadowMap = new MultiLightShadowMap(); //Instantiate the 3DManager Manager3D = new Graphics3D(groundMarkerNode, scene.ShadowMap); //Config Callbacks for Collitions ConfigCallBacks(); // Set up the lights used in the scene CreateLights(); // Create 3D objects CreateObjects(); // Show Frames-Per-Second on the screen for debugging State.ShowFPS = true; //State.ShowTriangleCount = true; //State.ShowNotifications = true; // Make the debugging message fade out after 3000 ms (3 seconds) Notifier.FadeOutTime = 1000; Console.WriteLine(DateTime.Now.ToString() + " End Loading\n"); //Server ServidorAr = new ARServer(GameLogic); ServidorAr.CallBackAddPlayer = AgregaPlayer; #if INIT_SERVER ServidorAr.StartServer(); //Add Ip Address My2Dmanager.ServerIp = ServidorAr.SetLocalIp(); #endif //Config Controls ConfigControls(); if (CtrlPlayers[0] == Ctrl_Player.KEYBOARD) ServidorAr.AddPlayerOne(); #if USR_DEBUG //GameLogic.CurrentGameState = Game_Logic.Game_States.SEL_PLY; //GameLogic.StateScreen = Game_Logic.Game_SCR.GAME_LOADING; //GameLogic.AddPlayer("Player 2", 2); //GameLogic.Players[1].IsPlyOK = true; //GameLogic.Players[1].PlySelect = 7; //GameLogic.Players[1].IsDead = true; //GameLogic.AddPlayer("Player 3", 3); //GameLogic.AddPlayer("Player 4", 4); #endif }
/********************* Helpers **********************/ public static GeometryNode LoadModel(string DirModel, string Modelname, bool InternalMaterial) { GeometryNode MyNode = new GeometryNode(Modelname); //Intento cargar un modelo ModelLoader loader = new ModelLoader(); MyNode.Physics.Mass = 20; MyNode.Physics.Shape = ShapeType.ConvexHull; MyNode.Physics.MaterialName = Modelname; MyNode.Physics.ApplyGravity = true; //Debo probar mas esta propiedad MyNode.Physics.NeverDeactivate = true; MyNode.AddToPhysicsEngine = true; //Load Model MyNode.Model = (Model)loader.Load(DirModel, Modelname); //Define Material if (InternalMaterial) { ((Model)MyNode.Model).UseInternalMaterials = true; } else { // Create a material for the Model Material ModelMat = new Material(); ModelMat.Diffuse = Color.Blue.ToVector4(); ModelMat.Specular = Color.White.ToVector4(); ModelMat.SpecularPower = 20; //Add Material MyNode.Material = ModelMat; } return MyNode; }
private void CreateObject() { // Loads a textured model of a ship ModelLoader loader = new ModelLoader(); Model shipModel = (Model)loader.Load("", "p1_wedge"); // Create a geometry node of a loaded ship model GeometryNode shipNode = new GeometryNode("Ship"); shipNode.Model = shipModel; ((Model)shipNode.Model).UseInternalMaterials = true; // Create a transform node to define the transformation for the ship TransformNode shipTransNode = new TransformNode(); shipTransNode.Translation = new Vector3(0, 0, -50); shipTransNode.Scale = new Vector3(0.01f, 0.01f, 0.01f); // It's huge! shipTransNode.Rotation = Quaternion.CreateFromAxisAngle(new Vector3(0, 1, 0), MathHelper.ToRadians(90)); shipTransParentNode = new TransformNode(); shipTransParentNode.Translation = Vector3.Zero; // Create a geometry node with model of a torus GeometryNode torusNode = new GeometryNode("Torus"); torusNode.Model = new Torus(12f, 15.5f, 20, 20); TransformNode torusTransNode = new TransformNode(); torusTransNode.Translation = new Vector3(-50, 0, 0); torusTransNode.Rotation = Quaternion.CreateFromAxisAngle(Vector3.UnitX, MathHelper.ToRadians(90)); // Create a material node for this torus model Material torusMaterial = new Material(); torusMaterial.Diffuse = Color.DarkGoldenrod.ToVector4(); torusMaterial.Specular = Color.White.ToVector4(); torusMaterial.SpecularPower = 5; torusNode.Material = torusMaterial; // Now add the above nodes to the scene graph in appropriate order scene.RootNode.AddChild(shipTransParentNode); shipTransParentNode.AddChild(shipTransNode); shipTransNode.AddChild(shipNode); scene.RootNode.AddChild(torusTransNode); torusTransNode.AddChild(torusNode); // Now create couple of particle effects to attach to the models // Create a smoke particle effect and fire particle effect to simulate a // ring of fire around the torus model #if WINDOWS_PHONE SmokePlumeParticleEffect smokeParticles = new SmokePlumeParticleEffect(20, spriteBatch); FireParticleEffect fireParticles = new FireParticleEffect(40, spriteBatch); #else SmokePlumeParticleEffect smokeParticles = new SmokePlumeParticleEffect(); FireParticleEffect fireParticles = new FireParticleEffect(); // The order defines which particle effect to render first. Since we want // to show the fire particles in front of the smoke particles, we make // the smoke particles to be rendered first, and then fire particles smokeParticles.DrawOrder = 200; fireParticles.DrawOrder = 300; #endif // Create a particle node to hold these two particle effects ParticleNode fireRingEffectNode = new ParticleNode(); fireRingEffectNode.ParticleEffects.Add(smokeParticles); fireRingEffectNode.ParticleEffects.Add(fireParticles); // Implement an update handler for each of the particle effects which will be called // every "Update" call fireRingEffectNode.UpdateHandler += new ParticleUpdateHandler(UpdateRingOfFire); torusNode.AddChild(fireRingEffectNode); // Create another set of fire and smoke particle effects to simulate the fire // the ship catches when the ship passes the ring of fire #if WINDOWS_PHONE FireParticleEffect shipFireEffect = new FireParticleEffect(150, spriteBatch); SmokePlumeParticleEffect shipSmokeEffect = new SmokePlumeParticleEffect(80, spriteBatch); shipFireEffect.MinScale *= 1.5f; shipFireEffect.MaxScale *= 1.5f; #else FireParticleEffect shipFireEffect = new FireParticleEffect(); SmokePlumeParticleEffect shipSmokeEffect = new SmokePlumeParticleEffect(); shipSmokeEffect.DrawOrder = 400; shipFireEffect.DrawOrder = 500; #endif ParticleNode shipFireNode = new ParticleNode(); shipFireNode.ParticleEffects.Add(shipFireEffect); shipFireNode.ParticleEffects.Add(shipSmokeEffect); shipFireNode.UpdateHandler += new ParticleUpdateHandler(UpdateShipFire); shipNode.AddChild(shipFireNode); }
private void CreateObjects() { // Loads a textured model of a ship ModelLoader loader = new ModelLoader(); Model shipModel = (Model)loader.Load("", "p1_wedge"); // Create a geometry node of a loaded ship model GeometryNode shipNode = new GeometryNode("Ship"); shipNode.Model = shipModel; // This ship model has material definitions in the model file, so instead // of creating a material node for this ship model, we simply use its internal materials ((Model)shipNode.Model).UseInternalMaterials = true; ((Model)shipNode.Model).ContainsTransparency = true; // Create a transform node to define the transformation for the ship TransformNode shipTransNode = new TransformNode(); // shipTransNode.Translation = new Vector3(0, 5, -12); shipTransNode.Scale = new Vector3(0.002f, 0.002f, 0.002f); // It's huge! shipTransNode.Rotation = Quaternion.CreateFromAxisAngle(new Vector3(0, 1, 0), MathHelper.ToRadians(-90)); shipTransParentNode = new TransformNode(); //Set our rotation animation to ease in initially animationRotation = new AnimationHelper(Easing.EaseIn); startPosition = new Vector3(-10, 0, -10); endPosition = new Vector3(5, 2, -5); startRotationVector = new Vector3(0, 0, 0); endRotationVector = new Vector3(MathHelper.ToRadians(0), MathHelper.ToRadians(180), MathHelper.ToRadians(180)); //Set our translation animation to ease in initially animationTranslation = new AnimationHelper(Easing.EaseIn); //Define what kind of interpolation to use. animationTranslation.Animate(arrayOfTransitions[currentInterpolation], startPosition, endPosition, 2); // animationTranslation.SetLooping(true, 5); // Use if you want to loop through an animation. // Set an action to take place once the animation concludes. animationTranslation.SetEndAction(delegate() { animationRotation.Animate(arrayOfTransitions[currentInterpolation], startRotationVector, endRotationVector, 2.0); }); // Note: if you loop and set this animation, it'll occur after the end of the first loop, not after the end of all loops! textToPrint = "Linear interpolation"; // Now add the above nodes to the scene graph in appropriate order scene.RootNode.AddChild(shipTransParentNode); shipTransParentNode.AddChild(shipTransNode); shipTransNode.AddChild(shipNode); }
private void CreateObject() { // Loads a textured model of a ship ModelLoader loader = new ModelLoader(); Model shipModel = (Model)loader.Load("", "p1_wedge"); // Create a geometry node of a loaded ship model GeometryNode shipNode = new GeometryNode("Ship"); shipNode.Model = shipModel; // This ship model has material definitions in the model file, so instead // of creating a material node for this ship model, we simply use its internal materials shipNode.Model.UseInternalMaterials = true; // Create a transform node to define the transformation for the ship shipTransNode = new TransformNode(); shipTransNode.Translation = new Vector3(0, 0, 0); shipTransNode.Scale = new Vector3(0.002f, 0.002f, 0.002f); // It's huge! shipTransNode.Rotation = Quaternion.CreateFromAxisAngle(new Vector3(1, 0, 0), MathHelper.ToRadians(0)); scene.RootNode.AddChild(shipTransNode); shipTransNode.AddChild(shipNode); }
/// <summary> /// Create the different types of ships available in the game /// </summary> private void CreateShips() { AvailableShips = new List<Ship>(); Ship sailBoat = new Ship(); sailBoat.Ammo = 0; sailBoat.Armour = 0; sailBoat.Boat_Name = "Fighter"; sailBoat.Health = 100; sailBoat.Speed = 0; sailBoat.Position = Vector3.Zero; ModelLoader loader = new ModelLoader(); sailBoat.Player_Ship_Model = (Model)loader.Load("Models//", "fighter"); missileModel = (Model)loader.Load("Models//", "missile"); AvailableShips.Add(sailBoat); }
public static RaceCar AddRaceCarOld(Scene scene, TransformNode parentTrans, Vector3 CarPos, Vector4 CarColor, CarType_Enum CType) { TransformNode transNode = new TransformNode(); //transNode.Scale = new Vector3(2.8f, 2.8f, 2.8f); transNode.Translation = CarPos; Material carMat = new Material(); carMat.Diffuse = CarColor; carMat.Specular = Color.White.ToVector4(); carMat.SpecularPower = 10; GeometryNode carNode = new GeometryNode("Race Car"); //Intento cargar un modelo ModelLoader loader = new ModelLoader(); //Cargo el modelo Dependiendo del tipo switch (CType) { case CarType_Enum.Basic: carNode.Model = new Box(3, 1.0f, 2); carNode.Material = carMat; break; case CarType_Enum.Ferrary: carNode.Model = (Model)loader.Load("Models", "ferrari"); ((Model)carNode.Model).UseInternalMaterials = true; break; case CarType_Enum.Tank: carNode.Model = (Model)loader.Load("Models", "Osirian_Battle_Tank"); ((Model)carNode.Model).UseInternalMaterials = true; break; default: carNode.Model = new Box(3, 1.0f, 2); carNode.Material = carMat; break; } carNode.Model.ShadowAttribute = ShadowAttribute.ReceiveCast; NewtonPhysics physicsEngine = (NewtonPhysics)scene.PhysicsEngine; RaceCar car = new RaceCar(carNode, physicsEngine); for (int i = 0; i < 4; i++) car.Tires[i] = CreateTire((TireID)Enum.ToObject(typeof(TireID), i), car.TireTransformNode[i], carNode, scene.PhysicsEngine.Gravity); car.Collidable = true; car.Interactable = true; car.StartPos = CarPos; carNode.Physics = car; carNode.Physics.NeverDeactivate = true; carNode.AddToPhysicsEngine = true; parentTrans.AddChild(transNode); transNode.AddChild(carNode); Newton.NewtonSetBodyLeaveWorldEvent(physicsEngine.NewtonWorld, car.LeaveWorldCallback); return car; }
private void markerHelper(GameTime gameTime) { if (rotationFlag) { if (rotationDirection == "Clockwise") { if (label == "Humvee") { if (rotationAxis == "x-axis") humveeX = (float) rotationSpeed * (float)0.01; if (rotationAxis == "y-axis") humveeY = (float) rotationSpeed * (float)0.01; if (rotationAxis == "z-axis") humveeZ = (float) rotationSpeed * (float)0.01; humveeRotation = humveeRotation * Matrix.CreateFromAxisAngle(new Vector3(1, 0, 0), humveeX) * Matrix.CreateFromAxisAngle(new Vector3(0, 1, 0), humveeY) * Matrix.CreateFromAxisAngle(new Vector3(0, 0, 1), humveeZ); } else if (label == "Gears") { if (rotationAxis == "x-axis") gearsX = (float) rotationSpeed * (float)0.01; if (rotationAxis == "y-axis") gearsY = (float) rotationSpeed * (float)0.01; if (rotationAxis == "z-axis") gearsZ = (float) rotationSpeed * (float)0.01; gearsRotation = gearsRotation * Matrix.CreateFromAxisAngle(new Vector3(1, 0, 0), gearsX) * Matrix.CreateFromAxisAngle(new Vector3(0, 1, 0), gearsY) * Matrix.CreateFromAxisAngle(new Vector3(0, 0, 1), gearsZ); } else if (label == "Cup") { if (rotationAxis == "x-axis") cupX = (float) rotationSpeed * (float)0.01; if (rotationAxis == "y-axis") cupY = (float) rotationSpeed * (float)0.01; if (rotationAxis == "z-axis") cupZ = (float) rotationSpeed * (float)0.01; cupRotation = cupRotation * Matrix.CreateFromAxisAngle(new Vector3(1, 0, 0), cupX) * Matrix.CreateFromAxisAngle(new Vector3(0, 1, 0), cupY) * Matrix.CreateFromAxisAngle(new Vector3(0, 0, 1), cupZ); } else if (label == "G36C Gun") { if (rotationAxis == "x-axis") g36cX = (float) rotationSpeed * (float)0.01; if (rotationAxis == "y-axis") g36cY = (float) rotationSpeed * (float)0.01; if (rotationAxis == "z-axis") g36cZ = (float) rotationSpeed * (float)0.01; g36cRotation = g36cRotation * Matrix.CreateFromAxisAngle(new Vector3(1, 0, 0), g36cX) * Matrix.CreateFromAxisAngle(new Vector3(0, 1, 0), g36cY) * Matrix.CreateFromAxisAngle(new Vector3(0, 0, 1), g36cZ); } } if (rotationDirection == "Counterclockwise") { if (label == "Humvee") { if (rotationAxis == "x-axis") humveeX = rotationSpeed * (float) -0.01; if (rotationAxis == "y-axis") humveeY = rotationSpeed * (float) -0.01; if (rotationAxis == "z-axis") humveeZ = rotationSpeed * (float) -0.01; humveeRotation = humveeRotation * Matrix.CreateFromAxisAngle(new Vector3(1, 0, 0), humveeX) * Matrix.CreateFromAxisAngle(new Vector3(0, 1, 0), humveeY) * Matrix.CreateFromAxisAngle(new Vector3(0, 0, 1), humveeZ); } else if (label == "Gears") { if (rotationAxis == "x-axis") gearsX = rotationSpeed * (float) -0.01; if (rotationAxis == "y-axis") gearsY = rotationSpeed * (float) -0.01; if (rotationAxis == "z-axis") gearsZ = rotationSpeed * (float) -0.01; gearsRotation = gearsRotation * Matrix.CreateFromAxisAngle(new Vector3(1, 0, 0), gearsX) * Matrix.CreateFromAxisAngle(new Vector3(0, 1, 0), gearsY) * Matrix.CreateFromAxisAngle(new Vector3(0, 0, 1), gearsZ); } else if (label == "Cup") { if (rotationAxis == "x-axis") cupX = rotationSpeed * (float) -0.01; if (rotationAxis == "y-axis") cupY = rotationSpeed * (float) -0.01; if (rotationAxis == "z-axis") cupZ = rotationSpeed * (float) -0.01; cupRotation = cupRotation * Matrix.CreateFromAxisAngle(new Vector3(1, 0, 0), cupX) * Matrix.CreateFromAxisAngle(new Vector3(0, 1, 0), cupY) * Matrix.CreateFromAxisAngle(new Vector3(0, 0, 1), cupZ); } else if (label == "G36C Gun") { if (rotationAxis == "x-axis") g36cX = rotationSpeed * (float) -0.01; if (rotationAxis == "y-axis") g36cY = rotationSpeed * (float) -0.01; if (rotationAxis == "z-axis") g36cZ = rotationSpeed * (float) -0.01; g36cRotation = g36cRotation * Matrix.CreateFromAxisAngle(new Vector3(1, 0, 0), g36cX) * Matrix.CreateFromAxisAngle(new Vector3(0, 1, 0), g36cY) * Matrix.CreateFromAxisAngle(new Vector3(0, 0, 1), g36cZ); } } } if (scaleFlag) { if (groundMarkerNode.MarkerFound) { if (toolbarMarkerNode.MarkerFound) { if (label == "Humvee") { if (toolbarMarkerNode.WorldTransformation.Translation.Y > 0) humveeSize = toolbarMarkerNode.WorldTransformation.Translation.Y * (float)0.01; ((NewtonPhysics)scene.PhysicsEngine).SetTransform(humvee.Physics, Matrix.CreateScale(humveeSize) * humveeRotation * humveeTrans * humveeMatrix); } if (label == "Gears") { if (toolbarMarkerNode.WorldTransformation.Translation.Y > 0) gearsSize = toolbarMarkerNode.WorldTransformation.Translation.Y * (float)0.01; ((NewtonPhysics)scene.PhysicsEngine).SetTransform(gears.Physics, Matrix.CreateScale(gearsSize) * gearsRotation * gearsTrans * gearsMatrix); } if (label == "Cup") { if (toolbarMarkerNode.WorldTransformation.Translation.Y > 0) cupSize = toolbarMarkerNode.WorldTransformation.Translation.Y * (float)0.01; ((NewtonPhysics)scene.PhysicsEngine).SetTransform(cup.Physics, Matrix.CreateScale(cupSize) * cupRotation * cupTrans * cupMatrix); } if (label == "G36C Gun") { if (toolbarMarkerNode.WorldTransformation.Translation.Y > 0) g36cSize = toolbarMarkerNode.WorldTransformation.Translation.Y * (float)0.01; ((NewtonPhysics)scene.PhysicsEngine).SetTransform(g36c.Physics, Matrix.CreateScale(g36cSize) * g36cRotation * g36cTrans * g36cMatrix); } } } } if (rotationObjectFlag) { if (groundMarkerNode.MarkerFound) { if (toolbarMarkerNode.MarkerFound) { if (label == "Humvee") { humveeRotation = Matrix.CreateFromAxisAngle(new Vector3(1, 0, 0), MathHelper.ToRadians(toolbarMarkerNode.WorldTransformation.Translation.Y * 6)) * Matrix.CreateFromAxisAngle(new Vector3(0, 1, 0), MathHelper.ToRadians(toolbarMarkerNode.WorldTransformation.Translation.Z * 6)) * Matrix.CreateFromAxisAngle(new Vector3(0, 0, 1), MathHelper.ToRadians(toolbarMarkerNode.WorldTransformation.Translation.X * 6)); ((NewtonPhysics)scene.PhysicsEngine).SetTransform(humvee.Physics, Matrix.CreateScale(humveeSize) * humveeRotation * humveeTrans * humveeMatrix); } if (label == "Gears") { gearsRotation = Matrix.CreateFromAxisAngle(new Vector3(1, 0, 0), MathHelper.ToRadians(toolbarMarkerNode.WorldTransformation.Translation.Y * 6)) * Matrix.CreateFromAxisAngle(new Vector3(0, 1, 0), MathHelper.ToRadians(toolbarMarkerNode.WorldTransformation.Translation.Z * 6)) * Matrix.CreateFromAxisAngle(new Vector3(0, 0, 1), MathHelper.ToRadians(toolbarMarkerNode.WorldTransformation.Translation.X * 6)); ((NewtonPhysics)scene.PhysicsEngine).SetTransform(gears.Physics, Matrix.CreateScale(gearsSize) * gearsRotation * gearsTrans * gearsMatrix); } if (label == "Cup") { cupRotation = Matrix.CreateFromAxisAngle(new Vector3(1, 0, 0), MathHelper.ToRadians(toolbarMarkerNode.WorldTransformation.Translation.Y * 6)) * Matrix.CreateFromAxisAngle(new Vector3(0, 1, 0), MathHelper.ToRadians(toolbarMarkerNode.WorldTransformation.Translation.Z * 6)) * Matrix.CreateFromAxisAngle(new Vector3(0, 0, 1), MathHelper.ToRadians(toolbarMarkerNode.WorldTransformation.Translation.X * 6)); ((NewtonPhysics)scene.PhysicsEngine).SetTransform(cup.Physics, Matrix.CreateScale(cupSize) * cupRotation * cupTrans * cupMatrix); } if (label == "G36C Gun") { g36cRotation = Matrix.CreateFromAxisAngle(new Vector3(1, 0, 0), MathHelper.ToRadians(toolbarMarkerNode.WorldTransformation.Translation.Y * 6)) * Matrix.CreateFromAxisAngle(new Vector3(0, 1, 0), MathHelper.ToRadians(toolbarMarkerNode.WorldTransformation.Translation.Z * 6)) * Matrix.CreateFromAxisAngle(new Vector3(0, 0, 1), MathHelper.ToRadians(toolbarMarkerNode.WorldTransformation.Translation.X * 6)); ((NewtonPhysics)scene.PhysicsEngine).SetTransform(g36c.Physics, Matrix.CreateScale(g36cSize) * g36cRotation * g36cTrans * g36cMatrix); } } } } if (translationModeFlag) { // If ground marker array is detected if (groundMarkerNode.MarkerFound) { if (toolbarMarkerNode.MarkerFound) { if (label == "Humvee") { humveeMatrix = Matrix.CreateTranslation(toolbarMarkerNode.WorldTransformation.Translation) * Matrix.Invert(groundMarkerNode.WorldTransformation); // Modify the transformation in the physics engine ((NewtonPhysics)scene.PhysicsEngine).SetTransform(humvee.Physics, Matrix.CreateScale(humveeSize) * humveeRotation * humveeTrans * humveeMatrix); } if (label == "Gears") { gearsMatrix = Matrix.CreateTranslation(toolbarMarkerNode.WorldTransformation.Translation) * Matrix.Invert(groundMarkerNode.WorldTransformation); // Modify the transformation in the physics engine ((NewtonPhysics)scene.PhysicsEngine).SetTransform(gears.Physics, Matrix.CreateScale(gearsSize) * gearsRotation * gearsTrans * gearsMatrix); } if (label == "Cup") { cupMatrix = Matrix.CreateTranslation(toolbarMarkerNode.WorldTransformation.Translation) * Matrix.Invert(groundMarkerNode.WorldTransformation); // Modify the transformation in the physics engine ((NewtonPhysics)scene.PhysicsEngine).SetTransform(cup.Physics, Matrix.CreateScale(cupSize) * cupRotation * cupTrans * cupMatrix); } if (label == "G36C Gun") { g36cMatrix = Matrix.CreateTranslation(toolbarMarkerNode.WorldTransformation.Translation) * Matrix.Invert(groundMarkerNode.WorldTransformation); // Modify the transformation in the physics engine ((NewtonPhysics)scene.PhysicsEngine).SetTransform(g36c.Physics, Matrix.CreateScale(g36cSize) * g36cRotation * g36cTrans * g36cMatrix); } } } } else if (translationModeFlag == false || label == "Nothing is selected") { // If ground marker array is detected if (groundMarkerNode.MarkerFound) { if (resetFlag == true) { UI2DRenderer.WriteText(Vector2.Zero, "System has been reset", Color.Red, textFont1, GoblinEnums.HorizontalAlignment.Right, GoblinEnums.VerticalAlignment.Top); } if (label == "Humvee" || label == "Gears" || label == "Cup" || label == "G36C Gun") if (panelTrigger) objectFrame.Visible = true; // If the toolbar marker array is detected if (toolbarMarkerNode.MarkerFound) { if (collusionflag == false) { // Create collision pair1 and add a collision callback function that will be called when the pair collides NewtonPhysics.CollisionPair pair1 = new NewtonPhysics.CollisionPair(humvee.Physics, pointingMarker.Physics); ((NewtonPhysics)scene.PhysicsEngine).AddCollisionCallback(pair1, humveeCollision); // Create collision pair2 and add a collision callback function that will be called when the pair collides NewtonPhysics.CollisionPair pair2 = new NewtonPhysics.CollisionPair(gears.Physics, pointingMarker.Physics); ((NewtonPhysics)scene.PhysicsEngine).AddCollisionCallback(pair2, gearsCollision); // Create collision pair3 and add a collision callback function that will be called when the pair collides NewtonPhysics.CollisionPair pair3 = new NewtonPhysics.CollisionPair(cup.Physics, pointingMarker.Physics); ((NewtonPhysics)scene.PhysicsEngine).AddCollisionCallback(pair3, cupCollision); // Create collision pair4 and add a collision callback function that will be called when the pair collides NewtonPhysics.CollisionPair pair4 = new NewtonPhysics.CollisionPair(g36c.Physics, pointingMarker.Physics); ((NewtonPhysics)scene.PhysicsEngine).AddCollisionCallback(pair4, g36cCollision); collusionflag = true; } if (rotationObjectFlag) { ((NewtonPhysics)scene.PhysicsEngine).SetTransform(pointingMarker.Physics, Matrix.CreateTranslation(-200, -200, -200)); pointingMarker.Material.Diffuse = new Vector4(pointingMarker.Material.Diffuse.X, pointingMarker.Material.Diffuse.Y, pointingMarker.Material.Diffuse.Z, 0); } else if (scaleFlag) { ((NewtonPhysics)scene.PhysicsEngine).SetTransform(pointingMarker.Physics, Matrix.CreateTranslation(-200, -200, -200)); pointingMarker.Material.Diffuse = new Vector4(pointingMarker.Material.Diffuse.X, pointingMarker.Material.Diffuse.Y, pointingMarker.Material.Diffuse.Z, 0); } else { pointingMarker.Material.Diffuse = new Vector4(pointingMarker.Material.Diffuse.X, pointingMarker.Material.Diffuse.Y, pointingMarker.Material.Diffuse.Z, 0.6f); Matrix markerMatrix = Matrix.CreateScale((float)0.4) * toolbarMarkerNode.WorldTransformation * Matrix.Invert(groundMarkerNode.WorldTransformation); // Modify the transformation in the physics engine ((NewtonPhysics)scene.PhysicsEngine).SetTransform(pointingMarker.Physics, markerMatrix); } } else { ((NewtonPhysics)scene.PhysicsEngine).SetTransform(pointingMarker.Physics, Matrix.CreateTranslation(-400, -400, -400)); pointingMarker.Material.Diffuse = new Vector4(pointingMarker.Material.Diffuse.X, pointingMarker.Material.Diffuse.Y, pointingMarker.Material.Diffuse.Z, 0); } ((NewtonPhysics)scene.PhysicsEngine).SetTransform(humvee.Physics, Matrix.CreateScale(humveeSize) * humveeRotation * humveeTrans * humveeMatrix); ((NewtonPhysics)scene.PhysicsEngine).SetTransform(gears.Physics, Matrix.CreateScale(gearsSize) * gearsRotation * gearsTrans * gearsMatrix); ((NewtonPhysics)scene.PhysicsEngine).SetTransform(cup.Physics, Matrix.CreateScale(cupSize) * cupRotation * cupTrans * cupMatrix); ((NewtonPhysics)scene.PhysicsEngine).SetTransform(g36c.Physics, Matrix.CreateScale(g36cSize) * g36cRotation * g36cTrans * g36cMatrix); } else { objectFrame.Visible = false; } } if (groundMarkerNode.MarkerFound == true && toolbarMarkerNode.MarkerFound == true && transferFlag == true) { pointingMarker.Material.Diffuse = new Vector4(pointingMarker.Material.Diffuse.X, pointingMarker.Material.Diffuse.Y, pointingMarker.Material.Diffuse.Z, 0); if (label == "Humvee") { if (humveeflag == false) { groundMarkerNode.RemoveChild(humvee); toolbarMarkerNode.AddChild(humvee); humveeflag = true; } } if (label == "Gears") { if (gearsflag == false) { groundMarkerNode.RemoveChild(gears); toolbarMarkerNode.AddChild(gears); gearsflag = true; } } if (label == "Cup") { if (cupflag == false) { groundMarkerNode.RemoveChild(cup); toolbarMarkerNode.AddChild(cup); cupflag = true; } } if (label == "G36C Gun") { if (g36cflag == false) { groundMarkerNode.RemoveChild(g36c); toolbarMarkerNode.AddChild(g36c); g36cflag = true; } } } if (groundMarkerNode.MarkerFound == true && toolbarMarkerNode.MarkerFound == false && transferFlag == true) { if (humveeflag == true) { toolbarMarkerNode.RemoveChild(humvee); // Create humvee model. ModelLoader loader = new ModelLoader(); humvee = new GeometryNode("Humvee"); humvee.Model = (Model)loader.Load("", "humvee"); // Add this humvee model to the physics engine for collision detection humvee.AddToPhysicsEngine = true; humvee.Physics.Shape = ShapeType.ConvexHull; // Set model materials. ((Model)humvee.Model).UseInternalMaterials = true; // Create collision pair1 and add a collision callback function that will be called when the pair collides NewtonPhysics.CollisionPair pair1 = new NewtonPhysics.CollisionPair(humvee.Physics, pointingMarker.Physics); ((NewtonPhysics)scene.PhysicsEngine).AddCollisionCallback(pair1, humveeCollision); ((Model)humvee.Model).ShowBoundingBox = true; groundMarkerNode.AddChild(humvee); humveeflag = false; } if (gearsflag == true) { toolbarMarkerNode.RemoveChild(gears); // Create humvee model. ModelLoader loader = new ModelLoader(); // Create gears model. gears = new GeometryNode("Gears"); gears.Model = (Model)loader.Load("", "gears"); // Add this gears model to the physics engine for collision detection gears.AddToPhysicsEngine = true; gears.Physics.Shape = ShapeType.ConvexHull; // Set model materials. ((Model)gears.Model).UseInternalMaterials = true; // Create collision pair2 and add a collision callback function that will be called when the pair collides NewtonPhysics.CollisionPair pair2 = new NewtonPhysics.CollisionPair(gears.Physics, pointingMarker.Physics); ((NewtonPhysics)scene.PhysicsEngine).AddCollisionCallback(pair2, gearsCollision); ((Model)gears.Model).ShowBoundingBox = true; groundMarkerNode.AddChild(gears); gearsflag = false; } if (cupflag == true) { toolbarMarkerNode.RemoveChild(cup); // Create humvee model. ModelLoader loader = new ModelLoader(); // Create cup model. cup = new GeometryNode("Cup"); cup.Model = (Model)loader.Load("", "bardak"); // Add this cup model to the physics engine for collision detection cup.AddToPhysicsEngine = true; cup.Physics.Shape = ShapeType.ConvexHull; // Set model materials. ((Model)cup.Model).UseInternalMaterials = true; // Create collision pair3 and add a collision callback function that will be called when the pair collides NewtonPhysics.CollisionPair pair3 = new NewtonPhysics.CollisionPair(cup.Physics, pointingMarker.Physics); ((NewtonPhysics)scene.PhysicsEngine).AddCollisionCallback(pair3, cupCollision); ((Model)cup.Model).ShowBoundingBox = true; groundMarkerNode.AddChild(cup); cupflag = false; } if (g36cflag == true) { toolbarMarkerNode.RemoveChild(g36c); // Create humvee model. ModelLoader loader = new ModelLoader(); // Create g36c model. g36c = new GeometryNode("G36C Gun"); g36c.Model = (Model)loader.Load("", "g36c"); // Add this g36c model to the physics engine for collision detection g36c.AddToPhysicsEngine = true; g36c.Physics.Shape = ShapeType.ConvexHull; // Set model materials. ((Model)g36c.Model).UseInternalMaterials = true; // Create collision pair4 and add a collision callback function that will be called when the pair collides NewtonPhysics.CollisionPair pair4 = new NewtonPhysics.CollisionPair(g36c.Physics, pointingMarker.Physics); ((NewtonPhysics)scene.PhysicsEngine).AddCollisionCallback(pair4, g36cCollision); ((Model)g36c.Model).ShowBoundingBox = true; groundMarkerNode.AddChild(g36c); g36cflag = false; } } }
private void CreateObjects() { // Create humvee model. ModelLoader loader = new ModelLoader(); humvee = new GeometryNode("Humvee"); humvee.Model = (Model)loader.Load("", "humvee"); // Add this humvee model to the physics engine for collision detection humvee.AddToPhysicsEngine = true; humvee.Physics.Shape = ShapeType.ConvexHull; // Set model materials. ((Model)humvee.Model).UseInternalMaterials = true; // Get the dimension of the model. Vector3 dimension1 = Vector3Helper.GetDimensions(humvee.Model.MinimumBoundingBox); // Scale the model to fit to the size of 5 markers. float scale1 = markerSize * (float) 1.5 / Math.Max(dimension1.X, dimension1.Z); // Transformation node of the humvee model. humveeSize = scale1; humveeTrans = Matrix.CreateTranslation(0, 30, 0); humveeRotation = Matrix.CreateFromAxisAngle(new Vector3(1, 0, 0), MathHelper.ToRadians(0)); // Create gears model. gears = new GeometryNode("Gears"); gears.Model = (Model)loader.Load("", "gears"); // Add this gears model to the physics engine for collision detection gears.AddToPhysicsEngine = true; gears.Physics.Shape = ShapeType.ConvexHull; // Set model materials. ((Model)gears.Model).UseInternalMaterials = true; // Get the dimension of the model. Vector3 dimension2 = Vector3Helper.GetDimensions(gears.Model.MinimumBoundingBox); // Scale the model to fit to the size of 5 markers. float scale2 = markerSize / Math.Max(dimension2.X, dimension2.Z); // Transformation node of the gears model. gearsSize = scale2; gearsTrans = Matrix.CreateTranslation(0, 110, 0); gearsRotation = Matrix.CreateFromAxisAngle(new Vector3(1, 0, 0), MathHelper.ToRadians(60)); // Create cup model. cup = new GeometryNode("Cup"); cup.Model = (Model)loader.Load("", "bardak"); // Add this cup model to the physics engine for collision detection cup.AddToPhysicsEngine = true; cup.Physics.Shape = ShapeType.ConvexHull; // Set model materials. ((Model)cup.Model).UseInternalMaterials = true; // Get the dimension of the model. Vector3 dimension3 = Vector3Helper.GetDimensions(cup.Model.MinimumBoundingBox); // Scale the model to fit to the size of 5 markers. float scale3 = markerSize / Math.Max(dimension3.X, dimension3.Z); cupSize = scale3; cupTrans = Matrix.CreateTranslation(60, 60, 0); cupRotation = Matrix.CreateFromAxisAngle(new Vector3(1, 0, 0), MathHelper.ToRadians(0)); // Create g36c model. g36c = new GeometryNode("G36C Gun"); g36c.Model = (Model)loader.Load("", "g36c"); // Add this g36c model to the physics engine for collision detection g36c.AddToPhysicsEngine = true; g36c.Physics.Shape = ShapeType.ConvexHull; // Set model materials. ((Model)g36c.Model).UseInternalMaterials = true; // Get the dimension of the model. Vector3 dimension4 = Vector3Helper.GetDimensions(g36c.Model.MinimumBoundingBox); // Scale the model to fit to the size of 5 markers. float scale4 = markerSize * 2 / Math.Max(dimension4.X, dimension4.Z); g36cSize = scale4; g36cTrans = Matrix.CreateTranslation(-60, 80, 0); g36cRotation = Matrix.CreateFromAxisAngle(new Vector3(1, 0, 0), MathHelper.ToRadians(0)); // Toolbar marker pointingMarker = new GeometryNode("Marker"); pointingMarker.Model = new Cylinder(markerSize, 4, markerSize * 3, 40); // Add this pointingMarker model to the physics engine for collision detection. pointingMarker.AddToPhysicsEngine = true; pointingMarker.Physics.Shape = ShapeType.Cylinder; // Set model materials. Material markerMat = new Material(); markerMat.Diffuse = Color.BlueViolet.ToVector4(); markerMat.Specular = Color.White.ToVector4(); markerMat.SpecularPower = 20; pointingMarker.Material = markerMat; pointingMarker.Material.Diffuse = new Vector4(pointingMarker.Material.Diffuse.X, pointingMarker.Material.Diffuse.Y, pointingMarker.Material.Diffuse.Z, 0); groundMarkerNode.AddChild(humvee); groundMarkerNode.AddChild(gears); groundMarkerNode.AddChild(cup); groundMarkerNode.AddChild(g36c); groundMarkerNode.AddChild(pointingMarker); }
private void CreateObjects() { // Create a material to apply to the sphere model Material sphereMaterial = new Material(); sphereMaterial.Diffuse = new Vector4(0, 0.5f, 0, 1); sphereMaterial.Specular = Color.Green.ToVector4(); sphereMaterial.SpecularPower = 10; Material sphereMaterial2 = new Material(); sphereMaterial2.Diffuse = new Vector4(0, 0, 0.5f, 1); sphereMaterial2.Specular = Color.Blue.ToVector4(); sphereMaterial2.SpecularPower = 10; Material sphereMaterial3 = new Material(); sphereMaterial3.Diffuse = new Vector4(0.5f, 0, 0, 1); sphereMaterial3.Specular = Color.Red.ToVector4(); sphereMaterial3.SpecularPower = 10; Material sphereMaterial4 = new Material(); sphereMaterial4.Diffuse = new Vector4(0.5f, 0, 0, 1); sphereMaterial4.Specular = Color.Cyan.ToVector4(); sphereMaterial4.SpecularPower = 10; Material sphereMaterial5 = new Material(); sphereMaterial5.Diffuse = new Vector4(0.5f, 0, 0, 1); sphereMaterial5.Specular = Color.Magenta.ToVector4(); sphereMaterial5.SpecularPower = 10; Material sphereMaterial6 = new Material(); sphereMaterial6.Diffuse = new Vector4(0.5f, 0, 0, 1); sphereMaterial6.Specular = Color.Yellow.ToVector4(); sphereMaterial6.SpecularPower = 10; Material sphereMaterial7 = new Material(); sphereMaterial7.Diffuse = new Vector4(0.5f, 0, 0, 1); sphereMaterial7.Specular = Color.DarkGray.ToVector4(); sphereMaterial7.SpecularPower = 10; Material sphereMaterial8 = new Material(); sphereMaterial8.Diffuse = new Vector4(0.5f, 0, 0, 1); sphereMaterial8.Specular = Color.Orange.ToVector4(); sphereMaterial8.SpecularPower = 10; Material sphereMaterial9 = new Material(); sphereMaterial9.Diffuse = new Vector4(0.5f, 0, 0, 1); sphereMaterial9.Specular = Color.Purple.ToVector4(); sphereMaterial9.SpecularPower = 10; Material sphereMaterial10 = new Material(); sphereMaterial10.Diffuse = new Vector4(0.5f, 0, 0, 1); sphereMaterial10.Specular = Color.Pink.ToVector4(); sphereMaterial10.SpecularPower = 10; int[] zero = new int[1]; int[] first = new int[1]; int[] two = new int[1]; int[] three = new int[1]; int[] four = new int[1]; int[] five = new int[1]; int[] six = new int[1]; int[] seven = new int[1]; int[] eight = new int[1]; int[] nine = new int[1]; int[] ten = new int[1]; int[] eleven = new int[1]; int[] twelve = new int[1]; int[] thirteen = new int[1]; int[] fourteen = new int[1]; int[] fifteen = new int[1]; int[] sixteen = new int[1]; int[] seventeen = new int[1]; int[] eighteen = new int[1]; int[] nineteen = new int[1]; int[] twenty = new int[1]; int[] twentyone = new int[1]; int[] twentytwo = new int[1]; int[] twentythree = new int[1]; int[] twentyfour = new int[1]; int[] twentyfive = new int[1]; int[] twentysix = new int[1]; int[] twentyseven = new int[1]; int[] twentyeight = new int[1]; int[] twentynine = new int[1]; int[] thirty = new int[1]; int[] thirtyone = new int[1]; int[] thirtytwo = new int[1]; int[] thirtythree = new int[1]{133}; int[] thirtyfour = new int[1]{134}; int[] thirtyfive = new int[1]{135}; int[] thirtysix = new int[1]{136}; int[] thirtyseven = new int[1]{137}; int[] thirtyeight = new int[1] { 138 }; int[] thirtynine = new int[1] { 139 }; int[] forty = new int[1] { 140 }; int[] fortyone = new int[1] { 141 }; zero[0] = 100; first[0] = 101; two[0] = 102; three[0] = 103; four[0] = 104; five[0] = 105; six[0] = 106; seven[0] = 107; eight[0] = 108; nine[0] = 100; ten[0] = 110; eleven[0] = 111; twelve[0] = 112; thirteen[0] = 113; fourteen[0] = 114; fifteen[0] = 115; sixteen[0] = 116; seventeen[0] = 117; eighteen[0] = 118; nineteen[0] = 119; twenty[0] = 120; twentyone[0] = 121; twentytwo[0] = 122; twentythree[0] = 123; twentyfour[0] = 124; twentyfive[0] = 125; twentysix[0] = 126; twentyseven[0] = 127; twentyeight[0] = 128; twentynine[0] = 129; thirty[0] = 130; thirtyone[0] = 131; thirtytwo[0] = 132; ModelLoader loader = new ModelLoader(); Model trapModel0 = (Model)loader.Load("", "Boxwhite"); Model trapModel1 = (Model)loader.Load("", "Boxwhite"); Model trapModel2 = (Model)loader.Load("", "Boxwhite"); Model trapModel3 = (Model)loader.Load("", "Boxwhite"); Model trapModel4 = (Model)loader.Load("", "Boxwhite"); Model trapModel5 = (Model)loader.Load("", "Boxwhite"); Model trapModel6 = (Model)loader.Load("", "Boxwhite"); Model trapModel7 = (Model)loader.Load("", "Boxwhite"); Model trapModel8 = (Model)loader.Load("", "Boxwhite"); Model trapModel9 = (Model)loader.Load("", "Boxwhite"); Model spellModel0 = (Model)loader.Load("", "MagicHat"); Model spellModel1 = (Model)loader.Load("", "MagicHat"); Model spellModel2 = (Model)loader.Load("", "MagicHat"); Model spellModel3 = (Model)loader.Load("", "MagicHat"); Model spellModel4 = (Model)loader.Load("", "MagicHat"); Model spellModel5 = (Model)loader.Load("", "MagicHat"); Model spellModel6 = (Model)loader.Load("", "MagicHat"); Model spellModel7 = (Model)loader.Load("", "MagicHat"); Model spellModel8 = (Model)loader.Load("", "MagicHat"); Model spellModel9 = (Model)loader.Load("", "MagicHat"); Model monsterModel0 = (Model)loader.Load("", "Slime"); Model monsterModel1 = (Model)loader.Load("", "Slime"); Model monsterModel2 = (Model)loader.Load("", "Slime"); Model monsterModel3 = (Model)loader.Load("", "Slime"); Model monsterModel4 = (Model)loader.Load("", "Slime"); Model monsterModel5 = (Model)loader.Load("", "Slime"); Model monsterModel6 = (Model)loader.Load("", "Slime"); Model monsterModel7 = (Model)loader.Load("", "Slime"); Model monsterModel8 = (Model)loader.Load("", "Slime"); Model monsterModel9 = (Model)loader.Load("", "Slime"); //Marker 100 cylinderMarkerNode100 = new MarkerNode(scene.MarkerTracker, "ALVARConfigFromXML100.xml", zero); GeometryNode cylinderNode0 = new GeometryNode("Cylinder"); cylinderNode0.Model = monsterModel0; ((Model)cylinderNode0.Model).UseInternalMaterials = false; cylinderNode0.Material = sphereMaterial; TransformNode cylinderTransNode0 = new TransformNode(); cylinderTransNode0.Scale = new Vector3(5, 5, 5); cylinderTransNode0.Rotation = Quaternion.CreateFromYawPitchRoll(0, 1.5f, 0); cylinderMarkerNode100.AddChild(cylinderTransNode0); cylinderTransNode0.AddChild(cylinderNode0); //add to Card array here: generic monster card here cards[0] = new Card('M', cylinderMarkerNode100, 90, 125, "Tethys, Goddess of Light", "Attack"); //Marker 101 cylinderMarkerNode101 = new MarkerNode(scene.MarkerTracker, "ALVARConfigFromXML101.xml", first); GeometryNode cylinderNode1 = new GeometryNode("Cylinder"); cylinderNode1.Model = monsterModel1; ((Model)cylinderNode1.Model).UseInternalMaterials = false; cylinderNode1.Material = sphereMaterial2; TransformNode cylinderTransNode1 = new TransformNode(); cylinderTransNode1.Scale = new Vector3(5, 5, 5); cylinderTransNode1.Rotation = Quaternion.CreateFromYawPitchRoll(0, 1.5f, 0); cylinderMarkerNode101.AddChild(cylinderTransNode1); cylinderTransNode1.AddChild(cylinderNode1); //add to Card array here: generic monster card here cards[1] = new Card('M', cylinderMarkerNode101, 120, 150, "Athena", "Attack"); //Marker 102 cylinderMarkerNode102 = new MarkerNode(scene.MarkerTracker, "ALVARConfigFromXML102.xml", two); GeometryNode cylinderNode2 = new GeometryNode("Cylinder"); cylinderNode2.Model = monsterModel2; ((Model)cylinderNode2.Model).UseInternalMaterials = false; cylinderNode2.Material = sphereMaterial3; TransformNode cylinderTransNode2 = new TransformNode(); cylinderTransNode2.Scale = new Vector3(5, 5, 5); cylinderTransNode2.Rotation = Quaternion.CreateFromYawPitchRoll(0, 1.5f, 0); cylinderMarkerNode102.AddChild(cylinderTransNode2); cylinderTransNode2.AddChild(cylinderNode2); //add to Card array here: generic monster card here cards[2] = new Card('M', cylinderMarkerNode102, 105, 120, "Victoria", "Attack"); //Marker 103 cylinderMarkerNode103 = new MarkerNode(scene.MarkerTracker, "ALVARConfigFromXML103.xml", three); GeometryNode cylinderNode3 = new GeometryNode("Cylinder"); cylinderNode3.Model = monsterModel3; ((Model)cylinderNode3.Model).UseInternalMaterials = false; cylinderNode3.Material = sphereMaterial4; TransformNode cylinderTransNode3 = new TransformNode(); cylinderTransNode3.Scale = new Vector3(5, 5, 5); cylinderTransNode3.Rotation = Quaternion.CreateFromYawPitchRoll(0, 1.5f, 0); cylinderMarkerNode103.AddChild(cylinderTransNode3); cylinderTransNode3.AddChild(cylinderNode3); //add to Card array here: generic monster card here cards[3] = new Card('M', cylinderMarkerNode103, 130, 160, "The Agent of Force - Mars", "Attack"); //Marker 104 cylinderMarkerNode104 = new MarkerNode(scene.MarkerTracker, "ALVARConfigFromXML104.xml", four); GeometryNode cylinderNode4 = new GeometryNode("Cylinder"); cylinderNode4.Model = monsterModel4; ((Model)cylinderNode4.Model).UseInternalMaterials = false; cylinderNode4.Material = sphereMaterial5; TransformNode cylinderTransNode4 = new TransformNode(); cylinderTransNode4.Scale = new Vector3(5, 5, 5); cylinderTransNode4.Rotation = Quaternion.CreateFromYawPitchRoll(0, 1.5f, 0); cylinderMarkerNode104.AddChild(cylinderTransNode4); cylinderTransNode4.AddChild(cylinderNode4); //add to Card array here: generic monster card here cards[4] = new Card('M', cylinderMarkerNode104, 115, 155, "The Agent of Wisdom - Mercury", "Attack"); //Marker 105 cylinderMarkerNode105 = new MarkerNode(scene.MarkerTracker, "ALVARConfigFromXML105.xml", five); GeometryNode cylinderNode5 = new GeometryNode("Cylinder"); cylinderNode5.Model = monsterModel5; ((Model)cylinderNode5.Model).UseInternalMaterials = false; cylinderNode5.Material = sphereMaterial6; TransformNode cylinderTransNode5 = new TransformNode(); cylinderTransNode5.Scale = new Vector3(5, 5, 5); cylinderTransNode5.Rotation = Quaternion.CreateFromYawPitchRoll(0, 1.5f, 0); cylinderMarkerNode105.AddChild(cylinderTransNode5); cylinderTransNode5.AddChild(cylinderNode5); //add to Card array here: generic monster card here cards[5] = new Card('M', cylinderMarkerNode105, 95, 145, "The Agent of Mystery - Earth", "Attack"); //Marker 106 cylinderMarkerNode106 = new MarkerNode(scene.MarkerTracker, "ALVARConfigFromXML106.xml", six); GeometryNode cylinderNode6 = new GeometryNode("Cylinder"); cylinderNode6.Model = monsterModel6; ((Model)cylinderNode6.Model).UseInternalMaterials = false; cylinderNode6.Material = sphereMaterial7; TransformNode cylinderTransNode6 = new TransformNode(); cylinderTransNode6.Scale = new Vector3(5, 5, 5); cylinderTransNode6.Rotation = Quaternion.CreateFromYawPitchRoll(0, 1.5f, 0); cylinderMarkerNode106.AddChild(cylinderTransNode6); cylinderTransNode6.AddChild(cylinderNode6); //add to Card array here: generic monster card here cards[6] = new Card('M', cylinderMarkerNode106, 130, 175, "The Agent of Miracles - Jupiter", "Attack"); //Marker 107 cylinderMarkerNode107 = new MarkerNode(scene.MarkerTracker, "ALVARConfigFromXML107.xml", seven); GeometryNode cylinderNode7 = new GeometryNode("Cylinder"); cylinderNode7.Model = monsterModel7; ((Model)cylinderNode7.Model).UseInternalMaterials = false; cylinderNode7.Material = sphereMaterial8; TransformNode cylinderTransNode7 = new TransformNode(); cylinderTransNode7.Scale = new Vector3(5, 5, 5); cylinderTransNode7.Rotation = Quaternion.CreateFromYawPitchRoll(0, 1.5f, 0); cylinderMarkerNode107.AddChild(cylinderTransNode7); cylinderTransNode7.AddChild(cylinderNode7); //add to Card array here: generic monster card here cards[7] = new Card('M', cylinderMarkerNode107, 80, 120, "The Agent of Judgment - Saturn", "Attack"); //Marker 108 cylinderMarkerNode108 = new MarkerNode(scene.MarkerTracker, "ALVARConfigFromXML108.xml", eight); GeometryNode cylinderNode8 = new GeometryNode("Cylinder"); cylinderNode8.Model = monsterModel8; ((Model)cylinderNode8.Model).UseInternalMaterials = false; cylinderNode8.Material = sphereMaterial9; TransformNode cylinderTransNode8 = new TransformNode(); cylinderTransNode8.Scale = new Vector3(5, 5, 5); cylinderTransNode8.Rotation = Quaternion.CreateFromYawPitchRoll(0, 1.5f, 0); cylinderMarkerNode108.AddChild(cylinderTransNode8); cylinderTransNode8.AddChild(cylinderNode8); //add to Card array here: generic monster card here cards[8] = new Card('M', cylinderMarkerNode108, 75, 140, "The Agent of Creation - Venus", "Attack"); //Marker 109 cylinderMarkerNode109 = new MarkerNode(scene.MarkerTracker, "ALVARConfigFromXML109.xml", nine); GeometryNode cylinderNode9 = new GeometryNode("Cylinder"); cylinderNode9.Model = monsterModel9; ((Model)cylinderNode9.Model).UseInternalMaterials = false; cylinderNode9.Material = sphereMaterial10; TransformNode cylinderTransNode9 = new TransformNode(); cylinderTransNode9.Scale = new Vector3(5, 5, 5); cylinderTransNode9.Rotation = Quaternion.CreateFromYawPitchRoll(0, 1.5f, 0); cylinderMarkerNode109.AddChild(cylinderTransNode9); cylinderTransNode9.AddChild(cylinderNode9); //add to Card array here: generic monster card here cards[9] = new Card('M', cylinderMarkerNode109, 150, 200, "Master Hyperion", "Attack"); //Marker 110 cylinderMarkerNode110 = new MarkerNode(scene.MarkerTracker, "ALVARConfigFromXML110.xml", ten); GeometryNode cylinderNode10 = new GeometryNode("Cylinder"); cylinderNode10.Model = spellModel0; ((Model)cylinderNode10.Model).UseInternalMaterials = false; cylinderNode10.Material = sphereMaterial; TransformNode cylinderTransNode10 = new TransformNode(); cylinderTransNode10.Scale = new Vector3(5, 5, 5); cylinderTransNode10.Rotation = Quaternion.CreateFromYawPitchRoll(0, 1.5f, 0); cylinderMarkerNode110.AddChild(cylinderTransNode10); cylinderTransNode10.AddChild(cylinderNode10); //add to Card array here: generic spell card here cards[10] = new Card('S', cylinderMarkerNode110, 100, 100, "Cards from the Sky", "All of your monsters are healed for 100 hp."); //Marker 111 cylinderMarkerNode111 = new MarkerNode(scene.MarkerTracker, "ALVARConfigFromXML111.xml", eleven); GeometryNode cylinderNode11 = new GeometryNode("Cylinder"); cylinderNode11.Model = spellModel1; ((Model)cylinderNode11.Model).UseInternalMaterials = false; cylinderNode11.Material = sphereMaterial2; TransformNode cylinderTransNode11 = new TransformNode(); cylinderTransNode11.Scale = new Vector3(5, 5, 5); cylinderTransNode11.Rotation = Quaternion.CreateFromYawPitchRoll(0, 1.5f, 0); cylinderMarkerNode111.AddChild(cylinderTransNode11); cylinderTransNode11.AddChild(cylinderNode11); //add to Card array here: generic spell card here cards[11] = new Card('S', cylinderMarkerNode111, 100, 100, "Valhalla, Hall of the Fallen", "All of your monsters are completly healed."); //Marker 112 cylinderMarkerNode112 = new MarkerNode(scene.MarkerTracker, "ALVARConfigFromXML112.xml", twelve); GeometryNode cylinderNode12 = new GeometryNode("Cylinder"); cylinderNode12.Model = spellModel2; ((Model)cylinderNode12.Model).UseInternalMaterials = false; cylinderNode12.Material = sphereMaterial3; TransformNode cylinderTransNode12 = new TransformNode(); cylinderTransNode12.Scale = new Vector3(5, 5, 5); cylinderTransNode12.Rotation = Quaternion.CreateFromYawPitchRoll(0, 1.5f, 0); cylinderMarkerNode112.AddChild(cylinderTransNode12); cylinderTransNode12.AddChild(cylinderNode12); //add to Card array here: generic spell card here cards[12] = new Card('S', cylinderMarkerNode112, 100, 100, "Terraforming", "All of your monsters are healed for 1 hp."); //Marker 113 cylinderMarkerNode113 = new MarkerNode(scene.MarkerTracker, "ALVARConfigFromXML113.xml", thirteen); GeometryNode cylinderNode13 = new GeometryNode("Cylinder"); cylinderNode13.Model = spellModel3; ((Model)cylinderNode13.Model).UseInternalMaterials = false; cylinderNode13.Material = sphereMaterial4; TransformNode cylinderTransNode13 = new TransformNode(); cylinderTransNode13.Scale = new Vector3(5, 5, 5); cylinderTransNode13.Rotation = Quaternion.CreateFromYawPitchRoll(0, 1.5f, 0); cylinderMarkerNode113.AddChild(cylinderTransNode13); cylinderTransNode13.AddChild(cylinderNode13); //add to Card array here: generic spell card here cards[13] = new Card('S', cylinderMarkerNode113, 100, 100, "Smashing Ground", "All of your monsters are healed for 20 hp."); //Marker 114 cylinderMarkerNode114 = new MarkerNode(scene.MarkerTracker, "ALVARConfigFromXML114.xml", fourteen); GeometryNode cylinderNode14 = new GeometryNode("Cylinder"); cylinderNode14.Model = spellModel4; ((Model)cylinderNode14.Model).UseInternalMaterials = false; cylinderNode14.Material = sphereMaterial5; TransformNode cylinderTransNode14 = new TransformNode(); cylinderTransNode14.Scale = new Vector3(5, 5, 5); cylinderTransNode14.Rotation = Quaternion.CreateFromYawPitchRoll(0, 1.5f, 0); cylinderMarkerNode114.AddChild(cylinderTransNode14); cylinderTransNode14.AddChild(cylinderNode14); //add to Card array here: generic spell card here cards[14] = new Card('S', cylinderMarkerNode114, 100, 100, "The Sanctuary in the Sky", "All of your monsters are healed for 75 hp."); //Marker 115 cylinderMarkerNode115 = new MarkerNode(scene.MarkerTracker, "ALVARConfigFromXML115.xml", fifteen); GeometryNode cylinderNode15 = new GeometryNode("Cylinder"); cylinderNode15.Model = spellModel5; ((Model)cylinderNode15.Model).UseInternalMaterials = false; cylinderNode15.Material = sphereMaterial6; TransformNode cylinderTransNode15 = new TransformNode(); cylinderTransNode15.Scale = new Vector3(5, 5, 5); cylinderTransNode15.Rotation = Quaternion.CreateFromYawPitchRoll(0, 1.5f, 0); cylinderMarkerNode115.AddChild(cylinderTransNode15); cylinderTransNode15.AddChild(cylinderNode15); //add to Card array here: generic spell card here cards[15] = new Card('S', cylinderMarkerNode115, 100, 100, "The Sanctuary in the Sky", "All of your monsters are healed for 75 hp."); //Marker 116 cylinderMarkerNode116 = new MarkerNode(scene.MarkerTracker, "ALVARConfigFromXML116.xml", sixteen); GeometryNode cylinderNode16 = new GeometryNode("Cylinder"); cylinderNode16.Model = spellModel6; ((Model)cylinderNode16.Model).UseInternalMaterials = false; cylinderNode16.Material = sphereMaterial7; TransformNode cylinderTransNode16 = new TransformNode(); cylinderTransNode16.Scale = new Vector3(5, 5, 5); cylinderTransNode16.Rotation = Quaternion.CreateFromYawPitchRoll(0, 1.5f, 0); cylinderTransNode16.AddChild(cylinderNode16); cylinderMarkerNode116.AddChild(cylinderTransNode16); //add to Card array here: generic spell card here cards[16] = new Card('S', cylinderMarkerNode116, 100, 100, "Celestial Transformation", "All of your monsters are healed for half of their hp."); //Marker 117 cylinderMarkerNode117 = new MarkerNode(scene.MarkerTracker, "ALVARConfigFromXML117.xml", seventeen); GeometryNode cylinderNode17 = new GeometryNode("Cylinder"); cylinderNode17.Model = spellModel7; ((Model)cylinderNode17.Model).UseInternalMaterials = false; cylinderNode17.Material = sphereMaterial8; TransformNode cylinderTransNode17 = new TransformNode(); cylinderTransNode17.Scale = new Vector3(5, 5, 5); cylinderTransNode17.Rotation = Quaternion.CreateFromYawPitchRoll(0, 1.5f, 0); cylinderTransNode17.AddChild(cylinderNode17); cylinderMarkerNode117.AddChild(cylinderTransNode17); //add to Card array here: generic spell card here cards[17] = new Card('S', cylinderMarkerNode117, 100, 100, "Burial from a Different Dimension", "You're protected from 1 trap."); //Marker 118 cylinderMarkerNode118 = new MarkerNode(scene.MarkerTracker, "ALVARConfigFromXML118.xml", eighteen); GeometryNode cylinderNode18 = new GeometryNode("Cylinder"); cylinderNode18.Model = spellModel8; ((Model)cylinderNode18.Model).UseInternalMaterials = false; cylinderNode18.Material = sphereMaterial9; TransformNode cylinderTransNode18 = new TransformNode(); cylinderTransNode18.Scale = new Vector3(5, 5, 5); cylinderTransNode18.Rotation = Quaternion.CreateFromYawPitchRoll(0, 1.5f, 0); cylinderTransNode18.AddChild(cylinderNode18); cylinderMarkerNode118.AddChild(cylinderTransNode18); //add to Card array here: generic spell card here cards[18] = new Card('S', cylinderMarkerNode118, 100, 100, "Mausoleum of the Emperor", "All of your monsters are healed for 75% of their HP."); //Marker 119 cylinderMarkerNode119 = new MarkerNode(scene.MarkerTracker, "ALVARConfigFromXML119.xml", nineteen); GeometryNode cylinderNode19 = new GeometryNode("Cylinder"); cylinderNode19.Model = spellModel9; ((Model)cylinderNode19.Model).UseInternalMaterials = false; cylinderNode19.Material = sphereMaterial10; TransformNode cylinderTransNode19 = new TransformNode(); cylinderTransNode19.Scale = new Vector3(5, 5, 5); cylinderTransNode19.Rotation = Quaternion.CreateFromYawPitchRoll(0, 1.5f, 0); cylinderTransNode19.AddChild(cylinderNode19); cylinderMarkerNode119.AddChild(cylinderTransNode19); //add to Card array here: generic spell card here cards[19] = new Card('S', cylinderMarkerNode119, 100, 100, "The Fountain in the Sky ", "All of your monsters are healed for 25% of their HP."); //Marker 120 cylinderMarkerNode120 = new MarkerNode(scene.MarkerTracker, "ALVARConfigFromXML120.xml", twenty); GeometryNode cylinderNode20 = new GeometryNode("Cylinder"); cylinderNode20.Model = trapModel0; ((Model)cylinderNode20.Model).UseInternalMaterials = false; cylinderNode20.Material = sphereMaterial; TransformNode cylinderTransNode20 = new TransformNode(); cylinderTransNode20.Scale = new Vector3(5, 5, 5); cylinderTransNode20.Rotation = Quaternion.CreateFromYawPitchRoll(0, 1.5f, 0); cylinderTransNode20.AddChild(cylinderNode20); cylinderMarkerNode120.AddChild(cylinderTransNode20); //add to Card array here: generic trap card here cards[20] = new Card('T', cylinderMarkerNode120, 0, 100, "Divine Punishment", "All of your opponent's monsters take damage equal to half of their current health."); //Marker 121 cylinderMarkerNode121 = new MarkerNode(scene.MarkerTracker, "ALVARConfigFromXML121.xml", twentyone); GeometryNode cylinderNode21 = new GeometryNode("Cylinder"); cylinderNode21.Model = trapModel1; ((Model)cylinderNode21.Model).UseInternalMaterials = false; cylinderNode21.Material = sphereMaterial2; TransformNode cylinderTransNode21 = new TransformNode(); cylinderTransNode21.Scale = new Vector3(5, 5, 5); cylinderTransNode21.Rotation = Quaternion.CreateFromYawPitchRoll(0, 1.5f, 0); cylinderTransNode21.AddChild(cylinderNode21); cylinderMarkerNode121.AddChild(cylinderTransNode21); //add to Card array here: generic trap card here cards[21] = new Card('T', cylinderMarkerNode121, 0, 100, "Return from the Different Dimension", "Your opponent may not attack for the remainder of their turn."); //Marker 122 cylinderMarkerNode122 = new MarkerNode(scene.MarkerTracker, "ALVARConfigFromXML122.xml", twentytwo); GeometryNode cylinderNode22 = new GeometryNode("Cylinder"); cylinderNode22.Model = trapModel2; ((Model)cylinderNode22.Model).UseInternalMaterials = false; cylinderNode22.Material = sphereMaterial3; TransformNode cylinderTransNode22 = new TransformNode(); cylinderTransNode22.Scale = new Vector3(5, 5, 5); cylinderTransNode22.Rotation = Quaternion.CreateFromYawPitchRoll(0, 1.5f, 0); cylinderTransNode22.AddChild(cylinderNode22); cylinderMarkerNode122.AddChild(cylinderTransNode22); //add to Card array here: generic trap card here cards[22] = new Card('T', cylinderMarkerNode122, 0, 100, "Torrential Tribute", "Destroy a spell card."); //Marker 123 cylinderMarkerNode123 = new MarkerNode(scene.MarkerTracker, "ALVARConfigFromXML123.xml", twentythree); GeometryNode cylinderNode23 = new GeometryNode("Cylinder"); cylinderNode23.Model = trapModel3; ((Model)cylinderNode23.Model).UseInternalMaterials = false; cylinderNode23.Material = sphereMaterial4; TransformNode cylinderTransNode23 = new TransformNode(); cylinderTransNode23.Scale = new Vector3(5, 5, 5); cylinderTransNode23.Rotation = Quaternion.CreateFromYawPitchRoll(0, 1.5f, 0); cylinderTransNode23.AddChild(cylinderNode23); cylinderMarkerNode123.AddChild(cylinderTransNode23); //add to Card array here: generic trap card here cards[23] = new Card('T', cylinderMarkerNode123, 0, 100, "Beckoning Light", "Your opponent may not activate a trap during your next turn."); //Marker 124 cylinderMarkerNode124 = new MarkerNode(scene.MarkerTracker, "ALVARConfigFromXML124.xml", twentyfour); GeometryNode cylinderNode24 = new GeometryNode("Cylinder"); cylinderNode24.Model = trapModel4; ((Model)cylinderNode24.Model).UseInternalMaterials = false; cylinderNode24.Material = sphereMaterial5; TransformNode cylinderTransNode24 = new TransformNode(); cylinderTransNode24.Scale = new Vector3(5, 5, 5); cylinderTransNode24.Rotation = Quaternion.CreateFromYawPitchRoll(0, 1.5f, 0); cylinderTransNode24.AddChild(cylinderNode24); cylinderMarkerNode124.AddChild(cylinderTransNode24); //add to Card array here: generic trap card here cards[24] = new Card('T', cylinderMarkerNode124, 0, 100, "Miraculous Descent", "Reduce the damage taken to your life points to 0 for the remainder of your opponent's turn."); //Marker 125 cylinderMarkerNode125 = new MarkerNode(scene.MarkerTracker, "ALVARConfigFromXML125.xml", twentyfive); GeometryNode cylinderNode25 = new GeometryNode("Cylinder"); cylinderNode25.Model = trapModel5; ((Model)cylinderNode25.Model).UseInternalMaterials = false; cylinderNode25.Material = sphereMaterial6; TransformNode cylinderTransNode25 = new TransformNode(); cylinderTransNode25.Scale = new Vector3(5, 5, 5); cylinderTransNode25.Rotation = Quaternion.CreateFromYawPitchRoll(0, 1.5f, 0); cylinderTransNode25.AddChild(cylinderNode25); cylinderMarkerNode125.AddChild(cylinderTransNode25); //add to Card array here: generic trap card here cards[25] = new Card('T', cylinderMarkerNode125, 0, 100, "Miraculous Descent", "Reduce the damage taken to your life points to 0 for the remainder of your opponent's turn."); //Marker 126 cylinderMarkerNode126 = new MarkerNode(scene.MarkerTracker, "ALVARConfigFromXML126.xml", twentysix); GeometryNode cylinderNode26 = new GeometryNode("Cylinder"); cylinderNode26.Model = trapModel6; ((Model)cylinderNode26.Model).UseInternalMaterials = false; cylinderNode26.Material = sphereMaterial7; TransformNode cylinderTransNode26 = new TransformNode(); cylinderTransNode26.Scale = new Vector3(5, 5, 5); cylinderTransNode26.Rotation = Quaternion.CreateFromYawPitchRoll(0, 1.5f, 0); cylinderTransNode26.AddChild(cylinderNode26); cylinderMarkerNode126.AddChild(cylinderTransNode26); //add to Card array here: generic trap card here cards[26] = new Card('T', cylinderMarkerNode126, 0, 100, "Solemn Judgment", "Your opponent may not activate spells until the end of their turn."); //Marker 127 cylinderMarkerNode127 = new MarkerNode(scene.MarkerTracker, "ALVARConfigFromXML127.xml", twentyseven); GeometryNode cylinderNode27 = new GeometryNode("Cylinder"); cylinderNode27.Model = trapModel7; ((Model)cylinderNode27.Model).UseInternalMaterials = false; cylinderNode27.Material = sphereMaterial8; TransformNode cylinderTransNode27 = new TransformNode(); cylinderTransNode27.Scale = new Vector3(5, 5, 5); cylinderTransNode27.Rotation = Quaternion.CreateFromYawPitchRoll(0, 1.5f, 0); cylinderTransNode27.AddChild(cylinderNode27); cylinderMarkerNode127.AddChild(cylinderTransNode27); //add to Card array here: generic trap card here cards[27] = new Card('T', cylinderMarkerNode127, 0, 100, "Power Break", "Reduce a monster's attack by 50 for the remainder of your opponent's turn."); //Marker 128 cylinderMarkerNode128 = new MarkerNode(scene.MarkerTracker, "ALVARConfigFromXML128.xml", twentyeight); GeometryNode cylinderNode28 = new GeometryNode("Cylinder"); cylinderNode28.Model = trapModel8; ((Model)cylinderNode28.Model).UseInternalMaterials = false; cylinderNode28.Material = sphereMaterial9; TransformNode cylinderTransNode28 = new TransformNode(); cylinderTransNode28.Scale = new Vector3(5, 5, 5); cylinderTransNode28.Rotation = Quaternion.CreateFromYawPitchRoll(0, 1.5f, 0); cylinderTransNode28.AddChild(cylinderNode28); cylinderMarkerNode128.AddChild(cylinderTransNode28); //add to Card array here: generic trap card here cards[28] = new Card('T', cylinderMarkerNode128, 0, 100, "Reinforcements", "Increase a target monster's attack by 40 for the remainder of your opponent's turn."); //Marker 129 cylinderMarkerNode129 = new MarkerNode(scene.MarkerTracker, "ALVARConfigFromXML129.xml", twentynine); GeometryNode cylinderNode29 = new GeometryNode("Cylinder"); cylinderNode29.Model = trapModel9; ((Model)cylinderNode29.Model).UseInternalMaterials = false; cylinderNode29.Material = sphereMaterial10; TransformNode cylinderTransNode29 = new TransformNode(); cylinderTransNode29.Scale = new Vector3(5, 5, 5); cylinderTransNode29.Rotation = Quaternion.CreateFromYawPitchRoll(0, 1.5f, 0); cylinderTransNode29.AddChild(cylinderNode29); cylinderMarkerNode129.AddChild(cylinderTransNode29); //add to Card array here: generic trap card here cards[29] = new Card('T', cylinderMarkerNode129, 0, 100, "Earthshaker", "For the remainder of your opponent's turn, reduce the attack of a monster to 0."); //Marker 30 = Player 1 Marker cylinderMarkerNode130 = new MarkerNode(scene.MarkerTracker, "ALVARConfigFromXML130.xml", thirty); GeometryNode cylinderNode30 = new GeometryNode("Sphere"); cylinderNode30.Model = new Sphere(5, 20, 20); cylinderNode30.Material = sphereMaterial3; TransformNode cylinderTransNode30 = new TransformNode(); cylinderTransNode30.Translation = new Vector3(0, 0, 3); cylinderTransNode30.AddChild(cylinderNode30); cylinderMarkerNode130.AddChild(cylinderTransNode30); //Marker 31 = Player 2 Marker cylinderMarkerNode131 = new MarkerNode(scene.MarkerTracker, "ALVARConfigFromXML131.xml", thirtyone); GeometryNode cylinderNode31 = new GeometryNode("Sphere"); cylinderNode31.Model = new Sphere(5, 20, 20); cylinderNode31.Material = sphereMaterial; TransformNode cylinderTransNode31 = new TransformNode(); cylinderTransNode31.Translation = new Vector3(0, 0, 3); cylinderTransNode31.AddChild(cylinderNode31); cylinderMarkerNode131.AddChild(cylinderTransNode31); //Marker 32 = P1 Monster Position Marker 1 cylinderMarkerNode132 = new MarkerNode(scene.MarkerTracker, "ALVARConfigFromXML132.xml", thirtytwo); //Marker 33 = P1 Monster Position Marker 2 cylinderMarkerNode133 = new MarkerNode(scene.MarkerTracker, "ALVARConfigFromXML133.xml", thirtythree); //Marker 34 = P1 Monster Position Marker 3 cylinderMarkerNode134 = new MarkerNode(scene.MarkerTracker, "ALVARConfigFromXML134.xml", thirtyfour); //Marker 35 = P2 Monster Position Marker 1 cylinderMarkerNode135 = new MarkerNode(scene.MarkerTracker, "ALVARConfigFromXML135.xml", thirtyfive); //Marker 36 = P2 Monster Position Marker 2 cylinderMarkerNode136 = new MarkerNode(scene.MarkerTracker, "ALVARConfigFromXML136.xml", thirtysix); //Marker 37 = P2 Monster Position Marker 3 cylinderMarkerNode137 = new MarkerNode(scene.MarkerTracker, "ALVARConfigFromXML137.xml", thirtyseven); //Marker 38 = P1 Spell Position Marker cylinderMarkerNode138 = new MarkerNode(scene.MarkerTracker, "ALVARConfigFromXML138.xml", thirtyeight); //Marker 39 = P2 Spell Position Marker cylinderMarkerNode139 = new MarkerNode(scene.MarkerTracker, "ALVARConfigFromXML139.xml", thirtynine); //Marker 40 = P1 Trap Position Marker cylinderMarkerNode140 = new MarkerNode(scene.MarkerTracker, "ALVARConfigFromXML140.xml", forty); //Marker 41 = P2 Trap Position Marker cylinderMarkerNode141 = new MarkerNode(scene.MarkerTracker, "ALVARConfigFromXML141.xml", fortyone); scene.RootNode.AddChild(cylinderMarkerNode100); scene.RootNode.AddChild(cylinderMarkerNode101); scene.RootNode.AddChild(cylinderMarkerNode102); scene.RootNode.AddChild(cylinderMarkerNode103); scene.RootNode.AddChild(cylinderMarkerNode104); scene.RootNode.AddChild(cylinderMarkerNode105); scene.RootNode.AddChild(cylinderMarkerNode106); scene.RootNode.AddChild(cylinderMarkerNode107); scene.RootNode.AddChild(cylinderMarkerNode108); scene.RootNode.AddChild(cylinderMarkerNode109); scene.RootNode.AddChild(cylinderMarkerNode110); scene.RootNode.AddChild(cylinderMarkerNode111); scene.RootNode.AddChild(cylinderMarkerNode112); scene.RootNode.AddChild(cylinderMarkerNode113); scene.RootNode.AddChild(cylinderMarkerNode114); scene.RootNode.AddChild(cylinderMarkerNode115); scene.RootNode.AddChild(cylinderMarkerNode116); scene.RootNode.AddChild(cylinderMarkerNode117); scene.RootNode.AddChild(cylinderMarkerNode118); scene.RootNode.AddChild(cylinderMarkerNode119); scene.RootNode.AddChild(cylinderMarkerNode120); scene.RootNode.AddChild(cylinderMarkerNode121); scene.RootNode.AddChild(cylinderMarkerNode122); scene.RootNode.AddChild(cylinderMarkerNode123); scene.RootNode.AddChild(cylinderMarkerNode124); scene.RootNode.AddChild(cylinderMarkerNode125); scene.RootNode.AddChild(cylinderMarkerNode126); scene.RootNode.AddChild(cylinderMarkerNode127); scene.RootNode.AddChild(cylinderMarkerNode128); scene.RootNode.AddChild(cylinderMarkerNode129); scene.RootNode.AddChild(cylinderMarkerNode130); scene.RootNode.AddChild(cylinderMarkerNode131); scene.RootNode.AddChild(cylinderMarkerNode132); scene.RootNode.AddChild(cylinderMarkerNode133); scene.RootNode.AddChild(cylinderMarkerNode134); scene.RootNode.AddChild(cylinderMarkerNode135); scene.RootNode.AddChild(cylinderMarkerNode136); scene.RootNode.AddChild(cylinderMarkerNode137); scene.RootNode.AddChild(cylinderMarkerNode138); scene.RootNode.AddChild(cylinderMarkerNode139); scene.RootNode.AddChild(cylinderMarkerNode140); scene.RootNode.AddChild(cylinderMarkerNode141); }
private void CreateObjects() { myPyramid = new GeometryNode("Pyramid"); myPyramid.Model = new Pyramid(markerSize * 4 / 8, markerSize, markerSize); Material PyramidMaterial = new Material() { Diffuse = Color.Orange.ToVector4(), Specular = Color.White.ToVector4(), SpecularPower = 20 }; myPyramid.Material = PyramidMaterial; myPyramid.AddToPhysicsEngine = true; myPyramid.Physics.Shape = ShapeType.ConvexHull; groundMarkerNode.AddChild(myPyramid); myPyramid.Material.Diffuse = new Vector4(myPyramid.Material.Diffuse.X, myPyramid.Material.Diffuse.Y, myPyramid.Material.Diffuse.Z, 0); ModelLoader loader = new ModelLoader(); modelEDU10001 = new GeometryNode("Block Education"); modelEDU10001.Model = (Model)loader.Load("", "education"); modelEDU10001.AddToPhysicsEngine = true; modelEDU10001.Physics.Shape = ShapeType.ConvexHull; ((Model)modelEDU10001.Model).UseInternalMaterials = true; groundMarkerNode.AddChild(modelEDU10001); modelEMP10001 = new GeometryNode("Block Employment"); modelEMP10001.Model = (Model)loader.Load("", "employment"); modelEMP10001.AddToPhysicsEngine = true; modelEMP10001.Physics.Shape = ShapeType.ConvexHull; ((Model)modelEMP10001.Model).UseInternalMaterials = true; groundMarkerNode.AddChild(modelEMP10001); modelDEM10001 = new GeometryNode("Block Demographics"); modelDEM10001.Model = (Model)loader.Load("", "demographics"); modelDEM10001.AddToPhysicsEngine = true; modelDEM10001.Physics.Shape = ShapeType.ConvexHull; ((Model)modelDEM10001.Model).UseInternalMaterials = true; groundMarkerNode.AddChild(modelDEM10001); modelHOU10001 = new GeometryNode("Block Housing"); modelHOU10001.Model = (Model)loader.Load("", "housing"); modelHOU10001.AddToPhysicsEngine = true; modelHOU10001.Physics.Shape = ShapeType.ConvexHull; ((Model)modelHOU10001.Model).UseInternalMaterials = true; groundMarkerNode.AddChild(modelHOU10001); modelEDU10002 = new GeometryNode("Block Education"); modelEDU10002.Model = (Model)loader.Load("", "education"); modelEDU10002.AddToPhysicsEngine = true; modelEDU10002.Physics.Shape = ShapeType.ConvexHull; ((Model)modelEDU10002.Model).UseInternalMaterials = true; groundMarkerNode.AddChild(modelEDU10002); modelEMP10002 = new GeometryNode("Block Employment"); modelEMP10002.Model = (Model)loader.Load("", "employment"); modelEMP10002.AddToPhysicsEngine = true; modelEMP10002.Physics.Shape = ShapeType.ConvexHull; ((Model)modelEMP10002.Model).UseInternalMaterials = true; groundMarkerNode.AddChild(modelEMP10002); modelDEM10002 = new GeometryNode("Block Demographics"); modelDEM10002.Model = (Model)loader.Load("", "demographics"); modelDEM10002.AddToPhysicsEngine = true; modelDEM10002.Physics.Shape = ShapeType.ConvexHull; ((Model)modelDEM10002.Model).UseInternalMaterials = true; groundMarkerNode.AddChild(modelDEM10002); modelHOU10002 = new GeometryNode("Block Housing"); modelHOU10002.Model = (Model)loader.Load("", "housing"); modelHOU10002.AddToPhysicsEngine = true; modelHOU10002.Physics.Shape = ShapeType.ConvexHull; ((Model)modelHOU10002.Model).UseInternalMaterials = true; groundMarkerNode.AddChild(modelHOU10002); modelEDU10003 = new GeometryNode("Block Education"); modelEDU10003.Model = (Model)loader.Load("", "education"); modelEDU10003.AddToPhysicsEngine = true; modelEDU10003.Physics.Shape = ShapeType.ConvexHull; ((Model)modelEDU10003.Model).UseInternalMaterials = true; groundMarkerNode.AddChild(modelEDU10003); modelEMP10003 = new GeometryNode("Block Employment"); modelEMP10003.Model = (Model)loader.Load("", "employment"); modelEMP10003.AddToPhysicsEngine = true; modelEMP10003.Physics.Shape = ShapeType.ConvexHull; ((Model)modelEMP10003.Model).UseInternalMaterials = true; groundMarkerNode.AddChild(modelEMP10003); modelDEM10003 = new GeometryNode("Block Demographics"); modelDEM10003.Model = (Model)loader.Load("", "demographics"); modelDEM10003.AddToPhysicsEngine = true; modelDEM10003.Physics.Shape = ShapeType.ConvexHull; ((Model)modelDEM10003.Model).UseInternalMaterials = true; groundMarkerNode.AddChild(modelDEM10003); modelHOU10003 = new GeometryNode("Block Housing"); modelHOU10003.Model = (Model)loader.Load("", "housing"); modelHOU10003.AddToPhysicsEngine = true; modelHOU10003.Physics.Shape = ShapeType.ConvexHull; ((Model)modelHOU10003.Model).UseInternalMaterials = true; groundMarkerNode.AddChild(modelHOU10003); modelEDU10004 = new GeometryNode("Block Education"); modelEDU10004.Model = (Model)loader.Load("", "education"); modelEDU10004.AddToPhysicsEngine = true; modelEDU10004.Physics.Shape = ShapeType.ConvexHull; ((Model)modelEDU10004.Model).UseInternalMaterials = true; groundMarkerNode.AddChild(modelEDU10004); modelEMP10004 = new GeometryNode("Block Employment"); modelEMP10004.Model = (Model)loader.Load("", "employment"); modelEMP10004.AddToPhysicsEngine = true; modelEMP10004.Physics.Shape = ShapeType.ConvexHull; ((Model)modelEMP10004.Model).UseInternalMaterials = true; groundMarkerNode.AddChild(modelEMP10004); modelDEM10004 = new GeometryNode("Block Demographics"); modelDEM10004.Model = (Model)loader.Load("", "demographics"); modelDEM10004.AddToPhysicsEngine = true; modelDEM10004.Physics.Shape = ShapeType.ConvexHull; ((Model)modelDEM10004.Model).UseInternalMaterials = true; groundMarkerNode.AddChild(modelDEM10004); modelHOU10004 = new GeometryNode("Block Housing"); modelHOU10004.Model = (Model)loader.Load("", "housing"); modelHOU10004.AddToPhysicsEngine = true; modelHOU10004.Physics.Shape = ShapeType.ConvexHull; ((Model)modelHOU10004.Model).UseInternalMaterials = true; groundMarkerNode.AddChild(modelHOU10004); }
private void CreateObjects() { ModelLoader loader = new ModelLoader(); overlayNode = new GeometryNode("Overlay"); overlayNode.Model = (Model)loader.Load("", "p1_wedge"); ((Model)overlayNode.Model).UseInternalMaterials = true; // Get the dimension of the model Vector3 dimension = Vector3Helper.GetDimensions(overlayNode.Model.MinimumBoundingBox); // Scale the model to fit to the size of 5 markers float scale = markerSize * 5 / Math.Max(dimension.X, dimension.Z); TransformNode overlayTransNode = new TransformNode() { Translation = new Vector3(0, 0, dimension.Y * scale / 2), Rotation = Quaternion.CreateFromAxisAngle(Vector3.UnitX, MathHelper.ToRadians(90)) * Quaternion.CreateFromAxisAngle(Vector3.UnitY, MathHelper.ToRadians(90)), Scale = new Vector3(scale, scale, scale) }; scene.RootNode.AddChild(overlayTransNode); overlayTransNode.AddChild(overlayNode); }
private void CreateObjects() { // Loads a textured model of the Sun. ModelLoader loader = new ModelLoader(); Model mySunModel = (Model)loader.Load("", "sun1"); // Loaded Sun model to the geometry node mySun mySun = new GeometryNode("Sun"); mySun.Model = mySunModel; mySun.Material.Diffuse = new Vector4(mySun.Material.Diffuse.X, mySun.Material.Diffuse.Y, mySun.Material.Diffuse.Z, 0.7f); // Use its internal materials ((Model)mySun.Model).UseInternalMaterials = true; ((Model)mySun.Model).ContainsTransparency = true; //Transforme node for the Sun node. TransformNode mySunTransNode = new TransformNode(); mySunTransNode.Translation = new Vector3(0, 0, 0); mySunTransNode.Scale = new Vector3(0.01f, 0.01f, 0.01f); //mySunTransNode.Rotation = Quaternion.CreateFromAxisAngle(new Vector3(1, 0, 0), MathHelper.ToRadians(90)); mySunRotationParentNode = new TransformNode(); mySunRotationParentNode.Translation = Vector3.Zero; mySun.Physics.Pickable = true; mySun.AddToPhysicsEngine = true; // Loads a textured model of the Earth. Model myEarthModel = (Model)loader.Load("", "planet2"); // Loaded Sun model to the geometry node myEarth myEarth = new GeometryNode("Earth"); myEarth.Model = myEarthModel; // Use its internal materials ((Model)myEarth.Model).UseInternalMaterials = true; //Transforme node for the Earth node. TransformNode myEarthTransNode = new TransformNode(); myEarthTransNode.Translation = new Vector3(0, 0, 2); myEarthTransNode.Scale = new Vector3(0.003f, 0.003f, 0.003f); myEarthRotationParentNode1 = new TransformNode(); myEarthRotationParentNode1.Translation = Vector3.Zero; myEarthRotationParentNode2 = new TransformNode(); myEarthRotationParentNode2.Translation = Vector3.Zero; earthControlPanel = new TransformNode(); earthControlPanel.Translation = Vector3.Zero; earthControlPanel1 = new TransformNode(); earthControlPanel1.Translation = Vector3.Zero; earthControlPanel2 = new TransformNode(); earthControlPanel2.Translation = Vector3.Zero; myEarth.Physics.Pickable = true; myEarth.AddToPhysicsEngine = true; // Loads a textured model of the Moon. Model myMoonModel = (Model)loader.Load("", "moon1"); // Loaded Sun model to the geometry node myMoon myMoon = new GeometryNode("Moon"); myMoon.Model = myMoonModel; // Use its internal materials ((Model)myMoon.Model).UseInternalMaterials = true; //Transforme node for the Moon node. TransformNode myMoonTransNode = new TransformNode(); myMoonTransNode.Translation = new Vector3(0, 0, (float)0.5); myMoonTransNode.Scale = new Vector3(0.0008f, 0.0008f, 0.0008f); myMoonRotationParentNode1 = new TransformNode(); myMoonRotationParentNode1.Translation = Vector3.Zero; myMoonRotationParentNode2 = new TransformNode(); myMoonRotationParentNode2.Translation = Vector3.Zero; myMoonRotationParentNode3 = new TransformNode(); myMoonRotationParentNode3.Translation = Vector3.Zero; myMoonRotationParentNode4 = new TransformNode(); myMoonRotationParentNode4.Translation = Vector3.Zero; moonControlPanel = new TransformNode(); moonControlPanel.Translation = Vector3.Zero; moonControlPanel1 = new TransformNode(); moonControlPanel1.Translation = Vector3.Zero; moonControlPanel2 = new TransformNode(); moonControlPanel2.Translation = Vector3.Zero; myMoon.Physics.Pickable = true; myMoon.AddToPhysicsEngine = true; // Loads a textured model of the Mercury. Model myMercuryModel = (Model)loader.Load("", "planet4"); // Loaded Sun model to the geometry node myMercury myMercury = new GeometryNode("Mercury"); myMercury.Model = myMercuryModel; // Use its internal materials ((Model)myMercury.Model).UseInternalMaterials = true; //Transforme node for the Mercury node. TransformNode myMercuryTransNode = new TransformNode(); myMercuryTransNode.Translation = new Vector3(0, 0, 1); myMercuryTransNode.Scale = new Vector3(0.001f, 0.001f, 0.001f); myMercuryRotationParentNode1 = new TransformNode(); myMercuryRotationParentNode1.Translation = Vector3.Zero; myMercuryRotationParentNode2 = new TransformNode(); myMercuryRotationParentNode2.Translation = Vector3.Zero; mercuryControlPanel = new TransformNode(); mercuryControlPanel.Translation = Vector3.Zero; mercuryControlPanel1 = new TransformNode(); mercuryControlPanel1.Translation = Vector3.Zero; mercuryControlPanel2 = new TransformNode(); mercuryControlPanel2.Translation = Vector3.Zero; myMercury.Physics.Pickable = true; myMercury.AddToPhysicsEngine = true; // Loads a textured model of the Mars. Model myMarsModel = (Model)loader.Load("", "planet3"); // Loaded Sun model to the geometry node myMars myMars = new GeometryNode("Mars"); myMars.Model = myMarsModel; // Use its internal materials ((Model)myMars.Model).UseInternalMaterials = true; //Transforme node for the Mars node. TransformNode myMarsTransNode = new TransformNode(); myMarsTransNode.Translation = new Vector3(0, 0, 3); myMarsTransNode.Scale = new Vector3(0.0015f, 0.0015f, 0.0015f); myMarsRotationParentNode1 = new TransformNode(); myMarsRotationParentNode1.Translation = Vector3.Zero; myMarsRotationParentNode2 = new TransformNode(); myMarsRotationParentNode2.Translation = Vector3.Zero; marsControlPanel = new TransformNode(); marsControlPanel.Translation = Vector3.Zero; marsControlPanel1 = new TransformNode(); marsControlPanel1.Translation = Vector3.Zero; marsControlPanel2 = new TransformNode(); marsControlPanel2.Translation = Vector3.Zero; myMars.Physics.Pickable = true; myMars.AddToPhysicsEngine = true; // Loads a textured model of the myJupiter. Model myJupiterModel = (Model)loader.Load("", "planet1"); // Loaded Sun model to the geometry node myJupiter myJupiter = new GeometryNode("Jupiter"); myJupiter.Model = myJupiterModel; // Use its internal materials ((Model)myJupiter.Model).UseInternalMaterials = true; //Transforme node for the Jupiter box node. TransformNode myJupiterTransNode = new TransformNode(); myJupiterTransNode.Translation = new Vector3(0, 0, 4); myJupiterTransNode.Scale = new Vector3(0.004f, 0.004f, 0.004f); myJupiterRotationParentNode1 = new TransformNode(); myJupiterRotationParentNode1.Translation = Vector3.Zero; myJupiterRotationParentNode2 = new TransformNode(); myJupiterRotationParentNode2.Translation = Vector3.Zero; jupiterControlPanel = new TransformNode(); jupiterControlPanel.Translation = Vector3.Zero; jupiterControlPanel1 = new TransformNode(); jupiterControlPanel1.Translation = Vector3.Zero; jupiterControlPanel2 = new TransformNode(); jupiterControlPanel2.Translation = Vector3.Zero; myJupiter.Physics.Pickable = true; myJupiter.AddToPhysicsEngine = true; //Space Debris Fields //Create a geometry node with a model of cylinder. cylinderNode = new SynchronizedGeometryNode("Dubris-Cylinder"); cylinderNode.Model = new Cylinder(1.5f, 1.5f, 4f, 20); //Initializing materials for cylinder. Material cylinderMat = new Material(); cylinderMat.Diffuse = Color.Indigo.ToVector4(); cylinderMat.Specular = Color.White.ToVector4(); cylinderMat.SpecularPower = 4; //Set cylinder materials cylinderNode.Material = cylinderMat; //Transforme node for the cylinder node. TransformNode cylinderTransNode = new TransformNode(); cylinderTransNode.Scale = new Vector3(0.03f, 0.03f, 0.03f); cylinderTransNode.Rotation = Quaternion.CreateFromAxisAngle(new Vector3(1, 0, 0), MathHelper.ToRadians(60)); cylinderTransNode.Translation = new Vector3(0, (float) 0.6, 3); cylinderRotationParentNode = new TransformNode(); cylinderRotationParentNode.Translation = Vector3.Zero; cylinderRotationParentNode = new TransformNode(); cylinderControlPanel = new TransformNode(); cylinderControlPanel.Translation = Vector3.Zero; cylinderControlPanel1 = new TransformNode(); cylinderControlPanel1.Translation = Vector3.Zero; cylinderControlPanel2 = new TransformNode(); cylinderControlPanel2.Translation = Vector3.Zero; cylinderRotateSunNode = new TransformNode(); cylinderRotateSunNode.Translation = Vector3.Zero; cylinderNode.Physics.Pickable = true; cylinderNode.AddToPhysicsEngine = true; // Create a geometry node with a model of cone. coneNode = new SynchronizedGeometryNode("Dubris-Cone"); coneNode.Model = new Cylinder(1.5f, 0, 4f, 20); //Initializing materials for cone. Material coneMat = new Material(); coneMat.Diffuse = Color.Lime.ToVector4(); coneMat.Specular = Color.White.ToVector4(); coneMat.SpecularPower = 5; coneNode.Material = coneMat; //Transforme node for the cone node. TransformNode coneTransNode = new TransformNode(); coneTransNode.Scale = new Vector3(0.03f, 0.03f, 0.03f); coneTransNode.Rotation = Quaternion.CreateFromAxisAngle(new Vector3(1, 1, 0), MathHelper.ToRadians(45)); coneTransNode.Translation = new Vector3(0, (float)0.4, (float)3.2); coneRotationParentNode = new TransformNode(); coneRotationParentNode.Translation = Vector3.Zero; coneControlPanel = new TransformNode(); coneControlPanel.Translation = Vector3.Zero; coneControlPanel1 = new TransformNode(); coneControlPanel1.Translation = Vector3.Zero; coneControlPanel2 = new TransformNode(); coneControlPanel2.Translation = Vector3.Zero; coneRotateSunNode = new TransformNode(); coneRotateSunNode.Translation = Vector3.Zero; coneNode.Physics.Pickable = true; coneNode.AddToPhysicsEngine = true; // Create a geometry node with a model of torus. torusNode = new SynchronizedGeometryNode("Dubris-Torus"); torusNode.Model = new Torus(0.7f, 1.5f, 30, 30); //Initializing materials for torus. Material torusMat = new Material(); torusMat.Diffuse = Color.Magenta.ToVector4(); torusMat.Specular = Color.White.ToVector4(); torusMat.SpecularPower = 10; torusNode.Material = torusMat; //Transforme node for the torus node. TransformNode torusTransNode = new TransformNode(); torusTransNode.Scale = new Vector3(0.03f, 0.03f, 0.03f); torusTransNode.Translation = new Vector3(0, (float)0.6, (float)3.4); torusTransNode.Rotation = Quaternion.CreateFromAxisAngle(new Vector3(0, 0, 1), MathHelper.ToRadians(60)); torusRotationParentNode = new TransformNode(); torusRotationParentNode.Translation = Vector3.Zero; torusControlPanel = new TransformNode(); torusControlPanel.Translation = Vector3.Zero; torusControlPanel1 = new TransformNode(); torusControlPanel1.Translation = Vector3.Zero; torusControlPanel2 = new TransformNode(); torusControlPanel2.Translation = Vector3.Zero; torusRotateSunNode = new TransformNode(); torusRotateSunNode.Translation = Vector3.Zero; torusNode.Physics.Pickable = true; torusNode.AddToPhysicsEngine = true; // Create a geometry node with a model of box boxNode = new SynchronizedGeometryNode("Dubris-Box"); boxNode.Model = new Box(1, 4, 4); //Initiallizing materials for box. Material boxMat = new Material(); boxMat.Diffuse = Color.Crimson.ToVector4(); boxMat.Specular = Color.White.ToVector4(); boxMat.SpecularPower = 5; boxNode.Material = boxMat; //Transforme node for the box node. TransformNode boxTransNode = new TransformNode(); boxTransNode.Scale = new Vector3(0.03f, 0.03f, 0.03f); boxTransNode.Translation = new Vector3(0, (float)0.45, (float)3.3); boxTransNode.Rotation = Quaternion.CreateFromAxisAngle(new Vector3(0, 0, 1), MathHelper.ToRadians(30)); boxRotationParentNode = new TransformNode(); boxRotationParentNode.Translation = Vector3.Zero; boxControlPanel = new TransformNode(); boxControlPanel.Translation = Vector3.Zero; boxControlPanel1 = new TransformNode(); boxControlPanel1.Translation = Vector3.Zero; boxControlPanel2 = new TransformNode(); boxControlPanel2.Translation = Vector3.Zero; boxRotateSunNode = new TransformNode(); boxRotateSunNode.Translation = Vector3.Zero; boxNode.Physics.Pickable = true; boxNode.AddToPhysicsEngine = true; //Add the Sun node to the scene graph scene.RootNode.AddChild(mySunRotationParentNode); mySunRotationParentNode.AddChild(mySunTransNode); mySunTransNode.AddChild(mySun); //Add the Earth node to the scene graph scene.RootNode.AddChild(myEarthRotationParentNode1); myEarthRotationParentNode1.AddChild(myEarthTransNode); myEarthTransNode.AddChild(myEarthRotationParentNode2); myEarthRotationParentNode2.AddChild(earthControlPanel); earthControlPanel.AddChild(earthControlPanel1); earthControlPanel1.AddChild(earthControlPanel2); earthControlPanel2.AddChild(myEarth); //Add the Mercury to the scene graph scene.RootNode.AddChild(myMercuryRotationParentNode1); myMercuryRotationParentNode1.AddChild(myMercuryTransNode); myMercuryTransNode.AddChild(myMercuryRotationParentNode2); myMercuryRotationParentNode2.AddChild(mercuryControlPanel); mercuryControlPanel.AddChild(mercuryControlPanel1); mercuryControlPanel1.AddChild(mercuryControlPanel2); mercuryControlPanel2.AddChild(myMercury); //Add the Mars to the scene graph scene.RootNode.AddChild(myMarsRotationParentNode1); myMarsRotationParentNode1.AddChild(myMarsTransNode); myMarsTransNode.AddChild(myMarsRotationParentNode2); myMarsRotationParentNode2.AddChild(marsControlPanel); marsControlPanel.AddChild(marsControlPanel1); marsControlPanel1.AddChild(marsControlPanel2); marsControlPanel2.AddChild(myMars); //Add the Jupiter node to the scene graph scene.RootNode.AddChild(myJupiterRotationParentNode1); myJupiterRotationParentNode1.AddChild(myJupiterTransNode); myJupiterTransNode.AddChild(myJupiterRotationParentNode2); myJupiterRotationParentNode2.AddChild(jupiterControlPanel); jupiterControlPanel.AddChild(jupiterControlPanel1); jupiterControlPanel1.AddChild(jupiterControlPanel2); jupiterControlPanel2.AddChild(myJupiter); //Add the Moon node to the scene graph scene.RootNode.AddChild(myMoonRotationParentNode1); myMoonRotationParentNode1.AddChild(myMoonRotationParentNode2); myMoonRotationParentNode2.AddChild(myMoonRotationParentNode3); myMoonRotationParentNode3.AddChild(myMoonTransNode); myMoonTransNode.AddChild(myMoonRotationParentNode4); myMoonRotationParentNode4.AddChild(moonControlPanel); moonControlPanel.AddChild(moonControlPanel1); moonControlPanel1.AddChild(moonControlPanel2); moonControlPanel2.AddChild(myMoon); //Add the cylinder node to the scene graph scene.RootNode.AddChild(cylinderRotationParentNode); cylinderRotationParentNode.AddChild(cylinderTransNode); cylinderTransNode.AddChild(cylinderControlPanel); cylinderControlPanel.AddChild(cylinderControlPanel1); cylinderControlPanel1.AddChild(cylinderControlPanel2); cylinderControlPanel2.AddChild(cylinderRotateSunNode); cylinderRotateSunNode.AddChild(cylinderNode); //Add the cone node to the scene graph scene.RootNode.AddChild(coneRotationParentNode); coneRotationParentNode.AddChild(coneTransNode); coneTransNode.AddChild(coneControlPanel); coneControlPanel.AddChild(coneControlPanel1); coneControlPanel1.AddChild(coneControlPanel2); coneControlPanel2.AddChild(coneRotateSunNode); coneRotateSunNode.AddChild(coneNode); //Add the torus node to the scene graph scene.RootNode.AddChild(torusRotationParentNode); torusRotationParentNode.AddChild(torusTransNode); torusTransNode.AddChild(torusControlPanel); torusControlPanel.AddChild(torusControlPanel1); torusControlPanel1.AddChild(torusControlPanel2); torusControlPanel2.AddChild(torusRotateSunNode); torusRotateSunNode.AddChild(torusNode); //Add the box node to the scene graph scene.RootNode.AddChild(boxRotationParentNode); boxRotationParentNode.AddChild(boxTransNode); boxTransNode.AddChild(boxControlPanel); boxControlPanel.AddChild(boxControlPanel1); boxControlPanel1.AddChild(boxControlPanel2); boxControlPanel2.AddChild(boxRotateSunNode); boxRotateSunNode.AddChild(boxNode); }
private void CreateObject() { ModelLoader loader = new ModelLoader(); // Create a geometry node with a model of a space ship GeometryNode shipNode = new GeometryNode("Ship"); shipNode.Model = (Model)loader.Load("", "p1_wedge"); ((Model)shipNode.Model).UseInternalMaterials = true; // Compute the right scale to apply to the model so that the max dimension // of the model will be 50.0 cm (cm is used here since we used cm measure // for setting our interpupillary distance) Vector3 dim = Vector3Helper.GetDimensions(shipNode.Model.MinimumBoundingBox); float scale = 50.0f / Math.Max(Math.Max(dim.X, dim.Y), dim.Z); // Create a transform node to define the transformation of this model // (Transformation includes translation, rotation, and scaling) modelTransformNode = new TransformNode(); #if VR modelTransformNode.Scale = new Vector3(scale, scale, scale); // Place the model 60 cm away from the viewer modelTransformNode.Translation = new Vector3(0, 0, -60); modelTransformNode.Rotation = Quaternion.CreateFromAxisAngle(Vector3.UnitY, MathHelper.ToRadians(90)); scene.RootNode.AddChild(modelTransformNode); #else float largeScale = scale * 4; modelTransformNode.Scale = new Vector3(largeScale, largeScale, largeScale); modelTransformNode.Translation = new Vector3(0, 0, dim.Y * largeScale / 2); modelTransformNode.Rotation = Quaternion.CreateFromAxisAngle(Vector3.UnitX, MathHelper.ToRadians(90)) * Quaternion.CreateFromAxisAngle(Vector3.UnitY, MathHelper.ToRadians(90)); groundMarkerNode.AddChild(modelTransformNode); #endif modelTransformNode.AddChild(shipNode); }