Ejemplo n.º 1
0
 public void AddCommand(RenderMaterial material, MaterialAnim anim, Matrix4 world, Lighting lights, VertexBuffer buffer, PrimitiveTypes primitive, int baseVertex, int start, int count, int layer, float z = 0, CharacterSkinning skinning = null)
 {
     if (material.IsTransparent)
     {
         Transparents[transparentCommand++] = new RenderCommand()
         {
             Source       = material,
             MaterialAnim = anim,
             Lights       = lights,
             Buffer       = buffer,
             BaseVertex   = baseVertex,
             Start        = start,
             Count        = count,
             Primitive    = primitive,
             CmdType      = RenderCmdType.Material,
             World        = world,
             SortLayer    = layer,
             Z            = z
         };
     }
     else
     {
         material.MaterialAnim = anim;
         material.World        = world;
         material.Use(rstate, buffer.VertexType, ref lights);
         buffer.Draw(primitive, baseVertex, start, count);
         if (material.DoubleSided)
         {
             material.FlipNormals = true;
             material.UpdateFlipNormals();
             rstate.CullFace = CullFaces.Front;
             buffer.Draw(primitive, baseVertex, start, count);
             rstate.CullFace      = CullFaces.Back;
             material.FlipNormals = false;
         }
         material.Bones = skinning?.BonesBuffer;
     }
 }
Ejemplo n.º 2
0
 public void AddCommand(RenderMaterial material, MaterialAnim anim, Matrix4 world, Lighting lights, VertexBuffer buffer, PrimitiveTypes primitive, int baseVertex, int start, int count, int layer, float z = 0)
 {
     if (material.IsTransparent)
     {
         Transparents[transparentCommand++] = new RenderCommand()
         {
             Source       = material,
             MaterialAnim = anim,
             Lights       = lights,
             Buffer       = buffer,
             BaseVertex   = baseVertex,
             Start        = start,
             Count        = count,
             Primitive    = primitive,
             CmdType      = RenderCmdType.Material,
             World        = world,
             SortLayer    = layer,
             Z            = z
         };
     }
     else
     {
         Commands[currentCommand++] = new RenderCommand()
         {
             Source       = material,
             MaterialAnim = anim,
             Lights       = lights,
             Buffer       = buffer,
             BaseVertex   = baseVertex,
             Start        = start,
             Count        = count,
             Primitive    = primitive,
             CmdType      = RenderCmdType.Material,
             World        = world,
         };
     }
 }
Ejemplo n.º 3
0
 public void AddCommand(Shader shader, ShaderAction setup, Action <RenderContext> cleanup, WorldMatrixHandle world, RenderUserData user, VertexBuffer buffer, PrimitiveTypes primitive, int baseVertex, int start, int count, bool transparent, int layer, float z = 0, int renIndex = 0)
 {
     if (transparent)
     {
         Transparents[transparentCommand++] = new RenderCommand()
         {
             Key         = RenderCommand.MakeKey(RenderType.Transparent, 0, layer, z, renIndex),
             Source      = shader,
             ShaderSetup = setup,
             World       = world,
             UserData    = user,
             Cleanup     = cleanup,
             Buffer      = buffer,
             Start       = start,
             Count       = count,
             Primitive   = primitive,
             CmdType     = RenderCmdType.Shader,
         };
     }
     else
     {
         throw new InvalidOperationException();
     }
 }
Ejemplo n.º 4
0
        public void RenderCustom(RenderState rs, Shader shdr, ShaderAction customAction, ref RenderCommand cmd)
        {
            FlushCommands(rs);
            if (!_iboFilled)
            {
                ibo.SetData(indices, fillCount);
                _iboFilled = true;
                fillCount  = 0;
            }
            //Setup shader default state
            rs.Cull      = false;
            rs.BlendMode = BlendMode.Normal;
            var splt = new SplitInt()
            {
                I = shdr.UserTag
            };

            if (shdr.UserTag == 0)
            {
                splt.A       = (short)shdr.GetLocation("View");
                splt.B       = (short)shdr.GetLocation("ViewProjection");
                shdr.UserTag = splt.I;
            }
            var view = camera.View;

            shdr.SetMatrix(splt.A, ref view);
            var vp = camera.ViewProjection;

            shdr.SetMatrix(splt.B, ref vp);
            //User-defined
            customAction(shdr, rs, ref cmd);
            //Draw
            vbo.Draw(PrimitiveTypes.TriangleList, 0, lastIndex, 2);
            //Set stuff
            rs.Cull    = true;
            lasthash   = -1;
            lastIndex += 6;
        }