Esempio n. 1
0
 //Constructor
 public SkinInfo()
 {
     unchecked {
         shape        = null;
         skinInstance = null;
     }
 }
Esempio n. 2
0
 public NiGeometry()
 {
     skin           = null;
     data           = null;
     skinInstance   = null;
     shaderProperty = null;
     alphaProperty  = null;
 }
Esempio n. 3
0
        /*!
         * NIFLIB_HIDDEN function.  For internal use only.
         * Should only be called by NiTriBasedGeom.  Detaches the skin associated with a child mesh.
         */
        internal void RemoveSkin(NiSkinInstance skin_inst)
        {
            //Remove the reference
            skins.Remove(skin_inst);

            //Ensure that any multiply referenced bone nodes still
            //have their skin flag set
            IList <NiNode> bones;

            foreach (var it in skins)
            {
                bones = it.GetBones();
                for (var i = 0; i < bones.Count; ++i)
                {
                    bones[i].SetSkinFlag(true);
                }
            }
        }
Esempio n. 4
0
        /*!
         * Binds this geometry to a list of bones.  Creates and attatches a
         * NiSkinInstance and NiSkinData class. The bones must have a common
         * ancestor in the scenegraph.  This becomes the skeleton root.
         */
        public void BindSkinWith(IList <NiNode> bone_nodes, Action <NiObject> skinInstConstructor)
        {
            if (skinInstConstructor == null)
            {
                skinInstConstructor = NiSkinInstance.Create;
            }
            //Ensure skin is not aleady bound
            if (skinInstance != null)
            {
                throw new Exception("You have attempted to re-bind a skin that is already bound.  Unbind it first.");
            }
            //Ensure that some bones are given
            if (bone_nodes.Count == 0)
            {
                throw new Exception("You must specify at least one bone node.");
            }

            //--Find a suitable skeleton root--//
            //The skeleton root will be the common ancestor of all bones which influence this skin,
            //and the skin object itself.
            var objects = new List <NiAVObject>();

            objects.Add(this);
            for (var i = 0; i < bone_nodes.Count; ++i)
            {
                objects.Add(bone_nodes[i]);
            }
            var skeleton_root = Nif.FindCommonAncestor(objects);

            if (skeleton_root == null)
            {
                throw new Exception("Failed to find suitable skeleton root.");
            }
            //Create a skin instance using the bone and root data
            skinInstance = skinInstConstructor() as NiSkinInstance;
            if (skinInstance == null)
            {
                throw new Exception("Failed to construct NiSkinInstance");
            }
            skinInstance.BindSkin(skeleton_root, bone_nodes);
            //Create a NiSkinData object based on this mesh
            skinInstance.SkinData = new NiSkinData(this);
        }
Esempio n. 5
0
/*! NIFLIB_HIDDEN function.  For internal use only. */
        internal override void FixLinks(Dictionary <uint, NiObject> objects, List <uint> link_stack, List <NiObject> missing_link_stack, NifInfo info)
        {
            base.FixLinks(objects, link_stack, missing_link_stack, info);
            if ((info.userVersion2 >= 100))
            {
                if (IsDerivedType(NiParticleSystem.TYPE))
                {
                    skin = FixLink <NiObject>(objects, link_stack, missing_link_stack, info);
                }
            }
            if ((info.userVersion2 < 100))
            {
                data = FixLink <NiGeometryData>(objects, link_stack, missing_link_stack, info);
            }
            if ((info.userVersion2 >= 100))
            {
                if ((!IsDerivedType(NiParticleSystem.TYPE)))
                {
                    data = FixLink <NiGeometryData>(objects, link_stack, missing_link_stack, info);
                }
            }
            if ((info.version >= 0x0303000D) && ((info.userVersion2 < 100)))
            {
                skinInstance = FixLink <NiSkinInstance>(objects, link_stack, missing_link_stack, info);
            }
            if ((info.userVersion2 >= 100))
            {
                if ((!IsDerivedType(NiParticleSystem.TYPE)))
                {
                    skinInstance = FixLink <NiSkinInstance>(objects, link_stack, missing_link_stack, info);
                }
            }
            if ((info.version >= 0x14020007) && (info.userVersion == 12))
            {
                shaderProperty = FixLink <BSShaderProperty>(objects, link_stack, missing_link_stack, info);
                alphaProperty  = FixLink <NiAlphaProperty>(objects, link_stack, missing_link_stack, info);
            }
        }
Esempio n. 6
0
 /*!
  * Unbinds this geometry from the bones.  This removes the NiSkinInstance and NiSkinData objects and causes this geometry to stop behaving as a skin.
  */
 public void UnbindSkin()
 {
     //Clear skin instance
     skinInstance = null;
 }
Esempio n. 7
0
 /*!
  * NIFLIB_HIDDEN function.  For internal use only.
  * Should only be called by NiTriBasedGeom.  Adds a new SkinInstance to the specified mesh.  The bones must be below this node in the scene graph tree
  */
 internal void AddSkin(NiSkinInstance skin_inst) => skins.Add(skin_inst);