Exemple #1
0
        public BufferPointer GetBufferRenderer(string bufferName, string varNameInShader)
        {
            if (bufferName == strPosition)
            {
                using (var buffer = new PositionBuffer(varNameInShader))
                {
                    buffer.Alloc(positions.Count);
                    unsafe
                    {
                        var array = (vec3 *)buffer.FirstElement();
                        for (int i = 0; i < positions.Count; i++)
                        {
                            array[i] = positions[i];
                        }
                    }

                    return(buffer.GetBufferPtr());
                }
            }
            else if (bufferName == strColor)
            {
                using (var buffer = new ColorBuffer(varNameInShader))
                {
                    buffer.Alloc(normals.Count);
                    unsafe
                    {
                        var array = (vec3 *)buffer.FirstElement();
                        for (int i = 0; i < normals.Count; i++)
                        {
                            array[i] = normals[i];
                        }
                    }

                    return(buffer.GetBufferPtr());
                }
            }
            else if (bufferName == strNormal)
            {
                using (var buffer = new NormalBuffer(varNameInShader))
                {
                    buffer.Alloc(normals.Count);
                    unsafe
                    {
                        var array = (vec3 *)buffer.FirstElement();
                        for (int i = 0; i < normals.Count; i++)
                        {
                            array[i] = normals[i];
                        }
                    }

                    return(buffer.GetBufferPtr());
                }
            }
            else
            {
                return(null);
            }
        }
Exemple #2
0
        public PropertyBufferPtr GetProperty(string bufferName, string varNameInShader)
        {
            if (bufferName == strPosition)
            {
                using (var buffer = new PositionBuffer(varNameInShader))
                {
                    buffer.Alloc(positions.Length);
                    unsafe
                    {
                        var array = (vec3 *)buffer.FirstElement();
                        for (int i = 0; i < positions.Length; i++)
                        {
                            array[i] = positions[i];
                        }
                    }

                    return(buffer.GetBufferPtr() as PropertyBufferPtr);
                }
            }
            else if (bufferName == strColor)
            {
                using (var buffer = new ColorBuffer(varNameInShader))
                {
                    buffer.Alloc(colors.Length);
                    unsafe
                    {
                        var array = (vec3 *)buffer.FirstElement();
                        for (int i = 0; i < colors.Length; i++)
                        {
                            array[i] = colors[i];
                        }
                    }

                    return(buffer.GetBufferPtr() as PropertyBufferPtr);
                }
            }
            else if (bufferName == strNormal)
            {
                using (var buffer = new NormalBuffer(varNameInShader))
                {
                    buffer.Alloc(normals.Length);
                    unsafe
                    {
                        var array = (vec3 *)buffer.FirstElement();
                        for (int i = 0; i < normals.Length; i++)
                        {
                            array[i] = normals[i];
                        }
                    }

                    return(buffer.GetBufferPtr() as PropertyBufferPtr);
                }
            }
            else
            {
                return(null);
            }
        }
Exemple #3
0
        public PropertyBufferPtr GetProperty(string bufferName, string varNameInShader)
        {
            if (bufferName == strPosition)
            {
                using (var positionBuffer = new PositionBuffer(varNameInShader))
                {
                    positionBuffer.Alloc(1);
                    unsafe
                    {
                        var positionArray = (CubePosition *)positionBuffer.FirstElement();
                        positionArray[0] = this.position;
                    }

                    return(positionBuffer.GetBufferPtr() as PropertyBufferPtr);
                }
            }
            else if (bufferName == strColor)
            {
                using (var colorBuffer = new ColorBuffer(varNameInShader))
                {
                    colorBuffer.Alloc(1);
                    unsafe
                    {
                        var colorArray = (CubeColor *)colorBuffer.FirstElement();
                        colorArray[0] = this.color;
                    }

                    return(colorBuffer.GetBufferPtr() as PropertyBufferPtr);
                }
            }
            else if (bufferName == strNormal)
            {
                using (var normalBuffer = new NormalBuffer(varNameInShader))
                {
                    normalBuffer.Alloc(1);
                    unsafe
                    {
                        var normalArray = (CubeNormal *)normalBuffer.FirstElement();
                        normalArray[0] = this.normal;
                    }

                    return(normalBuffer.GetBufferPtr() as PropertyBufferPtr);
                }
            }
            else
            {
                return(null);
            }
        }
Exemple #4
0
        VertexBuffers.BufferPointer IModel.GetNormalBufferRenderer(string varNameInShader)
        {
            using (var buffer = new NormalBuffer(varNameInShader))
            {
                buffer.Alloc(this.normals.Length);
                unsafe
                {
                    vec3 *array = (vec3 *)buffer.FirstElement();
                    for (int i = 0; i < this.normals.Length; i++)
                    {
                        array[i] = this.normals[i];
                    }
                }

                return(buffer.GetRenderer());
            }
        }