using System;
using System.Collections.Generic;
using System.Linq;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.GamerServices;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Media;
using Microsoft.Xna.Framework.Net;
using Microsoft.Xna.Framework.Storage;
using SpaceSupport;
using BEPUphysics;
using BEPUphysics.DataStructures;
using BEPUphysics.Entities;
using BEPUphysics.Entities;
using System.Threading;
//using BEPUphysicsDrawer.Models;
namespace Derelict
{
///
/// This is the main type for your game
///
public class Game1 : Microsoft.Xna.Framework.Game
{
GraphicsDeviceManager graphics;
SpriteBatch spriteBatch;
//Model testModel,testModel2;
//TODO: reorganize this horror
List testModels;
List testTextures;
Dictionary wallModels;
Dictionary wallTextures;
float aspect;
Vector3 modelPosition;
float modelRotation = 0.0f;
Vector3 camPosition = new Vector3(0.0f,15.0f,50.0f);
Player p1;
List shipData;
PDA mainPDA;
//List tiles3d;
Dictionary tileWallOffsets;
Dictionary tileWallRotations;
//Dictionary tileWallTextures;
Effect tileEffect;
SpriteBatch HUDsb;
StandardHUDState standardHS;
ShipHUDState shipHS;
Random r;
string focusedActorName;
//physics stuff
Space globalSpace;
List verts;
List indices;
TriangleMesh triangleMesh;
StaticTriangleGroup triangleGroup;
// Ship3d testShip;
List armada;
int currentShip;
List asteroids;
SpriteFont tempFont;
GamePadState curGPS, prevGPS;
bool isPaused = false;
//public ModelDrawer mdrawer;
public Game1()
{
graphics = new GraphicsDeviceManager(this);
graphics.PreferredBackBufferWidth = 1280;
graphics.PreferredBackBufferHeight = 720;
GlobalData.graphics = graphics;
Content.RootDirectory = "Content";
curGPS = new GamePadState();
prevGPS = new GamePadState();
r = new Random();
currentShip = 0;
}
///
/// Allows the game to perform any initialization it needs to before starting to run.
/// This is where it can query for any required services and load any non-graphic
/// related content. Calling base.Initialize will enumerate through any components
/// and initialize them as well.
///
protected override void Initialize()
{
// TODO: Add your initialization logic here
base.Initialize();
}
///
/// LoadContent will be called once per game and is the place to load
/// all of your content.
///
protected override void LoadContent()
{
Model tempModel;
Texture2D tempTex;
Texture2D tempTex2;
Sphere tempSphere;
Box tempBox;
Actor tempAct;
PDATab tempTab;
PDAFolder tempFolder, tempFolder2;
// Create a new SpriteBatch, which can be used to draw textures.
spriteBatch = new SpriteBatch(GraphicsDevice);
Ship3d tempShip;
IA_Helm tempHelm;
HUDState.init(new Rectangle(0, 0, graphics.PreferredBackBufferWidth, graphics.PreferredBackBufferHeight));
PDATab.init(Content, GraphicsDevice.Viewport.Bounds);
GlobalData.init(graphics, Content);
PDAProgram.init();
// HUD Stuff
standardHS = new StandardHUDState(Content, GraphicsDevice.Viewport.Bounds);
HUDsb = new SpriteBatch(graphics.GraphicsDevice);
//tileWallTextures = new Dictionary();
shipHS = new ShipHUDState(Content, GraphicsDevice.Viewport.Bounds);
tempFont = Content.Load("Fonts/tempFont");
mainPDA = new PDA(Content, GraphicsDevice.Viewport.Bounds);
tempTab = new PDATab("People");
tempFolder = new PDAFolder("things", "things to keep track of");
tempFolder2 = new PDAFolder("deeper", "a second tier folder");
tempFolder2.items.Add(new PDAProgram_Map("Map", "Galaxy Map"));
tempFolder2.items.Add(new PDAProgram_VMap("Map", "Galaxy Map"));
tempFolder2.items.Add(new PDAProgram("prog2b", "program 2"));
tempFolder2.items.Add(new PDAProgram("prog3b", "program 3"));
tempFolder.items.Add(tempFolder2);
tempFolder.items.Add(new PDAProgram("prog1","program 1"));
tempFolder.items.Add(new PDAProgram("prog2","program 2"));
tempFolder.items.Add(new PDAProgram("prog3","program 3"));
tempTab.items.Add(tempFolder);
tempTab.items.Add(new PDAFolder("stuff","stuff to know"));
tempTab.items.Add(new PDAFolder("important","don't lose track of this"));
tempTab.items.Add(new PDAProgram("game1","the first game"));
tempTab.items.Add(new PDAProgram("spreadsheetz","business time!"));
tempTab.items.Add(new PDAProgram("mediaPLYR","videos and music"));
mainPDA.addTab(tempTab);
tempTab = new PDATab("Money");
tempTab.items.Add(new PDAFolder("things2","what, more things?"));
tempTab.items.Add(new PDAFolder("stuffX","eXTREME stuff!"));
tempTab.items.Add(new PDAFolder("trash","empty this frequently"));
tempTab.items.Add(new PDAFolder("space porn","hope you aren't squeamish"));
tempTab.items.Add(new PDAFolder("xenosamples","gathered with xenotools" ));
tempTab.items.Add(new PDAFolder("maps","to help with the whole exploration thing"));
tempTab.items.Add(new PDAProgram("spreadsheetz","boring stuff for the science officer"));
tempTab.items.Add(new PDAProgram("defrag","keep things tidy"));
mainPDA.addTab(tempTab);
tempTab = new PDATab("Places");
tempTab.items.Add(new PDAFolder("things"));
tempTab.items.Add(new PDAProgram("BlackICE"));
tempTab.items.Add(new PDAProgram("destruct"));
tempTab.items.Add(new PDAProgram("evac"));
tempTab.items.Add(new PDAProgram("landingSQNC"));
tempTab.items.Add(new PDAProgram("solitaire"));
mainPDA.addTab(tempTab);
tileEffect = Content.Load(@"Effects/BasicEffect1");
testModels = new List();
testTextures = new List();
testModels.Add(Content.Load("Test/floorTest"));
testModels.Add(Content.Load("Test/ceilingTest"));
testModels.Add(Content.Load("Test/terminalTest"));
testModels.Add(Content.Load("Test/referenceDome"));
testModels.Add(Content.Load("Test/asteroid"));
testModels.Add(Content.Load("Test/box"));
wallModels = new Dictionary();
wallModels.Add(wallType.flat, Content.Load(@"Test/flatWall"));
wallModels.Add(wallType.door, Content.Load(@"Test/door"));
wallModels.Add(wallType.leftCorner, Content.Load(@"Test/leftCorner"));
wallModels.Add(wallType.rightCorner, Content.Load(@"Test/rightCorner"));
wallModels.Add(wallType.twoCorners, Content.Load(@"Test/twoCorners"));
wallModels.Add(wallType.vent, Content.Load(@"Test/vent"));
wallModels.Add(wallType.windowLG, Content.Load(@"Test/largeWindow"));
wallModels.Add(wallType.windowSM, Content.Load(@"Test/smallWindow"));
tempTex2 = Content.Load(@"Textures/floorTile");
wallTextures = new Dictionary();
foreach (KeyValuePair kvp in wallModels)
{
RemapModel(kvp.Value, tileEffect, out tempTex);
wallTextures.Add(kvp.Key, tempTex2);
}
tileWallOffsets = new Dictionary();
tileWallOffsets.Add(tileWallLocation.front, Vector3.Zero);
tileWallOffsets.Add(tileWallLocation.left, Vector3.Zero);
tileWallOffsets.Add(tileWallLocation.right, Vector3.Zero);
tileWallOffsets.Add(tileWallLocation.back, Vector3.Zero);
tileWallRotations = new Dictionary();
tileWallRotations.Add(tileWallLocation.front, 0);
tileWallRotations.Add(tileWallLocation.left, 90);
tileWallRotations.Add(tileWallLocation.right, 270);
tileWallRotations.Add(tileWallLocation.back, 180);
//wallModels.Add(wallType.open, Content.Load(@"Test/flatWall"));
//setup physics for test sphere thingy
/* StaticTriangleGroup.GetVerticesAndIndicesFromModel(testModels[testModels.Count-1], out verts, out indices);
triangleMesh = new TriangleMesh(verts, indices);
triangleGroup = new StaticTriangleGroup(triangleMesh);*/
p1 = new Player();
globalSpace = new Space();
if (Environment.ProcessorCount > 1)
{
for (int i = 0; i < Environment.ProcessorCount; i++)
{
globalSpace.ThreadManager.AddThread();
}
globalSpace.UseMultithreadedUpdate = true;
}
globalSpace.UseMultithreadedUpdate = true;
globalSpace.SimulationSettings.CollisionResponse.Iterations = 5;
globalSpace.SimulationSettings.CollisionDetection.CollisionDetectionType = CollisionDetectionType.DiscreteMPRGJK;
foreach (Model m in testModels)
{
RemapModel(m, tileEffect,out tempTex );
testTextures.Add(tempTex);
}
asteroids = new List();
for (int lcv = 0; lcv < 25; lcv++)
{
tempSphere = new Sphere(new Vector3(r.Next(1200) - 600, r.Next(1200) - 600, r.Next(1200) - 600), 30, 20);
((Entity)tempSphere).ApplyAngularImpulse(new Vector3(r.Next(2000) * 2, r.Next(2000) * 2, r.Next(2000) * 2));
asteroids.Add(tempSphere);
globalSpace.Add(tempSphere);
}
aspect = graphics.GraphicsDevice.Viewport.AspectRatio;
shipData = Content.Load>(@"ShipData\ShipData1");
//testShip = new Ship3d(globalSpace, shipData[0]);
armada = new List();
for (int lcv = 0; lcv < 10; lcv++)
{
tempShip = new Ship3d(globalSpace, shipData[r.Next(shipData.Count)]);
tempShip.teleport(new Vector3(r.Next(1200) - 600, r.Next(1200) - 600, r.Next(1200) - 600));
//TODO: WHY ISN'T ALL THIS STUFF IN THE CONSTRUCTOR FOR THE SHIP???
tempShip.ID = lcv;
tempBox = new Box(new Vector3(0, 0, 0), 1.0f, 1.0f, 1.0f);
tempHelm = new IA_Helm(tempShip); // InteractiveActor();
tempHelm.collision = tempBox; //TODO: Fix this!
tempHelm.model = testModels[5];
tempShip.interactiveActors.Add(tempHelm);
tempShip.interiorSpace.Add(tempBox);
tempBox.TeleportTo(tempShip.helmPos.tileProxy.WorldTransform.Translation + new Vector3(0, 1.0f, 0));
foreach (ShipTile3d st3d in tempShip.tiles3d)
{
//add placed actors here
foreach (KeyValuePair kvp in st3d.tileTile.contents)
{
switch (kvp.Value)
{
case "box":
tempBox = new Box(new Vector3(0, 0, 0), 1.0f, 1.0f, 1.0f);
tempAct = new Actor();
tempAct.model = testModels[5];
tempAct.collision = tempBox; //TODO: Fix this!
tempShip.actors.Add(tempAct);
tempShip.interiorSpace.Add(tempBox);
tempBox.TeleportTo(st3d.tileProxy.WorldTransform.Translation + new Vector3(kvp.Key.X - 1.5f, 1.0f, kvp.Key.Y - 1.5f)); //TODO:INCORPORATE VERTICAL
break;
}
}
foreach (KeyValuePair stw in st3d.tileTile.walls)
{
//ASSUMING FLOOR AND CEILING FOR NOW
tempShip.interiorSpace.Add(new Box(st3d.tileEntity.WorldTransform.Translation + new Vector3(0, 0.5f, 0), 6.0f, 1, 6.0f));
tempShip.interiorSpace.Add(new Box(st3d.tileEntity.WorldTransform.Translation + new Vector3(0, 5.5f, 0), 6.0f, 1, 6.01f));
if ((wallModels.ContainsKey(stw.Value.type)) && (tileWallOffsets.ContainsKey(stw.Key)) && (tileWallRotations.ContainsKey(stw.Key)))
{
//StaticTriangleGroup.GetVerticesAndIndicesFromModel(wallModels[stw.Value.type], out verts, out indices);
verts = new List();
indices = new List();
VertexHelper.ExtractTrianglesFrom(wallModels[stw.Value.type], verts, indices, Matrix.Identity);
triangleMesh = new TriangleMesh(VertexHelper.makeMVArray(verts), indices.ToArray());
triangleGroup = new StaticTriangleGroup(triangleMesh);
triangleGroup.WorldMatrix = Matrix.CreateRotationY(MathHelper.ToRadians(tileWallRotations[stw.Key])) * st3d.tileEntity.WorldTransform;
tempShip.interiorSpace.Add(triangleGroup);
}
}
}
armada.Add(tempShip);
}
assignPlayerToShip(armada[currentShip], p1);
/*if (GraphicsDevice.GraphicsProfile == GraphicsProfile.HiDef)
mdrawer = new InstancedModelDrawer(this);
else
mdrawer = new BruteModelDrawer(this);*/
//SUPER KLUDGE. NEED WAY TO GET ACCESS TO CONTENT LOADED MODELS WITHIN SHIP
/*
//bEPU model drawer setup to debug ship geometry
foreach (Entity e in testShip.interiorSpace.Entities)
{
if ((string)e.Tag != "noDisplayObject")
{
mdrawer.Add(e);
}
else //Remove the now unnecessary tag.
e.Tag = null;
}*/
}
private void assignPlayerToShip(Ship3d s, Player p)
{
Vector3 tempVec;
tempVec = new Vector3(s.spawnPos.tileLoc.X * 6 - (s.shipContent.sizeX * 3), -3, s.spawnPos.tileLoc.Y * 6 - (s.shipContent.sizeY * 3)) + new Vector3(0, 4, 0);
//p.setPosition(s.spawnPos.tileProxy.WorldTransform.Translation + new Vector3(0, 1, 0));
p.setPosition(tempVec);
p.assignSpace(s.interiorSpace);
}
///
/// UnloadContent will be called once per game and is the place to unload
/// all content.
///
protected override void UnloadContent()
{
// TODO: Unload any non ContentManager content here
}
///
/// Allows the game to run logic such as updating the world,
/// checking for collisions, gathering input, and playing audio.
///
/// Provides a snapshot of timing values.
protected override void Update(GameTime gameTime)
{
int lcv;
prevGPS = curGPS;
curGPS = GamePad.GetState(PlayerIndex.One);
Entity testEntity;
Vector3 hitLocation;
Vector3 hitNormal;
float toi;
InteractiveActor currentIA;
// Allows the game to exit
if (curGPS.Buttons.Back == ButtonState.Pressed)
this.Exit();
//HUD Updates
standardHS.update(gameTime, GamePad.GetState(PlayerIndex.One));
if (mainPDA.isOn)
{
mainPDA.update(gameTime, GamePad.GetState(PlayerIndex.One));
if ((curGPS.Buttons.Start == ButtonState.Pressed) && (prevGPS.Buttons.Start == ButtonState.Released))
{
mainPDA.isOn = false;
}
}
else
{
//update character input stuff
currentIA = null;
focusedActorName = "";
if (p1.controlMode == "player")
{
//TODO: HANDLE INTERACTION FOCUS AND INTERACTIVITY INSIDE PLAYER CONTROLLER
if (armada[currentShip].interiorSpace.RayCast(p1.position + p1.headOffset, p1.lookVector, 5.0f, true, out testEntity, out hitLocation, out hitNormal, out toi))
{
foreach (InteractiveActor ia in armada[currentShip].interactiveActors)
{
if (ia.collision==testEntity)
{
currentIA = ia;
focusedActorName = ia.name;
}
}
}
if ((curGPS.Buttons.Y == ButtonState.Pressed) && (prevGPS.Buttons.Y == ButtonState.Released))
{
p1.controlMode = "ship";
}
if ((curGPS.Buttons.X == ButtonState.Pressed) && (prevGPS.Buttons.X == ButtonState.Released))
{
if (currentIA != null)
{
currentIA.interact(p1);
}
}
//if ((curGPS.Buttons.A == ButtonState.Pressed) && (prevGPS.Buttons.A == ButtonState.Released))
if (curGPS.Buttons.A == ButtonState.Pressed)
{
p1.collisionCyl.ApplyLinearImpulse(new Vector3(0, 5000, 0));
}
//TODO: HANDLE PDA EXIT INSIDE PDA INPUT CODE
if ((curGPS.Buttons.Start == ButtonState.Pressed) && (prevGPS.Buttons.Start == ButtonState.Released))
{
mainPDA.isOn = true;
}
if ((curGPS.DPad.Right == ButtonState.Pressed) && (prevGPS.DPad.Right == ButtonState.Released))
{
currentShip += 1;
if (currentShip >= armada.Count)
currentShip = 0;
assignPlayerToShip(armada[currentShip], p1);
}
p1.updateInput(curGPS, gameTime);
}
else if (p1.controlMode == "ship")
{
if ((curGPS.Buttons.Y == ButtonState.Pressed) && (prevGPS.Buttons.Y == ButtonState.Released))
{
p1.controlMode = "player";
}
if ((curGPS.Buttons.B == ButtonState.Pressed) && (prevGPS.Buttons.B == ButtonState.Released))
{
armada[currentShip].shipCore.AngularVelocity = Vector3.Zero;
armada[currentShip].shipCore.LinearVelocity = Vector3.Zero;
}
armada[currentShip].updateInput(curGPS, gameTime);
}
//update physics
globalSpace.Update(gameTime);
armada[currentShip].updatePhysics(gameTime);
armada[currentShip].updatePosition(Matrix.Identity);
p1.updatePosition(armada[currentShip].shipCore.WorldTransform);
//mdrawer.Update();
}
base.Update(gameTime);
}
public static void RemapModel(Model model, Effect effect, out Texture2D tex)
{
Texture2D tempTex;
tex = null;
foreach (ModelMesh mesh in model.Meshes)
{
foreach (ModelMeshPart part in mesh.MeshParts)
{
tex = ((BasicEffect)part.Effect).Texture;
part.Effect = effect;
//part.Effect.Parameters["xTexture"].SetValue(tempTex);
}
}
}
public void drawModel(Model m,Texture2D t, Vector3 position,float rotation,Matrix viewMat,Matrix projMat,string techStr)
{
Matrix[] transforms = new Matrix[m.Bones.Count];
m.CopyAbsoluteBoneTransformsTo(transforms);
/* tileEffect.Parameters["xView"].SetValue(viewMat);
tileEffect.Parameters["xWorld"].SetValue(projMat);
tileEffect.Parameters["xProjection"].SetValue(Matrix.CreateRotationY(MathHelper.ToRadians(rotation)) *
Matrix.CreateTranslation(position)); */
/*tileEffect.Parameters["xProjection"].SetValue(transforms[mesh.ParentBone.Index] *
Matrix.CreateRotationY(MathHelper.ToRadians(rotation)) *
Matrix.CreateTranslation(position)); */
foreach (ModelMesh mesh in m.Meshes)
{
foreach (Effect effect in mesh.Effects)
{
effect.Parameters["xView"].SetValue(viewMat);
effect.Parameters["xProjection"].SetValue(projMat);
effect.Parameters["xWorld"].SetValue(transforms[mesh.ParentBone.Index] *
Matrix.CreateRotationY(MathHelper.ToRadians(rotation)) *
Matrix.CreateTranslation(position));
effect.Parameters["xTexture"].SetValue(t);
effect.CurrentTechnique = effect.Techniques[techStr];
mesh.Draw();
}
}
}
public void drawModelMat(Model m, Texture2D t, Matrix worldMat, float rotation, Matrix viewMat, Matrix projMat, string techStr)
{
Matrix[] transforms = new Matrix[m.Bones.Count];
m.CopyAbsoluteBoneTransformsTo(transforms);
foreach (ModelMesh mesh in m.Meshes)
{
foreach (Effect effect in mesh.Effects)
{
effect.Parameters["xView"].SetValue(viewMat);
effect.Parameters["xProjection"].SetValue(projMat);
effect.Parameters["xWorld"].SetValue(transforms[mesh.ParentBone.Index] *
Matrix.CreateRotationY(MathHelper.ToRadians(rotation)) *
worldMat);
effect.Parameters["xTexture"].SetValue(t);
effect.CurrentTechnique = effect.Techniques[techStr];
mesh.Draw();
}
}
}
public void drawModelBasic(Model m, Vector3 position, float rotation, Matrix viewMat, Matrix projMat)
{
Matrix[] transforms = new Matrix[m.Bones.Count];
m.CopyAbsoluteBoneTransformsTo(transforms);
foreach (ModelMesh mesh in m.Meshes)
{
foreach (BasicEffect effect in mesh.Effects)
{
effect.World=transforms[mesh.ParentBone.Index] *
Matrix.CreateRotationY(MathHelper.ToRadians(rotation)) *
Matrix.CreateTranslation(position);
effect.View=viewMat;
effect.Projection=projMat;
mesh.Draw();
}
}
}
///
/// Provides a snapshot of timing values.
///
protected override void Draw(GameTime gameTime)
{
// GraphicsDevice.Clear(Color.CornflowerBlue);
GraphicsDevice.BlendState = BlendState.Opaque;
GraphicsDevice.DepthStencilState = DepthStencilState.Default;
Matrix vMat=new Matrix();
if (p1.controlMode == "player")
{
vMat = p1.viewMat;
}
if (p1.controlMode == "ship")
{
vMat = armada[currentShip].viewMat;
}
// Matrix.CreateLookAt(p1.position + p1.headOffset, p1.lookTarget, Vector3.Up);
Matrix pMat = Matrix.CreatePerspectiveFieldOfView(MathHelper.ToRadians(45.0f), aspect, 0.25f, 10000.0f);
Matrix pMat2 = Matrix.CreatePerspectiveFieldOfView(MathHelper.ToRadians(45.0f), aspect, 10f, 1000000.0f);
Vector3 tilePos;
ShipTile tempTile;
ShipTile3d tempTile3d;
int lcv,lcv2;
//draw the reference dome
drawModel(testModels[3], testTextures[3], armada[currentShip].shipCore.WorldTransform.Translation, 0, vMat, pMat, "SkyboxTechnique");
//bEPU debug drawing
//mdrawer.Draw(vMat, pMat);
//separate interior/exterior
for (lcv = 0; lcv < armada[currentShip].tiles3d.Count; lcv++)
{
tempTile3d = armada[currentShip].tiles3d[lcv];
//NOTE: these component pieces need their own worldTransforms relative to their static location in the ships InteriorSpace
//This will probably be a componentObject of some sort with the individual static walls grouped into it
//The current tileEntity.WorldTransform is tied to the shell box that is simulating in the globalSpace
drawModelMat(testModels[0], testTextures[0], tempTile3d.tileEntity.WorldTransform * armada[currentShip].shipCore.WorldTransform, 0, vMat, pMat, "NNTextured");
drawModelMat(testModels[1], testTextures[1], tempTile3d.tileEntity.WorldTransform * armada[currentShip].shipCore.WorldTransform, 0, vMat, pMat, "NNTextured");
foreach (KeyValuePair stw in tempTile3d.tileTile.walls)
{
if ((wallModels.ContainsKey(stw.Value.type)) && (tileWallOffsets.ContainsKey(stw.Key)) && (tileWallRotations.ContainsKey(stw.Key)))
drawModelMat(wallModels[stw.Value.type], wallTextures[stw.Value.type], tempTile3d.tileEntity.WorldTransform * armada[currentShip].shipCore.WorldTransform, tileWallRotations[stw.Key], vMat, pMat, "NNTextured");
}
}
for (lcv2 = 0; lcv2 < armada.Count; lcv2++)
{
for (lcv = 0; lcv < armada[lcv2].tiles3d.Count; lcv++)
{
tempTile3d = armada[lcv2].tiles3d[lcv];
//NOTE: these component pieces need their own worldTransforms relative to their static location in the ships InteriorSpace
//This will probably be a componentObject of some sort with the individual static walls grouped into it
//The current tileEntity.WorldTransform is tied to the shell box that is simulating in the globalSpace
drawModelMat(testModels[0], testTextures[0], tempTile3d.tileEntity.WorldTransform * armada[lcv2].shipCore.WorldTransform, 0, vMat, pMat, "NNTextured");
drawModelMat(testModels[1], testTextures[1], tempTile3d.tileEntity.WorldTransform * armada[lcv2].shipCore.WorldTransform, 0, vMat, pMat, "NNTextured");
foreach (KeyValuePair stw in tempTile3d.tileTile.walls)
{
if ((wallModels.ContainsKey(stw.Value.type)) && (tileWallOffsets.ContainsKey(stw.Key)) && (tileWallRotations.ContainsKey(stw.Key)))
drawModelMat(wallModels[stw.Value.type], wallTextures[stw.Value.type], tempTile3d.tileEntity.WorldTransform * armada[lcv2].shipCore.WorldTransform, tileWallRotations[stw.Key], vMat, pMat, "NNTextured");
}
}
}
foreach (Sphere a in asteroids)
{
drawModelMat(testModels[4], testTextures[4],a.WorldTransform, 0, vMat, pMat, "NNTextured");
}
foreach (InteractiveActor ia in armada[currentShip].interactiveActors)
{
//drawModelMat(testModels[5], testTextures[4], Matrix.CreateScale(0.0675f) * ia.collision.WorldTransform * armada[currentShip].shipCore.WorldTransform, 0, vMat, pMat, "NNTextured");
//TODO: MOVE THE LOCATION OF THE ACTOR TO INTERNAL DATA INSTEAD OF RELYING ON THE COLLISION'S TRANSFORM??
drawModelMat(ia.model, testTextures[4], ia.collision.WorldTransform * armada[currentShip].shipCore.WorldTransform, 0, vMat, pMat, "NNTextured");
}
foreach (Actor a in armada[currentShip].actors)
{
//drawModelMat(testModels[5], testTextures[4], Matrix.CreateScale(0.0675f) * ia.collision.WorldTransform * armada[currentShip].shipCore.WorldTransform, 0, vMat, pMat, "NNTextured");
drawModelMat(a.model, testTextures[4], a.collision.WorldTransform * armada[currentShip].shipCore.WorldTransform, 0, vMat, pMat, "NNTextured");
}
//ATTEMPTING TO RENDER A PLANET
//Matrix planTMat = asteroids[0].WorldTransform;// aMatrix.CreateTranslation(10, 0, 0);
//Matrix planSMat = Matrix.CreateScale(10);
// drawModelMat(testModels[4], testTextures[4], planSMat*planTMat, 0, vMat, pMat2, "NNTextured");
/*foreach (Model testModel in testModels)
{
drawModel(testModel,Vector3.Zero,vMat,pMat);
}*/
//TODO: Look at reimplementing this for performance
//http://blogs.msdn.com/b/shawnhar/archive/2006/11/13/spritebatch-and-renderstates.aspx
HUDsb.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend);
HUDsb.DrawString(tempFont, focusedActorName, new Vector2(300, 200), Color.White);
switch (p1.controlMode)
{
case "player":
if (mainPDA.isOn)
mainPDA.draw(HUDsb);
else
standardHS.draw(HUDsb);
break;
case "ship":
shipHS.draw(HUDsb);
break;
}
HUDsb.End();
base.Draw(gameTime);
}
}
}