public void Load(Stream source_stream) { NiHeader header = GetHeader(source_stream); header.Dump(); int bt_NiTriShapeData = header.GetBlockTypeIdxByName("NiTriShapeData"); int bt_BSLightingShaderProperty = header.GetBlockTypeIdxByName("BSLightingShaderProperty"); int bt_BSShaderTextureSet = header.GetBlockTypeIdxByName("BSShaderTextureSet"); int bt_NiSkinInstance = header.GetBlockTypeIdxByName("NiSkinInstance"); int bt_NiSkinPartition = header.GetBlockTypeIdxByName("NiSkinPartition"); int num_blocks = header.blocks.Length; for (int i = 0; i < num_blocks; i++) { if (header.blocks[i].type == bt_NiTriShapeData) { NiTriShapeData triShapeData = GetObject <NiTriShapeData>(header, i); triShapeData.Dump(); } if (header.blocks[i].type == bt_BSLightingShaderProperty) { BSLightingShaderProperty lightingShaderProperty = GetObject <BSLightingShaderProperty>(header, i); lightingShaderProperty.Dump(); } if (header.blocks[i].type == bt_BSShaderTextureSet) { BSShaderTextureSet shaderTextureSet = GetObject <BSShaderTextureSet>(header, i); shaderTextureSet.Dump(); } if (header.blocks[i].type == bt_NiSkinInstance) { NiSkinInstance skinInstance = GetObject <NiSkinInstance>(header, i); skinInstance.Dump(); foreach (ObjectRef boneref in skinInstance.bones) { NiNode node = GetObject <NiNode>(header, boneref); System.Console.WriteLine(header.strings[node.name]); } } if (header.blocks[i].type == bt_NiSkinPartition) { NiSkinPartition skinPartition = GetObject <NiSkinPartition>(header, i); skinPartition.Dump(); } } }
public static string GetNiNodeName(this NiHeader hdr, int id) { try { int typeIndex = hdr.GetBlockTypeIdxByName("NiNode"); } catch (System.Exception) { return(""); } //Console.WriteLine("BT idx 'NiNode': {0}", bt_NiNode); if (id >= hdr.blocks.Length) { return(""); } return(hdr.strings[hdr.GetObject <NiNode>(id).name]); }
void DumpNodes() { int bt_NiNode = header.GetBlockTypeIdxByName("NiNode"); //Console.WriteLine("BT idx 'NiNode': {0}", bt_NiNode); int num_blocks = header.blocks.Length; nodes = new NiNode[num_blocks]; for (int i = 0; i < num_blocks; i++) { if (header.blocks[i].type == bt_NiNode) { using (MemoryStream stream = new MemoryStream(header.blocks[i].data)) { BinaryReader reader = new BinaryReader(stream, System.Text.Encoding.Default); nodes[i] = new NiNode(); nodes[i].Read(reader); } } } int string_root = header.GetStringIdxByName("NPC Root [Root]"); //Console.WriteLine("String idx 'NPC Root [Root]': {0}", string_root); root_node_ref = -1; for (int i = 0; i < num_blocks; i++) { NiNode node = nodes[i]; if (node == null) { continue; } if (node.name == string_root) { root_node_ref = i; break; } } SetNodeRefParent(root_node_ref, null); DumpNodeRef(root_node_ref); }
public NiFile(Device device, string path) { Console.WriteLine("NiFile.ctor path:{0}", path); this.header = NiHeader.Load(path); int bt_NiTriShape = header.GetBlockTypeIdxByName("NiTriShape"); int num_blocks = header.blocks.Length; List <Mesh> mesh_collection = new List <Mesh>(); for (int i = 0; i < header.blocks.Length; i++) { if (header.blocks[i].type == bt_NiTriShape) { Mesh mesh = new Mesh(device, header, i); mesh_collection.Add(mesh); } } this.meshes = mesh_collection.ToArray(); }
void CreateNodes() { int bt_NiNode = header.GetBlockTypeIdxByName("NiNode"); //Console.WriteLine("BT idx 'NiNode': {0}", bt_NiNode); int num_blocks = header.blocks.Length; nodes = new NiNode[num_blocks]; for (int i = 0; i < num_blocks; i++) { if (header.blocks[i].type == bt_NiNode) { using (MemoryStream stream = new MemoryStream(header.blocks[i].data)) { BinaryReader reader = new BinaryReader(stream, System.Text.Encoding.Default); nodes[i] = new NiNode(); nodes[i].Read(reader); } } } }