Inheritance: NativeElement
示例#1
0
        public ATMOSkySceneNode(Texture tex, SceneNode parent, SceneManager mgr, int faces, int id)
            : base(parent, mgr, id)
        {
            smgr = mgr;
            AutomaticCulling = CullingType.Off;
            material = new Material();
            material.Lighting = false;
            material.ZBuffer = 0;
            material.Texture1 = tex;

            face = faces;
            vertices = new Vertex3D[face + 1];
            indices = new ushort[face * 3];

            double angle = 0.0f;
            double angle2 = 360.0f / face;
            vert = 0;                          //vertice nr
            int nr = -3;                     //indices nr

            vertices[0] = new Vertex3D(Vector3D.From(0.0f, 100.0f, 0.0f),
                                       Vector3D.From(0.0568988f, 0.688538f, -0.722965f),
                                       Color.White,
                                       Vector2D.From(0.0f, 0.1f)
                                      );

            double x, z;

            for (ushort n = 1; n < face + 1; n++)
            {
                vert++;
                nr += 3;
                x = Math.Cos(angle * 0.017453292519943295769236907684886f) * 100;
                z = Math.Sin(angle * 0.017453292519943295769236907684886f) * 100;

                vertices[vert] = new Vertex3D(Vector3D.From((float)x, -5.0f, (float)z),
                                       Vector3D.From(0.0568988f, 0.688538f, -0.722965f),
                                       Color.White,
                                       Vector2D.From(0.0f, 0.9f)
                                      );

                angle = angle + angle2;
                indices[nr] = 0;
                indices[nr + 1] = (ushort)vert;
                indices[nr + 2] = (ushort)(vert + 1);
            }
            indices[nr + 2] = 1;
        }
        public LensflareSceneNode(SceneNode parent, SceneManager mgr, int id, Vector3D position)
            : base(parent, mgr, id)
        {
            draw_flare = true;
            ign_geom = false;
            smgr = mgr;

            indices = new ushort[6];
            indices[0] = 0;
            indices[1] = 2;
            indices[2] = 1;
            indices[3] = 0;
            indices[4] = 3;
            indices[5] = 2;

            vertices = new Vertex3D[4];
            for (int i = 0; i < 4; i++)
            {
                vertices[i] = new Vertex3D();
            }
            vertices[0].TCoords = Vector2D.From(0.0f, 1.0f);
            vertices[0].Color = Color.White;
            vertices[1].TCoords = Vector2D.From(0.0f, 0.0f);
            vertices[1].Color = Color.White;
            vertices[2].TCoords = Vector2D.From(1.0f, 0.0f);
            vertices[2].Color = Color.White;
            vertices[3].TCoords = Vector2D.From(1.0f, 1.0f);
            vertices[3].Color = Color.White;

            material = new Material();

            material.Lighting = false;

            material.MaterialType = MaterialType.TransparentAddColor;

            material.ZBuffer = 0;

            material.ZWriteEnable = false;

            bbox = new Box3D();

            bbox.MinEdge = Vector3D.From(-2, -2, -2);

            bbox.MaxEdge = Vector3D.From(2, 2, 2);

        }
示例#3
0
        public CustomSceneNode(SceneNode parent, SceneManager mgr, int id)
            : base(parent, mgr, id)
        {
            _mgr = mgr;
            _driver = _mgr.VideoDriver;
            Material.Wireframe = false;
            Material.Lighting = false;

            Vertices[0] = new Vertex3D(new Vector3D(0, 0, 10), new Vector3D(1, 1, 0), Color.From(255, 0, 255, 255), new Vector2D(0, 1));
            Vertices[1] = new Vertex3D(new Vector3D(10, 0, -10), new Vector3D(1, 0, 0), Color.From(255, 255, 0, 255), new Vector2D(1, 1));
            Vertices[2] = new Vertex3D(new Vector3D(0, 20, 0), new Vector3D(0, 1, 1), Color.From(255, 255, 255, 0), new Vector2D(1, 0));
            Vertices[3] = new Vertex3D(new Vector3D(-10, 0, -10), new Vector3D(0, 0, 1), Color.From(255, 0, 255, 0), new Vector2D(0, 0));

            Box = new Box3D();
            for (int i = 0; i < Vertices.Length; i++)
                Box.AddInternalPoint(Vertices[i].Position);
        }
示例#4
0
 public void DrawVertexPrimitiveList(Vertex3D[] vertices, ushort[] indexList, PrimitiveType pType)
 {
     DrawVertexPrimitiveList(vertices, indexList, vertices.Length / 3, pType);
 }
示例#5
0
 public void DrawVertexPrimitiveList(Vertex3D[] vertices, ushort[] indexList,int triangleCount, PrimitiveType pType)
 {
     DrawVertexPrimitiveList(vertices, vertices.Length, indexList, triangleCount, pType);
 }
