Init
This commit is contained in:
398
Assets/MindPowerSdk/Model/lwAnimDataInfo.cs
Normal file
398
Assets/MindPowerSdk/Model/lwAnimDataInfo.cs
Normal file
@ -0,0 +1,398 @@
|
||||
using System.IO;
|
||||
using System.Runtime.InteropServices;
|
||||
using UnityEngine;
|
||||
|
||||
namespace MindPowerSdk
|
||||
{
|
||||
[StructLayout(LayoutKind.Sequential, Pack = 1)]
|
||||
public class lwAnimDataInfo
|
||||
{
|
||||
[MarshalAs(UnmanagedType.LPStruct)]
|
||||
/* this+0x4 */
|
||||
public lwAnimDataBone anim_bone;
|
||||
|
||||
[MarshalAs(UnmanagedType.LPStruct)]
|
||||
/* this+0x8 */
|
||||
public lwAnimDataMatrix anim_mat;
|
||||
|
||||
[MarshalAs(UnmanagedType.LPStruct)]
|
||||
/* this+0xc */
|
||||
public lwAnimDataMtlOpacitySet anim_mtlopac;
|
||||
|
||||
[MarshalAs(UnmanagedType.LPStruct)]
|
||||
/* this+0x4c */
|
||||
public lwAnimDataTexUVSet anim_tex;
|
||||
|
||||
[MarshalAs(UnmanagedType.LPStruct)]
|
||||
/* this+0x14c */
|
||||
public lwAnimDataTexImgSet anim_img;
|
||||
}
|
||||
|
||||
public enum lwBoneKeyInfoType
|
||||
{
|
||||
BONE_KEY_TYPE_MAT43 = 1,
|
||||
BONE_KEY_TYPE_MAT44 = 2,
|
||||
BONE_KEY_TYPE_QUAT = 3,
|
||||
BONE_KEY_TYPE_INVALID = -1
|
||||
}
|
||||
|
||||
[StructLayout(LayoutKind.Sequential, Pack = 1)]
|
||||
public struct lwBoneBaseInfo
|
||||
{
|
||||
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 64)]
|
||||
/* this+0x0 */
|
||||
public char[] name;
|
||||
|
||||
/* this+0x40 */
|
||||
public uint id;
|
||||
|
||||
/* this+0x44 */
|
||||
public uint parent_id;
|
||||
}
|
||||
|
||||
[StructLayout(LayoutKind.Sequential, Pack = 1)]
|
||||
public struct lwBoneDummyInfo
|
||||
{
|
||||
/* this+0x0 */
|
||||
public uint id;
|
||||
|
||||
/* this+0x4 */
|
||||
public uint parent_bone_id;
|
||||
|
||||
/* this+0x8 */
|
||||
public Matrix4x4 mat;
|
||||
}
|
||||
|
||||
[StructLayout(LayoutKind.Sequential, Pack = 1)]
|
||||
public class lwMatrix43
|
||||
{
|
||||
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 12)]
|
||||
/* this+0x0 */
|
||||
public float[] m;
|
||||
};
|
||||
|
||||
[StructLayout(LayoutKind.Sequential, Pack = 1)]
|
||||
public class lwBoneKeyInfo
|
||||
{
|
||||
[MarshalAs(UnmanagedType.LPArray)]
|
||||
/* this+0x0 */
|
||||
public lwMatrix43[] mat43_seq;
|
||||
|
||||
[MarshalAs(UnmanagedType.LPArray)]
|
||||
/* this+0x4 */
|
||||
public Matrix4x4[] mat44_seq;
|
||||
|
||||
[MarshalAs(UnmanagedType.LPArray)]
|
||||
/* this+0x8 */
|
||||
public Vector3[] pos_seq;
|
||||
|
||||
[MarshalAs(UnmanagedType.LPArray)]
|
||||
/* this+0xc */
|
||||
public Quaternion[] quat_seq;
|
||||
};
|
||||
|
||||
[StructLayout(LayoutKind.Sequential, Pack = 1)]
|
||||
public class lwAnimDataMatrix
|
||||
{
|
||||
[MarshalAs(UnmanagedType.LPArray)]
|
||||
/* this+0x4 */
|
||||
public lwMatrix43[] _mat_seq;
|
||||
|
||||
/* this+0x8 */
|
||||
public uint _frame_num;
|
||||
|
||||
public int Load(BinaryReader fp, uint version)
|
||||
{
|
||||
this._frame_num = fp.ReadUInt32();
|
||||
this._mat_seq = StructReader.ReadStructArray<lwMatrix43>(fp, this._frame_num);
|
||||
return 0;
|
||||
}
|
||||
|
||||
public int Load(BinaryReader fp, uint version, uint frames)
|
||||
{
|
||||
this._frame_num = fp.ReadUInt32();
|
||||
if (frames < _frame_num)
|
||||
_frame_num = frames;
|
||||
this._mat_seq = StructReader.ReadStructArray<lwMatrix43>(fp, this._frame_num);
|
||||
return 0;
|
||||
}
|
||||
};
|
||||
|
||||
[StructLayout(LayoutKind.Sequential, Pack = 1)]
|
||||
public class lwAnimDataBone
|
||||
{
|
||||
[StructLayout(LayoutKind.Sequential, Pack = 1)]
|
||||
/* this+0x4 */
|
||||
public struct lwBoneInfoHeader
|
||||
{
|
||||
/* this+0x0 */
|
||||
public uint bone_num;
|
||||
|
||||
/* this+0x4 */
|
||||
public uint frame_num;
|
||||
|
||||
/* this+0x8 */
|
||||
public uint dummy_num;
|
||||
|
||||
/* this+0xc */
|
||||
public lwBoneKeyInfoType key_type; // MindPower::lwBoneKeyInfoType
|
||||
};
|
||||
|
||||
/* this+0x4 */
|
||||
public lwBoneInfoHeader _header;
|
||||
|
||||
[MarshalAs(UnmanagedType.LPArray)]
|
||||
/* this+0x14 */
|
||||
public lwBoneBaseInfo[] _base_seq;
|
||||
|
||||
[MarshalAs(UnmanagedType.LPArray)]
|
||||
/* this+0x18 */
|
||||
public lwBoneDummyInfo[] _dummy_seq;
|
||||
|
||||
[MarshalAs(UnmanagedType.LPArray)]
|
||||
/* this+0x1c */
|
||||
public lwBoneKeyInfo[] _key_seq;
|
||||
|
||||
[MarshalAs(UnmanagedType.LPArray)]
|
||||
/* this+0x20 */
|
||||
public Matrix4x4[] _invmat_seq;
|
||||
|
||||
public int Load(BinaryReader fp, uint version)
|
||||
{
|
||||
if (version == 0)
|
||||
{
|
||||
uint old_version = fp.ReadUInt32();
|
||||
int x = 0;
|
||||
}
|
||||
|
||||
if (this._base_seq != null)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
this._header = StructReader.ReadStruct<lwAnimDataBone.lwBoneInfoHeader>(fp);
|
||||
this._base_seq = StructReader.ReadStructArray<lwBoneBaseInfo>(fp, this._header.bone_num);
|
||||
this._key_seq = new lwBoneKeyInfo[this._header.bone_num];
|
||||
this._invmat_seq = StructReader.ReadStructArray<Matrix4x4>(fp, this._header.bone_num);
|
||||
this._dummy_seq = StructReader.ReadStructArray<lwBoneDummyInfo>(fp, this._header.dummy_num);
|
||||
|
||||
if (this._header.key_type == lwBoneKeyInfoType.BONE_KEY_TYPE_MAT43)
|
||||
{
|
||||
for (uint i = 0; i < this._header.bone_num; i++)
|
||||
{
|
||||
this._key_seq[i] = new lwBoneKeyInfo();
|
||||
lwBoneKeyInfo key = this._key_seq[i];
|
||||
key.mat43_seq = StructReader.ReadStructArray<lwMatrix43>(fp, this._header.frame_num);
|
||||
}
|
||||
}
|
||||
else if (this._header.key_type == lwBoneKeyInfoType.BONE_KEY_TYPE_MAT44)
|
||||
{
|
||||
for (uint i = 0; i < this._header.bone_num; i++)
|
||||
{
|
||||
this._key_seq[i] = new lwBoneKeyInfo();
|
||||
lwBoneKeyInfo key = this._key_seq[i];
|
||||
key.mat44_seq = StructReader.ReadStructArray<Matrix4x4>(fp, this._header.frame_num);
|
||||
}
|
||||
}
|
||||
else if (this._header.key_type == lwBoneKeyInfoType.BONE_KEY_TYPE_QUAT)
|
||||
{
|
||||
if (version >= 0x1003)
|
||||
{
|
||||
for (uint i = 0; i < this._header.bone_num; i++)
|
||||
{
|
||||
this._key_seq[i] = new lwBoneKeyInfo();
|
||||
lwBoneKeyInfo key = this._key_seq[i];
|
||||
key.pos_seq = StructReader.ReadStructArray<Vector3>(fp, this._header.frame_num);
|
||||
key.quat_seq = StructReader.ReadStructArray<Quaternion>(fp, this._header.frame_num);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for (uint i = 0; i < this._header.bone_num; i++)
|
||||
{
|
||||
this._key_seq[i] = new lwBoneKeyInfo();
|
||||
lwBoneKeyInfo key = this._key_seq[i];
|
||||
uint pos_num = this._base_seq[i].parent_id == 0xffffffff ? this._header.frame_num : 1;
|
||||
key.pos_seq = StructReader.ReadStructArray<Vector3>(fp, pos_num);
|
||||
if (pos_num == 1)
|
||||
{
|
||||
for (uint j = 1; j < this._header.frame_num; j++)
|
||||
{
|
||||
key.pos_seq[i] = key.pos_seq[0];
|
||||
}
|
||||
}
|
||||
|
||||
key.quat_seq = StructReader.ReadStructArray<Quaternion>(fp, this._header.frame_num);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
public int Load(string file)
|
||||
{
|
||||
int ret = -1;
|
||||
if (!File.Exists(file))
|
||||
return -1;
|
||||
FileStream fs = File.Open(file, FileMode.Open, FileAccess.Read);
|
||||
BinaryReader fp = new BinaryReader(fs);
|
||||
|
||||
uint version = fp.ReadUInt32();
|
||||
if (version < 0x1000)
|
||||
{
|
||||
version = 0;
|
||||
|
||||
Debug.LogError("old animation file: " + file + ", need re-export it");
|
||||
|
||||
fp.Close();
|
||||
fs.Close();
|
||||
return ret;
|
||||
}
|
||||
|
||||
if (this.Load(fp, version) >= 0)
|
||||
{
|
||||
// Overloaded version
|
||||
ret = 0;
|
||||
}
|
||||
|
||||
fp.Close();
|
||||
fs.Close();
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
||||
[StructLayout(LayoutKind.Sequential, Pack = 1)]
|
||||
public struct lwKeyFloat
|
||||
{
|
||||
/* this+0x0 */
|
||||
public uint key;
|
||||
|
||||
/* this+0x4 */
|
||||
public uint slerp_type;
|
||||
|
||||
/* this+0x8 */
|
||||
public float data;
|
||||
};
|
||||
|
||||
public interface lwIAnimKeySetFloat
|
||||
{
|
||||
uint SetKeySequence(lwKeyFloat[] seq, uint num);
|
||||
};
|
||||
|
||||
[StructLayout(LayoutKind.Sequential, Pack = 1)]
|
||||
public class lwAnimKeySetFloat : lwIAnimKeySetFloat
|
||||
{
|
||||
[MarshalAs(UnmanagedType.LPArray)]
|
||||
/* this+0x4 */
|
||||
public lwKeyFloat[] _data_seq;
|
||||
|
||||
/* this+0x8 */
|
||||
public uint _data_num;
|
||||
|
||||
/* this+0xc */
|
||||
public uint _data_capacity;
|
||||
|
||||
public uint SetKeySequence(lwKeyFloat[] seq, uint num)
|
||||
{
|
||||
_data_seq = seq;
|
||||
_data_num = num;
|
||||
_data_capacity = num;
|
||||
return 0;
|
||||
}
|
||||
};
|
||||
|
||||
[StructLayout(LayoutKind.Sequential, Pack = 1)]
|
||||
public struct lwAnimDataMtlOpacity
|
||||
{
|
||||
[MarshalAs(UnmanagedType.LPStruct)]
|
||||
/* this+0x4 */
|
||||
public lwIAnimKeySetFloat _aks_ctrl;
|
||||
|
||||
public int Load(BinaryReader fp, uint version)
|
||||
{
|
||||
int ret = -1;
|
||||
uint num = fp.ReadUInt32();
|
||||
lwKeyFloat[] seq = StructReader.ReadStructArray<lwKeyFloat>(fp, num);
|
||||
this._aks_ctrl = new lwAnimKeySetFloat();
|
||||
if (this._aks_ctrl.SetKeySequence(seq, num) >= 0)
|
||||
{
|
||||
ret = 0;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
||||
[StructLayout(LayoutKind.Sequential, Pack = 1)]
|
||||
public struct lwAnimDataTexUV
|
||||
{
|
||||
[MarshalAs(UnmanagedType.LPArray)]
|
||||
/* this+0x4 */
|
||||
public Matrix4x4[] _mat_seq;
|
||||
|
||||
/* this+0x8 */
|
||||
public uint _frame_num;
|
||||
|
||||
public int Load(BinaryReader fp, uint version)
|
||||
{
|
||||
this._frame_num = fp.ReadUInt32();
|
||||
this._mat_seq = StructReader.ReadStructArray<Matrix4x4>(fp, this._frame_num);
|
||||
return 0;
|
||||
}
|
||||
};
|
||||
|
||||
[StructLayout(LayoutKind.Sequential, Pack = 1)]
|
||||
public struct lwAnimDataTexUVSet
|
||||
{
|
||||
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 64)]
|
||||
public lwAnimDataTexUV[] mtl;
|
||||
}
|
||||
|
||||
[StructLayout(LayoutKind.Sequential, Pack = 1)]
|
||||
public class lwAnimDataTexImg
|
||||
{
|
||||
[MarshalAs(UnmanagedType.LPArray)]
|
||||
/* this+0x4 */
|
||||
public lwTexInfo[] _data_seq;
|
||||
|
||||
/* this+0x8 */
|
||||
public uint _data_num;
|
||||
|
||||
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 260)]
|
||||
/* this+0xc */
|
||||
public char[] _tex_path;
|
||||
|
||||
public int Load(BinaryReader fp, uint version)
|
||||
{
|
||||
int ret = 0;
|
||||
if (version == 0)
|
||||
{
|
||||
Debug.LogError("old version file, need re-export it");
|
||||
ret = -1;
|
||||
}
|
||||
else
|
||||
{
|
||||
this._data_num = fp.ReadUInt32();
|
||||
this._data_seq = StructReader.ReadStructArray<lwTexInfo>(fp, this._data_num);
|
||||
}
|
||||
|
||||
;
|
||||
return ret;
|
||||
}
|
||||
};
|
||||
|
||||
[StructLayout(LayoutKind.Sequential, Pack = 1)]
|
||||
public struct lwAnimDataMtlOpacitySet
|
||||
{
|
||||
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 16)]
|
||||
public lwAnimDataMtlOpacity[] mtl;
|
||||
}
|
||||
|
||||
[StructLayout(LayoutKind.Sequential, Pack = 1)]
|
||||
public struct lwAnimDataTexImgSet
|
||||
{
|
||||
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 64)]
|
||||
public lwAnimDataTexImg[] mtl;
|
||||
}
|
||||
}
|
3
Assets/MindPowerSdk/Model/lwAnimDataInfo.cs.meta
generated
Normal file
3
Assets/MindPowerSdk/Model/lwAnimDataInfo.cs.meta
generated
Normal file
@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 25c5131c55384e3ab69ff06cde9318ba
|
||||
timeCreated: 1728045346
|
129
Assets/MindPowerSdk/Model/lwHelperInfo.cs
Normal file
129
Assets/MindPowerSdk/Model/lwHelperInfo.cs
Normal file
@ -0,0 +1,129 @@
|
||||
using System.Runtime.InteropServices;
|
||||
using UnityEngine;
|
||||
|
||||
namespace MindPowerSdk
|
||||
{
|
||||
public class lwHelperInfo
|
||||
{
|
||||
/* this+0x4 */
|
||||
public uint type; // MindPower::lwHelperInfoType
|
||||
|
||||
[MarshalAs(UnmanagedType.LPArray)]
|
||||
/* this+0x8 */
|
||||
public lwHelperDummyInfo[] dummy_seq;
|
||||
|
||||
[MarshalAs(UnmanagedType.LPArray)]
|
||||
/* this+0xc */
|
||||
public lwHelperBoxInfo[] box_seq;
|
||||
|
||||
[MarshalAs(UnmanagedType.LPArray)]
|
||||
/* this+0x10 */
|
||||
public lwHelperMeshInfo[] mesh_seq;
|
||||
|
||||
[MarshalAs(UnmanagedType.LPArray)]
|
||||
/* this+0x14 */
|
||||
public lwBoundingBoxInfo[] bbox_seq;
|
||||
|
||||
[MarshalAs(UnmanagedType.LPArray)]
|
||||
/* this+0x18 */
|
||||
public lwBoundingSphereInfo[] bsphere_seq;
|
||||
|
||||
/* this+0x1c */
|
||||
public uint dummy_num;
|
||||
|
||||
/* this+0x20 */
|
||||
public uint box_num;
|
||||
|
||||
/* this+0x24 */
|
||||
public uint mesh_num;
|
||||
|
||||
/* this+0x28 */
|
||||
public uint bbox_num;
|
||||
|
||||
/* this+0x2c */
|
||||
public uint bsphere_num;
|
||||
}
|
||||
|
||||
[StructLayout(LayoutKind.Sequential, Pack = 4)]
|
||||
public struct lwHelperDummyInfo
|
||||
{
|
||||
public uint Id;
|
||||
public Matrix4x4 Mat;
|
||||
public Matrix4x4 MatLocal;
|
||||
public uint ParentType; // 0: default, 1: bone parent, 2: bone dummy parent
|
||||
public uint ParentId;
|
||||
}
|
||||
|
||||
public struct lwHelperBoxInfo
|
||||
{
|
||||
public uint Id;
|
||||
public uint Type;
|
||||
public uint State;
|
||||
public Bounds Box;
|
||||
public Matrix4x4 Mat;
|
||||
|
||||
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 32)]
|
||||
public string Name; // 32
|
||||
}
|
||||
|
||||
[StructLayout(LayoutKind.Sequential, Pack = 1)]
|
||||
public class lwHelperMeshInfo
|
||||
{
|
||||
public uint Id;
|
||||
public uint Type;
|
||||
|
||||
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 32)]
|
||||
public string Name;
|
||||
|
||||
public uint State;
|
||||
public uint SubType;
|
||||
public Matrix4x4 Mat;
|
||||
public Bounds Box;
|
||||
|
||||
[MarshalAs(UnmanagedType.LPArray)] public Vector3[] VertexSeq;
|
||||
|
||||
[MarshalAs(UnmanagedType.LPArray)] public lwHelperMeshFaceInfo[] face_seq;
|
||||
public uint vertex_num;
|
||||
public uint face_num;
|
||||
}
|
||||
|
||||
[StructLayout(LayoutKind.Sequential, Pack = 1)]
|
||||
public struct lwHelperMeshFaceInfo
|
||||
{
|
||||
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 3)]
|
||||
public uint[] vertex;
|
||||
|
||||
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 3)]
|
||||
public uint[] adj_face;
|
||||
|
||||
public Plane plane;
|
||||
|
||||
public Vector3 center;
|
||||
}
|
||||
|
||||
[StructLayout(LayoutKind.Sequential, Pack = 1)]
|
||||
public struct lwBoundingBoxInfo
|
||||
{
|
||||
/* this+0x0 */
|
||||
public uint id;
|
||||
|
||||
/* this+0x4 */
|
||||
public Bounds box;
|
||||
|
||||
/* this+0x1c */
|
||||
public Matrix4x4 mat;
|
||||
};
|
||||
|
||||
[StructLayout(LayoutKind.Sequential, Pack = 1)]
|
||||
public struct lwBoundingSphereInfo
|
||||
{
|
||||
/* this+0x0 */
|
||||
public uint id;
|
||||
|
||||
/* this+0x4 */
|
||||
public BoundingSphere sphere;
|
||||
|
||||
/* this+0x14 */
|
||||
public Matrix4x4 mat;
|
||||
};
|
||||
}
|
3
Assets/MindPowerSdk/Model/lwHelperInfo.cs.meta
generated
Normal file
3
Assets/MindPowerSdk/Model/lwHelperInfo.cs.meta
generated
Normal file
@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 0a597eb040b04616ab57eb9f3ab8ce8f
|
||||
timeCreated: 1728006798
|
545
Assets/MindPowerSdk/Model/lwModelObjInfo.cs
Normal file
545
Assets/MindPowerSdk/Model/lwModelObjInfo.cs
Normal file
@ -0,0 +1,545 @@
|
||||
using System.IO;
|
||||
using System.Runtime.InteropServices;
|
||||
using UnityEngine;
|
||||
|
||||
namespace MindPowerSdk
|
||||
{
|
||||
public enum ModelObjType : uint
|
||||
{
|
||||
Geometry = 1,
|
||||
Helper = 2
|
||||
}
|
||||
|
||||
public class lwModelObjInfo
|
||||
{
|
||||
[StructLayout(LayoutKind.Sequential, Pack = 4)]
|
||||
struct lwModelObjInfoHeader
|
||||
{
|
||||
public ModelObjType Type;
|
||||
public uint Addr;
|
||||
public uint Size;
|
||||
}
|
||||
|
||||
public int GeomObjNum;
|
||||
|
||||
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 32)]
|
||||
public lwGeomObjInfo[] GeomObjSeq; // 最多32个
|
||||
|
||||
public int Load(string file)
|
||||
{
|
||||
string filePath = Path.Combine(GlobalDefine.ClientDir, file);
|
||||
using FileStream fs = File.OpenRead(filePath);
|
||||
using BinaryReader fp = new BinaryReader(fs);
|
||||
|
||||
uint version = fp.ReadUInt32();
|
||||
int objNum = fp.ReadInt32();
|
||||
|
||||
lwModelObjInfoHeader[] header = new lwModelObjInfoHeader[objNum];
|
||||
for (int i = 0; i < objNum; i++)
|
||||
{
|
||||
var h = StructReader.ReadStruct<lwModelObjInfoHeader>(fp);
|
||||
header[i] = h;
|
||||
}
|
||||
|
||||
GeomObjNum = 0;
|
||||
GeomObjSeq = new lwGeomObjInfo[32];
|
||||
for (int i = 0; i < objNum; i++)
|
||||
{
|
||||
var headerInfo = header[i];
|
||||
fs.Seek(headerInfo.Addr, SeekOrigin.Begin);
|
||||
|
||||
switch (headerInfo.Type)
|
||||
{
|
||||
case ModelObjType.Geometry:
|
||||
{
|
||||
this.GeomObjSeq[GeomObjNum] = new lwGeomObjInfo();
|
||||
if (version == 0) // EXP_OBJ_VERSION_0_0_0_0
|
||||
{
|
||||
int old_version = fp.ReadInt32();
|
||||
}
|
||||
|
||||
this.GeomObjSeq[GeomObjNum].Load(fp, version);
|
||||
GeomObjNum += 1;
|
||||
break;
|
||||
}
|
||||
case ModelObjType.Helper:
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
public enum lwModelObjectLoadType
|
||||
{
|
||||
MODELOBJECT_LOAD_RESET = 0,
|
||||
MODELOBJECT_LOAD_MERGE = 1,
|
||||
MODELOBJECT_LOAD_MERGE2 = 2
|
||||
};
|
||||
|
||||
public struct lwRenderCtrlCreateInfo
|
||||
{
|
||||
public uint ctrl_id;
|
||||
public uint decl_id;
|
||||
public uint vs_id;
|
||||
public uint ps_id;
|
||||
}
|
||||
|
||||
[StructLayout(LayoutKind.Sequential, Pack = 1)]
|
||||
public class lwStateCtrl
|
||||
{
|
||||
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 8)]
|
||||
/* this+0x0 */
|
||||
public byte[] _state_seq; // MindPower::lwObjectStateEnum ???
|
||||
|
||||
public void SetState(uint state, byte value)
|
||||
{
|
||||
this._state_seq[state] = value;
|
||||
}
|
||||
}
|
||||
|
||||
public class lwGeomObjInfo
|
||||
{
|
||||
[StructLayout(LayoutKind.Sequential, Pack = 1)]
|
||||
/* this+0x4 */
|
||||
public struct lwGeomObjInfoHeader
|
||||
{
|
||||
/* this+0x0 */
|
||||
public uint id;
|
||||
|
||||
/* this+0x4 */
|
||||
public uint parent_id;
|
||||
|
||||
/* this+0x8 */
|
||||
public lwModelObjectLoadType type;
|
||||
|
||||
/* this+0xc */
|
||||
public Matrix4x4 mat_local;
|
||||
|
||||
/* this+0x4c */
|
||||
public lwRenderCtrlCreateInfo rcci;
|
||||
|
||||
/* this+0x5c */
|
||||
public lwStateCtrl state_ctrl;
|
||||
|
||||
/* this+0x64 */
|
||||
public uint mtl_size;
|
||||
|
||||
/* this+0x68 */
|
||||
public uint mesh_size;
|
||||
|
||||
/* this+0x6c */
|
||||
public uint helper_size;
|
||||
|
||||
/* this+0x70 */
|
||||
public uint anim_size;
|
||||
};
|
||||
|
||||
/* this+0x4 */
|
||||
public lwGeomObjInfoHeader header;
|
||||
|
||||
/* this+0x78 */
|
||||
public uint mtl_num;
|
||||
|
||||
[MarshalAs(UnmanagedType.LPArray)]
|
||||
/* this+0x7c */
|
||||
public lwMtlTexInfo[] mtl_seq;
|
||||
|
||||
/* this+0x80 */
|
||||
public lwMeshInfo mesh;
|
||||
|
||||
/* this+0x130 */
|
||||
public lwHelperInfo helper_data;
|
||||
|
||||
/* this+0x160 */
|
||||
public lwAnimDataInfo anim_data;
|
||||
|
||||
public int Load(BinaryReader fp, uint version)
|
||||
{
|
||||
this.header = StructReader.ReadStruct<lwGeomObjInfoHeader>(fp);
|
||||
this.header.state_ctrl.SetState(5, 0);
|
||||
this.header.state_ctrl.SetState(3, 1);
|
||||
if (this.header.mtl_size > 100000)
|
||||
{
|
||||
// System.Windows.Forms.MessageBox.Show("iii", "error");
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (this.header.mtl_size > 0)
|
||||
{
|
||||
// lwLoadMtlTexInfo(ref this.mtl_seq, ref this.mtl_num, fp, version);
|
||||
}
|
||||
|
||||
if (this.header.mesh_size > 0)
|
||||
{
|
||||
// lwMeshInfo_Load(ref this.mesh, fp, version);
|
||||
}
|
||||
|
||||
if (this.header.helper_size > 0)
|
||||
{
|
||||
// this.helper_data.Load(fp, version);
|
||||
}
|
||||
|
||||
if (this.header.anim_size > 0)
|
||||
{
|
||||
this.anim_data = new lwAnimDataInfo();
|
||||
// this.anim_data.Load(fp, version);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
public int Load(string file)
|
||||
{
|
||||
if (!File.Exists(file))
|
||||
return -1;
|
||||
FileStream fs = File.Open(file, FileMode.Open, FileAccess.Read);
|
||||
BinaryReader fp = new BinaryReader(fs);
|
||||
|
||||
uint version = fp.ReadUInt32();
|
||||
int ret = this.Load(fp, version);
|
||||
fp.Close();
|
||||
fs.Close();
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
||||
[StructLayout(LayoutKind.Sequential, Pack = 1)]
|
||||
public class lwMtlTexInfo
|
||||
{
|
||||
/* this+0x0 */
|
||||
public float opacity;
|
||||
|
||||
/* this+0x4 */
|
||||
[MarshalAs(UnmanagedType.U4)] public lwMtlTexInfoTransparencyTypeEnum transp_type; // MindPower::lwMtlTexInfoTransparencyTypeEnum
|
||||
|
||||
/* this+0x8 */
|
||||
public lwMaterial mtl;
|
||||
|
||||
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 8)]
|
||||
/* this+0x4c */
|
||||
public lwRenderStateAtom[] rs_set;
|
||||
|
||||
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 4)]
|
||||
/* this+0xac */
|
||||
public lwTexInfo[] tex_seq;
|
||||
}
|
||||
|
||||
public enum lwMtlTexInfoTransparencyTypeEnum
|
||||
{
|
||||
MTLTEX_TRANSP_FILTER = 0,
|
||||
MTLTEX_TRANSP_ADDITIVE = 1,
|
||||
MTLTEX_TRANSP_ADDITIVE1 = 2,
|
||||
MTLTEX_TRANSP_ADDITIVE2 = 3,
|
||||
MTLTEX_TRANSP_ADDITIVE3 = 4,
|
||||
MTLTEX_TRANSP_SUBTRACTIVE = 5,
|
||||
MTLTEX_TRANSP_SUBTRACTIVE1 = 6,
|
||||
MTLTEX_TRANSP_SUBTRACTIVE2 = 7,
|
||||
MTLTEX_TRANSP_SUBTRACTIVE3 = 8
|
||||
}
|
||||
|
||||
[StructLayout(LayoutKind.Sequential, Pack = 1)]
|
||||
public struct lwMaterial
|
||||
{
|
||||
/* this+0x0 */
|
||||
public Color dif;
|
||||
|
||||
/* this+0x10 */
|
||||
public Color amb;
|
||||
|
||||
/* this+0x20 */
|
||||
public Color spe;
|
||||
|
||||
/* this+0x30 */
|
||||
public Color emi;
|
||||
|
||||
/* this+0x40 */
|
||||
public float power;
|
||||
}
|
||||
|
||||
[StructLayout(LayoutKind.Sequential, Pack = 1)]
|
||||
public struct lwRenderStateAtom
|
||||
{
|
||||
/* this+0x0 */
|
||||
public uint state; // MindPower::lwRenderStateAtomType
|
||||
|
||||
/* this+0x4 */
|
||||
public uint value0;
|
||||
|
||||
/* this+0x8 */
|
||||
public uint value1;
|
||||
}
|
||||
|
||||
[StructLayout(LayoutKind.Sequential, Pack = 1)]
|
||||
public class lwTexInfo
|
||||
{
|
||||
/* this+0x0 */
|
||||
public uint stage;
|
||||
|
||||
/* this+0x4 */
|
||||
public uint level;
|
||||
|
||||
/* this+0x8 */
|
||||
public uint usage;
|
||||
|
||||
/* this+0xc */
|
||||
[MarshalAs(UnmanagedType.U4)] public _D3DFORMAT format;
|
||||
|
||||
/* this+0x10 */
|
||||
[MarshalAs(UnmanagedType.U4)] public _D3DPOOL pool;
|
||||
|
||||
/* this+0x14 */
|
||||
public uint byte_alignment_flag;
|
||||
|
||||
/* this+0x18 */
|
||||
[MarshalAs(UnmanagedType.U4)] public lwTexInfoTypeEnum type;
|
||||
|
||||
/* this+0x1c */
|
||||
public uint width;
|
||||
|
||||
/* this+0x20 */
|
||||
public uint height;
|
||||
|
||||
/* this+0x24 */
|
||||
[MarshalAs(UnmanagedType.U4)] public lwColorKeyTypeEnum colorkey_type;
|
||||
|
||||
/* this+0x28 */
|
||||
public Color32 colorkey;
|
||||
|
||||
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 64)]
|
||||
/* this+0x2c */
|
||||
public char[] file_name;
|
||||
|
||||
/* this+0x6c */
|
||||
public uint data_pointer;
|
||||
|
||||
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 8)]
|
||||
/* this+0x70 */
|
||||
public lwRenderStateAtom[] tss_set;
|
||||
};
|
||||
|
||||
public enum _D3DFORMAT
|
||||
{
|
||||
D3DFMT_UNKNOWN = 0x0,
|
||||
D3DFMT_R8G8B8 = 0x14,
|
||||
D3DFMT_A8R8G8B8 = 0x15,
|
||||
D3DFMT_X8R8G8B8 = 0x16,
|
||||
D3DFMT_R5G6B5 = 0x17,
|
||||
D3DFMT_X1R5G5B5 = 0x18,
|
||||
D3DFMT_A1R5G5B5 = 0x19,
|
||||
D3DFMT_A4R4G4B4 = 0x1a,
|
||||
D3DFMT_R3G3B2 = 0x1b,
|
||||
D3DFMT_A8 = 0x1c,
|
||||
D3DFMT_A8R3G3B2 = 0x1d,
|
||||
D3DFMT_X4R4G4B4 = 0x1e,
|
||||
D3DFMT_A2B10G10R10 = 0x1f,
|
||||
D3DFMT_G16R16 = 0x22,
|
||||
D3DFMT_A8P8 = 0x28,
|
||||
D3DFMT_P8 = 0x29,
|
||||
D3DFMT_L8 = 0x32,
|
||||
D3DFMT_A8L8 = 0x33,
|
||||
D3DFMT_A4L4 = 0x34,
|
||||
D3DFMT_V8U8 = 0x3c,
|
||||
D3DFMT_L6V5U5 = 0x3d,
|
||||
D3DFMT_X8L8V8U8 = 0x3e,
|
||||
D3DFMT_Q8W8V8U8 = 0x3f,
|
||||
D3DFMT_V16U16 = 0x40,
|
||||
D3DFMT_W11V11U10 = 0x41,
|
||||
D3DFMT_A2W10V10U10 = 0x43,
|
||||
D3DFMT_UYVY = 0x59565955,
|
||||
D3DFMT_YUY2 = 0x32595559,
|
||||
D3DFMT_DXT1 = 0x31545844,
|
||||
D3DFMT_DXT2 = 0x32545844,
|
||||
D3DFMT_DXT3 = 0x33545844,
|
||||
D3DFMT_DXT4 = 0x34545844,
|
||||
D3DFMT_DXT5 = 0x35545844,
|
||||
D3DFMT_D16_LOCKABLE = 0x46,
|
||||
D3DFMT_D32 = 0x47,
|
||||
D3DFMT_D15S1 = 0x49,
|
||||
D3DFMT_D24S8 = 0x4b,
|
||||
D3DFMT_D16 = 0x50,
|
||||
D3DFMT_D24X8 = 0x4d,
|
||||
D3DFMT_D24X4S4 = 0x4f,
|
||||
D3DFMT_VERTEXDATA = 0x64,
|
||||
D3DFMT_INDEX16 = 0x65,
|
||||
D3DFMT_INDEX32 = 0x66,
|
||||
D3DFMT_FORCE_DWORD = 0x7fffffff,
|
||||
}
|
||||
|
||||
public enum _D3DPOOL
|
||||
{
|
||||
D3DPOOL_DEFAULT = 0x0,
|
||||
D3DPOOL_MANAGED = 0x1,
|
||||
D3DPOOL_SYSTEMMEM = 0x2,
|
||||
D3DPOOL_SCRATCH = 0x3,
|
||||
D3DPOOL_FORCE_DWORD = 0x7fffffff,
|
||||
}
|
||||
|
||||
public enum lwTexInfoTypeEnum
|
||||
{
|
||||
TEX_TYPE_FILE = 0,
|
||||
TEX_TYPE_SIZE = 1,
|
||||
TEX_TYPE_DATA = 2,
|
||||
TEX_TYPE_INVALID = -1
|
||||
}
|
||||
|
||||
public enum lwColorKeyTypeEnum
|
||||
{
|
||||
COLORKEY_TYPE_NONE = 0,
|
||||
COLORKEY_TYPE_COLOR = 1,
|
||||
COLORKEY_TYPE_PIXEL = 2
|
||||
}
|
||||
|
||||
[StructLayout(LayoutKind.Sequential, Pack = 1)]
|
||||
public struct lwMeshInfo
|
||||
{
|
||||
[StructLayout(LayoutKind.Sequential, Pack = 1)]
|
||||
public struct lwMeshInfoHeader
|
||||
{
|
||||
/* this+0x0 */
|
||||
public uint fvf;
|
||||
|
||||
/* this+0x4 */
|
||||
[MarshalAs(UnmanagedType.U4)] public _D3DPRIMITIVETYPE pt_type;
|
||||
|
||||
/* this+0x8 */
|
||||
public uint vertex_num;
|
||||
|
||||
/* this+0xc */
|
||||
public uint index_num;
|
||||
|
||||
/* this+0x10 */
|
||||
public uint subset_num;
|
||||
|
||||
/* this+0x14 */
|
||||
public uint bone_index_num;
|
||||
|
||||
/* this+0x18 */
|
||||
public uint bone_infl_factor;
|
||||
|
||||
/* this+0x1c */
|
||||
public uint vertex_element_num;
|
||||
|
||||
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 8)]
|
||||
/* this+0x20 */
|
||||
public lwRenderStateAtom[] rs_set;
|
||||
};
|
||||
|
||||
/* this+0x0 */
|
||||
public lwMeshInfoHeader header;
|
||||
|
||||
[MarshalAs(UnmanagedType.LPArray)]
|
||||
/* this+0x80 */
|
||||
public Vector3[] vertex_seq;
|
||||
|
||||
[MarshalAs(UnmanagedType.LPArray)]
|
||||
/* this+0x84 */
|
||||
public Vector3[] normal_seq;
|
||||
|
||||
[MarshalAs(UnmanagedType.LPArray)]
|
||||
/* this+0x88 */
|
||||
public Vector2[] texcoord0_seq;
|
||||
|
||||
[MarshalAs(UnmanagedType.LPArray)]
|
||||
/* this+0x8c */
|
||||
public Vector2[] texcoord1_seq;
|
||||
|
||||
[MarshalAs(UnmanagedType.LPArray)]
|
||||
/* this+0x90 */
|
||||
public Vector2[] texcoord2_seq;
|
||||
|
||||
[MarshalAs(UnmanagedType.LPArray)]
|
||||
/* this+0x94 */
|
||||
public Vector2[] texcoord3_seq;
|
||||
|
||||
[MarshalAs(UnmanagedType.LPArray)]
|
||||
/* this+0x98 */
|
||||
public uint[] vercol_seq;
|
||||
|
||||
[MarshalAs(UnmanagedType.LPArray)]
|
||||
/* this+0x9c */
|
||||
public uint[] index_seq;
|
||||
|
||||
[MarshalAs(UnmanagedType.LPArray)]
|
||||
/* this+0xa0 */
|
||||
public uint[] bone_index_seq;
|
||||
|
||||
[MarshalAs(UnmanagedType.LPArray)]
|
||||
/* this+0xa4 */
|
||||
public lwBlendInfo[] blend_seq;
|
||||
|
||||
[MarshalAs(UnmanagedType.LPArray)]
|
||||
/* this+0xa8 */
|
||||
public lwSubsetInfo[] subset_seq;
|
||||
|
||||
[MarshalAs(UnmanagedType.LPArray)]
|
||||
/* this+0xac */
|
||||
public _D3DVERTEXELEMENT9[] vertex_element_seq;
|
||||
}
|
||||
|
||||
[StructLayout(LayoutKind.Sequential, Pack = 1)]
|
||||
public struct _D3DVERTEXELEMENT9
|
||||
{
|
||||
/* this+0x0 */
|
||||
public ushort Stream;
|
||||
|
||||
/* this+0x2 */
|
||||
public ushort Offset;
|
||||
|
||||
/* this+0x4 */
|
||||
public byte Type;
|
||||
|
||||
/* this+0x5 */
|
||||
public byte Method;
|
||||
|
||||
/* this+0x6 */
|
||||
public byte Usage;
|
||||
|
||||
/* this+0x7 */
|
||||
public byte UsageIndex;
|
||||
};
|
||||
|
||||
[StructLayout(LayoutKind.Sequential, Pack = 1)]
|
||||
public struct lwSubsetInfo
|
||||
{
|
||||
/* this+0x0 */
|
||||
public uint primitive_num;
|
||||
|
||||
/* this+0x4 */
|
||||
public uint start_index;
|
||||
|
||||
/* this+0x8 */
|
||||
public uint vertex_num;
|
||||
|
||||
/* this+0xc */
|
||||
public uint min_index;
|
||||
}
|
||||
|
||||
[StructLayout(LayoutKind.Sequential, Pack = 1)]
|
||||
public struct lwBlendInfo
|
||||
{
|
||||
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 4)]
|
||||
/* this+0x0 */
|
||||
public byte[] index;
|
||||
|
||||
/* this+0x0 */
|
||||
//uint indexd;
|
||||
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 4)]
|
||||
/* this+0x4 */
|
||||
public float[] weight;
|
||||
}
|
||||
|
||||
public enum _D3DPRIMITIVETYPE
|
||||
{
|
||||
D3DPT_POINTLIST = 0x1,
|
||||
D3DPT_LINELIST = 0x2,
|
||||
D3DPT_LINESTRIP = 0x3,
|
||||
D3DPT_TRIANGLELIST = 0x4,
|
||||
D3DPT_TRIANGLESTRIP = 0x5,
|
||||
D3DPT_TRIANGLEFAN = 0x6,
|
||||
D3DPT_FORCE_DWORD = 0x7fffffff,
|
||||
}
|
||||
}
|
3
Assets/MindPowerSdk/Model/lwModelObjInfo.cs.meta
generated
Normal file
3
Assets/MindPowerSdk/Model/lwModelObjInfo.cs.meta
generated
Normal file
@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: d7614eb326704773a4cb56c1f021865e
|
||||
timeCreated: 1728005423
|
Reference in New Issue
Block a user