public void Evaluate(int SpreadMax)
        {
            this.FInvalidate = false;
            if (this.FInPath.IsChanged || this.FInReload[0])
            {
                this.DisposeResources();

                this.FOutGeom.SliceCount  = this.FInPath.SliceCount;
                this.FOutValid.SliceCount = this.FInPath.SliceCount;

                for (int i = 0; i < this.FInPath.SliceCount; i++)
                {
                    try
                    {
                        AssimpScene scene = new AssimpScene(this.FInPath[i], true, false);
                        this.FOutGeom[i].SliceCount = scene.MeshCount;
                        for (int j = 0; j < this.FOutGeom[i].SliceCount; j++)
                        {
                            this.FOutGeom[i][j] = new DX11Resource <DX11IndexedGeometry>();
                        }
                        this.scenes.Add(scene);
                    }
                    catch
                    {
                        this.scenes.Add(null);
                        this.FOutGeom[i].SliceCount = 0;
                    }
                }

                this.FInvalidate = true;
            }
        }
        public void Evaluate(int SpreadMax)
        {
            if (this.FOutGeom[0] == null)
            {
                this.FOutGeom[0]    = new DX11Resource <DX11IndexOnlyGeometry>();
                this.FOutId[0]      = new DX11Resource <IDX11ReadableStructureBuffer>();
                this.FOutIndices[0] = new DX11Resource <DX11RawBuffer>();
                this.FOutUvs[0]     = new DX11Resource <IDX11ReadableStructureBuffer>();
            }

            this.FInvalidate = false;
            if (this.FInPath.IsChanged || this.FInReload[0])
            {
                this.DisposeResources();

                try
                {
                    AssimpScene scene = new AssimpScene(this.FInPath[0], true, false);
                    this.scene = scene;
                }
                catch
                {
                    this.scene = null;
                }
            }

            this.FInvalidate = true;
        }
Exemple #3
0
 /// <summary>
 ///		Konstruktor opengl sveta.
 /// </summary>
 public World(OpenGL gl)
 {
     m_textures    = new uint[m_textureCount];
     this.formula1 = new AssimpScene(Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "Formula\\Audi"), "Audi_S3.3ds", gl);
     this.formula2 = new AssimpScene(Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "Formula\\Mini"), "Car mini N300114.3DS", gl);
     Console.WriteLine(Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "Formula"));
 }
Exemple #4
0
        public World(String scenePath, String sceneFileName, int width, int height, OpenGL gl)
        {
            this.scene  = new AssimpScene(scenePath, sceneFileName, gl);
            this.width  = width;
            this.height = height;

            m_textures = new uint[m_textureCount];
        }
