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


C# Assimp.Node类代码示例

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


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

示例1: ComputeBoundingBox

        /// <summary>
        /// Recursively calculates the bounding box of the whole model.
        /// </summary>
        private void ComputeBoundingBox(Scene scene, Node node,
            ref Vector3 min, ref Vector3 max,
            ref Matrix transform)
        {
            var previousTransform = transform;
            transform = Matrix.Multiply(previousTransform, node.Transform.ToMatrix());

            if (node.HasMeshes)
            {
                foreach (int index in node.MeshIndices)
                {
                    Mesh mesh = scene.Meshes[index];
                    for (int i = 0; i < mesh.VertexCount; i++)
                    {
                        var tmp = mesh.Vertices[i].ToVector3();
                        Vector4 result;
                        Vector3.Transform(ref tmp, ref transform, out result);

                        min.X = System.Math.Min(min.X, result.X);
                        min.Y = System.Math.Min(min.Y, result.Y);
                        min.Z = System.Math.Min(min.Z, result.Z);

                        max.X = System.Math.Max(max.X, result.X);
                        max.Y = System.Math.Max(max.Y, result.Y);
                        max.Z = System.Math.Max(max.Z, result.Z);
                    }
                }
            }

            // Go down the hierarchy if children are present.
            for (int i = 0; i < node.ChildCount; i++)
                ComputeBoundingBox(scene, node.Children[i], ref min, ref max, ref transform);

            transform = previousTransform;
        }
开发者ID:modulexcite,项目名称:rasterizr,代码行数:38,代码来源:ModelLoader.cs

示例2: GetRootNode

 public static Node GetRootNode(Node myNode)
 {
     Node parent = myNode.Parent;
     if (myNode.Parent != null)
         return GetRootNode(parent);
     return (parent);
 }
开发者ID:loic-lavergne,项目名称:mckineap,代码行数:7,代码来源:AssimpUtil.cs

示例3: CreateBoneTree

		private Bone CreateBoneTree(ref Skeleton skele, Node node, Bone parent) {

			var internalNode = new Bone {
				Name = node.Name, Parent = parent,
			};
			if (boneNames.ContainsKey (node.Name)) {
				boneNames [node.Name].OffsetMatrix.Transpose ();
				internalNode.Offset = FromMatrix (boneNames [node.Name].OffsetMatrix);

			}if (internalNode.Name == "") {
				internalNode.Name = "bone_" + _i++;
			}
			//skele[internalNode.Name] = internalNode;
			var trans = node.Transform;
			trans.Transpose(); //drectx stuff
			internalNode.LocalTransform =FromMatrix(trans);
			internalNode.OriginalLocalTransform = internalNode.LocalTransform;
			CalculateBoneToWorldTransform(internalNode);
			internalNode.Children = new List<Bone> ();
			for (var i = 0; i < node.ChildCount; i++) {
				var child = CreateBoneTree(ref skele,node.Children[i], internalNode);
				if (child != null) {
					internalNode.Children.Add(child);
				}
			}

			return internalNode;
		}
开发者ID:BreyerW,项目名称:Sharp.Engine,代码行数:28,代码来源:SkeletonPipeline.cs

示例4: ComputeBoundingBox

        //recursively calculates the bounding box of the whole model
        private void ComputeBoundingBox(Scene scene, Node node, ref Vector3 min, ref Vector3 max, ref Matrix transform)
        {
            Matrix previousTransform = transform;
            transform = Matrix.Multiply(previousTransform, FromMatrix(node.Transform));

            if (node.HasMeshes)
            {
                foreach (int index in node.MeshIndices)
                {
                    Assimp.Mesh mesh = scene.Meshes[index];
                    for (int i = 0; i < mesh.VertexCount; i++)
                    {
                        Vector3 tmp = FromVector(mesh.Vertices[i]);
                        Vector4 result;
                        Vector3.Transform(ref tmp, ref transform, out result);

                        min.X = Math.Min(min.X, result.X);
                        min.Y = Math.Min(min.Y, result.Y);
                        min.Z = Math.Min(min.Z, result.Z);

                        max.X = Math.Max(max.X, result.X);
                        max.Y = Math.Max(max.Y, result.Y);
                        max.Z = Math.Max(max.Z, result.Z);
                    }
                }
            }

            //go down the hierarchy if children are present
            for (int i = 0; i < node.ChildCount; i++)
            {
                ComputeBoundingBox(scene, node.Children[i], ref min, ref max, ref transform);
            }
            transform = previousTransform;
        }
