public override void Load(byte[] data) { _file = new J3DFormat(); _renderList = new List<RenderBatch>(); _textureCache = new Dictionary<int, int>(); _file.Load(data); _dataCache = data; Selected = false; /* Dump info for debugging */ Console.WriteLine("Model: {0}, Vertex Count: {1} Packet Count: {2} Joint Count: {3}", FileName, _file.Info.GetVertexCount(), _file.Info.GetPacketCount(), _file.Joints.GetJointCount()); Console.WriteLine("Envelope Count: {0} Draw Count: {1}", _file.Envelopes.GetEnvelopeCount(), _file.Draw.GetDrawCount()); //Extract the data from the file format into something we can use. _vertDataBind = BuildVertexArraysFromFile(); //Build our scene-graph so we can iterate through it. _root = BuildSceneGraphFromInfo(); _skeleton = BuildSkeletonFromHierarchy(); //Generate our VBO, and upload the data GL.GenBuffers(1, out _glVbo); GL.BindBuffer(BufferTarget.ArrayBuffer, _glVbo); GL.BufferData(BufferTarget.ArrayBuffer, (IntPtr)(_vertDataBind.Count * 9 * 4), _vertDataBind.ToArray(), BufferUsageHint.StaticDraw); //Make sure we get drawn J3DRenderer.Instance.AddRenderable(this); }
public override void Load(byte[] data) { _file = new J3DFormat(); _renderList = new List <RenderBatch>(); _textureCache = new Dictionary <int, int>(); _file.Load(data); _dataCache = data; Selected = false; /* Dump info for debugging */ Console.WriteLine("Model: {0}, Vertex Count: {1} Packet Count: {2} Joint Count: {3}", FileName, _file.Info.GetVertexCount(), _file.Info.GetPacketCount(), _file.Joints.GetJointCount()); Console.WriteLine("Envelope Count: {0} Draw Count: {1}", _file.Envelopes.GetEnvelopeCount(), _file.Draw.GetDrawCount()); //Extract the data from the file format into something we can use. _vertDataBind = BuildVertexArraysFromFile(); //Build our scene-graph so we can iterate through it. _root = BuildSceneGraphFromInfo(); _skeleton = BuildSkeletonFromHierarchy(); //Generate our VBO, and upload the data GL.GenBuffers(1, out _glVbo); GL.BindBuffer(BufferTarget.ArrayBuffer, _glVbo); GL.BufferData(BufferTarget.ArrayBuffer, (IntPtr)(_vertDataBind.Count * 9 * 4), _vertDataBind.ToArray(), BufferUsageHint.StaticDraw); //Make sure we get drawn J3DRenderer.Instance.AddRenderable(this); }
private uint GetAttribElementSize(J3DFormat.DataTypes dataType) { switch (dataType) { case J3DFormat.DataTypes.Unsigned8: case J3DFormat.DataTypes.Signed8: return 1; case J3DFormat.DataTypes.Unsigned16: case J3DFormat.DataTypes.Signed16: return 2; case J3DFormat.DataTypes.Float32: case J3DFormat.DataTypes.Rgba8: return 4; } Console.WriteLine("Unknown attrib datatype {0}, guessing at 2!", dataType); return 2; }
public SceneGraph(J3DFormat.HierarchyDataTypes type, ushort index) { Children = new List<SceneGraph>(); NodeType = type; DataIndex = index; }