private GameObject loadNIFForSlot(GearSlot slot, GameObject skeleton, GameObject meshHolder, string nifFile, string geo) { //Debug.Log("load nif[" + nifFile + "] for slot " + slot, this.gameObject); // First move all the meshes across to the skeleton GameObject meshes = new GameObject(slot.ToString()); //Debug.Log("create new gameobh:" + meshes.name); try { NIFFile file = NIFLoader.getNIF(nifFile); GameObject newNifRoot = NIFLoader.loadNIF(file, nifFile, true); meshes.transform.parent = meshHolder.transform; //Debug.Log("Move components from loaded nif to our new gameobj"); foreach (SkinnedMeshRenderer r in newNifRoot.GetComponentsInChildren <SkinnedMeshRenderer>(true)) { // Debug.Log("Move renderer " + r.gameObject.name); r.transform.parent = meshes.transform; } /** I'm not quite sure how bows are supposed to work yet. The quiver, bow and prop all appear to be a single mesh, so they must be moved around using bones or something.. * At the moment they don't even show propertly because the ROOT bone assigned while loading is not copied over and is destroyed causing the SKinnedMeshRender to behave poorly * More research required. */ // weapons are a bit different if (!WardrobeStuff.isWeapon(slot)) { // process the NiSkinningMeshModifier NIFLoader.linkBonesToMesh(file, skeleton); } else { //Debug.Log("Treating slot (" + slot + ") as weapon and attach it to AP_r_hand on skeleton"); Transform t = skeleton.transform.FindDeepChild("AP_r_hand"); meshes.transform.parent = t; meshes.transform.localPosition = new Vector3(0, 0, 0); } this.animationNif.clearBoneMap(); // disable the proxy geo enableDisableGeo(nifFile, skeleton, false); // special case to ensure boots are disabled as well if (nifFile.Contains("foot")) { enableDisableGeo("boots", skeleton, false); } GameObject.DestroyObject(newNifRoot); } catch (Exception ex) { Debug.Log("Exception trying to load nif[" + nifFile + "]" + ex); } return(meshes); }
public ClothingItem(DB db, long id, long key) { this.key = key; this.id = id; try { CObject gearDef = db.toObj(id, key); if (id == 7629) { this.name = gearDef.getMember(0).convert() + ""; if (gearDef.hasMember(1)) { this.langKey = gearDef.getMember(1).getIntMember(0); } if (gearDef.hasMember(4)) { icon = db.toObj(6009, gearDef.getIntMember(4)).getStringMember(1); } if (gearDef.hasMember(5)) { CObject allowedSlotsArray = gearDef.getMember(5); foreach (CObject o in allowedSlotsArray.members) { int slot = int.Parse(o.convert() + ""); allowedSlots.Add(WardrobeStuff.getSlot(slot)); } } if (gearDef.hasMember(6)) { type = WardrobeStuff.getGearType(gearDef.getIntMember(6)); } if (gearDef.hasMember(7)) { hidden = gearDef.getBoolMember(7, false); } nifKey = gearDef.getIntMember(2); nifRef = new NIFReference(db, nifKey); } else if (id == 7305) { nifRef = new NIFReference(db, key); nifKey = key; if (gearDef.hasMember(2)) { string nifPath = gearDef.getMember(2).convert() + ""; this.name = System.IO.Path.GetFileName(nifPath); if (nifPath.Contains(@"\player\") && nifPath.Contains(@"\wings\")) { allowedSlots.Add(GearSlot.CAPE); } } if (gearDef.hasMember(15)) { CObject allowedSlotsArray = gearDef.getMember(15); foreach (CObject o in allowedSlotsArray.members) { int slot = int.Parse(o.convert() + ""); allowedSlots.Add(WardrobeStuff.getSlot(slot)); } } else { } } else { throw new Exception("Bad id:" + id); } } catch (Exception ex) { Debug.Log("Unable to process [" + this + "] nif reference:" + ex); } }