Exemple #5
0
 public World(String scenePath, String sceneFileName, String bulletPath, String BulletFileName, int height, int width, OpenGL gl)
 {
     this.m_scene  = new AssimpScene(scenePath, sceneFileName, gl);
     this.m_bullet = new AssimpScene(bulletPath, BulletFileName, gl);
     this.m_height = height;
     this.m_width  = width;
     m_textures    = new uint[m_textureCount];
 }
        public void Update(DX11RenderContext context)
        {
            if (this.FInvalidate || this.FEmpty)
            {
                for (int i = 0; i < this.scenes.Count; i++)
                {
                    if (scenes[i] != null)
                    {
                        AssimpScene scene = scenes[i];

                        for (int j = 0; j < scene.MeshCount; j++)
                        {
                            AssimpMesh assimpmesh = scene.Meshes[j];


                            DataStream vS = assimpmesh.Vertices;
                            vS.Position = 0;

                            List <int> inds = assimpmesh.Indices;

                            if (inds.Count > 0 && assimpmesh.VerticesCount > 0)
                            {
                                var vertices = new SlimDX.Direct3D11.Buffer(context.Device, vS, new BufferDescription()
                                {
                                    BindFlags      = BindFlags.VertexBuffer,
                                    CpuAccessFlags = CpuAccessFlags.None,
                                    OptionFlags    = ResourceOptionFlags.None,
                                    SizeInBytes    = (int)vS.Length,
                                    Usage          = ResourceUsage.Default
                                });

                                var indexstream = new DataStream(inds.Count * 4, true, true);
                                indexstream.WriteRange(inds.ToArray());
                                indexstream.Position = 0;


                                DX11IndexedGeometry geom = new DX11IndexedGeometry(context);
                                geom.VertexBuffer   = vertices;
                                geom.IndexBuffer    = new DX11IndexBuffer(context, indexstream, false, true);
                                geom.InputLayout    = assimpmesh.GetInputElements().ToArray();
                                geom.Topology       = PrimitiveTopology.TriangleList;
                                geom.VerticesCount  = assimpmesh.VerticesCount;
                                geom.VertexSize     = assimpmesh.CalculateVertexSize();
                                geom.HasBoundingBox = true;
                                geom.BoundingBox    = assimpmesh.BoundingBox;

                                this.FOutGeom[i][j][context] = geom;
                            }
                        }
                    }
                }
                this.FEmpty      = false;
                this.FInvalidate = false;
            }
        }
        public void Evaluate(int SpreadMax)
        {
            this.FInvalidate = false;
            if (this.FInPath.IsChanged || this.FInReload[0])
            {
                this.DisposeResources();

                this.FOutGeom.SliceCount          = this.FInPath.SliceCount;
                this.FOutIndices.SliceCount       = this.FInPath.SliceCount;
                this.FOutIndicesCount.SliceCount  = this.FInPath.SliceCount;
                this.FOutNormals.SliceCount       = this.FInPath.SliceCount;
                this.FOutPosition.SliceCount      = this.FInPath.SliceCount;
                this.FOutVerticesCount.SliceCount = this.FInPath.SliceCount;
                this.FOutUvs.SliceCount           = this.FInPath.SliceCount;

                for (int i = 0; i < this.FInPath.SliceCount; i++)
                {
                    try
                    {
                        AssimpScene scene = new AssimpScene(this.FInPath[i], true, false);
                        this.FOutGeom[i].SliceCount          = scene.MeshCount;
                        this.FOutPosition[i].SliceCount      = scene.MeshCount;
                        this.FOutNormals[i].SliceCount       = scene.MeshCount;
                        this.FOutIndicesCount[i].SliceCount  = scene.MeshCount;
                        this.FOutVerticesCount[i].SliceCount = scene.MeshCount;
                        this.FOutIndices[i].SliceCount       = scene.MeshCount;
                        this.FOutUvs[i].SliceCount           = scene.MeshCount;

                        for (int j = 0; j < this.FOutGeom[i].SliceCount; j++)
                        {
                            this.FOutGeom[i][j]          = new DX11Resource <DX11IndexOnlyGeometry>();
                            this.FOutPosition[i][j]      = new DX11Resource <IDX11ReadableStructureBuffer>();
                            this.FOutNormals[i][j]       = new DX11Resource <IDX11ReadableStructureBuffer>();
                            this.FOutIndicesCount[i][j]  = scene.Meshes[j].Indices.Count;
                            this.FOutVerticesCount[i][j] = scene.Meshes[j].VerticesCount;
                            this.FOutIndices[i][j]       = new DX11Resource <DX11RawBuffer>();
                            this.FOutUvs[i][j]           = new DX11Resource <IDX11ReadableStructureBuffer>();
                        }
                        this.scenes.Add(scene);
                    }
                    catch
                    {
                        this.scenes.Add(null);
                        this.FOutGeom[i].SliceCount = 0;
                    }
                }

                this.FInvalidate = true;
            }
        }
        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;
            }
        }
 private void DisposeResources()
 {
     if (scene != null)
     {
         scene.Dispose();
     }
     if (this.FOutGeom[0] != null)
     {
         this.FOutGeom[0].Dispose();
     }
     if (this.FOutPosition[0] != null)
     {
         this.FOutPosition[0].Dispose();
     }
     if (this.FOutUvs[0] != null)
     {
         this.FOutUvs[0].Dispose();
     }
     this.scene = null;
 }
        public void Evaluate(int SpreadMax)
        {
            if (this.FInPath.IsChanged || this.FInReload[0])
            {
                if (this.scene != null)
                {
                    this.scene.Dispose();
                }

                string p = this.FInPath[0];
                if (File.Exists(p))
                {
                    try
                    {
                        this.scene                 = new AssimpScene(p, this.FInPreload[0], false);
                        this.FOutValid[0]          = true;
                        this.FOutMeshCount[0]      = this.scene.MeshCount;
                        this.FOutMeshes.SliceCount = this.scene.MeshCount;

                        for (int i = 0; i < this.scene.MeshCount; i++)
                        {
                            this.FOutMeshes[i] = this.scene.Meshes[i];
                        }
                    }
                    catch (Exception ex)
                    {
                        this.FLogger.Log(ex);
                        this.FOutValid[0]          = false;
                        this.FOutMeshCount[0]      = 0;
                        this.FOutMeshes.SliceCount = 0;
                    }
                }
                else
                {
                    this.FOutValid[0]          = false;
                    this.FOutMeshCount[0]      = 0;
                    this.FOutMeshes.SliceCount = 0;
                }
                this.FOutScene[0] = this.scene;
            }
        }