开发者ID:loic-lavergne,项目名称:mckineap,代码行数:35,代码来源:ModelLoader.cs

示例5: SetNode

        public void SetNode(MainWindow mainWindow, Scene scene, Node node)
        {
            _node = node;
            _scene = scene;

            var matrix4X4 = _node.Transform;
            trafoMatrixViewControlLocal.SetMatrix(ref matrix4X4);

            var mat = Matrix4x4.Identity;
            var cur = node;
            while(cur != null)
            {
                var trafo = cur.Transform;
                trafo.Transpose();
                mat = trafo * mat;
                cur = cur.Parent;
            }
            mat.Transpose();
            trafoMatrixViewControlGlobal.SetMatrix(ref mat);

            Text = node.Name + " - Node Details";

            // populate statistics
            labelMeshesDirect.Text = node.MeshCount.ToString(CultureInfo.InvariantCulture);
            labelChildrenDirect.Text = node.ChildCount.ToString(CultureInfo.InvariantCulture);

            var meshTotal = 0;
            var childTotal = 0;
            CountMeshAndChildrenTotal(node, ref meshTotal, ref childTotal);

            labelMeshesTotal.Text = node.MeshCount.ToString(CultureInfo.InvariantCulture);
            labelChildrenTotal.Text = node.ChildCount.ToString(CultureInfo.InvariantCulture);
        }
开发者ID:Kolky,项目名称:open3mod,代码行数:33,代码来源:NodeItemsDialog.cs

示例6: AddChildNode

 private Node AddChildNode(Node parentNode, Joint childJoint)
 {
     Node newChildNode = new Node();
     newChildNode.Name = GetNodeIdName(childJoint.JointType);
     parentNode.Children.Add(newChildNode);
     return (newChildNode);
 }
开发者ID:loic-lavergne,项目名称:mckineap,代码行数:7,代码来源:KinectConverter.cs

示例7: AddChildBone

 private Node AddChildBone(string fingerType, string boneType, Hand hand, Node parentNode)
 {
     Node boneNode = new Node();
     boneNode.Name = GetNodeBoneName(fingerType, boneType, hand);
     parentNode.Children.Add(boneNode);
     return (boneNode);
 }
开发者ID:loic-lavergne,项目名称:mckineap,代码行数:7,代码来源:LeapMotionConverter.cs

示例8: CreateNodeHierarchy

        /// <summary>
        /// Build a Node hierachy into the scene property 'mainScene' from a Hand object
        /// </summary>
        /// <param name="hand"></param>
        private void CreateNodeHierarchy(Hand hand, Scene handScene)
        {
            Node rootNode = handScene.RootNode = new Node();

            Node handNode = new Node();
            handNode.Name = GetNodeHandName(hand.Id.ToString());
            rootNode.Children.Add(handNode);
            
            NodeAnimationChannel bonetest = new NodeAnimationChannel();
            bonetest.NodeName = GetNodeHandName(hand.Id.ToString());
            handScene.Animations[0].NodeAnimationChannels.Add(bonetest);

            foreach (Finger finger in hand.Fingers)
            {
                Node fingerNode = handNode;

                foreach (Leap.Bone.BoneType boneType in (Leap.Bone.BoneType[])Enum.GetValues(typeof(Leap.Bone.BoneType)))
                {
                    string fingerType = finger.Type.ToString();
                    //Add a node hierarchy
                    fingerNode = AddChildBone(fingerType, boneType.ToString(), hand, fingerNode);
                    //Fill the NodeAnimChannel
                    NodeAnimationChannel bone = new NodeAnimationChannel();
                    bone.NodeName = GetNodeBoneName(fingerType, boneType.ToString(), hand);
                    handScene.Animations[0].NodeAnimationChannels.Add(bone);
                }
            }
        }
开发者ID:loic-lavergne,项目名称:mckineap,代码行数:32,代码来源:LeapMotionConverter.cs

