Exemplo n.º 1
0
    public ConeRenderer(RenderingDevice device)
    {
        _device           = device;
        _fanIndexBuffer   = device.CreateIndexBuffer(FanIndices);
        _fanVertexBuffer  = device.CreateEmptyVertexBuffer(IntgameVertex.Size * 20, debugName: "ConeRendererFanVb");
        _fanBufferBinding = device.CreateMdfBufferBinding().Ref();
        _fanBufferBinding.Resource.AddBuffer <IntgameVertex>(_fanVertexBuffer.Resource, 0)
        .AddElement(VertexElementType.Float4, VertexElementSemantic.Position)
        .AddElement(VertexElementType.Float4, VertexElementSemantic.Normal)
        .AddElement(VertexElementType.Color, VertexElementSemantic.Color)
        .AddElement(VertexElementType.Float2, VertexElementSemantic.TexCoord);

        _ringIndexBuffer   = device.CreateIndexBuffer(RingIndices);
        _ringVertexBuffer  = device.CreateEmptyVertexBuffer(IntgameVertex.Size * 38, debugName: "ConeRendererRingVb");
        _ringBufferBinding = device.CreateMdfBufferBinding().Ref();
        _ringBufferBinding.Resource.AddBuffer <IntgameVertex>(_ringVertexBuffer.Resource, 0)
        .AddElement(VertexElementType.Float4, VertexElementSemantic.Position)
        .AddElement(VertexElementType.Float4, VertexElementSemantic.Normal)
        .AddElement(VertexElementType.Color, VertexElementSemantic.Color)
        .AddElement(VertexElementType.Float2, VertexElementSemantic.TexCoord);

        _flankIndexBuffer   = device.CreateIndexBuffer(FlankIndices);
        _flankVertexBuffer  = device.CreateEmptyVertexBuffer(IntgameVertex.Size * 10, debugName: "ConeRendererRingFlank");
        _flankBufferBinding = device.CreateMdfBufferBinding().Ref();
        _flankBufferBinding.Resource.AddBuffer <IntgameVertex>(_flankVertexBuffer.Resource, 0)
        .AddElement(VertexElementType.Float4, VertexElementSemantic.Position)
        .AddElement(VertexElementType.Float4, VertexElementSemantic.Normal)
        .AddElement(VertexElementType.Color, VertexElementSemantic.Color)
        .AddElement(VertexElementType.Float2, VertexElementSemantic.TexCoord);
    }
    public PickerAreaRenderer(RenderingDevice device)
    {
        _device           = device;
        _fanIndexBuffer   = device.CreateIndexBuffer(FanIndices);
        _fanVertexBuffer  = device.CreateEmptyVertexBuffer(IntgameVertex.Size * 39, debugName: "PickerAreaFan");
        _fanBufferBinding = device.CreateMdfBufferBinding().Ref();
        _fanBufferBinding.Resource.AddBuffer <IntgameVertex>(_fanVertexBuffer.Resource, 0)
        .AddElement(VertexElementType.Float4, VertexElementSemantic.Position)
        .AddElement(VertexElementType.Float4, VertexElementSemantic.Normal)
        .AddElement(VertexElementType.Color, VertexElementSemantic.Color)
        .AddElement(VertexElementType.Float2, VertexElementSemantic.TexCoord);

        _ringIndexBuffer   = device.CreateIndexBuffer(RingIndices);
        _ringVertexBuffer  = device.CreateEmptyVertexBuffer(IntgameVertex.Size * 76, debugName: "PickerAreaRing");
        _ringBufferBinding = device.CreateMdfBufferBinding().Ref();
        _ringBufferBinding.Resource.AddBuffer <IntgameVertex>(_ringVertexBuffer.Resource, 0)
        .AddElement(VertexElementType.Float4, VertexElementSemantic.Position)
        .AddElement(VertexElementType.Float4, VertexElementSemantic.Normal)
        .AddElement(VertexElementType.Color, VertexElementSemantic.Color)
        .AddElement(VertexElementType.Float2, VertexElementSemantic.TexCoord);
    }
