当前位置: 首页>>代码示例>>C#>>正文


C# UnityEngine.BoneWeight类代码示例

本文整理汇总了C#中UnityEngine.BoneWeight的典型用法代码示例。如果您正苦于以下问题:C# BoneWeight类的具体用法?C# BoneWeight怎么用?C# BoneWeight使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


BoneWeight类属于UnityEngine命名空间,在下文中一共展示了BoneWeight类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: MakeSkinDeepCopy

        public static void MakeSkinDeepCopy(Vector3[] av3VerticesSource,  Vector2[] av2MappingSource,  BoneWeight[] aBoneWeightsSource,  int[] anTrianglesRopeSource,  int[] anTrianglesSectionsSource,  Matrix4x4[] aBindPosesSource, 
                                            Vector3[] av3VerticesDestiny, Vector2[] av2MappingDestiny, BoneWeight[] aBoneWeightsDestiny, int[] anTrianglesRopeDestiny, int[] anTrianglesSectionsDestiny, Matrix4x4[] aBindPosesDestiny)
        {
            int nVertices = av3VerticesSource.Length;

            for(int nVertex = 0; nVertex < nVertices; nVertex++)
            {
                av3VerticesDestiny [nVertex] = av3VerticesSource [nVertex];
                av2MappingDestiny  [nVertex] = av2MappingSource  [nVertex];
                aBoneWeightsDestiny[nVertex] = aBoneWeightsSource[nVertex];
            }

            for(int nIndex = 0; nIndex < anTrianglesRopeDestiny.Length; nIndex++)
            {
                anTrianglesRopeDestiny[nIndex] = anTrianglesRopeSource[nIndex];
            }

            for(int nIndex = 0; nIndex < anTrianglesSectionsDestiny.Length; nIndex++)
            {
                anTrianglesSectionsDestiny[nIndex] = anTrianglesSectionsSource[nIndex];
            }

            for(int nIndex = 0; nIndex < aBindPosesSource.Length; nIndex++)
            {
                aBindPosesDestiny[nIndex] = aBindPosesSource[nIndex];
            }
        }
开发者ID:kafedorov89,项目名称:ElectroLab3D_Stands,代码行数:27,代码来源:UltimateRope.cs

示例2: RopeData

        public RopeData(UltimateRope rope)
        {
            m_rope                  = rope;
            m_hashFieldName2Value   = new Dictionary<string, object>();
            m_aLinkTransformInfo    = new TransformInfo[rope.TotalLinks];
            m_transformInfoSegments = new TransformInfo[rope.RopeNodes.Count];

            m_bSkin = rope.GetComponent<SkinnedMeshRenderer>() != null;

            if(m_bSkin)
            {
                SkinnedMeshRenderer skin = rope.GetComponent<SkinnedMeshRenderer>();

                Mesh skinMesh = skin.sharedMesh;

                int nVertices          = skin.sharedMesh.vertexCount;
                int nTrianglesRope     = skin.sharedMesh.GetTriangles(0).Length;
                int nTrianglesSections = skin.sharedMesh.GetTriangles(1).Length;

                m_av3SkinVertices         = new Vector3   [nVertices];
                m_av2SkinMapping          = new Vector2   [nVertices];
                m_av4SkinTangents         = skinMesh.tangents != null ? new Vector4[skinMesh.tangents.Length] : null;
		        m_aSkinBoneWeights        = new BoneWeight[nVertices];
		        m_anSkinTrianglesRope     = new int       [nTrianglesRope];
                m_anSkinTrianglesSections = new int       [nTrianglesSections];
                m_amtxSkinBindPoses       = new Matrix4x4 [skin.sharedMesh.bindposes.Length];

                MakeSkinDeepCopy(skinMesh.vertices, skinMesh.uv,      skinMesh.tangents, skinMesh.boneWeights, skinMesh.GetTriangles(0), skinMesh.GetTriangles(1),  skinMesh.bindposes,
                                 m_av3SkinVertices, m_av2SkinMapping, m_av4SkinTangents, m_aSkinBoneWeights,   m_anSkinTrianglesRope,    m_anSkinTrianglesSections, m_amtxSkinBindPoses);
            }
        }
开发者ID:pnmentertainment,项目名称:fireworks,代码行数:31,代码来源:UltimateRope.cs