Exemple #11
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;
            }
        }
Exemple #12
0
        public void Evaluate(int SpreadMax)
        {
            if (this.FInPath.IsChanged || this.FInReload[0])
            {
                if (this.scene != null)
                {
                    this.scene.Dispose();
                }

                string p = this.FInPath[0];
                if (File.Exists(p))
                {
                    try
                    {
                        this.scene            = new AssimpScene(p);
                        this.FOutValid[0]     = true;
                        this.FOutMeshCount[0] = this.scene.MeshCount;

                        this.FOutCameras.AssignFrom(this.scene.Cameras);
                        this.FOutMaterials.AssignFrom(this.scene.Materials);
                    }
                    catch
                    {
                        this.FOutValid[0]             = false;
                        this.FOutMeshCount[0]         = 0;
                        this.FOutMaterials.SliceCount = 0;
                        this.FOutCameras.SliceCount   = 0;
                    }
                }
                else
                {
                    this.FOutValid[0]             = false;
                    this.FOutMeshCount[0]         = 0;
                    this.FOutMaterials.SliceCount = 0;
                    this.FOutCameras.SliceCount   = 0;
                }
                this.FOutScene[0] = this.scene;
            }
        }
        public void Evaluate(int SpreadMax)
        {
            if (this.FInPath.IsChanged || this.FInReload[0])
            {
                if (this.scene != null) { this.scene.Dispose(); }

                string p = this.FInPath[0];
                if (File.Exists(p))
                {
                    try
                    {
                        this.scene = new AssimpScene(p, this.FInPreload[0], false);
                        this.FOutValid[0] = true;
                        this.FOutMeshCount[0] = this.scene.MeshCount;
                        this.FOutMeshes.SliceCount = this.scene.MeshCount;

                        for (int i = 0; i < this.scene.MeshCount; i++)
                        {
                            this.FOutMeshes[i] = this.scene.Meshes[i];
                        }
                    }
                    catch (Exception ex)
                    {
                        this.FLogger.Log(ex);
                        this.FOutValid[0] = false;
                        this.FOutMeshCount[0] = 0;
                        this.FOutMeshes.SliceCount = 0;
                    }
                }
                else
                {
                    this.FOutValid[0] = false;
                    this.FOutMeshCount[0] = 0;
                    this.FOutMeshes.SliceCount = 0;
                }
                this.FOutScene[0] = this.scene;
            }
        }