Exemplo n.º 3
0
    public RectangleRenderer(RenderingDevice device)
    {
        _device             = device;
        _innerIndexBuffer   = device.CreateIndexBuffer(InnerIndices);
        _innerVertexBuffer  = device.CreateEmptyVertexBuffer(IntgameVertex.Size * 22, debugName: "RectangleInner");
        _innerBufferBinding = device.CreateMdfBufferBinding().Ref();
        _innerBufferBinding.Resource.AddBuffer <IntgameVertex>(_innerVertexBuffer.Resource, 0)
        .AddElement(VertexElementType.Float4, VertexElementSemantic.Position)
        .AddElement(VertexElementType.Float4, VertexElementSemantic.Normal)
        .AddElement(VertexElementType.Color, VertexElementSemantic.Color)
        .AddElement(VertexElementType.Float2, VertexElementSemantic.TexCoord);

        _outerIndexBuffer   = device.CreateIndexBuffer(OuterIndices);
        _outerVertexBuffer  = device.CreateEmptyVertexBuffer(IntgameVertex.Size * 52, debugName: "RectangleOuter");
        _outerBufferBinding = device.CreateMdfBufferBinding().Ref();
        _outerBufferBinding.Resource.AddBuffer <IntgameVertex>(_outerVertexBuffer.Resource, 0)
        .AddElement(VertexElementType.Float4, VertexElementSemantic.Position)
        .AddElement(VertexElementType.Float4, VertexElementSemantic.Normal)
        .AddElement(VertexElementType.Color, VertexElementSemantic.Color)
        .AddElement(VertexElementType.Float2, VertexElementSemantic.TexCoord);
    }
Exemplo n.º 4
0
    public ShapeRenderer3d(RenderingDevice device)
    {
        _device = device;

        _lineMaterial         = CreateLineMaterial(false).Ref();
        _quadMaterial         = CreateQuadMaterial().Ref();
        _lineOccludedMaterial = CreateLineMaterial(true).Ref();
        _discBufferBinding    = _device.CreateMdfBufferBinding().Ref();
        _lineBinding          = new BufferBinding(_device, _lineMaterial.Resource.VertexShader).Ref();
        _circleBinding        = new BufferBinding(_device, _lineMaterial.Resource.VertexShader).Ref();

        _discVerticesTpl[0].pos  = new Vector4(-1.0f, 0.0f, -1.0f, 1);
        _discVerticesTpl[1].pos  = new Vector4(0.0f, 0.0f, -1.0f, 1);
        _discVerticesTpl[2].pos  = new Vector4(0.0f, 0.0f, 0.0f, 1);
        _discVerticesTpl[3].pos  = new Vector4(-1.0f, 0.0f, 0.0f, 1);
        _discVerticesTpl[4].pos  = new Vector4(0.0f, 0.0f, -1.0f, 1);
        _discVerticesTpl[5].pos  = new Vector4(1.0f, 0.0f, -1.0f, 1);
        _discVerticesTpl[6].pos  = new Vector4(1.0f, 0.0f, 0.0f, 1);
        _discVerticesTpl[7].pos  = new Vector4(0.0f, 0.0f, 0.0f, 1);
        _discVerticesTpl[8].pos  = new Vector4(0.0f, 0.0f, 0.0f, 1);
        _discVerticesTpl[9].pos  = new Vector4(1.0f, 0.0f, 0.0f, 1);
        _discVerticesTpl[10].pos = new Vector4(1.0f, 0.0f, 1.0f, 1);
        _discVerticesTpl[11].pos = new Vector4(0.0f, 0.0f, 1.0f, 1);
        _discVerticesTpl[12].pos = new Vector4(-1.0f, 0.0f, 0.0f, 1);
        _discVerticesTpl[13].pos = new Vector4(0.0f, 0.0f, 0.0f, 1);
        _discVerticesTpl[14].pos = new Vector4(0.0f, 0.0f, 1.0f, 1);
        _discVerticesTpl[15].pos = new Vector4(-1.0f, 0.0f, 1.0f, 1);

        for (var i = 0; i < _discVerticesTpl.Length; i++)
        {
            _discVerticesTpl[i].normal = new Vector4(0, 1, 0, 0);
        }

        _discVerticesTpl[0].uv  = new Vector2(0, 0);
        _discVerticesTpl[1].uv  = new Vector2(1, 0);
        _discVerticesTpl[2].uv  = new Vector2(1, 1);
        _discVerticesTpl[3].uv  = new Vector2(0, 1);
        _discVerticesTpl[4].uv  = new Vector2(0, 1);
        _discVerticesTpl[5].uv  = new Vector2(0, 0);
        _discVerticesTpl[6].uv  = new Vector2(1, 0);
        _discVerticesTpl[7].uv  = new Vector2(1, 1);
        _discVerticesTpl[8].uv  = new Vector2(1, 1);
        _discVerticesTpl[9].uv  = new Vector2(0, 1);
        _discVerticesTpl[10].uv = new Vector2(0, 0);
        _discVerticesTpl[11].uv = new Vector2(1, 0);
        _discVerticesTpl[12].uv = new Vector2(1, 0);
        _discVerticesTpl[13].uv = new Vector2(1, 1);
        _discVerticesTpl[14].uv = new Vector2(0, 1);
        _discVerticesTpl[15].uv = new Vector2(0, 0);

        _resourceListener = new ResourceLifecycleCallbacks(_device, CreateResources, FreeResources);
    }
