using System.Collections.Generic;
using ACE.DatLoader;
using ACE.DatLoader.FileTypes;
namespace ACE.Server.Entity
{
///
/// A static mesh contains all data that is common
/// to each instance with this model id
///
public class StaticMesh
{
///
/// The unique model identifier
///
public uint ModelId;
///
/// A multi-part model
///
public SetupModel SetupModel;
///
/// The individual model parts
///
public List GfxObjs;
///
/// The list of polygons for this model
///
public List Polygons;
///
/// Constructs a new static mesh from a model id
///
public StaticMesh(uint modelId)
{
ModelId = modelId;
var modelType = modelId >> 24;
if (modelType == 0x01)
{
LoadModelPart(modelId);
}
else if (modelType == 0x02)
{
SetupModel = DatManager.PortalDat.ReadFromDat(modelId);
foreach (var part in SetupModel.Parts)
LoadModelPart(part);
}
}
///
/// Loads an individual piece of a model
///
public void LoadModelPart(uint modelId)
{
if (GfxObjs == null) GfxObjs = new List();
if (Polygons == null) Polygons = new List();
var gfxObj = DatManager.PortalDat.ReadFromDat(modelId);
GfxObjs.Add(gfxObj);
foreach (var poly in gfxObj.Polygons.Values)
{
Polygons.Add(new ModelPolygon(poly, gfxObj.VertexArray));
}
}
}
}