/// <summary>
        /// Hit test Result
        /// </summary>
        /// <param name="rawresult">Result Parameter</param>
        /// <returns></returns>
        private HitTestResultBehavior HTResult(HitTestResult rawresult)
        {
            RayHitTestResult rayResult = rawresult as RayHitTestResult;

            if (rayResult != null)
            {
                RayMeshGeometry3DHitTestResult rayMeshResult = rayResult as RayMeshGeometry3DHitTestResult;

                if (rayMeshResult != null && rayMeshResult.VisualHit.GetType().Name == "ModelVisual3D")
                {
                    hitgeo = rayMeshResult.ModelHit as GeometryModel3D;

                    joint = Session.CurrentSession.CurrentProject.CurrentModel3D.Joints.FindJointByMatrix(hitgeo.Transform.Value);

                    if (joint != null)
                    {
                        targetModel = Session.CurrentSession.CurrentProject.CurrentModel3D.Content.Find(hitgeo);

                        BaseOffsetX = hitgeo.Transform.Value.OffsetX;
                        BaseOffsetY = hitgeo.Transform.Value.OffsetY;
                        BaseOffsetZ = hitgeo.Transform.Value.OffsetZ;
                    }
                    else
                        hitgeo = null;
                }
                else
                    hitgeo = null;
            }
            return HitTestResultBehavior.Stop;
        }
        /// <summary>
        /// Build a joint for drawing
        /// </summary>
        /// <param name="joint">Joint</param>
        /// <returns>Joint created</returns>
        private GeometryModel3D BuildJoint(Joint joint)
        {
            MeshBuilder jointBuilder = new MeshBuilder();
            jointBuilder.AddSphere(new Point3D(0, 0, 0), jointDiameter, thetaDiv, 10);

            GeometryModel3D jointModel = new GeometryModel3D(jointBuilder.ToMesh(), Materials.Red);
            jointModel.SetName(joint.Name);

            MatrixTransform3D transform = new MatrixTransform3D(joint.Matrix.ElementAtOrDefault(Session.CurrentSession.CurrentProject.CurrentModel3D.Animation.Tick));
            jointModel.Transform = transform;

            return jointModel;
        }
        /// <summary>
        /// Update a 3D Joint in the joint Collection
        /// </summary>
        /// <param name="nodeName">The joint Name</param>
        /// <param name="absoluteMatrix">Destintation Matrix of the specified node</param>
        private void SetJoint(string nodeName, Matrix3D absoluteMatrix, Assimp.Vector3D delta)
        {
            Joint myJoint = joints.FindJointByName(nodeName);
            if (myJoint == null)
            {
                myJoint = new Joint();
                myJoint.Name = nodeName;
                myJoint.Matrix.Add(absoluteMatrix);
                myJoint.Delta.Add(delta);

                joints.Add(myJoint);
            }
            else
            {
                myJoint.Matrix.Add(absoluteMatrix);
                myJoint.Delta.Add(delta);
            }
        }
        /// <summary>
        /// Update a 3D Joint in the joint Collection
        /// </summary>
        /// <param name="nodeName">The joint Name</param>
        /// <param name="destMatrix">Destintation Matrix of the specified node</param>
        private void SetJoint(string nodeName, Matrix3D destMatrix)
        {
            Joint myJoint = joints.FindJointByName(nodeName);
            if (myJoint == null)
            {
                myJoint = new Joint();
                myJoint.Name = nodeName;
                myJoint.Matrix.Add(destMatrix);

                joints.Add(myJoint);
            }
            else
                myJoint.Matrix.Add(destMatrix);
        }
Esempio n. 5
0
        /// <summary>
        /// Set the new position in Assimp Database for export
        /// </summary>
        /// <param name="joint">joint with position</param>
        public void SetNewJointPosition(Joint joint)
        {
            Assimp.NodeAnimationChannel nodeChannel = assimpAnimation.NodeAnimationChannels.FindNodeByName(joint.Name);
            if (nodeChannel != null)
            {
                // TODO : Check here

                Assimp.Vector3D newPoint = joint.GetAssimpPoint();

                Assimp.VectorKey[] newPositionKeys = new Assimp.VectorKey[nodeChannel.PositionKeyCount];
                nodeChannel.PositionKeys.CopyTo(newPositionKeys);
                newPositionKeys[Tick].Value = newPoint;
                
                nodeChannel.PositionKeys.Clear();
                nodeChannel.PositionKeys.AddRange(newPositionKeys);
            }
        }
Esempio n. 6
0
 /// <summary>
 /// Replace a model in the Content
 /// </summary>
 /// <param name="oldModel">Old Model</param>
 /// <param name="newModel">New Model</param>
 public void ReplaceInContent(Joint joint)
 {
     Animation.SetNewJointPosition(joint);
     RaisePropertyChangedEvent("ContentReplaced");
 }