• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C# Assimp.Node类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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


示例16: Populate

        /// <summary>
        /// Sets the contents of the info pop-up given an assimp node.
        /// 
        /// At the time this method is called, the node info popup's
        /// location has already been adjusted by the caller.
        /// </summary>
        public void Populate(Assimp.Scene scene, Node node, NodePurpose purpose)
        {
            Debug.Assert(scene != null);
            Debug.Assert(node != null);
            Debug.Assert(_owner != null);
            switch (purpose)
            {
                case NodePurpose.Joint:
                    labelCaption.Text = "Joint";
                    break;
                case NodePurpose.ImporterGenerated:
                    labelCaption.Text = "Root";
                    break;
                case NodePurpose.GenericMeshHolder:
                    labelCaption.Text = "Node";
                    break;
                case NodePurpose.Camera:
                    labelCaption.Text = "Camera";
                    break;
                case NodePurpose.Light:
                    labelCaption.Text = "Light";
                    break;
                default:
                    Debug.Assert(false);
                    break;
            }

            // count children recursively
            var children = 0;
            CountChildren(node, ref children);

            var animated = false;

            // check whether there are any animation channels for this node
            for (var i = 0; i < scene.AnimationCount && !animated; ++i )
            {
                var anim = scene.Animations[i];
                for(var j = 0; j < anim.NodeAnimationChannelCount; ++j)
                {
                    if(anim.NodeAnimationChannels[j].NodeName == node.Name)
                    {
                        animated = true;
                        break;
                    }
                }
            }

            labelInfo.Text = string.Format("{0} Children\n{1}", children, (animated ? "Animated" : "Not animated"));
        }
开发者ID:Kolky,项目名称:open3mod,代码行数:55,代码来源:NodeInfoPopup.cs


示例17: DrawNormals

        public static void DrawNormals(Node node, int meshIndex, Mesh mesh, CpuSkinningEvaluator skinner, float invGlobalScale)
        {
            if (!mesh.HasNormals)
            {
                return;
            }
            // 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, meshIndex, i, out v);
                }
                else
                {
                    v = AssimpToOpenTk.FromVector(mesh.Vertices[(int)i]);
                }

                Vector3 n;
                if (skinner != null)
                {
                    skinner.GetTransformedVertexNormal(node, meshIndex, i, out n);
                }
                else
                {
                    n = AssimpToOpenTk.FromVector(mesh.Normals[(int)i]);
                }

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

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


示例18: LookForMatch

 static Node LookForMatch(Node root, string name)
 {
     string namelow = name.ToLower();
     if (root.Name.ToLower() == namelow)
     {
         return root;
     }
     for (int i = 0; i < root.ChildCount; i++)
     {
         Node found = LookForMatch(root.Children[i], name);
         if (found != null)
         {
             return found;
         }
     }
     return null;
 }
开发者ID:Morphan1,项目名称:Voxalia,代码行数:17,代码来源:Program.cs


示例19: GetTransformedVertexPosition

            public void GetTransformedVertexPosition(Node node, uint vertexIndex, out Vector3 pos)
            {
                // note: the scenario in which a skinned mesh is referenced by multiple nodes
                // is not currently implemented properly. It works, but it prevents caching.
                if (node != _lastNode)
                {
                    _lastNode = node;
                    _dirty = true;
                }
                if(_dirty)
                {
                   Cache();        
                }
                Debug.Assert(!_dirty);

                Debug.Assert(vertexIndex < _cachedPositions.Length);
                pos = _cachedPositions[vertexIndex];
            }
开发者ID:Kolky,项目名称:open3mod,代码行数:18,代码来源:CpuSkinningEvaluator.cs


示例20: Node

        /// <summary>
        /// Constructs a new Node.
        /// </summary>
        /// <param name="aiNode">Unmanaged AiNode structure</param>
        /// <param name="parent">Parent of this node or null</param>
        internal Node(AiNode aiNode, Node parent)
        {
            _name = aiNode.Name.GetString();
            _transform = aiNode.Transformation;
            _parent = parent;

            if(aiNode.NumChildren > 0 && aiNode.Children != IntPtr.Zero) {
                AiNode[] childNodes = MemoryHelper.MarshalArray<AiNode>(aiNode.Children, (int) aiNode.NumChildren, true);
                _children = new Node[childNodes.Length];
                for(int i = 0; i < _children.Length; i++) {
                    _children[i] = new Node(childNodes[i], this);
                }
            }

            if(aiNode.NumMeshes > 0 && aiNode.Meshes != IntPtr.Zero) {
                _meshes = MemoryHelper.MarshalArray<int>(aiNode.Meshes, (int) aiNode.NumMeshes);
            }
        }
开发者ID:dkushner,项目名称:Assimp-Net,代码行数:23,代码来源:Node.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# Assistant.PacketHandlerEventArgs类代码示例发布时间:2022-05-24
下一篇:
C# Core.StoreSettingConfig类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap