//---------------------------------------------------------------------------------------------------------------------------------------------------
//
// Copyright (C)2007 DarkWynter Studios. All rights reserved.
//
//---------------------------------------------------------------------------------------------------------------------------------------------------
// {Contact : darkwynter.com for licensing information
//---------------------------------------------------------------------------------------------------------------------------------------------------
namespace DarkWynter.Engine.ObjectLib
{
#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;
#endregion
using Globals;
using GameObjects;
using DarkWynter.Stream;
///
/// Class which manages a list of our billboard objects
///
public class BillboardList
{
List billboardList;
///
/// The common texture drawn on the billboards
///
public Texture2D texture;
///
/// The common bump map texture used on all the billboards
///
public Texture2D bump;
VertexPositionTexture[] vertSprites = null;
VertexDeclaration vertexDeclSprites = null;
short[] indexBuffer = null;
///
/// Constructor
///
public BillboardList()
{
billboardList = new List();
vertexDeclSprites = new VertexDeclaration(Statics_Stream.RenderSettings.graphics.GraphicsDevice, VertexPositionTexture.VertexElements);
vertSprites = new VertexPositionTexture[]
{
new VertexPositionTexture(new Vector3(-0.5f, -0.5f, 0), new Vector2(0,1)),
new VertexPositionTexture(new Vector3(0.5f, -0.5f, 0), new Vector2(1,1)),
new VertexPositionTexture(new Vector3(0.5f, 0.5f, 0), new Vector2(1,0)),
new VertexPositionTexture(new Vector3(-0.5f, 0.5f, 0), new Vector2(0,0))
};
indexBuffer = new short[] { 0, 1, 2, 2, 3, 0 };
}
///
/// Load stuff, currently empty
///
/// This billboard list's XML node
/// ObjectLibrary
public void Load(XmlNode objectNode, ObjectLibrary objectLibrary)
{
// Load from Xml
}
///
/// Adds a List of billboard to our current list
///
/// new list of billboards
public void Add(List billboard)
{
billboardList.AddRange(billboard);
}
///
/// Adds a single new billboard to our current list
///
/// New billboard
public void Add(Billboard billboard)
{
billboardList.Add(billboard);
}
///
/// Removes the billboard from our list
///
/// Billboard to be removed
public void Remove(Billboard billboard)
{
billboardList.Remove(billboard);
}
///
/// Draws all of the current billboards in our list
///
/// ObjectLibrary
/// The index of the current player whose view is being drawn (for orienting the billboard)
public List Draw_Billboards(ObjectLibrary objectLibrary, int playerIndex)
{
List drawList = new List();
// For each Billboard in the List<>
for (int i = 0; i < billboardList.Count; i++)
{
drawList.Add(billboardList[i].Draw_Billboards(objectLibrary, playerIndex));
}
return drawList;
}
private void DrawBillboard(float width, float height)
{
GraphicsDevice device = Statics_Stream.RenderSettings.graphics.GraphicsDevice;
//vertSprites[0].Position.X = - width / 2.0f;
//vertSprites[0].Position.Y = - height / 2.0f;
//vertSprites[0].Position.Z = 0.0f;
//vertSprites[1].Position.X = + width / 2.0f;
//vertSprites[1].Position.Y = - height / 2.0f;
//vertSprites[1].Position.Z = 0.0f;
//vertSprites[2].Position.X = + width / 2.0f;
//vertSprites[2].Position.Y = + height / 2.0f;
//vertSprites[2].Position.Z = 0.0f;
//vertSprites[3].Position.X = - width / 2.0f;
//vertSprites[3].Position.Y = + height / 2.0f;
//vertSprites[3].Position.Z = 0.0f;
// Render our quad
ShaderParameters.DrawFX.effect.Begin();
foreach (EffectPass pass in ShaderParameters.DrawFX.effect.CurrentTechnique.Passes)
{
pass.Begin();
device.DrawUserIndexedPrimitives
(PrimitiveType.TriangleList, vertSprites, 0, 4, indexBuffer, 0, 2);
pass.End();
}
ShaderParameters.DrawFX.effect.End();
}
}
}