示例9: DrawNormals

        public static void DrawNormals(Node node, int meshIndex, Mesh mesh, CpuSkinningEvaluator skinner, float invGlobalScale, Matrix4 transform)
        {
            if (!mesh.HasNormals)
            {
                return;
            }

            // The normal directions are transformed using the transpose(inverse(transform)).
            // This ensures correct direction is used when non-uniform scaling is present.
            Matrix4 normalMatrix = transform;
            normalMatrix.Invert();
            normalMatrix.Transpose();

            // Scale by scene size because the scene will be resized to fit
            // the unit box, but the normals should have a fixed length.
            var scale = invGlobalScale * 0.05f;

            GL.Begin(BeginMode.Lines);

            GL.Disable(EnableCap.Lighting);
            GL.Disable(EnableCap.Texture2D);
            GL.Enable(EnableCap.ColorMaterial);

            GL.Color4(new Color4(0.0f, 1.0f, 0.0f, 1.0f));

            for (uint i = 0; i < mesh.VertexCount; ++i)
            {
                Vector3 v;
                if (skinner != null && mesh.HasBones)
                {
                    skinner.GetTransformedVertexPosition(node, mesh, i, out v);
                }
                else
                {
                    v = AssimpToOpenTk.FromVector(mesh.Vertices[(int)i]);
                }
                v = Vector4.Transform(new Vector4(v, 1.0f), transform).Xyz; // Skip dividing by W component. It should always be 1, here.

                Vector3 n;
                if (skinner != null)
                {
                    skinner.GetTransformedVertexNormal(node, mesh, i, out n);
                }
                else
                {
                    n = AssimpToOpenTk.FromVector(mesh.Normals[(int)i]);
                }
                n = Vector4.Transform(new Vector4(n, 0.0f), normalMatrix).Xyz; // Toss the W component. It is non-sensical for normals.
                n.Normalize();

                GL.Vertex3(v);
                GL.Vertex3(v + n * scale);
            }
            GL.End();

            GL.Disable(EnableCap.ColorMaterial);
        }
开发者ID:Kolky,项目名称:open3mod,代码行数:57,代码来源:OverlayNormals.cs

示例10: CountNodeNumber

 /// <summary>
 /// Counts recursively the number of nodes in a node architecture.<br />
 /// Each node contains a pointer to the next nodes in a node architecture.
 /// </summary>
 /// <param name="node">The node to be counted and containing the next nodes as pointers in the node architecture, as a Asssimp.Node.</param>
 /// <param name="nodeNumber">The number of nodes to be updated as the algorithm goes deeper into the node architecture, as an Integer.</param>
 private static void CountNodeNumber(Node node, ref int nodeNumber)
 {
     if (node != null)
     {
         nodeNumber += 1;
         for (int i = 0; i < node.ChildCount; i++)
             CountNodeNumber(node.Children[i], ref nodeNumber);
     }
 }
开发者ID:loic-lavergne,项目名称:mckineap,代码行数:15,代码来源:MergeAcceptance.cs

示例11: CreateAssimpAnimation

 /// <summary>
 /// Creates an Assimp.Animation by copying the given source Assimp.Animation content.<br />
 /// </summary>
 /// <param name="rootNode"></param>
 /// <param name="sourceAnimation">The source Assimp.Animation to copy.</param>
 /// <returns></returns>
 private static Assimp.Animation CreateAssimpAnimation(Node rootNode, Assimp.Animation sourceAnimation)
 {
     Assimp.Animation animation = new Assimp.Animation();
     animation.DurationInTicks = sourceAnimation.DurationInTicks;
     animation.Name = sourceAnimation.Name;
     animation.TicksPerSecond = sourceAnimation.TicksPerSecond;
     CreateNodeAnimationChannels(animation, sourceAnimation.NodeAnimationChannels, rootNode);
     return animation;
 }
开发者ID:loic-lavergne,项目名称:mckineap,代码行数:15,代码来源:Model3DMerger.cs

示例12: CreateNodeAnimationChannels

        /// <summary>
        /// Creates an Assimp.NodeAnimationChannel from the given NodeAnimationChannel list and Assimp.Node.<br />
        /// Adds the Assimp.NodeAnimationChannel to the given Assimp.Animation
        /// </summary>
        /// <param name="node"></param>
        /// <param name="channel"></param>
        private static void CreateNodeAnimationChannels(Assimp.Animation animation, List<NodeAnimationChannel> sourceNodeAnimationChannels, Node node)
        {
            NodeAnimationChannel nodeAnimationChannel = new NodeAnimationChannel();
            nodeAnimationChannel = sourceNodeAnimationChannels[animation.NodeAnimationChannelCount];
            nodeAnimationChannel.NodeName = node.Name;
            animation.NodeAnimationChannels.Add(nodeAnimationChannel);

            for (int i = 0; i < node.ChildCount; i++)
                CreateNodeAnimationChannels(animation, sourceNodeAnimationChannels, node.Children[i]);
        }
