private void RecurseNodes(List <Tuple <AssimpNode, AssimpNode> > nodes, AssimpNode parent, AssimpNode current)
 {
     nodes.Add(new Tuple <AssimpNode, AssimpNode>(parent, current));
     foreach (AssimpNode child in current.Children)
     {
         RecurseNodes(nodes, current, child);
     }
 }
 private void RecurseNodes(List <AssimpNode> nodes, AssimpNode current)
 {
     nodes.Add(current);
     foreach (AssimpNode child in current.Children)
     {
         RecurseNodes(nodes, child);
     }
 }
 private void RecurseNodes(List<Tuple<AssimpNode, AssimpNode>> nodes,AssimpNode parent, AssimpNode current)
 {
     nodes.Add(new Tuple<AssimpNode, AssimpNode>(parent, current));
     foreach (AssimpNode child in current.Children)
     {
         RecurseNodes(nodes,current, child);
     }
 }
Beispiel #4
0
 private void AddNode(AssimpNode an, TreeNode tn)
 {
     for (int i = 0; i < an.Children.Count; i++)
     {
         var node = new AssimpTreeNode(an.Children[i]);
         this.AddNode(an.Children[i], node);
         tn.Nodes.Add(node);
     }
 }
Beispiel #5
0
 private void RecurseNodes(List <AssimpNode> nodes, AssimpNode current, bool addcurrent = true)
 {
     if (addcurrent)
     {
         nodes.Add(current);
     }
     foreach (AssimpNode child in current.Children)
     {
         RecurseNodes(nodes, child);
     }
 }
        private void AppendNode(AssimpNode node)
        {
            foreach (AssimpNode child in node.Children)
            {
                this.AppendNode(child);
            }

            /*if (node.MeshCount > 0)
             * {
             *  for (int i = 0; i < node.MeshCount;i++)
             *  {
             *      this.AppendMesh(node, this.scene.Meshes[node.MeshIndices[i]);
             *  }
             * }*/
        }
Beispiel #7
0
        void tv_AfterSelect(object sender, TreeViewEventArgs e)
        {
            if (this.scene == null)
            {
                return;
            }

            if (tv.SelectedNode is AssimpTreeNode)
            {
                this.SelectedNode = ((AssimpTreeNode)tv.SelectedNode).AssimpNode;
            }
            else
            {
                this.SelectedNode = this.scene.RootNode;
            }
        }
        private void RecurseNodes(AssimpNode node, int meshidx)
        {
            for (int i = 0; i < node.MeshCount; i++)
            {
                if (meshidx == node.MeshIndices[i])
                {
                    found = node;
                    return;
                }
            }

            for (int i = 0; i < node.Children.Count; i++)
            {
                RecurseNodes(node.Children[i], meshidx);
            }
        }
        private void RecurseNodesByName(AssimpNode node, string name)
        {
            for (int i = 0; i < node.MeshCount; i++)
            {
                if (name == node.Name)
                {
                    found = node;
                    return;
                }
            }

            for (int i = 0; i < node.Children.Count; i++)
            {
                RecurseNodesByName(node.Children[i], name);
            }
        }
Beispiel #10
0
        private void TraverseNode(AssimpNode node, List <Matrix> transforms, List <int> meshes)
        {
            for (int i = 0; i < node.MeshCount; i++)
            {
                var am = this.scene.Meshes[node.MeshIndices[i]];

                //Ignore invalid meshes
                if (am.Indices.Count > 0 || am.VerticesCount > 0)
                {
                    transforms.Add(node.RelativeTransform);
                    meshes.Add(node.MeshIndices[i]);
                }
            }

            for (int i = 0; i < node.Children.Count; i++)
            {
                this.TraverseNode(node.Children[i], transforms, meshes);
            }
        }
        private void AppendMesh(AssimpNode node, AssimpMesh mesh)
        {
            List <int> inds = mesh.Indices;

            if (inds.Count > 0 && mesh.VerticesCount > 0)
            {
                for (int idx = 0; idx < inds.Count; idx++)
                {
                    inds[idx] += vertexoffset;
                }

                indexbuffer.AddRange(inds);

                //vp.AddRange(mesh.v)

                vertexoffset += mesh.VerticesCount;
                this.currentid++;
            }
        }
        private void CreateSkeleton(ref Skeleton skeleton, AssimpNode node, string parent, ref int id)
        {
            IJoint joint = new AssimpBoneWrapper(node);

            joint.Id = id;
            id++;
            if (skeleton.Root == null)
            {
                skeleton.InsertJoint("", joint);
            }
            else
            {
                skeleton.InsertJoint(parent, joint);
            }

            foreach (AssimpNode child in node.Children)
            {
                CreateSkeleton(ref skeleton, child, node.Name, ref id);
            }
        }
