//--------------------------------------------------------------------------------------------------------------------------------------------------- // // Copyright (C)2007 DarkWynter Studios. All rights reserved. // //--------------------------------------------------------------------------------------------------------------------------------------------------- // {Contact : darkwynter.com for licensing information //--------------------------------------------------------------------------------------------------------------------------------------------------- namespace DarkWynter.Game.GameObjects { #region Using Statements using System; using System.Collections.Generic; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Audio; using Microsoft.Xna.Framework.Content; using Microsoft.Xna.Framework.Graphics; using Microsoft.Xna.Framework.Input; using Microsoft.Xna.Framework.Storage; using System.Xml; using DarkWynter.Engine.Globals; using DarkWynter.Engine.Physics; using DarkWynter.Engine.ObjectLib; using DarkWynter.Engine.GameObjects; using DarkWynter.Engine.Init; using DarkWynter.Stream; using DarkWynter.Engine.EventControl; using System.Diagnostics; using Xclna.Xna.Animation; #endregion public class CubeOfCubes : GameObject { private CubeOfCubes[,] cubes; Stopwatch stopWatch = new Stopwatch(); static int maxdepth = 1; static int currentDepth = 0; const int TIMER = 1; public CubeOfCubes(XmlNode objectNode, Vector3 startingLocation) : base(objectNode, startingLocation) { mass.dynamicFrictionCoefficient = 0.0f; mass.isMoving = true; } public override bool Load(ObjectLibrary objectLibrary) { // Call before user code is executed if (!base.Load(objectLibrary)) { return false; } // Increment depth counter for recursive cell-division. if (currentDepth++ < maxdepth) { Vector3 dimensions = new Vector3(10, 20, 10); for (int x = -(int)(dimensions.X / 2.0f); x < (int)(dimensions.X / 2.0f); x++) { for (int y = -(int)(dimensions.Y / 2.0f); y < (int)(dimensions.Y / 2.0f); y++) { for (int z = -(int)(dimensions.Z / 2.0f); z < (int)(dimensions.Z / 2.0f); z++) { //CubeOfCubes // Create Scaled down CubeOfCubes // mass.scale *= 1/10th; // // mass.SetPosition( } } } } return true; } private bool Load(ObjectLibrary objectLibrary, Vector3 position, Vector3 scale) { // Call before user code is executed if (!base.Load(objectLibrary)) { return false; } //draw.textureList[0] = Statics_Engine.SystemSettings.content.Load("Content/_textures/arrow"); // Get terrain height at position //float yPosition = objectLibrary.terrain.GetTerrainHeight(load.startPosition.X / Statics_Engine.TerrainSettings.terrainScaleFactor, // load.startPosition.Z / Statics_Engine.TerrainSettings.terrainScaleFactor); float yPosition = float.Parse(node.Attributes["y"].Value) * Statics_Engine.TerrainSettings.terrainScaleFactor; // Set position and reference Vector3 locpos = new Vector3(startPosition.X, yPosition, startPosition.Z); Vector3 refpos = new Vector3(startPosition.X, yPosition, startPosition.Z - 1); mass.SetPosition(locpos, refpos); draw.drawMethod = Enums_Stream.DrawMethod.BasicGameObject_Draw; draw.technique = "BasicLightingShaderMain"; mass.scale = new Vector3(mass.scale.X, 20, mass.scale.Z); mass.boundingVolume = new BoundingVolume(new BoundingSphere(mass.currentPosition, 180.0f)); stopWatch.Start(); return true; } public override void Update(ref ObjectLibrary objectLibrary) { // Call before user code is executed //base.Update(ref objectLibrary); //mass.boundingVolume.radius = 200.0f; //mass.boundingVolume.UpdateSphere(mass.currentPosition); } public override Draw Draw() { draw.matrix = draw.initialTransform * Matrix.CreateScale(mass.scale) * Matrix.CreateRotationY((float)Math.PI) * Matrix.CreateBillboard(this.mass.currentPosition, Statics_Stream.RenderSettings.cameraList[0].cameraPosition, Statics_Stream.RenderSettings.cameraList[0].upVec, Statics_Stream.RenderSettings.cameraList[0].lookAtPosition); //Matrix.CreateFromQuaternion(mass.currentRotation) * // Matrix.CreateTranslation(mass.currentPosition); return draw; } } }