Subversion Repositories AndroidProjects

Rev

Rev 168 | Blame | Compare with Previous | Last modification | View Log | RSS feed

package com.gebauz.Bauzoid.graphics;

import javax.microedition.khronos.opengles.GL10;

import com.gebauz.Bauzoid.graphics.model.SimpleGeometry;
import com.gebauz.Bauzoid.math.Vector4;

public class RenderUtil
{
       
        private RenderUtil()
        {
               
        }
       
        public static SimpleGeometry createQuad(float minX, float minY, float maxX, float maxY, float minS, float minT, float maxS, float maxT, Vector4 color)
        {
                SimpleGeometry mesh = new SimpleGeometry();
               
                SimpleGeometry.AttributeArray vertices = new SimpleGeometry.AttributeArray(SimpleGeometry.COLOR_ELEMENTS_COUNT * 6);
                vertices.fill(minX, minY, 0.0f);
                vertices.fill(maxX, minY, 0.0f);
                vertices.fill(minX, maxY, 0.0f);
               
                vertices.fill(minX, maxY, 0.0f);
                vertices.fill(maxX, minY, 0.0f);
                vertices.fill(maxX, maxY, 0.0f);

                SimpleGeometry.AttributeArray colors = new SimpleGeometry.AttributeArray(SimpleGeometry.COLOR_ELEMENTS_COUNT * 6);
                colors.fill(color.x, color.y, color.z, color.w);
                colors.fill(color.x, color.y, color.z, color.w);
                colors.fill(color.x, color.y, color.z, color.w);
                colors.fill(color.x, color.y, color.z, color.w);
                colors.fill(color.x, color.y, color.z, color.w);
                colors.fill(color.x, color.y, color.z, color.w);
               
                SimpleGeometry.AttributeArray texCoords = new SimpleGeometry.AttributeArray(SimpleGeometry.TEX_COORD_ELEMENTS_COUNT * 6);
                texCoords.fill(minS, maxT);
                texCoords.fill(maxS, maxT);
                texCoords.fill(minS, minT);
               
                texCoords.fill(minS, minT);
                texCoords.fill(maxS, maxT);
                texCoords.fill(maxS, minT);
               
                mesh.setVertices(vertices.getAttributeArray());
                mesh.setColors(colors.getAttributeArray());
                mesh.setTexCoords(texCoords.getAttributeArray());              
                mesh.setPrimitiveType(GL10.GL_TRIANGLES);
               
                return mesh;
        }
       
        public static SimpleGeometry createQuad(float minX, float minY, float maxX, float maxY, float minS, float minT, float maxS, float maxT)
        {
                return createQuad(minX, minY, maxX, maxY, minS, minT, maxS, maxT, new Vector4(1.0f, 1.0f, 1.0f, 1.0f));
        }
       
        public static SimpleGeometry createQuad(float minX, float minY, float maxX, float maxY, Vector4 color)
        {
                return createQuad(minX, minY, maxX, maxY, 0.0f, 0.0f, 1.0f, 1.0f, new Vector4(1.0f, 1.0f, 1.0f, 1.0f));
        }

        public static SimpleGeometry createQuad(float minX, float minY, float maxX, float maxY)
        {
                return createQuad(minX, minY, maxX, maxY, 0.0f, 0.0f, 1.0f, 1.0f);
        }
}