本文整理汇总了C#中Bone类的典型用法代码示例。如果您正苦于以下问题:C# Bone类的具体用法?C# Bone怎么用?C# Bone使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Bone类属于命名空间,在下文中一共展示了Bone类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Arm
public Arm(int p, Entity.Gender g)
{
if(p > 9 || p < 1)
{
throw new System.OverflowException("Position: " + p + " is invalid for arm!");
}
position = p;
switch(g){
case Entity.Gender.MALE: //placeholder
{
break;
}
case Entity.Gender.FEMALE: //females have weaker bone structure than males
{
Bone Scapula = new Bone (.7, 20, 1);
Bone Humerus = new Bone (.65, 14, 2);
Bone Radius = new Bone (.25, 10, 3);
Bone Ulna = new Bone (.25, 10, 3);
Bone Carpus = new Bone (.35, 12, 4);
Bone Thumb = new Bone (.12, 8, 5);
Bone Pointer = new Bone (.12, 8, 5);
Bone Middle = new Bone (.12, 8, 5);
Bone Ring = new Bone (.12, 8, 5);
Bone Pinky = new Bone (.12, 5, 5);
break;
}
}
}
示例2: LateUpdate
public void LateUpdate()
{
if (!valid) {
Reset();
return;
}
if (bone == null) {
if (boneName == null || boneName.Length == 0) return;
bone = skeletonRenderer.skeleton.FindBone(boneName);
if (bone == null) {
Debug.LogError("Bone not found: " + boneName, this);
return;
}
}
if (cachedTransform.parent == skeletonTransform) {
cachedTransform.localPosition = new Vector3(bone.worldX, bone.worldY, cachedTransform.localPosition.z);
Vector3 rotation = cachedTransform.localRotation.eulerAngles;
cachedTransform.localRotation = Quaternion.Euler(rotation.x, rotation.y, bone.worldRotation);
} else {
cachedTransform.position = skeletonTransform.TransformPoint(new Vector3(bone.worldX, bone.worldY, cachedTransform.position.z));
Vector3 rotation = skeletonTransform.rotation.eulerAngles;
cachedTransform.rotation = Quaternion.Euler(rotation.x, rotation.y,
skeletonTransform.rotation.eulerAngles.z + bone.worldRotation);
}
}
示例3: CalculateBoneWeights
public static Bone2DWeights CalculateBoneWeights(Transform owner, Bone[] bones, Mesh mesh)
{
if (bones != null) {
Bone2DWeights boneWeights = new Bone2DWeights();
boneWeights.weights = new Bone2DWeight[] { };
int vIndex = 0;
foreach (Vector3 v in mesh.vertices) {
Bone closest = FindClosestBone(v, bones);
if (closest != null) {
boneWeights.SetWeight(vIndex++, closest.name, Array.IndexOf(bones, closest), 1f);
}
}
BoneWeight[] unitweights = boneWeights.GetUnityBoneWeights();
mesh.boneWeights = unitweights;
Transform[] bonesArr = bones.Select(b => b.transform).ToArray();
Matrix4x4[] bindPoses = new Matrix4x4[bonesArr.Length];
for (int i = 0; i < bonesArr.Length; i++) {
bindPoses[i] = bonesArr[i].worldToLocalMatrix * owner.localToWorldMatrix;
}
mesh.bindposes = bindPoses;
return boneWeights;
}
return null;
}
示例4: BackwardReaching
/// <summary>
/// The backwards reaching phase
/// </summary>
/// <param name="bones"></param>
/// <param name="distances"></param>
/// <param name="root"></param>
/// <param name="parent"></param>
private void BackwardReaching(ref Bone[] bones, ref float[] distances, Vector3 root, Bone parent)
{
bones[0].Pos = root;
for (int i = 0; i < bones.Length - 1; i++)
{
SamePosCheck(ref bones, i);
Vector3 newPos;
// Position
float r = (bones[i + 1].Pos - bones[i].Pos).Length;
float l = distances[i] / r;
newPos = (1 - l) * bones[i].Pos + l * bones[i + 1].Pos;
Bone prevBone = (i > 0) ? bones[i - 1] : parent;
bones[i + 1].Pos = newPos;
// Orientation
bones[i].RotateTowards(bones[i + 1].Pos - bones[i].Pos,bones[i].Stiffness);
if (bones[i].HasConstraints)
{
Quaternion rot;
if (constraints.CheckOrientationalConstraint(bones[i], prevBone, out rot))
{
bones[i].Rotate(rot);
}
}
}
}
示例5: SolveBoneChain
public override bool SolveBoneChain(Bone[] bones, Bone target, Bone parent)
{
// Calculate distances
float[] distances = GetDistances(ref bones);
double dist = Math.Abs((bones[0].Pos - target.Pos).Length);
if (dist > distances.Sum()) // the target is unreachable
{
TargetUnreachable(bones, target.Pos, parent);
return true;
}
// The target is reachable
int numberOfBones = bones.Length;
bones[numberOfBones - 1].Orientation = target.Orientation;
Vector3 root = bones[0].Pos;
int iterations = 0;
float lastDistToTarget = float.MaxValue;
float distToTarget = (bones[bones.Length - 1].Pos - target.Pos).Length;
while (distToTarget > threshold && iterations++ < MaxIterations && distToTarget < lastDistToTarget)
{
// Forward reaching
ForwardReaching(ref bones, ref distances, target);
// Backward reaching
BackwardReaching(ref bones, ref distances, root, parent);
lastDistToTarget = distToTarget;
distToTarget = (bones[bones.Length - 1].Pos - target.Pos).Length;
}
bones[bones.Length - 1].Orientation = target.Orientation;
return (distToTarget <= threshold);
}
示例6: MirrorNode
public MirrorNode(Node parentNode, Bone referenceBone)
{
this.ReferenceBone = referenceBone;
Node = parentNode.CreateChild(ReferenceBone.InitialPosition, ReferenceBone.InitialOrientation);
Children = new List<MirrorNode>(ReferenceBone.NumChildren());
foreach (Bone bone in referenceBone.GetChildIterator().OfType<Bone>())
Children.Add(new MirrorNode(Node, bone));
}
示例7: SceneAnimator
public SceneAnimator() {
_skeleton = null;
CurrentAnimationIndex = -1;
_bonesByName = new Dictionary<string, Bone>();
_bonesToIndex = new Dictionary<string, int>();
_animationNameToId = new Dictionary<string, int>();
_bones = new List<Bone>();
Animations = new List<AnimEvaluator>();
}
示例8: ContainsDuplicateBone
/// <summary>
/// Checks if an array of objects contains any duplicates.
/// </summary>
public static Transform ContainsDuplicateBone(Bone[] bones)
{
for (int i = 0; i < bones.Length; i++) {
for (int i2 = 0; i2 < bones.Length; i2++) {
if (i != i2 && bones[i].transform == bones[i2].transform) return bones[i].transform;
}
}
return null;
}
示例9: GetDistances
/// <summary>
/// Gets the total length from the root of each bone in the kinematic chain (the bone chain)
/// </summary>
/// <param name="distances"></param>
/// <param name="bones"></param>
protected float[] GetDistances(ref Bone[] bones)
{
float[] distances = new float[bones.Length - 1];
for (int i = 0; i < distances.Length; i++)
{
distances[i] = (bones[i].Pos - bones[i + 1].Pos).Length;
}
return distances;
}
示例10: IsReachable
/// <summary>
/// Checks wheter the target is reacheble for the bone chain or not
/// </summary>
/// <param name="bones">The chain of bone, the IK Chain</param>
/// <param name="target">The target</param>
/// <returns>True if target is reachable, false otherwise</returns>
protected bool IsReachable(Bone[] bones, Bone target)
{
float acc = 0;
for (int i = 0; i < bones.Length - 1; i++)
{
acc += (bones[i].Pos - bones[i + 1].Pos).Length;
}
float dist = System.Math.Abs((bones[0].Pos - target.Pos).Length);
return dist < acc; // the target is unreachable
}
示例11: EditAttachedObjectEventArgs
/// <summary>
/// Initializes a new instance of the EditAttachedObjectEventArgs class.
/// </summary>
/// <param name="response">EditObjectResponse.</param>
/// <param name="index">Index of the attached object.</param>
/// <param name="modelid">Model of the attached object.</param>
/// <param name="bone">The bone the object was attached to.</param>
/// <param name="offset">Offset of the attached object.</param>
/// <param name="rotation">Rotation of the attached object.</param>
/// <param name="scale">Scale of the attached object.</param>
public EditAttachedObjectEventArgs(EditObjectResponse response, int index, int modelid, Bone bone,
Vector3 offset, Vector3 rotation, Vector3 scale)
{
EditObjectResponse = response;
Index = index;
ModelId = modelid;
Bone = bone;
Offset = offset;
Rotation = rotation;
Scale = scale;
}
示例12: QMesh
internal QMesh(Point3f[] v, TexCoord[] t, Color[] c, ushort[] f, Matrix m, Texture tx, string n, Bone[] pmBones, bool outline)
: base(Matrix.IDENTITY, pmBones)
{
vertices= v;
texcoords= t;
colors= c;
faces= f;
pMatrix= m;
pTexture= tx;
name= n;
bRenderOutline= outline;
}
示例13: UpdateSegmentPosition
void UpdateSegmentPosition(JointID j1, JointID j2, Segment seg)
{
var bone = new Bone(j1, j2);
if (segments.ContainsKey(bone))
{
BoneData data = segments[bone];
data.UpdateSegment(seg);
segments[bone] = data;
}
else
segments.Add(bone, new BoneData(seg));
}
示例14: HeadIK
public HeadIK( FullBodyIK fullBodyIK )
{
_settings = fullBodyIK.settings;
_internalValues = fullBodyIK.internalValues;
_neckBone = _PrepareBone( fullBodyIK.headBones.neck );
_headBone = _PrepareBone( fullBodyIK.headBones.head );
_leftEyeBone = _PrepareBone( fullBodyIK.headBones.leftEye );
_rightEyeBone = _PrepareBone( fullBodyIK.headBones.rightEye );
_headEffector = fullBodyIK.headEffectors.head;
_eyesEffector = fullBodyIK.headEffectors.eyes;
}
示例15: init
protected override void init()
{
bones = new List<Bone>();
Bone bone = new Bone();
bone.Scale(new Vector3(0.2f, 1f, 0.2f));
bones.Add(bone);
bone = new Bone();
bone.Scale(new Vector3(0.2f, 0.5f, 0.2f));
bone.Move(new Vector3(0.3f, 0f, 0f));
bones[0].AddChild(bone);
bones.Add(bone);
SetupDepthAndCull();
}