Exemplo n.º 5
0
    public SpellPointerRenderer(RenderingDevice device)
    {
        _device       = device;
        _indexBuffer  = device.CreateIndexBuffer(Indices);
        _vertexBuffer = device.CreateEmptyVertexBuffer(IntgameVertex.Size * 4, debugName: "SpellPointer");

        _bufferBinding = device.CreateMdfBufferBinding().Ref();
        _bufferBinding.Resource.AddBuffer <IntgameVertex>(_vertexBuffer.Resource, 0)
        .AddElement(VertexElementType.Float4, VertexElementSemantic.Position)
        .AddElement(VertexElementType.Float4, VertexElementSemantic.Normal)
        .AddElement(VertexElementType.Color, VertexElementSemantic.Color)
        .AddElement(VertexElementType.Float2, VertexElementSemantic.TexCoord);

        _material = Tig.MdfFactory.LoadMaterial("art/interface/intgame_select/Spell_Effect-Pointer.mdf");
    }
Exemplo n.º 6
0
    public FrogGrappleController(RenderingDevice device,
                                 MdfMaterialFactory mdfFactory)
    {
        mDevice        = device;
        mBufferBinding = device.CreateMdfBufferBinding();

        mTongueMaterial = mdfFactory.LoadMaterial("art/meshes/Monsters/GiantFrog/tongue.mdf");

        mVertexBuffer = device.CreateEmptyVertexBuffer(TongueVertex.Size * VertexCount, debugName: "FrogTongue");

        CreateIndexBuffer();

        mBufferBinding.AddBuffer(mVertexBuffer, 0, TongueVertex.Size)
        .AddElement(VertexElementType.Float4, VertexElementSemantic.Position)
        .AddElement(VertexElementType.Float4, VertexElementSemantic.Normal)
        .AddElement(VertexElementType.Float2, VertexElementSemantic.TexCoord);
    }
    protected LineSegmentRenderer(RenderingDevice device, MdfMaterialFactory materialFactory, PerlinNoise noise,
                                  int maxLineSegments, string debugName)
    {
        _noise   = noise;
        Vertices = new Vertex[maxLineSegments * 2];
        Jitter   = new float[maxLineSegments];

        _device   = device;
        _material = materialFactory.LoadMaterial("art/meshes/lightning.mdf",
                                                 material => material.perVertexColor = true);

        _indexBuffer    = CreateIndexBuffer(_device, maxLineSegments, debugName);
        _capIndexBuffer = CreateIndexBuffer2(_device, debugName);
        _vertexBuffer   =
            _device.CreateEmptyVertexBuffer(Vertex.Size * Vertices.Length, debugName: debugName);
        _bufferBinding = _device.CreateMdfBufferBinding(true).Ref();
        _bufferBinding.Resource.AddBuffer <Vertex>(_vertexBuffer.Resource, 0)
        .AddElement(VertexElementType.Float3, VertexElementSemantic.Position)
        .AddElement(VertexElementType.Float3, VertexElementSemantic.Normal)
        .AddElement(VertexElementType.Color, VertexElementSemantic.Color)
        .AddElement(VertexElementType.Float2, VertexElementSemantic.TexCoord);
    }
