summaryrefslogtreecommitdiff
path: root/NW4RTools/Models
diff options
context:
space:
mode:
authorTreeki <treeki@gmail.com>2011-02-04 15:40:12 +0100
committerTreeki <treeki@gmail.com>2011-02-04 15:40:12 +0100
commitdb8fc350b2bffda63d27797bfe7ae4afb4af327e (patch)
treea0a89cd83615e7794d9507d10c329e30c4226670 /NW4RTools/Models
downloadnw4rtools-db8fc350b2bffda63d27797bfe7ae4afb4af327e.tar.gz
nw4rtools-db8fc350b2bffda63d27797bfe7ae4afb4af327e.zip
Initial commit of NW4RTools.
Supports BRRES reading for: Model Bytecode, Model Nodes, Model Vertex Data, and incomplete Materials. Writing is completely unimplemented so far.
Diffstat (limited to '')
-rw-r--r--NW4RTools/Models/ByteCode.cs74
-rw-r--r--NW4RTools/Models/Material.cs54
-rw-r--r--NW4RTools/Models/Model.cs37
-rw-r--r--NW4RTools/Models/Node.cs26
-rw-r--r--NW4RTools/Models/VertexData.cs46
5 files changed, 237 insertions, 0 deletions
diff --git a/NW4RTools/Models/ByteCode.cs b/NW4RTools/Models/ByteCode.cs
new file mode 100644
index 0000000..438c009
--- /dev/null
+++ b/NW4RTools/Models/ByteCode.cs
@@ -0,0 +1,74 @@
+using System;
+using System.Collections.Generic;
+
+namespace NW4RTools.Models {
+ public class ByteCode {
+ public enum OpType {
+ None, Done, AssignNodeToParentMtx, BlendMatrices, DrawShape, AssignMtxToNode
+ }
+
+ public class Instruction {
+ public virtual OpType GetOp() {
+ return OpType.None;
+ }
+ }
+
+ public class DoneInstruction : Instruction {
+ public override OpType GetOp() {
+ return OpType.Done;
+ }
+ }
+
+ public class AssignNodeToParentMtxInstruction : Instruction {
+ public override OpType GetOp() {
+ return OpType.AssignNodeToParentMtx;
+ }
+
+ public UInt16 NodeID;
+ public UInt16 ParentMatrixID;
+ }
+
+ public class BlendMatricesInstruction : Instruction {
+ public override OpType GetOp() {
+ return OpType.BlendMatrices;
+ }
+
+ public UInt16 MatrixID;
+ public BlendedMatrix[] BlendedMatrices;
+
+ public struct BlendedMatrix {
+ public UInt16 MatrixID;
+ public float Ratio;
+ }
+ }
+
+ public class DrawShapeInstruction : Instruction {
+ public override OpType GetOp() {
+ return OpType.DrawShape;
+ }
+
+ public UInt16 MaterialID;
+ public UInt16 ShapeID;
+ public UInt16 NodeID;
+ }
+
+ public class AssignMtxToNodeInstruction : Instruction {
+ public override OpType GetOp() {
+ return OpType.AssignMtxToNode;
+ }
+
+ public UInt16 MatrixID;
+ public UInt16 NodeID;
+ }
+
+
+
+
+ public List<Instruction> Instructions;
+
+ public ByteCode() {
+ Instructions = new List<Instruction>();
+ }
+ }
+}
+
diff --git a/NW4RTools/Models/Material.cs b/NW4RTools/Models/Material.cs
new file mode 100644
index 0000000..bb1b85a
--- /dev/null
+++ b/NW4RTools/Models/Material.cs
@@ -0,0 +1,54 @@
+using System;
+
+namespace NW4RTools.Models {
+ public class ChanCtrl {
+ public UInt32 Flags;
+ public Color MatColor, AmbColor;
+ public UInt32 FlagC, FlagA;
+ }
+
+ public class SRTSettingInfo {
+ public float ScaleX, ScaleY, Rotate, TranslateX, TranslateY;
+
+ public byte CameraID;
+ public byte LightID;
+ public byte MapType;
+ public byte Flags;
+ public Matrix TexMatrix;
+ }
+
+ public class BoundTextureInfo {
+ public string TextureName, PaletteName;
+ public UInt32 TexMapID, TlutID, WrapS, WrapT, MinFilt, MagFilt;
+ public float LODBias;
+ public UInt32 MaxAniso;
+ }
+
+
+
+ public class Material {
+ public UInt32 Index, Flags;
+
+ // ResGenMode
+ public byte TexCoordGenCount, ChanCount, TevStageCount, IndStageCount;
+ public UInt32 CullMode;
+
+ // ResMatMisc
+ public byte ZCompLoc, LightSetID, FogID;
+ public byte[] IndirectTexMtxCalcMethod1;
+ public byte[] IndirectTexMtxCalcMethod2;
+
+ // ResTexObj and ResTlutObj
+ public byte[][] TexObj;
+ public byte[] TlutObj;
+
+ // ResTexSrt
+ public SRTSettingInfo[] SRTSettings;
+
+ // UNFINISHED
+
+ public Material() {
+ }
+ }
+}
+
diff --git a/NW4RTools/Models/Model.cs b/NW4RTools/Models/Model.cs
new file mode 100644
index 0000000..ea95f4f
--- /dev/null
+++ b/NW4RTools/Models/Model.cs
@@ -0,0 +1,37 @@
+using System;
+namespace NW4RTools.Models {
+ public class Model {
+ public enum ScaleModeType {
+ Standard, SoftImage, Maya
+ }
+
+ public enum TexMatrixModeType {
+ Maya, SoftImage, Max
+ }
+
+ public ResDict<ByteCode> Bytecode;
+ public ResDict<Node> Nodes;
+ public ResDict<VertexPosData> VtxPosData;
+ public ResDict<VertexNrmData> VtxNrmData;
+ public ResDict<VertexClrData> VtxClrData;
+ public ResDict<VertexTexCoordData> VtxTexCoordData;
+
+ /*public ResDict Bytecode, Nodes, VtxPosData, VtsNrmData, VtxClrData, VtxTexCoordData;
+ public ResDict VtxFurVecData, VtxFurPosData, Materials, Shaders, Shapes;
+ public ResDict Textures, Palettes;*/
+
+ public ScaleModeType ScaleMode;
+ public TexMatrixModeType TexMatrixMode;
+
+ public bool UsesNrmMtxArray, UsesTexMtxArray;
+
+ public Int32[] MatrixIDtoNodeID;
+
+ public Vec3 Minimum, Maximum;
+
+
+ public Model() {
+ }
+ }
+}
+
diff --git a/NW4RTools/Models/Node.cs b/NW4RTools/Models/Node.cs
new file mode 100644
index 0000000..4031ae9
--- /dev/null
+++ b/NW4RTools/Models/Node.cs
@@ -0,0 +1,26 @@
+using System;
+
+namespace NW4RTools.Models {
+ public class Node {
+ public enum BillboardType {
+ None, Type1, Type2, Type3, Type4, Type5, Type6
+ }
+
+ public UInt32 Index;
+ public UInt32 MatrixID;
+ public UInt32 Flags;
+ public BillboardType BillboardMode;
+
+ public Vec3 Scale, Rotation, Translation;
+ public Vec3 BoxMin, BoxMax;
+
+ public Node Parent, FirstChild, Next, Previous;
+ public byte[] UserData;
+
+ public Matrix NodeMatrix, NodeInvMatrix;
+
+ public Node() {
+ }
+ }
+}
+
diff --git a/NW4RTools/Models/VertexData.cs b/NW4RTools/Models/VertexData.cs
new file mode 100644
index 0000000..d8733b3
--- /dev/null
+++ b/NW4RTools/Models/VertexData.cs
@@ -0,0 +1,46 @@
+using System;
+
+namespace NW4RTools.Models {
+ public class VertexDataBase {
+ public UInt32 Index;
+
+ public UInt32 ComponentCount, ComponentType; // todo: enums
+ public byte Fraction /* Not used for colours */, EntrySize;
+ public UInt16 EntryCount;
+
+ // Todo, decode data when reading
+ public byte[] Data;
+
+ public VertexDataBase() {
+ }
+ }
+
+
+ public class VertexPosData : VertexDataBase {
+ public Vec3 Minimum, Maximum;
+
+ public VertexPosData() {
+ }
+ }
+
+
+ public class VertexNrmData : VertexDataBase {
+ public VertexNrmData() {
+ }
+ }
+
+
+ public class VertexClrData : VertexDataBase {
+ public VertexClrData() {
+ }
+ }
+
+
+ public class VertexTexCoordData : VertexDataBase {
+ public Vec2 Minimum, Maximum;
+
+ public VertexTexCoordData() {
+ }
+ }
+}
+