示例3: recalculateIndexes

 /*
 @Description: Setting the Indexes for the new bones
 */
 static BoneWeight recalculateIndexes(BoneWeight bw,Hashtable boneHash,Transform[] meshBones )
 {
     BoneWeight retBw = bw;
     retBw.boneIndex0 = (int)boneHash[meshBones[bw.boneIndex0].name];
     retBw.boneIndex1 = (int)boneHash[meshBones[bw.boneIndex1].name];
     retBw.boneIndex2 = (int)boneHash[meshBones[bw.boneIndex2].name];
     retBw.boneIndex3 = (int)boneHash[meshBones[bw.boneIndex3].name];
     return retBw;
 }
开发者ID:hismile06jf,项目名称:sgqy8,代码行数:12,代码来源:CombineSkinnedMeshes.cs

示例4: Build

        public void Build()
        {
            var halfwidth = 0.5f * width;
            var nSegments = bones.Length - 1;

            var vertices = new Vector3[bones.Length * 2];
            var weights = new BoneWeight[vertices.Length];
            var poses = new Matrix4x4[bones.Length];
            var counter = 0;
            for (var i = 0; i < bones.Length; i++) {
                var bone = bones[i];
                poses[i] = bone.worldToLocalMatrix * transform.localToWorldMatrix;
                var center = transform.InverseTransformPoint(bone.position);
                var right = halfwidth * bone.InverseTransformDirection(axis);
                vertices[counter] = center - right;
                vertices[counter + 1] = center + right;
                for (var j = 0; j < 2; j++) {
                    weights[counter + j].boneIndex0 = i;
                    weights[counter + j].weight0 = 1f;
                }
                counter += 2;
            }

            counter = 0;
            var triangles = new int[6 * nSegments];
            for (var i = 0; i < nSegments; i++) {
                var baseVertex = 2 * i;
                triangles[counter++] = baseVertex;
                triangles[counter++] = baseVertex + 1;
                triangles[counter++] = baseVertex + 3;
                triangles[counter++] = baseVertex;
                triangles[counter++] = baseVertex + 3;
                triangles[counter++] = baseVertex + 2;
            }

            var skin = GetComponent<SkinnedMeshRenderer>();
            if (skin == null)
                skin = gameObject.AddComponent<SkinnedMeshRenderer>();

            var bounds = new Bounds();
            foreach (var bone in bones)
                bounds.Encapsulate(bone.transform.localPosition);

            var mesh = skin.sharedMesh;
            if (mesh == null)
                mesh = skin.sharedMesh = new Mesh();
            mesh.vertices = vertices;
            mesh.triangles = triangles;
            mesh.boneWeights = weights;
            mesh.bindposes = poses;
            mesh.bounds = bounds;

            skin.bones = bones;
            skin.localBounds = bounds;
            skin.sharedMaterial = mat;
        }
开发者ID:nobnak,项目名称:RopePhysics,代码行数:56,代码来源:Skinned2DLine.cs

示例5: SBoneWeight

 public SBoneWeight(BoneWeight source)
 {
     this.boneIndex0 = source.boneIndex0;
     this.boneIndex1 = source.boneIndex1;
     this.boneIndex2 = source.boneIndex2;
     this.boneIndex3 = source.boneIndex3;
     this.weight0 = source.weight0;
     this.weight1 = source.weight1;
     this.weight2 = source.weight2;
     this.weight3 = source.weight3;
 }
开发者ID:WhiteRavensGame,项目名称:JRPGTownPrototype,代码行数:11,代码来源:MeshDataSnapshot.cs

示例6: constructor

	static public int constructor(IntPtr l) {
		try {
			UnityEngine.BoneWeight o;
			o=new UnityEngine.BoneWeight();
			pushValue(l,true);
			pushValue(l,o);
			return 2;
		}
		catch(Exception e) {
			return error(l,e);
		}
	}
开发者ID:602147629,项目名称:2DPlatformer-SLua,代码行数:12,代码来源:Lua_UnityEngine_BoneWeight.cs

示例7: Uni2DBoneWeight

	public Uni2DBoneWeight(BoneWeight a_oBoneWeight)
	{
		boneIndex0 = a_oBoneWeight.boneIndex0;
		boneIndex1 = a_oBoneWeight.boneIndex1;
		boneIndex2 = a_oBoneWeight.boneIndex2;
		boneIndex3 = a_oBoneWeight.boneIndex3;
		
		weight0 = a_oBoneWeight.weight0;
		weight1 = a_oBoneWeight.weight1;
		weight2 = a_oBoneWeight.weight2;
		weight3 = a_oBoneWeight.weight3;
	}