Beispiel #13
0
        public void Evaluate(int SpreadMax)
        {
            if (this.FInScene.SliceCount == 0)
            {
                this.tv.Nodes.Clear();
                this.scene = null;
                this.FOutMeshId.SliceCount         = 0;
                this.FOutWorldTransform.SliceCount = 0;
                return;
            }

            if (this.FInScene.IsChanged)
            {
                this.scene = this.FInScene[0];

                if (this.scene != null)
                {
                    this.RebuildTreeview(this.FInScene[0]);
                    this.invalidate   = true;
                    this.selectednode = this.scene.RootNode;
                }
            }

            if (this.invalidate && this.scene != null)
            {
                List <Matrix> transforms = new List <Matrix>();
                List <int>    meshes     = new List <int>();

                this.TraverseNode(this.SelectedNode, transforms, meshes);

                this.FOutWorldTransform.SliceCount = transforms.Count;
                this.FOutMeshId.SliceCount         = meshes.Count;
                for (int i = 0; i < meshes.Count; i++)
                {
                    this.FOutWorldTransform[i] = transforms[i];
                    this.FOutMeshId[i]         = meshes[i];
                }

                this.invalidate = false;
            }
        }
        public void Evaluate(int SpreadMax)
        {
            if (this.FInScene.PluginIO.IsConnected)
            {
                this.FSkeletonOutput.SliceCount = 1;

                if (this.FInScene.IsChanged || this.FInRoot.IsChanged)
                {
                    FSkeleton.ClearAll();

                    List <AssimpNode> allnodes = new List <AssimpNode>();
                    this.RecurseNodes(allnodes, this.FInScene[0].RootNode);

                    AssimpNode found = null;
                    foreach (AssimpNode node in allnodes)
                    {
                        if (node.Name == this.FInRoot[0])
                        {
                            found = node;
                        }
                    }

                    if (found != null)
                    {
                        int id = 0;
                        CreateSkeleton(ref FSkeleton, found, "", ref id);
                    }

                    FSkeletonOutput.SetInterface(FSkeleton);
                    FSkeletonOutput.MarkPinAsChanged();
                }
            }
            else
            {
                this.FSkeletonOutput.SliceCount = 0;
            }
        }
 public AssimpBoneWrapper(AssimpNode node)
     : this(-1, node.Name)
 {
     FBaseTransform = node.LocalTransform.ToMatrix4x4();// bone.GetTransformMatrix(0).ToMatrix4x4();
 }
Beispiel #16
0
 public AssimpBoneWrapper(AssimpNode node)
     : this(-1, node.Name)
 {
     FBaseTransform = node.LocalTransform.ToMatrix4x4();// bone.GetTransformMatrix(0).ToMatrix4x4();
 }
        private void AppendNode(AssimpNode node)
        {
            foreach (AssimpNode child in node.Children)
            {
                this.AppendNode(child);
            }

            /*if (node.MeshCount > 0)
            {
                for (int i = 0; i < node.MeshCount;i++)
                {
                    this.AppendMesh(node, this.scene.Meshes[node.MeshIndices[i]);
                }
            }*/
        }
        private void AppendMesh(AssimpNode node, AssimpMesh mesh)
        {
            List<int> inds = mesh.Indices;

            if (inds.Count > 0 && mesh.VerticesCount > 0)
            {
                for (int idx = 0; idx < inds.Count; idx++)
                {
                    inds[idx] += vertexoffset;
                }

                indexbuffer.AddRange(inds);

                //vp.AddRange(mesh.v)

                vertexoffset += mesh.VerticesCount;
                this.currentid++;
            }
        }
 private void AddNode(AssimpNode an, TreeNode tn)
 {
     for (int i = 0; i < an.Children.Count; i++)
     {
         var node = new AssimpTreeNode(an.Children[i]);
         this.AddNode(an.Children[i], node);
         tn.Nodes.Add(node);
     }
 }