Exemple #14
0
        private void RebuildTreeview(AssimpScene scene)
        {
            this.tv.Nodes.Clear();

            TreeNode meshes = new TreeNode("Meshes");

            this.tv.Nodes.Add(meshes);

            for (int i = 0; i < scene.MeshCount; i++)
            {
                var      mesh = scene.Meshes[i];
                TreeNode node = new TreeNode("Mesh " + i.ToString() + " (" + mesh.Indices.Count + ")");
                if (mesh.Indices.Count == 0)
                {
                    node.BackColor = Color.Red;
                }
                else if (mesh.UvChannelCount == 0 || !mesh.HasNormals)
                {
                    node.BackColor = Color.Yellow;
                    StringBuilder tooltip = new StringBuilder();
                    if (mesh.UvChannelCount == 0)
                    {
                        tooltip.AppendLine("No UV channel");
                    }
                    if (!mesh.HasNormals)
                    {
                        tooltip.AppendLine("No Normals detected");
                    }
                    node.ToolTipText = tooltip.ToString();
                }
                meshes.Nodes.Add(node);
            }

            var root = new AssimpTreeNode(scene.RootNode);

            this.tv.Nodes.Add(root);
            this.AddNode(scene.RootNode, root);
        }
        public void Evaluate(int SpreadMax)
        {
            this.FInvalidate = false;
            if (this.FInPath.IsChanged || this.FInReload[0])
            {
                this.DisposeResources();

                this.FOutGeom.SliceCount = this.FInPath.SliceCount;
                this.FOutValid.SliceCount = this.FInPath.SliceCount;

                for (int i = 0; i < this.FInPath.SliceCount; i++)
                {
                    try
                    {
                        AssimpScene scene = new AssimpScene(this.FInPath[i],true, false);
                        this.FOutGeom[i].SliceCount = scene.MeshCount;
                        for (int j = 0; j < this.FOutGeom[i].SliceCount;j++ )
                        {
                            this.FOutGeom[i][j] = new DX11Resource<DX11IndexedGeometry>();
                        }
                        this.scenes.Add(scene);
                    }
                    catch
                    {
                        this.scenes.Add(null);
                        this.FOutGeom[i].SliceCount = 0;
                    }
                }

                this.FInvalidate = true;
            }
        }
        public void Update(IPluginIO pin, DX11RenderContext context)
        {
            if (this.FInvalidate || this.FEmpty)
            {
                for (int i = 0; i < this.scenes.Count; i++)
                {
                    if (scenes[i] != null)
                    {
                        AssimpScene scene = scenes[i];

                        for (int j = 0; j < scene.MeshCount; j++)
                        {
                            AssimpMesh assimpmesh = scene.Meshes[j];

                            List <int> inds = assimpmesh.Indices;

                            if (inds.Count > 0 && assimpmesh.VerticesCount > 0)
                            {
                                var indexstream = new DataStream(inds.Count * 4, true, true);
                                indexstream.WriteRange(inds.ToArray());
                                indexstream.Position = 0;


                                DX11IndexOnlyGeometry geom = new DX11IndexOnlyGeometry(context);
                                geom.IndexBuffer    = new DX11IndexBuffer(context, indexstream, false, true);
                                geom.InputLayout    = assimpmesh.GetInputElements().ToArray();
                                geom.Topology       = PrimitiveTopology.TriangleList;
                                geom.HasBoundingBox = true;
                                geom.BoundingBox    = assimpmesh.BoundingBox;


                                DX11DynamicStructuredBuffer <Vector3> p =
                                    new DX11DynamicStructuredBuffer <Vector3>(context, assimpmesh.PositionPointer, assimpmesh.VerticesCount);

                                DX11DynamicStructuredBuffer <Vector3> n =
                                    new DX11DynamicStructuredBuffer <Vector3>(context, assimpmesh.NormalsPointer, assimpmesh.VerticesCount);

                                if (assimpmesh.UvChannelCount > 0)
                                {
                                    DX11DynamicStructuredBuffer <Vector3> u =
                                        new DX11DynamicStructuredBuffer <Vector3>(context, assimpmesh.GetUvPointer(0), assimpmesh.VerticesCount);


                                    this.FOutUvs[i][j][context] = u;
                                }



                                DX11RawBuffer rb = new DX11RawBuffer(context, geom.IndexBuffer.Buffer);

                                this.FOutPosition[i][j][context] = p;
                                this.FOutNormals[i][j][context]  = n;
                                this.FOutGeom[i][j][context]     = geom;
                                this.FOutIndices[i][j][context]  = rb;
                            }
                        }
                    }
                }
                this.FInvalidate = false;
                this.FEmpty      = false;
            }
        }
        private void RebuildTreeview(AssimpScene scene)
        {
            this.tv.Nodes.Clear();

            TreeNode meshes = new TreeNode("Meshes");
            this.tv.Nodes.Add(meshes);

            for (int i = 0 ;i < scene.MeshCount; i++)
            {
                var mesh = scene.Meshes[i];
                TreeNode node = new TreeNode("Mesh " + i.ToString() + " (" + mesh.Indices.Count + ")");
                if (mesh.Indices.Count == 0)
                {
                    node.BackColor = Color.Red;
                }
                else if (mesh.UvChannelCount == 0 || !mesh.HasNormals)
                {
                    node.BackColor = Color.Yellow;
                    StringBuilder tooltip = new StringBuilder();
                    if (mesh.UvChannelCount == 0)
                    {
                        tooltip.AppendLine("No UV channel");
                    }
                    if(!mesh.HasNormals)
                    {
                        tooltip.AppendLine("No Normals detected");
                    }
                    node.ToolTipText = tooltip.ToString();
                }
                meshes.Nodes.Add(node);
            }

            var root = new AssimpTreeNode(scene.RootNode);
            this.tv.Nodes.Add(root);
            this.AddNode(scene.RootNode, root);
        }