开发者ID:loic-lavergne,项目名称:mckineap,代码行数:16,代码来源:Model3DMerger.cs

示例13: CopyNodeTree

 private static void CopyNodeTree(Node oriParentNode, Node copyRootNode)
 {
     foreach (Node oriChildNode in oriParentNode.Children)
     {
         //We could use a CopyNode method later if its necessary to add more metadata inside.
         Node newNode = new Node(oriChildNode.Name);
         copyRootNode.Children.Add(newNode);
         CopyNodeTree(oriChildNode, newNode);
     }
 }
开发者ID:loic-lavergne,项目名称:mckineap,代码行数:10,代码来源:AssimpUtil.cs

示例14: DrawSkeletonBone

        public static void DrawSkeletonBone(Node node, float invGlobalScale, bool highlight)
        {
            var target = new Vector3(node.Transform.A4, node.Transform.B4, node.Transform.C4);
            if (!(target.LengthSquared > 1e-6f))
            {
                return;
            }

            GL.Disable(EnableCap.Lighting);
            GL.Disable(EnableCap.Texture2D);
            GL.Enable(EnableCap.ColorMaterial);
            GL.Disable(EnableCap.DepthTest);

            GL.Color4(highlight ? new Color4(0.0f, 1.0f, 0.5f, 1.0f) : new Color4(0.0f, 0.5f, 1.0f, 1.0f));

            var right = new Vector3(1, 0, 0);
            var targetNorm = target;
            targetNorm.Normalize();

            Vector3 up;
            Vector3.Cross(ref targetNorm, ref right, out up);
            Vector3.Cross(ref up, ref targetNorm, out right);

            up *= invGlobalScale;
            right *= invGlobalScale;

            const float jointWidth = 0.03f;

            GL.Begin(BeginMode.LineLoop);
            GL.Vertex3(-jointWidth * up + -jointWidth * right);
            GL.Vertex3(-jointWidth * up + jointWidth * right);
            GL.Vertex3(jointWidth * up + jointWidth * right);
            GL.Vertex3(jointWidth * up + -jointWidth * right);
            GL.End();

            GL.Begin(BeginMode.Lines);
            GL.Vertex3(-jointWidth * up + -jointWidth * right);
            GL.Vertex3(target);
            GL.Vertex3(-jointWidth * up + jointWidth * right);
            GL.Vertex3(target);
            GL.Vertex3(jointWidth * up + jointWidth * right);
            GL.Vertex3(target);
            GL.Vertex3(jointWidth * up + -jointWidth * right);
            GL.Vertex3(target);

            GL.Color4(highlight ? new Color4(1.0f, 0.0f, 0.0f, 1.0f) : new Color4(1.0f, 1.0f, 0.0f, 1.0f));

            GL.Vertex3(Vector3.Zero);
            GL.Vertex3(target);
            GL.End();

            GL.Disable(EnableCap.ColorMaterial);
            GL.Enable(EnableCap.DepthTest);
        }
开发者ID:Kolky,项目名称:open3mod,代码行数:54,代码来源:OverlaySkeleton.cs

示例15: AutomaticRiggingFromSkeleton

        /// <summary>
        /// Generate weights and skeleton Nodes from an assimp skeleton Node.
        /// However pinocchio does not looks to be very good with
        /// that Method.
        /// It takes a
        /// </summary>
        /// <param name="modelPath">The original model Path</param>
        /// <param name="scene"></param>
        /// <param name="skeletalAnim"></param>
        /// <param name="rootSkeletalAnim"></param>
        public void AutomaticRiggingFromSkeleton(string modelPath, Scene scene, Animation skeletalAnim, Node rootSkeletalAnim)
        {
            string skelPathFile = Path.Combine(Path.Combine(projectPath, PINOCCHIO_TMP_DIR_INPUT), "skeleton.out");
            ExportToPinocchioFormat(projectPath, skeletalAnim, rootSkeletalAnim, 0);
            LaunchPinocchioBinary(modelPath, skelPathFile);

            //Import Data that pinocchio did generated
            //There is a problem here since we dont have a way to associate AssimpNodes and Bones in the attachement.out for now()
            BuildBones(scene.Meshes[0], rootSkeletalAnim);
            BuildBonesWeight(scene);
        }
开发者ID:loic-lavergne,项目名称:mckineap,代码行数:21,代码来源:Rigging.cs


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