Beispiel #20
0
 private void RecurseNodes(List<AssimpNode> nodes, AssimpNode current, bool addcurrent = true)
 {
     if (addcurrent)
     {
         nodes.Add(current);
     }
     foreach (AssimpNode child in current.Children)
     {
         RecurseNodes(nodes, child);
     }
 }
        void tv_AfterSelect(object sender, TreeViewEventArgs e)
        {
            if (this.scene == null)
            {
                return;
            }

            if (tv.SelectedNode is AssimpTreeNode)
            {
                this.SelectedNode = ((AssimpTreeNode)tv.SelectedNode).AssimpNode;
            }
            else
            {
                this.SelectedNode = this.scene.RootNode;
            }
        }
Beispiel #22
0
 public AssimpTreeNode(AssimpNode node)
 {
     this.node = node;
     this.Text = this.ToString();
 }
 public AssimpTreeNode(AssimpNode node)
 {
     this.node = node;
     this.Text = this.ToString();
 }
        public void Evaluate(int SpreadMax)
        {
            if (this.FInScene.SliceCount == 0)
            {
                this.tv.Nodes.Clear();
                this.scene = null;
                this.FOutMeshId.SliceCount = 0;
                this.FOutWorldTransform.SliceCount = 0;
                return;
            }

            if (this.FInScene.IsChanged)
            {
                this.scene = this.FInScene[0];

                if (this.scene != null)
                {
                    this.RebuildTreeview(this.FInScene[0]);
                    this.invalidate = true;
                    this.selectednode = this.scene.RootNode;
                }

            }

            if (this.invalidate && this.scene != null)
            {
                List<Matrix> transforms = new List<Matrix>();
                List<int> meshes = new List<int>();

                this.TraverseNode(this.SelectedNode, transforms, meshes);

                this.FOutWorldTransform.SliceCount = transforms.Count;
                this.FOutMeshId.SliceCount = meshes.Count;
                for (int i = 0; i < meshes.Count;i++)
                {
                    this.FOutWorldTransform[i] = transforms[i];
                    this.FOutMeshId[i] = meshes[i];
                }

                    this.invalidate = false;
            }
        }
        public void Evaluate(int SpreadMax)
        {
            this.FInvalidate = false;
            if (this.FInScene.IsChanged || this.FReload[0])
            {
                //Destroy old mesh
                if (this.FOutGeom[0] != null)
                {
                    this.FOutGeom[0].Dispose();
                    this.FOutBuffer[0].Dispose();
                    this.FOutUVBuffer[0].Dispose();
                }

                if (this.FInScene[0] != null)
                {
                    if (this.FOutGeom[0] == null)
                    {
                        this.FOutGeom[0] = new DX11Resource<DX11IndexedGeometry>();
                        this.FOutBuffer[0] = new DX11Resource<DX11ImmutableStructuredBuffer>();
                        this.FOutIndices[0] = new DX11Resource<DX11RawBuffer>();
                        this.FOutUVBuffer[0] = new DX11Resource<DX11ImmutableStructuredBuffer>();
                    }

                    if (this.FinUseName[0])
                    {

                        idsort.Clear();
                        this.FOutGeom.SliceCount = 1;
                        this.FOutTransforms.SliceCount = this.FInNodeName.SliceCount;

                        for (int i = 0; i < this.FInNodeName.SliceCount; i++)
                        {
                            found = null;
                            RecurseNodesByName(this.FInScene[0].RootNode, this.FInNodeName[i]);

                            if (found == null)
                            {
                                this.FOutTransforms[i] = Matrix.Identity;
                            }
                            else
                            {
                                this.FOutTransforms[i] = found.RelativeTransform;
                            }
                            idsort.Add(found.MeshIndices[0]);
                        }

                    }
                    else
                    {
                        int meshcnt = this.FInScene[0].MeshCount;

                        this.FOutGeom.SliceCount = 1;
                        this.FOutTransforms.SliceCount = meshcnt;

                        for (int i = 0; i < meshcnt; i++)
                        {
                            found = null;
                            RecurseNodes(this.FInScene[0].RootNode, i);

                            if (found == null)
                            {
                                this.FOutTransforms[i] = Matrix.Identity;
                            }
                            else
                            {
                                this.FOutTransforms[i] = found.RelativeTransform;
                            }
                        }

                    }

                    this.FOutUVChannelCount[0] = this.FInScene[0].Meshes[0].UvChannelCount;
                }
                else
                {
                    this.FOutTransforms.SliceCount = 0;
                    this.FOutGeom.SliceCount = 0;
                }
                this.FInvalidate = true;
            }
        }
