summaryrefslogtreecommitdiff
path: root/NW4RTools/Models
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--NW4RTools/Models/Material.cs13
-rw-r--r--NW4RTools/Models/OpenGL/GLModel.cs2
-rw-r--r--NW4RTools/Models/VertexData.cs52
3 files changed, 66 insertions, 1 deletions
diff --git a/NW4RTools/Models/Material.cs b/NW4RTools/Models/Material.cs
index 0bf0acc..519790c 100644
--- a/NW4RTools/Models/Material.cs
+++ b/NW4RTools/Models/Material.cs
@@ -18,6 +18,17 @@ namespace NW4RTools.Models {
public byte MapType;
public byte Flags;
public Matrix TexMatrix;
+
+ public SRTSettingInfo() {
+ ScaleX = 1.0f;
+ ScaleY = 1.0f;
+
+ CameraID = 0xFF;
+ LightID = 0xFf;
+ Flags = 1;
+
+ TexMatrix.Identity();
+ }
}
@@ -62,6 +73,8 @@ namespace NW4RTools.Models {
IndirectTexMtxCalcMethod2 = new byte[4];
TexObj = new byte[8][];
// todo
+ SRTSettings = new SRTSettingInfo[8];
+ ChanCtrls = new ChanCtrl[2];
TextureInfos = new List<TextureInfo>();
}
}
diff --git a/NW4RTools/Models/OpenGL/GLModel.cs b/NW4RTools/Models/OpenGL/GLModel.cs
index 8ca3f31..072ea00 100644
--- a/NW4RTools/Models/OpenGL/GLModel.cs
+++ b/NW4RTools/Models/OpenGL/GLModel.cs
@@ -257,7 +257,7 @@ namespace NW4RTools.Models.OpenGL {
break;
if ((cmd & (int)GXCommand.DrawPrimitiveMask) != 0) {
- PrimitiveType prim = (PrimitiveType)((cmd >> 3) & 7);
+ PrimitiveType prim = (PrimitiveType)((cmd >> (byte)GXCommand.PrimitiveShiftAmount) & 7);
int vtxCount = dl.ReadUInt16();
if ((cmd & 7) != 0)
diff --git a/NW4RTools/Models/VertexData.cs b/NW4RTools/Models/VertexData.cs
index 187b9aa..feb8eb6 100644
--- a/NW4RTools/Models/VertexData.cs
+++ b/NW4RTools/Models/VertexData.cs
@@ -60,6 +60,54 @@ namespace NW4RTools.Models {
}
}
+ public virtual void Save() {
+ int elementCount = Data[0].Length;
+ float scale = 1.0f / (1 << Fraction);
+ var output = new OutputStream();
+
+ switch (ComponentType) {
+ case VertexSettings.CompType.UInt8:
+ foreach (var array in Data) {
+ for (int i = 0; i < elementCount; i++) {
+ output.WriteByte((byte)(array[i] / scale));
+ }
+ }
+ break;
+ case VertexSettings.CompType.Int8:
+ foreach (var array in Data) {
+ for (int i = 0; i < elementCount; i++) {
+ output.WriteSByte((sbyte)(array[i] / scale));
+ }
+ }
+ break;
+ case VertexSettings.CompType.UInt16:
+ foreach (var array in Data) {
+ for (int i = 0; i < elementCount; i++) {
+ output.WriteUInt16((ushort)(array[i] / scale));
+ }
+ }
+ break;
+ case VertexSettings.CompType.Int16:
+ foreach (var array in Data) {
+ for (int i = 0; i < elementCount; i++) {
+ output.WriteInt16((short)(array[i] / scale));
+ }
+ }
+ break;
+ case VertexSettings.CompType.Float32:
+ foreach (var array in Data) {
+ for (int i = 0; i < elementCount; i++) {
+ output.WriteFloat(array[i]);
+ }
+ }
+ break;
+ default:
+ throw new NotImplementedException(String.Format("unimplemented type {0}", (int)ComponentType));
+ }
+
+ RawData = output.GetBuffer();
+ }
+
public abstract int GetRealCount();
}
@@ -186,6 +234,10 @@ namespace NW4RTools.Models {
return ret;
}
+
+ public override void Save() {
+ throw new NotImplementedException();
+ }
}