Exemplo n.º 8
0
    public ShapeRenderer2d(RenderingDevice device)
    {
        _device   = device;
        _textures = device.GetTextures();

        untexturedMaterial = CreateMaterial(device, "diffuse_only_ps");
        texturedMaterial   = CreateMaterial(device, "textured_simple_ps");
        texturedWithoutBlendingMaterial = CreateMaterial(device, "textured_simple_ps", false, false);
        texturedWithMaskMaterial        = CreateMaterial(device, "textured_two_ps");
        lineMaterial      = CreateMaterial(device, "diffuse_only_ps", true);
        outlineMaterial   = CreateOutlineMaterial(device);
        pieFillMaterial   = CreatePieFillMaterial(device);
        bufferBinding     = new BufferBinding(device, texturedMaterial.VertexShader).Ref();
        mdfBufferBinding  = _device.CreateMdfBufferBinding();
        lineBufferBinding = new BufferBinding(device, lineMaterial.VertexShader).Ref();


        SamplerSpec samplerWrapSpec = new SamplerSpec();

        samplerWrapSpec.addressU  = TextureAddress.Wrap;
        samplerWrapSpec.addressV  = TextureAddress.Wrap;
        samplerWrapSpec.minFilter = TextureFilterType.Linear;
        samplerWrapSpec.magFilter = TextureFilterType.Linear;
        samplerWrapSpec.mipFilter = TextureFilterType.Linear;
        samplerWrapState          = _device.CreateSamplerState(samplerWrapSpec);

        SamplerSpec samplerClampPointSpec = new SamplerSpec();

        samplerClampPointSpec.addressU  = TextureAddress.Clamp;
        samplerClampPointSpec.addressV  = TextureAddress.Clamp;
        samplerClampPointSpec.minFilter = TextureFilterType.NearestNeighbor;
        samplerClampPointSpec.magFilter = TextureFilterType.NearestNeighbor;
        samplerClampPointSpec.mipFilter = TextureFilterType.NearestNeighbor;
        samplerClampPointState          = _device.CreateSamplerState(samplerClampPointSpec);

        SamplerSpec samplerClampSpec = new SamplerSpec();

        samplerClampSpec.addressU  = TextureAddress.Clamp;
        samplerClampSpec.addressV  = TextureAddress.Clamp;
        samplerClampSpec.minFilter = TextureFilterType.Linear;
        samplerClampSpec.magFilter = TextureFilterType.Linear;
        samplerClampSpec.mipFilter = TextureFilterType.Linear;
        samplerClampState          = _device.CreateSamplerState(samplerClampSpec);

        DepthStencilSpec noDepthSpec = new DepthStencilSpec();

        noDepthSpec.depthEnable = false;
        noDepthState            = _device.CreateDepthStencilState(noDepthSpec);

        vertexBuffer = _device.CreateEmptyVertexBuffer(Vertex2d.Size * 8, debugName: "ShapeRenderer2d");

        var indexData = new ushort[]
        {
            0, 1, 2,
            2, 3, 0
        };

        indexBuffer = _device.CreateIndexBuffer(indexData);

        bufferBinding.Resource.AddBuffer <Vertex2d>(vertexBuffer, 0)
        .AddElement(VertexElementType.Float4, VertexElementSemantic.Position)
        .AddElement(VertexElementType.Float4, VertexElementSemantic.Normal)
        .AddElement(VertexElementType.Color, VertexElementSemantic.Color)
        .AddElement(VertexElementType.Float2, VertexElementSemantic.TexCoord);

        mdfBufferBinding.AddBuffer <Vertex2d>(vertexBuffer, 0)
        .AddElement(VertexElementType.Float4, VertexElementSemantic.Position)
        .AddElement(VertexElementType.Float4, VertexElementSemantic.Normal)
        .AddElement(VertexElementType.Color, VertexElementSemantic.Color)
        .AddElement(VertexElementType.Float2, VertexElementSemantic.TexCoord);
    }