Example #1
0
        //Transform3D[] t3DModels = null;

        private void MoveBalls(TSkeleton skeleton)
        {
            for (int a = 0; a < 21; a++)
            {
                BallBoundingBox bbb = (BallBoundingBox)balls[a];
                bbb.X = skeleton.Position[a].X;
                bbb.Y = skeleton.Position[a].Y;
                bbb.Z = skeleton.Position[a].Z;
            }
            for (int a = 0; a < jointIndexAray.Count; a++)
            {
                BallBoundingBox bbb       = (BallBoundingBox)balls[a + 21];
                JointIndex      ji        = (JointIndex)jointIndexAray[a];
                int             divHelper = ji.visuals.Count + 1;
                for (int b = 0; b < ji.visuals.Count; b++)
                {
                    ModelVisual3D mv3d = (ModelVisual3D)ji.visuals[b];
                    float         f16X = skeleton.Position[ji.joint1].X;
                    float         f16Y = skeleton.Position[ji.joint1].Y;
                    float         f16Z = skeleton.Position[ji.joint1].Z;

                    float f17X = skeleton.Position[ji.joint2].X;
                    float f17Y = skeleton.Position[ji.joint2].Y;
                    float f17Z = skeleton.Position[ji.joint2].Z;

                    float aa = (float)(b + 1) / divHelper;
                    //float aa = (float)b / ji.visuals.Count;
                    bbb.X = (aa * f16X) + ((1 - aa) * f17X);
                    bbb.Y = (aa * f16Y) + ((1 - aa) * f17Y);
                    bbb.Z = (aa * f16Z) + ((1 - aa) * f17Z);
                }
            }
        }
Example #2
0
        private void generateHelpJoints(int index1, int index2, int count, Color limbColor)
        {
            ModelVisual3D mv3d = null;

            JointIndex ji = new JointIndex();

            ji.joint1 = index1;
            ji.joint2 = index2;
            for (int b = 0; b < count; b++)
            {
                mv3d = GraphicPrimitiveGenerator.CreateSphere(
                    new Point3D(0, 0, 0), SmallBllSize, 4, 4, limbColor);
                _models.Add(mv3d);
                ji.visuals.Add(mv3d);

                balls.Add(new BallBoundingBox(0, 0, 0, SmallBllSize, index1, index2));
            }
            jointIndexAray.Add(ji);
        }
Example #3
0
        public void RenderModel(bool CheckBoxRelativeMoveIsChecked, TSkeleton skeleton)
        {
            MoveBalls(skeleton);
            for (int a = 0; a < 21; a++)
            {
                ModelVisual3D mv3d = _models[a];
                //Transform3DGroup transGroup = new Transform3DGroup();
                TranslateTransform3D translationTraansorm;
                if (CheckBoxRelativeMoveIsChecked == true)
                {
                    translationTraansorm = new TranslateTransform3D(skeleton.Position[a].X - skeleton.Position[0].X,
                                                                    skeleton.Position[a].Y,// - skeletons[0].Position[0].Y,
                                                                    skeleton.Position[a].Z - skeleton.Position[0].Z);
                }
                else
                {
                    translationTraansorm = new TranslateTransform3D(skeleton.Position[a].X,
                                                                    skeleton.Position[a].Y,// - skeletons[0].Position[0].Y,
                                                                    skeleton.Position[a].Z);
                }
                var myTransform3DGroup = new Transform3DGroup();
                myTransform3DGroup.Children.Add(translationTraansorm);
                mv3d.Transform = myTransform3DGroup;
            }

            for (int a = 0; a < jointIndexAray.Count; a++)
            {
                JointIndex ji        = (JointIndex)jointIndexAray[a];
                int        divHelper = ji.visuals.Count + 1;
                for (int b = 0; b < ji.visuals.Count; b++)
                {
                    ModelVisual3D mv3d = (ModelVisual3D)ji.visuals[b];
                    float         f16X = skeleton.Position[ji.joint1].X;
                    float         f16Y = skeleton.Position[ji.joint1].Y;
                    float         f16Z = skeleton.Position[ji.joint1].Z;

                    float f17X = skeleton.Position[ji.joint2].X;
                    float f17Y = skeleton.Position[ji.joint2].Y;
                    float f17Z = skeleton.Position[ji.joint2].Z;

                    float aa = (float)(b + 1) / divHelper;
                    //float aa = (float)b / ji.visuals.Count;
                    TranslateTransform3D translationTraansorm;
                    if (CheckBoxRelativeMoveIsChecked == true)
                    {
                        translationTraansorm = new TranslateTransform3D((aa * f16X) + ((1 - aa) * f17X) - skeleton.Position[0].X,
                                                                        (aa * f16Y) + ((1 - aa) * f17Y),// - skeletons[0].Position[0].Y,
                                                                        (aa * f16Z) + ((1 - aa) * f17Z) - skeleton.Position[0].Z);
                    }
                    else
                    {
                        translationTraansorm = new TranslateTransform3D((aa * f16X) + ((1 - aa) * f17X),
                                                                        (aa * f16Y) + ((1 - aa) * f17Y),// - skeletons[0].Position[0].Y,
                                                                        (aa * f16Z) + ((1 - aa) * f17Z));
                    }
                    var myTransform3DGroup = new Transform3DGroup();
                    myTransform3DGroup.Children.Add(translationTraansorm);
                    mv3d.Transform = myTransform3DGroup;
                }
            }
        }