示例#6
0
 /*
  *
  */
 public void DrawVertexPrimitiveList(Vertex3D[] vertices, int vertexCount, ushort[] indexList, int triangleCount, PrimitiveType pType)
 {
     IntPtr[] rawlist = new IntPtr[vertexCount];
     for (int i = 0; i < rawlist.Length; i++)
         rawlist[i] = vertices[i].Raw;
     VideoDriver_DrawVertexPrimitiveList(_raw, rawlist, vertexCount, indexList, triangleCount, VertexType.Standard, pType);
 }
示例#7
0
 public void DrawIndexedTriangleList(Vertex3D[] vertices)
 {
     ushort[] indexList = new ushort[vertices.Length];
     for (ushort i = 0; i < vertices.Length; i++)
         indexList[i] = i;
     DrawIndexedTriangleList(vertices, indexList);
 }
示例#8
0
 public void DrawIndexedTriangleList(Vertex3D[] vertices, ushort[] indexList)
 {
     DrawIndexedTriangleList(vertices, vertices.Length, indexList, vertices.Length / 3);
 }
示例#9
0
 public void DrawIndexedTriangleList(Vertex3D[] vertices, int vertexCount, ushort[] indexList, int triangleCount)
 {
     IntPtr[] rawlist = new IntPtr[vertexCount];
     for (int i = 0; i < vertexCount; i++)
         rawlist[i] = vertices[i].Raw;
     VideoDriver_DrawIndexedTriangleList(_raw, rawlist, vertexCount, indexList, triangleCount);
 }
示例#10
0
        private void export_to_model_linear(LaserDataSceneNode node)
        {
            float min_angle = m_current_laser_buffer.get_min_angle();
            float ang_increment = m_current_laser_buffer.get_resolution() * m_mesh_resolution;

            uint num_h_samples = m_current_laser_buffer.get_distance_count();

            uint horizontal_count = num_h_samples / m_mesh_resolution;

            float vertical_increment = m_vertical_scale * (m_vertical_sampler_max - m_vertical_sampler_min) / m_vertical_sampler_count;

            ushort sides = (ushort)horizontal_count;
            ushort slices = (ushort)m_vertical_sampler_count;

            // crear los vertices
            MeshBuffer mbuffer = node.get_mesh_buffer();

            uint vert_count = (uint)(sides * slices);

            mbuffer.AllocateVertices(vert_count);

            m_buffer_index = 0;
            float vertical_value = m_vertical_sampler_min * m_vertical_scale;
            float angular_value = min_angle;

            for (ushort i = 0; i < slices; i++)
            {
                angular_value = min_angle;
                for (ushort j = 0; j < sides; j++)
                {
                    float distance = m_laser_distances[num_h_samples*i + j*m_mesh_resolution];
                    Vector3D pivot = new Vector3D();
                    Vector3D normal = new Vector3D();
                    normal.Z = -(float)Math.Cos(deg_to_rad((double)angular_value));
                    normal.Y = -(float)Math.Sin(deg_to_rad((double)angular_value));
                    normal.X = 0;

                    pivot.Z = normal.Z * distance;
                    pivot.Y = normal.Y * distance;
                    pivot.X = vertical_value;

                    Vertex3D newvertex =  new Vertex3D();

                    newvertex.Position = pivot;
                    newvertex.Normal = normal;
                    newvertex.Color = new Color(255, 0, 0, 150);
                    newvertex.TCoords = new Vector2D(1, 1);

                    mbuffer.SetVertex(m_buffer_index, newvertex);
                    m_buffer_index++;

                    angular_value += ang_increment;

                }

                vertical_value += vertical_increment;
            }

            create_model_indices(node, sides, slices);
        }
示例#11
0
 public void DrawIndexedTriangleFan(Vertex3D[] vertices, ushort[] indexFan)
 {
     DrawIndexedTriangleFan(vertices, vertices.Length, indexFan, vertices.Length / 3);
 }
示例#12
0
 public void DrawIndexedTriangleFan(Vertex3D[] vertices, int vertexCount, ushort[] indexFan, int triangleCount)
 {
     IntPtr[] rawFan = new IntPtr[vertexCount];
     for (int i = 0; i < vertexCount; i++)
         rawFan[i] = vertices[i].Raw;
     VideoDriver_DrawIndexedTriangleFan(_raw, rawFan, vertexCount, indexFan, triangleCount);
 }