开发者ID:grifdail,项目名称:GGJ2016,代码行数:12,代码来源:Uni2DBoneWeight.cs

示例8: GetBone

 public static int GetBone(BoneWeight bw, int i)
 {
     if (i == 0)
         return bw.boneIndex0;
     else if (i == 1)
         return bw.boneIndex1;
     else if (i == 2)
         return bw.boneIndex2;
     else if (i == 3)
         return bw.boneIndex3;
     throw new Exception("44444");
 }
开发者ID:friuns,项目名称:New-Unity-Project-diablo,代码行数:12,代码来源:BoneCut.cs

示例9: constructor

 public static int constructor(IntPtr l)
 {
     try {
         UnityEngine.BoneWeight o;
         o=new UnityEngine.BoneWeight();
         pushValue(l,o);
         return 1;
     }
     catch(Exception e) {
         LuaDLL.luaL_error(l, e.ToString());
         return 0;
     }
 }
开发者ID:BobLChen,项目名称:hugula,代码行数:13,代码来源:Lua_UnityEngine_BoneWeight.cs

示例10: SetBone

 public static void SetBone(ref BoneWeight bw, int i, int id)
 {
     if (i == 0)
         bw.boneIndex0 = id;
     else if (i == 1)
         bw.boneIndex1 = id;
     else if (i == 2)
         bw.boneIndex2 = id;
     else if (i == 3)
         bw.boneIndex3 = id;
     else
         throw new Exception("4444");
 }
开发者ID:friuns,项目名称:New-Unity-Project-diablo,代码行数:13,代码来源:BoneCut.cs

示例11: EntryBoneWeights

			BoneWeight[] EntryBoneWeights(PMD.PMDFormat format)
			{
				int vcount = (int)format.vertex_list.vert_count;
				BoneWeight[] weights = new BoneWeight[vcount];
				for (int i = 0; i < vcount; i++)
				{
					weights[i].boneIndex0 = (int)format.vertex_list.vertex[i].bone_num[0];
					weights[i].boneIndex1 = (int)format.vertex_list.vertex[i].bone_num[1];
					weights[i].weight0 = format.vertex_list.vertex[i].bone_weight;
					weights[i].weight1 = 100 - format.vertex_list.vertex[i].bone_weight;
				}
				return weights;
			}
开发者ID:NektariosP,项目名称:unity-opencv-android,代码行数:13,代码来源:MMDConverter.cs

示例12: Clone

    public static BoneWeight Clone(this BoneWeight bw) {
        BoneWeight ret = new BoneWeight();
        ret.boneIndex0 = bw.boneIndex0;
        ret.boneIndex1 = bw.boneIndex1;
        ret.boneIndex2 = bw.boneIndex2;
        ret.boneIndex3 = bw.boneIndex3;
        ret.weight0 = bw.weight0;
        ret.weight1 = bw.weight1;
        ret.weight2 = bw.weight2;
        ret.weight3 = bw.weight3;

        return ret;
    }
开发者ID:CenzyGames,项目名称:Save-your-date-new,代码行数:13,代码来源:Utils.cs

