本文整理汇总了C#中Transform.GetTransformPath方法的典型用法代码示例。如果您正苦于以下问题:C# Transform.GetTransformPath方法的具体用法?C# Transform.GetTransformPath怎么用?C# Transform.GetTransformPath使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Transform
的用法示例。
在下文中一共展示了Transform.GetTransformPath方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CreateFrame
private AnimationFrame CreateFrame(Transform frame, AnimatorEditor editor, HashSet<string> extractFrames, HashSet<string> meshNames, Device device, List<AnimationFrame> meshFrames, Dictionary<string, Tuple<Matrix, Matrix>> extractMatrices)
{
AnimationFrame animationFrame = new AnimationFrame();
animationFrame.Name = frame.GetTransformPath();
animationFrame.TransformationMatrix = Matrix.Scaling(frame.m_LocalScale) * Matrix.RotationQuaternion(frame.m_LocalRotation) * Matrix.Translation(frame.m_LocalPosition);
animationFrame.OriginalTransform = animationFrame.TransformationMatrix;
animationFrame.CombinedTransform = extractMatrices[animationFrame.Name].Item1;
if (meshNames.Contains(animationFrame.Name))
{
MeshRenderer meshR = frame.m_GameObject.instance.FindLinkedComponent(UnityClassID.SkinnedMeshRenderer);
if (meshR == null)
{
meshR = frame.m_GameObject.instance.FindLinkedComponent(UnityClassID.MeshRenderer);
}
if (meshR != null)
{
Mesh mesh = Operations.GetMesh(meshR);
if (mesh != null)
{
SkinnedMeshRenderer smr = meshR as SkinnedMeshRenderer;
List<PPtr<Transform>> boneList = null;
string[] boneNames = null;
Matrix[] boneOffsets = null;
if (smr != null && smr.m_Bones.Count > 0)
{
boneList = smr.m_Bones;
int numBones = boneList.Count > 0 ? extractFrames.Count : 0;
boneNames = new string[numBones];
boneOffsets = new Matrix[numBones];
if (numBones > 0)
{
string[] extractArray = new string[numBones];
extractFrames.CopyTo(extractArray);
HashSet<string> extractCopy = new HashSet<string>(extractArray);
int invalidBones = 0;
for (int i = 0; i < boneList.Count; i++)
{
Transform bone = boneList[i].instance;
if (bone == null || bone.m_GameObject.instance == null || !extractCopy.Remove(bone.GetTransformPath()))
{
invalidBones++;
}
else if (i < numBones)
{
boneNames[i] = bone.GetTransformPath();
boneOffsets[i] = Operations.Mirror(Matrix.Transpose(mesh.m_BindPose[i]));
}
}
extractCopy.CopyTo(boneNames, boneList.Count - invalidBones);
for (int i = boneList.Count; i < extractFrames.Count; i++)
{
boneOffsets[i] = extractMatrices[boneNames[i]].Item2;
}
}
}
AnimationMeshContainer[] meshContainers = new AnimationMeshContainer[mesh.m_SubMeshes.Count];
Vector3 min = new Vector3(Single.MaxValue);
Vector3 max = new Vector3(Single.MinValue);
Operations.vMesh vMesh = new Operations.vMesh(meshR, true, true);
for (int i = 0; i < mesh.m_SubMeshes.Count; i++)
{
Operations.vSubmesh submesh = vMesh.submeshes[i];
List<Operations.vFace> faceList = submesh.faceList;
List<Operations.vVertex> vertexList = submesh.vertexList;
SlimDX.Direct3D9.Mesh animationMesh = null;
PositionBlendWeightsIndexedColored[] normalLines = null;
try
{
animationMesh = new SlimDX.Direct3D9.Mesh(device, faceList.Count, vertexList.Count, MeshFlags.Managed, PositionBlendWeightsIndexedNormalTexturedColoured.Format);
using (DataStream indexStream = animationMesh.LockIndexBuffer(LockFlags.None))
{
for (int j = 0; j < faceList.Count; j++)
{
ushort[] indices = faceList[j].index;
indexStream.Write(indices[0]);
indexStream.Write(indices[2]);
indexStream.Write(indices[1]);
}
animationMesh.UnlockIndexBuffer();
}
FillVertexBuffer(animationMesh, vertexList, -1);
normalLines = new PositionBlendWeightsIndexedColored[vertexList.Count * 2];
for (int j = 0; j < vertexList.Count; j++)
{
Operations.vVertex vertex = vertexList[j];
byte[] bIdx;
float[] bWeights;
if (vertex.boneIndices != null)
{
bIdx = new byte[4] { (byte)vertex.boneIndices[0], (byte)vertex.boneIndices[1], (byte)vertex.boneIndices[2], (byte)vertex.boneIndices[3] };
bWeights = vertex.weights;
}
//.........这里部分代码省略.........
示例2: CreateCombinedMatrices
private void CreateCombinedMatrices(Transform frame, HashSet<string> extractFrames, Matrix combinedParent, Dictionary<string, Tuple<Matrix, Matrix>> extractMatrices)
{
Matrix combinedTransform = combinedParent * Matrix.Scaling(frame.m_LocalScale) * Matrix.RotationQuaternion(frame.m_LocalRotation) * Matrix.Translation(frame.m_LocalPosition);
try
{
extractMatrices.Add(frame.GetTransformPath(), new Tuple<Matrix, Matrix>(combinedTransform, Matrix.Invert(combinedTransform)));
}
catch (ArgumentException)
{
string msg = "A transform named " + frame.m_GameObject.instance.m_Name + " already exists.";
if (!messageFilterCreateCombineMatrices.Contains(msg))
{
Report.ReportLog(msg);
messageFilterCreateCombineMatrices.Add(msg);
}
}
for (int i = 0; i < frame.Count; i++)
{
Transform child = frame[i];
if (extractFrames.Contains(child.GetTransformPath()))
{
CreateCombinedMatrices(child, extractFrames, combinedTransform, extractMatrices);
}
}
}