示例#13
0
        public P3DSimplexNoiseTerrain(SceneNode parent, SceneManager mgr, int id, int vertsPerRow, int vertsPerCol, int cellSpacing, float heightScale)
            : base(parent, mgr, id)
        {
            _mgr = mgr;
            _driver = _mgr.VideoDriver;

            Material = new Material();
            Material.Lighting = false;

            _numVertsPerRow = vertsPerRow;
            _numVertsPerCol = vertsPerCol;
            _cellSpacing = cellSpacing;
            _heightScale = heightScale;

            _numCellsPerRow = _numVertsPerRow - 1;
            _numCellsPerCol = _numVertsPerCol - 1;
            _width = _numCellsPerRow * _cellSpacing;
            _depth = _numCellsPerCol * _cellSpacing;
            NumVertices = _numVertsPerRow * _numVertsPerCol;
            _numIndices = (_numCellsPerRow * _numCellsPerCol) * 6;
            _numTriangles = (_numCellsPerRow * _numCellsPerCol) * 2;
            _indices = new ushort[_numIndices];

            int startX = -_width / 2;
            int startZ = _depth / 2;

            int endX = _width / 2;
            int endZ = -_depth / 2;

            Box3D = new Box3D(new Vector3D(startX, -_heightScale, startZ), new Vector3D(endX, _heightScale, endZ));

            float uCoordIncrementSize = 1.0f;
            float vCoordIncrementSize = 1.0f;

            _heights = new float[NumVertices];

            int i = 0;
            for (int z = startZ; z >= endZ; z -= _cellSpacing)
            {
                int j = 0;
                for (int x = startX; x <= endX; x += _cellSpacing)
                {

                    int index = i * _numVertsPerRow + j;
                    float height;// = noise.PerlinNoise1F(x, 100*heightScale, 0.001f);
                    // large noise.
                    height = PerlinSimplexNoise.noise(x * 0.0001f, z * 0.0001f) * _heightScale;
                    // detail noise.
                    height += PerlinSimplexNoise.noise(x * 0.001f, z * 0.001f) * _heightScale / 10;
                    Vertex3D v = new Vertex3D(
                        new Vector3D(x, height, z),
                        new Vector3D(0, 1, 0),
                        Color.Black,
                        new Vector2D(j * uCoordIncrementSize, i * vCoordIncrementSize)
                        );
                    _buffer.SetVertex((uint)index, v);
                    j++;
                }
                i++;
            }

            uint baseIndex = 0;

            for (uint k = 0; k < _numCellsPerRow; k++)
            {
                for (uint j = 0; j < _numCellsPerCol; j++)
                {
                    _buffer.SetIndex(baseIndex + 0, (ushort)(k * _numVertsPerRow + j));
                    _buffer.SetIndex(baseIndex + 1, (ushort)(k * _numVertsPerRow + j + 1));
                    _buffer.SetIndex(baseIndex + 2, (ushort)((k + 1) * _numVertsPerRow + j));
                    _buffer.SetIndex(baseIndex + 3, (ushort)((k + 1) * _numVertsPerRow + j));
                    _buffer.SetIndex(baseIndex + 4, (ushort)(k * _numVertsPerRow + j + 1));
                    _buffer.SetIndex(baseIndex + 5, (ushort)((k + 1) * _numVertsPerRow + j + 1));

                    baseIndex += 6;
                }
            }
        }
        /*private void DoParticleSystem(uint time)
        {
        }*/
        private void ReallocateBuffers()
        {
            if (Particles.Length * 4 > Vertices.Length || Particles.Length * 6 > Indices.Length)
            {
                int oldSize = Vertices.Length;
				ArrayList newvert = new ArrayList();
				
                int i = 0;
                newvert.AddRange(Vertices);
                for (i = oldSize; i < (Particles.Length * 4); i++)
                {
                   Vertex3D temp = new Vertex3D();
                   temp.Normal = new Vector3D(0, 1, 0);
                   newvert.Add(temp);
                }
                Vertices = (Vertex3D[])newvert.ToArray(typeof(Vertex3D));
                
                
                newvert.Clear();

                int oldIdxSize = Indices.Length;
                int oldvertices = oldSize;

                newvert.AddRange(Indices);
                    
                for (i = oldIdxSize; i < (Particles.Length * 12); i += 12)
                {
                    newvert.Add((ushort)(0 + oldvertices));
                    newvert.Add((ushort)(2 + oldvertices));
                    newvert.Add((ushort)(1 + oldvertices));
                    newvert.Add((ushort)(0 + oldvertices));
                    newvert.Add((ushort)(3 + oldvertices));
                    newvert.Add((ushort)(2 + oldvertices));

                    newvert.Add((ushort)(1 + oldvertices));
                    newvert.Add((ushort)(2 + oldvertices));
                    newvert.Add((ushort)(0 + oldvertices));
                    newvert.Add((ushort)(2 + oldvertices));
                    newvert.Add((ushort)(3 + oldvertices));
                    newvert.Add((ushort)(0 + oldvertices));

                    oldvertices += 4;
                }
                Indices = (ushort[])newvert.ToArray(typeof(ushort));
                newvert.Clear();
            }
        }
示例#15
0
 public void DrawVertexPrimitiveList(Vertex3D[] vertices, PrimitiveType pType)
 {
     ushort[] indexList = new ushort[vertices.Length];
     for (ushort i = 0; i < vertices.Length; i++)
         indexList[i] = i;
     DrawVertexPrimitiveList(vertices, indexList, pType);
 }
示例#16
0
 public void SetVertex(uint nr, Vertex3D vert)
 {
     MeshBuffer_SetVertex(_raw, nr, vert.Raw);
 }
示例#17
0
 public void DrawIndexedTriangleFan(Vertex3D[] vertices)
 {
     ushort[] indexFan = new ushort[vertices.Length];
     for (ushort i = 0; i < vertices.Length; i++)
         indexFan[i] = i;
     DrawIndexedTriangleFan(vertices, indexFan);
 }