Exemple #18
0
        public World(String scenePath, String sceneFileName, int width_, int height_)
        {
            this.scene = new AssimpScene(scenePath, sceneFileName);
            this.width = width_;
            this.height = height_;

            try
            {
                this.runway = new Box();
            }
            catch (Exception e)
            {
                MessageBox.Show("Neuspesno kreirana instanca OpenGL Box: " + e.Message, "GRESKA", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }

            try
            {
                bmpFont = new BitmapFont("Tahoma", 14, false, true, true, false);
            }
            catch (Exception e)
            {
                MessageBox.Show("Neuspesno kreirana instanca OpenGL fonta: " + e.Message, "GRESKA", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            try
            {
                textures = new int[textureCount];
            }
            catch (Exception)
            {
                MessageBox.Show("Neuspesno kreiran niz identifikatora za teksture", "GRESKA", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }

            this.Initialize();
            this.Resize();
        }
 private void DisposeResources()
 {
     if (scene != null) { scene.Dispose(); }
     if (this.FOutGeom[0] != null) { this.FOutGeom[0].Dispose(); }
     if (this.FOutPosition[0] != null) { this.FOutPosition[0].Dispose(); }
     if (this.FOutUvs[0] != null) { this.FOutUvs[0].Dispose(); }
     this.scene = null;
 }
        public void Evaluate(int SpreadMax)
        {
            if (this.FOutGeom[0] == null)
            {
                this.FOutGeom[0] = new DX11Resource<DX11IndexOnlyGeometry>();
                this.FOutId[0] = new DX11Resource<IDX11ReadableStructureBuffer>();
                this.FOutIndices[0] = new DX11Resource<DX11RawBuffer>();
                this.FOutUvs[0] = new DX11Resource<IDX11ReadableStructureBuffer>();
            }

            this.FInvalidate = false;
            if (this.FInPath.IsChanged || this.FInReload[0])
            {
                this.DisposeResources();

                try
                {
                    AssimpScene scene = new AssimpScene(this.FInPath[0], true, false);
                    this.scene = scene;
                }
                catch
                {
                    this.scene = null;
                }
            }

            this.FInvalidate = true;
        }
        public void Evaluate(int SpreadMax)
        {
            this.FInvalidate = false;
            if (this.FInPath.IsChanged || this.FInReload[0])
            {
                this.DisposeResources();

                this.FOutGeom.SliceCount = this.FInPath.SliceCount;
                this.FOutIndices.SliceCount = this.FInPath.SliceCount;
                this.FOutIndicesCount.SliceCount = this.FInPath.SliceCount;
                this.FOutNormals.SliceCount = this.FInPath.SliceCount;
                this.FOutPosition.SliceCount = this.FInPath.SliceCount;
                this.FOutVerticesCount.SliceCount = this.FInPath.SliceCount;
                this.FOutUvs.SliceCount = this.FInPath.SliceCount;

                for (int i = 0; i < this.FInPath.SliceCount; i++)
                {
                    try
                    {
                        AssimpScene scene = new AssimpScene(this.FInPath[i],true, false);
                        this.FOutGeom[i].SliceCount = scene.MeshCount;
                        this.FOutPosition[i].SliceCount = scene.MeshCount;
                        this.FOutNormals[i].SliceCount = scene.MeshCount;
                        this.FOutIndicesCount[i].SliceCount = scene.MeshCount;
                        this.FOutVerticesCount[i].SliceCount = scene.MeshCount;
                        this.FOutIndices[i].SliceCount = scene.MeshCount;
                        this.FOutUvs[i].SliceCount = scene.MeshCount;

                        for (int j = 0; j < this.FOutGeom[i].SliceCount;j++ )
                        {
                            this.FOutGeom[i][j] = new DX11Resource<DX11IndexOnlyGeometry>();
                            this.FOutPosition[i][j] = new DX11Resource<IDX11ReadableStructureBuffer>();
                            this.FOutNormals[i][j] = new DX11Resource<IDX11ReadableStructureBuffer>();
                            this.FOutIndicesCount[i][j] = scene.Meshes[j].Indices.Count;
                            this.FOutVerticesCount[i][j] = scene.Meshes[j].VerticesCount;
                            this.FOutIndices[i][j] = new DX11Resource<DX11RawBuffer>();
                            this.FOutUvs[i][j] = new DX11Resource<IDX11ReadableStructureBuffer>();
                        }
                        this.scenes.Add(scene);
                    }
                    catch
                    {
                        this.scenes.Add(null);
                        this.FOutGeom[i].SliceCount = 0;
                    }
                }

                this.FInvalidate = true;
            }
        }