示例#1
0
        public override MeshBase CreateMesh(GridderSource source)
        {
            PointGridderSource src           = (PointGridderSource)source;
            vec3 minvec3                     = new vec3();
            vec3 maxvec3                     = new vec3();
            bool isSet                       = false;
            PointPositionBuffer positions    = new PointPositionBuffer();
            PointRadiusBuffer   radiusBuffer = null;
            int    dimSize                   = src.DimenSize;
            Random random                    = new Random();

            // setup positions
            unsafe
            {
                positions.AllocMem(dimSize);
                var cells = (vec3 *)positions.Data;
                for (int gridIndex = 0; gridIndex < dimSize; gridIndex++)
                {
                    vec3 p = src.TranslateMatrix * src.Positions[gridIndex];
                    cells[gridIndex] = p;
                }
            }
            radiusBuffer = this.CreateRadiusBufferData(src, src.Radius);
            PointMeshGeometry3D mesh = new PointMeshGeometry3D(positions, radiusBuffer, dimSize);

            mesh.Max = src.TransformedActiveBounds.Max;
            mesh.Min = src.TransformedActiveBounds.Min;
            return(mesh);
        }
示例#2
0
        public void SetRadius(PointRadiusBuffer radius)
        {
            if (radius != null)
            {
                if (this.radiusBuffer != null)
                {
                    gl.DeleteBuffers(this.radiusBuffer.Length, this.radiusBuffer);
                }
                ////TODO:如果用此方式,则必须先将此对象加入scene树,然后再调用Init
                //OpenGL gl = this.TraverseToRootElement().ParentScene.OpenGL;
                this.radiusBuffer    = new uint[1];
                this.radiusBuffer[0] = CreateVertexBufferObject(OpenGL.GL_ARRAY_BUFFER, radius, OpenGL.GL_STATIC_DRAW);

                if (this.vertexArrayObject != null)
                {
                    gl.DeleteVertexArrays(this.vertexArrayObject.Length, this.vertexArrayObject);
                    this.vertexArrayObject = null;
                }
            }
            else
            {
                if (this.radiusBuffer != null)
                {
                    gl.DeleteBuffers(this.radiusBuffer.Length, this.radiusBuffer);
                }
            }
        }
        public override MeshBase CreateMesh(GridderSource source)
        {
            PointGridderSource  src          = (PointGridderSource)source;
            PointPositionBuffer positions    = new PointPositionBuffer();
            PointRadiusBuffer   radiusBuffer = null;
            int dimSize = src.DimenSize;

            // setup positions
            unsafe
            {
                positions.AllocMem(dimSize);
                Vertex *cells = (Vertex *)positions.Data;
                for (int gridIndex = 0; gridIndex < dimSize; gridIndex++)
                {
                    Vertex p = src.Transform * src.Positions[gridIndex];
                    cells[gridIndex] = p;
                }
            }
            radiusBuffer = this.CreateRadiusBufferData(src, src.Radius);
            PointMeshGeometry3D mesh = new PointMeshGeometry3D(positions, radiusBuffer, dimSize);

            mesh.Max = src.TransformedActiveBounds.Max;
            mesh.Min = src.TransformedActiveBounds.Min;
            return(mesh);
        }
示例#4
0
 public PointRadiusBuffer CreateRadiusBufferData(PointGridderSource src, float radius)
 {
     PointRadiusBuffer radiusBuffer = new PointRadiusBuffer();
     unsafe
     {
         int dimenSize = src.DimenSize;
         radiusBuffer.AllocMem(dimenSize);
         float* radiues = (float*)radiusBuffer.Data;
         for (int gridIndex = 0; gridIndex < dimenSize; gridIndex++)
         {
             radiues[gridIndex] = radius;
         }
     }
     return radiusBuffer;
 }
示例#5
0
        public PointRadiusBuffer CreateRadiusBufferData(PointGridderSource src, float radius)
        {
            PointRadiusBuffer radiusBuffer = new PointRadiusBuffer();

            unsafe
            {
                int dimenSize = src.DimenSize;
                radiusBuffer.AllocMem(dimenSize);
                float *radiues = (float *)radiusBuffer.Data;
                for (int gridIndex = 0; gridIndex < dimenSize; gridIndex++)
                {
                    radiues[gridIndex] = radius;
                }
            }
            return(radiusBuffer);
        }
        public override MeshBase CreateMesh(GridderSource source)
        {
            PointGridderSource src       = (PointGridderSource)source;
            Vertex             minVertex = new Vertex();
            Vertex             maxVertex = new Vertex();
            bool isSet = false;
            PointPositionBuffer positions    = new PointPositionBuffer();
            PointRadiusBuffer   radiusBuffer = null;
            int    dimSize = src.DimenSize;
            Random random  = new Random();

            // setup positions
            unsafe
            {
                positions.AllocMem(dimSize);
                Vertex *cells = (Vertex *)positions.Data;
                for (int gridIndex = 0; gridIndex < dimSize; gridIndex++)
                {
                    Vertex p = src.Positions[gridIndex];
                    cells[gridIndex] = p;
                    if (!isSet)
                    {
                        minVertex = p;
                        maxVertex = p;
                        isSet     = true;
                    }


                    if (src.IsActiveBlock(gridIndex))
                    {
                        minVertex = SimLab.SimGrid.helper.VertexHelper.MinVertex(minVertex, p);
                        maxVertex = SimLab.SimGrid.helper.VertexHelper.MaxVertex(maxVertex, p);
                    }
                }
            }
            radiusBuffer = this.CreateRadiusBufferData(src, src.Radius);
            PointMeshGeometry3D mesh = new PointMeshGeometry3D(positions, radiusBuffer, dimSize);

            mesh.Max = maxVertex;
            mesh.Min = minVertex;
            return(mesh);
        }
 /// <summary>
 ///
 /// </summary>
 /// <param name="positions"></param>
 /// <param name="count">有多少个顶点</param>
 public PointMeshGeometry3D(PointPositionBuffer positions, PointRadiusBuffer radius, int count)
     : base(positions)
 {
     this.Radius = radius;
     this.Count  = count;
 }
示例#8
0
 /// <summary>
 /// 
 /// </summary>
 /// <param name="positions"></param>
 /// <param name="count">有多少个顶点</param>
 public PointMeshGeometry3D(PointPositionBuffer positions, PointRadiusBuffer radius, int count)
     : base(positions)
 {
     this.Radius = radius;
     this.Count = count;
 }
示例#9
0
        public void SetRadius(PointRadiusBuffer radius)
        {
            if (radius != null)
            {
                if (this.radiusBuffer != null)
                {
                    gl.DeleteBuffers(this.radiusBuffer.Length, this.radiusBuffer);
                }
                ////TODO:如果用此方式,则必须先将此对象加入scene树,然后再调用Init
                //OpenGL gl = this.TraverseToRootElement().ParentScene.OpenGL;
                this.radiusBuffer = new uint[1];
                this.radiusBuffer[0] = CreateVertexBufferObject(OpenGL.GL_ARRAY_BUFFER, radius, OpenGL.GL_STATIC_DRAW);

                if (this.vertexArrayObject != null)
                {
                    gl.DeleteVertexArrays(this.vertexArrayObject.Length, this.vertexArrayObject);
                    this.vertexArrayObject = null;
                }
            }
            else
            {
                if (this.radiusBuffer != null)
                {
                    gl.DeleteBuffers(this.radiusBuffer.Length, this.radiusBuffer);
                }
            }
        }