示例13: Start

 void Start()
 {
     gameObject.AddComponent<Animation>();
     gameObject.AddComponent<SkinnedMeshRenderer>();
     SkinnedMeshRenderer renderer = GetComponent<SkinnedMeshRenderer>();
     Mesh mesh = new Mesh();
     mesh.vertices = new Vector3[] { new Vector3(-1, 0, 0), new Vector3(1, 0, 0), new Vector3(-1, 5, 0), new Vector3(1, 5, 0) };
     mesh.uv = new Vector2[] { new Vector2(0, 0), new Vector2(1, 0), new Vector2(0, 1), new Vector2(1, 1) };
     mesh.triangles = new int[] { 0, 1, 2, 1, 3, 2 };
     mesh.RecalculateNormals();
     renderer.material = new Material(Shader.Find(" Diffuse"));
     BoneWeight[] weights = new BoneWeight[4];
     weights[0].boneIndex0 = 0;
     weights[0].weight0 = 1;
     weights[1].boneIndex0 = 0;
     weights[1].weight0 = 1;
     weights[2].boneIndex0 = 1;
     weights[2].weight0 = 1;
     weights[3].boneIndex0 = 1;
     weights[3].weight0 = 1;
     mesh.boneWeights = weights;
     Transform[] bones = new Transform[2];
     Matrix4x4[] bindPoses = new Matrix4x4[2];
     bones[0] = new GameObject("Lower").transform;
     bones[0].parent = transform;
     bones[0].localRotation = Quaternion.identity;
     bone0_ratation = bones[0].localRotation;
     bones[0].localPosition = Vector3.zero;
     bindPoses[0] = bones[0].worldToLocalMatrix * transform.localToWorldMatrix;
     bones[1] = new GameObject("Upper").transform;
     bones[1].parent = transform;
     bones[1].localRotation = new Quaternion(0, 0, 0.717f, 0.717f);
     bone1_ratation = bones[1].localRotation;
     bones[1].localPosition = new Vector3(0, 5, 0);
     bindPoses[1] = bones[1].worldToLocalMatrix * transform.localToWorldMatrix;
     mesh.bindposes = bindPoses;
     renderer.bones = bones;
     renderer.sharedMesh = mesh;
     AnimationCurve curve = new AnimationCurve();
     curve.keys = new Keyframe[] { new Keyframe(0, 0), new Keyframe(1, 3), new Keyframe(2, 0.0F) };
     AnimationClip clip = new AnimationClip();
     clip.SetCurve("Lower", typeof(Transform), "m_LocalPosition.y", curve);
     AnimationCurve curve1 = new AnimationCurve();
     curve1.keys = new Keyframe[] { new Keyframe(0, 5), new Keyframe(1, 3), new Keyframe(2, 5F) };
     clip.SetCurve("Upper", typeof(Transform), "m_LocalPosition.y", curve1);
     clip.wrapMode = WrapMode.Loop;
     animation.AddClip(clip, "test");
     animation.Play("test");
 }
开发者ID:chenyufjfz,项目名称:Paoku,代码行数:49,代码来源:CreateSkin.cs

示例14: ImportCharMesh

    public static void ImportCharMesh(string meshPath, string zmsPath)
    {
        if (!File.Exists(zmsPath)) {
            Debug.LogWarning("Failed to find referenced ZMS.");
            return;
        }

        var mesh = new Mesh();

        var zms = new Revise.Files.ZMS.ModelFile();
        zms.Load(zmsPath);

        var verts = new Vector3[zms.Vertices.Count];
        var uvs = new Vector2[zms.Vertices.Count];
        var bones = new BoneWeight[zms.Vertices.Count];

        for (int k = 0; k < zms.Vertices.Count; ++k) {
            var v = zms.Vertices[k];
            v.TextureCoordinates[0].y = 1 - v.TextureCoordinates[0].y;

            verts[k] = rtuPosition(v.Position);
            uvs[k] = v.TextureCoordinates[0];

            bones[k] = new BoneWeight();
            bones[k].boneIndex0 = zms.BoneTable[v.BoneIndices.X];
            bones[k].boneIndex1 = zms.BoneTable[v.BoneIndices.Y];
            bones[k].boneIndex2 = zms.BoneTable[v.BoneIndices.Z];
            bones[k].boneIndex3 = zms.BoneTable[v.BoneIndices.W];
            bones[k].weight0 = v.BoneWeights.x;
            bones[k].weight1 = v.BoneWeights.y;
            bones[k].weight2 = v.BoneWeights.z;
            bones[k].weight3 = v.BoneWeights.w;
        }
        mesh.vertices = verts;
        mesh.uv = uvs;
        mesh.boneWeights = bones;

        int[] indices = new int[zms.Indices.Count * 3];
        for (int k = 0; k < zms.Indices.Count; ++k) {
            indices[k * 3 + 0] = zms.Indices[k].X;
            indices[k * 3 + 2] = zms.Indices[k].Y;
            indices[k * 3 + 1] = zms.Indices[k].Z;
        }
        mesh.triangles = indices;

        mesh.RecalculateNormals();

        AssetDatabase.CreateAsset(mesh, meshPath);
    }
开发者ID:brett19,项目名称:RoseTwoPointOh,代码行数:49,代码来源:Main.cs

示例15: GetBoneWeightStructs

	public BoneWeight[] GetBoneWeightStructs()
	{
		if(boneWeights == null)
		{
			return null;
		}
		
		int iBoneWeightCount = boneWeights.Length;
		
		BoneWeight[] oBoneWeights = new BoneWeight[iBoneWeightCount];
		for(int i = 0; i < iBoneWeightCount; ++i)
		{
			oBoneWeights[i] = boneWeights[i];
		}
		
		return oBoneWeights;
	}
开发者ID:grifdail,项目名称:GGJ2016,代码行数:17,代码来源:Uni2DMesh2D.cs


注:本文中的UnityEngine.BoneWeight类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。