Beispiel #26
0
        private void CreateSkeleton(ref Skeleton skeleton, AssimpNode node,string parent, ref int id)
        {
            IJoint joint = new AssimpBoneWrapper(node);
            joint.Id = id;
            id++;
            if (skeleton.Root == null)
                skeleton.InsertJoint("", joint);
            else
                skeleton.InsertJoint(parent, joint);

            foreach (AssimpNode child in node.Children)
            {
                CreateSkeleton(ref skeleton,child, node.Name, ref id);
            }
        }
        private void RecurseNodesByName(AssimpNode node, string name)
        {
            for (int i = 0; i < node.MeshCount; i++)
            {
                if (name == node.Name)
                {
                    found = node;
                    return;
                }
            }

            for (int i = 0; i < node.Children.Count; i++)
            {
                RecurseNodesByName(node.Children[i], name);
            }
        }
        private void RecurseNodes(AssimpNode node,int meshidx)
        {
            for (int i = 0;i < node.MeshCount; i++)
            {
                if (meshidx == node.MeshIndices[i])
                {
                    found = node;
                    return;
                }
            }

            for (int i = 0; i < node.Children.Count;i++)
            {
                RecurseNodes(node.Children[i], meshidx);
            }
        }
        private void TraverseNode(AssimpNode node, List<Matrix> transforms, List<int> meshes)
        {
            for (int i = 0;i < node.MeshCount;i++)
             {
                 var am = this.scene.Meshes[node.MeshIndices[i]];

                 //Ignore invalid meshes
                 if (am.Indices.Count > 0 || am.VerticesCount > 0)
                 {
                     transforms.Add(node.RelativeTransform);
                     meshes.Add(node.MeshIndices[i]);
                 }
             }

            for (int i = 0; i < node.Children.Count; i++)
            {

                this.TraverseNode(node.Children[i], transforms, meshes);
            }
        }
Beispiel #30
0
 private void RecurseNodes(List<AssimpNode> nodes, AssimpNode current)
 {
     nodes.Add(current);
     foreach (AssimpNode child in current.Children)
     {
         RecurseNodes(nodes, child);
     }
 }
Beispiel #31
0
        public void Evaluate(int SpreadMax)
        {
            if (this.FInScene.IsChanged || this.FInRootNode.IsChanged || this.FInRecurse.IsChanged)
            {
                if (this.FInScene[0] != null)
                {
                    List <AssimpNode> allnodes = new List <AssimpNode>();
                    //string[] str = this.FInRootNode[0].Split("/".ToCharArray());

                    this.RecurseNodes(allnodes, this.FInScene[0].RootNode);

                    List <AssimpNode> filterednodes = new List <AssimpNode>();

                    for (int i = 0; i < Math.Max(this.FInRootNode.SliceCount, this.FInRecurse.SliceCount); i++)
                    {
                        if (this.FInRootNode[i] != "")
                        {
                            AssimpNode found = null;
                            foreach (AssimpNode node in allnodes)
                            {
                                if (node.Name == this.FInRootNode[i])
                                {
                                    found = node;
                                }
                            }

                            if (found != null)
                            {
                                if (this.FInRecurse[i])
                                {
                                    this.RecurseNodes(filterednodes, found);
                                }
                                else
                                {
                                    filterednodes.Add(found);
                                }
                            }
                        }
                        else
                        {
                            if (this.FInRecurse[i])
                            {
                                filterednodes.AddRange(allnodes);
                            }
                            else
                            {
                                filterednodes.Add(this.FInScene[0].RootNode);
                            }
                        }
                    }


                    this.FOutMeshId.SliceCount         = filterednodes.Count;
                    this.FOutWorldTransform.SliceCount = filterednodes.Count;
                    this.FOutLocalTransform.SliceCount = filterednodes.Count;
                    this.FOutName.SliceCount           = filterednodes.Count;

                    for (int i = 0; i < filterednodes.Count; i++)
                    {
                        this.FOutWorldTransform[i]    = filterednodes[i].RelativeTransform;
                        this.FOutLocalTransform[i]    = filterednodes[i].LocalTransform;
                        this.FOutName[i]              = filterednodes[i].Name;
                        this.FOutMeshId[i].SliceCount = filterednodes[i].MeshCount;
                        this.FOutMeshId[i].AssignFrom(filterednodes[i].MeshIndices);
                    }
                }
                else
                {
                    this.FOutMeshId.SliceCount         = 0;
                    this.FOutLocalTransform.SliceCount = 0;
                    this.FOutWorldTransform.SliceCount = 0;
                    this.FOutName.SliceCount           = 0;
                }
            }
        }