Esempio n. 1
0
        public bool SetupSkinJoint(AvatarJoint joint)
        {
            Joint = joint;
            if (joint == null)
            {
                Logger.LogInfo("SkinJoint.SetupSkinJoint", "Can't find joint");
            }

            // compute the inverse root skin matrix
            RootToJointSkinOffset = AvatarJointMesh.TotalSkinOffset(joint);
            RootToJointSkinOffset = -RootToJointSkinOffset;

            RootToParentJointSkinOffset = AvatarJointMesh.TotalSkinOffset(AvatarJointMesh.GetBaseSkeletonAncestor(joint));
            RootToParentJointSkinOffset = -RootToParentJointSkinOffset;

            return(true);
        }
Esempio n. 2
0
        /// <summary>
        /// Called after construction to initialise the instance.
        /// </summary>
        public virtual void InitInstance()
        {
            // Initialise joint, mesh and shape members

            Root      = CreateAvatarJoint();
            Root.Name = "mRoot";

            foreach (var keyValuePair in AvatarAppearanceDictionary.Instance.MeshEntries)
            {
                AvatarAppearanceDictionary.MeshIndex meshIndex = keyValuePair.Key;
                AvatarAppearanceDictionary.MeshEntry meshEntry = keyValuePair.Value;

                AvatarJoint joint = CreateAvatarJoint();
                joint.Name   = meshEntry.Name;
                joint.MeshId = (int)meshIndex;
                MeshLod.Add(joint);

                for (int lod = 0; lod < meshEntry.Lod; lod++)
                {
                    // TODO: Stopped here!
                    AvatarJointMesh mesh = CreateAvatarJointMesh();

                    //// We pre-pended an m - need to capitalise first character for camelCase
                    char   first    = Char.ToUpper(meshEntry.Name[0]);
                    string meshName = $"m{first}{meshEntry.Name.Substring(1)}{lod}"; // "m" + mesh_dict->mName + boost::lexical_cast < std::string> (lod); // TODO: What is lexical_cast()?
                    mesh.Name   = meshName;
                    mesh.MeshId = (int)meshIndex;
                    //mesh->setPickName(mesh_dict->mPickName);
                    mesh.IsTransparent = false;
                    switch (meshIndex)
                    {
                    case AvatarAppearanceDictionary.MeshIndex.Hair:
                        mesh.IsTransparent = true;
                        break;

                    case AvatarAppearanceDictionary.MeshIndex.Skirt:
                        mesh.IsTransparent = true;
                        break;

                    case AvatarAppearanceDictionary.MeshIndex.EyeBallLeft:
                    case AvatarAppearanceDictionary.MeshIndex.EyeBallRight:
                        mesh.SetSpecular(new Color(1.0f, 1.0f, 1.0f, 1.0f), 1f);
                        break;
                    }

                    joint.MeshParts.Add(mesh);
                }
            }

            // Associate baked textures with meshes
            foreach (KeyValuePair <AvatarAppearanceDictionary.MeshIndex, AvatarAppearanceDictionary.MeshEntry> keyValuePair in AvatarAppearanceDictionary.Instance.MeshEntries)
            {
                AvatarAppearanceDictionary.MeshIndex         meshIndex         = keyValuePair.Key;
                AvatarAppearanceDictionary.MeshEntry         meshEntry         = keyValuePair.Value;
                AvatarAppearanceDictionary.BakedTextureIndex bakedTextureIndex = meshEntry.BakedTextureIndex;

                // Skip it if there's no associated baked texture.
                if (bakedTextureIndex == AvatarAppearanceDictionary.BakedTextureIndex.NumIndices)
                {
                    continue;
                }

                foreach (AvatarJointMesh mesh in MeshLod[(int)meshIndex].MeshParts)
                {
                    BakedTextureDatas[(int)bakedTextureIndex].JointMeshes.Add(mesh);
                }
            }

            BuildCharacter();

            InitFlags |= 1 << 0;
        }