本文整理汇总了Java中com.badlogic.gdx.graphics.VertexAttribute.Position方法的典型用法代码示例。如果您正苦于以下问题:Java VertexAttribute.Position方法的具体用法?Java VertexAttribute.Position怎么用?Java VertexAttribute.Position使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.badlogic.gdx.graphics.VertexAttribute
的用法示例。
在下文中一共展示了VertexAttribute.Position方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: makeMesh
import com.badlogic.gdx.graphics.VertexAttribute; //导入方法依赖的package包/类
public void makeMesh() {
int rayon = Math.max(ExterminateGame.rendu, ExterminateGame.MAX_VIEW_DISTANCE)+5;
int nbTriangles=ChunkBuilder.GRIDSIZE*ChunkBuilder.GRIDSIZE*2*rayon*2*rayon*2;
int nbVertex=(ChunkBuilder.GRIDSIZE+1)*(ChunkBuilder.GRIDSIZE+1)*rayon*2*rayon*2;
FloatBuffer vertexL = org.lwjgl.BufferUtils.createFloatBuffer(nbVertex*ChunkBuilder.SOL_VERTICE_SIZE);
IntBuffer indicesL = org.lwjgl.BufferUtils.createIntBuffer(nbTriangles*3);
mesh = new UniMesh(true, true, nbVertex, nbTriangles*3, new VertexAttributes(VertexAttribute.Position(), VertexAttribute.NormalPacked(), VertexAttribute.TexCoords(0), VertexAttribute.ColorPacked()));
mesh.setVertices(vertexL, 0, nbVertex*ChunkBuilder.SOL_VERTICE_SIZE);
mesh.setIndices(indicesL, 0, nbTriangles*3);
mesh.setCapacity(0);
usedSol = new boolean[rayon*2*rayon*2];
forChunk = new Chunk[rayon*2*rayon*2];
for(int i=0;i<rayon*2*rayon*2;i++) {
usedSol[i] = false;
}
UniVertexBufferObject.showMem();
}
示例2: buildMesh
import com.badlogic.gdx.graphics.VertexAttribute; //导入方法依赖的package包/类
private void buildMesh() {
mesh = new Mesh(true, SIZE, 6, VertexAttribute.Position(), VertexAttribute.TexCoords(0));
mesh.setVertices(vertices);
short[] indices = new short[6];
int v = 0;
for (int i = 0; i < indices.length; i += 6, v += 4) {
indices[i] = (short)(v);
indices[i + 1] = (short)(v + 2);
indices[i + 2] = (short)(v + 1);
indices[i + 3] = (short)(v + 1);
indices[i + 4] = (short)(v + 2);
indices[i + 5] = (short)(v + 3);
}
mesh.setIndices(indices);
}
示例3: build
import com.badlogic.gdx.graphics.VertexAttribute; //导入方法依赖的package包/类
public static Mesh build(float size, TextureRegion region) {
Mesh mesh = new Mesh(true, SIZE, 6, VertexAttribute.Position(), VertexAttribute.TexCoords(0));
mesh.setVertices(verticies(size, region));
mesh.setAutoBind(false);
short[] indices = new short[6];
int v = 0;
for (int i = 0; i < indices.length; i += 6, v += 4) {
indices[i] = (short)(v);
indices[i + 1] = (short)(v + 2);
indices[i + 2] = (short)(v + 1);
indices[i + 3] = (short)(v + 1);
indices[i + 4] = (short)(v + 2);
indices[i + 5] = (short)(v + 3);
}
mesh.setIndices(indices);
return mesh;
}
示例4: create
import com.badlogic.gdx.graphics.VertexAttribute; //导入方法依赖的package包/类
@Override
public void create () {
String vertexShader = "attribute vec4 a_position; \n" + "attribute vec4 a_color;\n" + "attribute vec2 a_texCoord0;\n"
+ "uniform mat4 u_worldView;\n" + "varying vec4 v_color;" + "varying vec2 v_texCoords;"
+ "void main() \n" + "{ \n" + " v_color = vec4(1, 1, 1, 1); \n"
+ " v_texCoords = a_texCoord0; \n" + " gl_Position = u_worldView * a_position; \n"
+ "} \n";
String fragmentShader = "#ifdef GL_ES\n" + "precision mediump float;\n" + "#endif\n" + "varying vec4 v_color;\n"
+ "varying vec2 v_texCoords;\n" + "uniform sampler2D u_texture;\n" + "void main() \n"
+ "{ \n" + " gl_FragColor = v_color * texture2D(u_texture, v_texCoords);\n"
+ "}";
shader = new ShaderProgram(vertexShader, fragmentShader);
if (shader.isCompiled() == false) {
Gdx.app.log("ShaderTest", shader.getLog());
Gdx.app.exit();
}
mesh = new Mesh(true, 4, 6, VertexAttribute.Position(), VertexAttribute.ColorUnpacked(), VertexAttribute.TexCoords(0));
mesh.setVertices(new float[] {-0.5f, -0.5f, 0, 1, 1, 1, 1, 0, 1, 0.5f, -0.5f, 0, 1, 1, 1, 1, 1, 1, 0.5f, 0.5f, 0, 1, 1, 1,
1, 1, 0, -0.5f, 0.5f, 0, 1, 1, 1, 1, 0, 0});
mesh.setIndices(new short[] {0, 1, 2, 2, 3, 0});
texture = new Texture(Gdx.files.internal("data/bobrgb888-32x32.png"));
}
示例5: InputVisualizer
import com.badlogic.gdx.graphics.VertexAttribute; //导入方法依赖的package包/类
public InputVisualizer() {
eventBuffer = new RingBuffer<MouseEvent>(MAX_EVENTS);
eventPool = new ReflectionPool<MouseEvent>(MouseEvent.class);
shader = new ShaderProgram(
Gdx.files.internal("assets/shaders/visualizer.vert"),
Gdx.files.internal("assets/shaders/visualizer.frag"));
if (!shader.isCompiled()) {
Gdx.app.log("InputVisualizer", shader.getLog());
}
evBufferLoc = shader.getUniformLocation("u_mouseEvs[0]");
projMatrixLoc = shader.getUniformLocation("u_projTrans");
if (evBufferLoc == -1) {
Gdx.app.log("InputVisualizer",
"No uniform with name u_mouseEvents found in shader");
}
mesh = new Mesh(false, 4, 4, VertexAttribute.Position());
addListener(new MouseListener());
}
示例6: buildMeshes
import com.badlogic.gdx.graphics.VertexAttribute; //导入方法依赖的package包/类
public static void buildMeshes() {
if (indices == null) {
int len = 3 * 6 * 6 / 3;
indices = new short[len];
short j = 0;
for (int i = 0; i < len; i += 6, j += 4) {
indices[i + 0] = (short) (j + 0);
indices[i + 1] = (short) (j + 1);
indices[i + 2] = (short) (j + 2);
indices[i + 3] = (short) (j + 2);
indices[i + 4] = (short) (j + 3);
indices[i + 5] = (short) (j + 0);
}
}
for (Voxel v : voxels.values()) {
v.mesh = new Mesh(true, 24, indices.length, VertexAttribute.Position(), VertexAttribute.Normal(), VertexAttribute.ColorPacked(), VertexAttribute.TexCoords(0), VertexAttribute.TexCoords(1));
v.mesh.setIndices(indices);
verts = new FloatArray();
for (Direction d : Direction.values())
new TextureFace(d, new Vector3(), v.getTextureUV(0, 0, 0, d)).getVertexData(verts);
v.mesh.setVertices(verts.items, 0, verts.size);
}
}
示例7: setupMesh
import com.badlogic.gdx.graphics.VertexAttribute; //导入方法依赖的package包/类
private void setupMesh(Model model, MaterialTileMapping textures) {
int numVertices = countModelVertices(model);
vertices = new Vertices(
numVertices,
VertexAttribute.Position(),
VertexAttribute.ColorUnpacked(),
VertexAttribute.Normal(),
VertexAttribute.TexCoords(0)
);
model.calculateBoundingBox(tmpModelBounds);
if (scaleToSize != null) {
MathHelpers.getScaleFactor(tmpModelBounds.getDimensions(), scaleToSize, tmpScaleFactor);
bounds = new BoundingBox().set(Vector3.Zero, scaleToSize);
} else {
bounds = new BoundingBox().set(Vector3.Zero, tmpModelBounds.getDimensions());
tmpScaleFactor.set(1.0f, 1.0f, 1.0f);
}
for (int i = 0; i < model.nodes.size; ++i)
collectModelNodeVertices(model.nodes.get(i), vertices, textures, color, tmpScaleFactor, positionOffset);
}
示例8: create
import com.badlogic.gdx.graphics.VertexAttribute; //导入方法依赖的package包/类
@Override
protected final void create() {
short slices = (short) (4 * Math.cbrt(bottomRadius) + 8);
mesh = new Mesh(true, slices + 2, slices * 6, VertexAttribute.Position());
vertices = new float[(slices + 2) * 3];
float angle = 360f / slices;
int i = 0;
for (int s = 0; s < slices; s++) {
vertices[i++] = bottomRadius * MathUtils.cosDeg(s * angle);
vertices[i++] = -height / 2;
vertices[i++] = bottomRadius * MathUtils.sinDeg(s * angle);
}
vertices[i++] = vertices[i + 2] = 0;
vertices[i++] = -height / 2;
vertices[i + 2] = height / 2;
vertices[i++] = vertices[i + 2] = 0;
indices = new short[slices * 6];
short p = 0;
for (i = 0; i < indices.length - 6; i += 3) {
indices[i++] = indices[i + 2] = p++;
indices[i++] = indices[i + 2] = p;
indices[i++] = indices[i + 2] = slices;
indices[i + 2]++;
}
indices[i++] = indices[i + 2] = p;
indices[i++] = indices[i + 2] = 0;
indices[i++] = indices[i + 2] = slices;
indices[i + 2]++;
super.create();
}
示例9: create
import com.badlogic.gdx.graphics.VertexAttribute; //导入方法依赖的package包/类
@Override
protected final void create() {
mesh = new Mesh(true, 8, 36, VertexAttribute.Position());
vertices = new float[]{
-1.0f, +1.0f, +1.0f, // 0
+1.0f, +1.0f, +1.0f, // 1
+1.0f, -1.0f, +1.0f, // 2
-1.0f, -1.0f, +1.0f, // 3
-1.0f, +1.0f, -1.0f, // 4
+1.0f, +1.0f, -1.0f, // 5
+1.0f, -1.0f, -1.0f, // 6
-1.0f, -1.0f, -1.0f, // 7
};
for (int i = 0; i < vertices.length;) {
vertices[i++] *= width / 2;
vertices[i++] *= height / 2;
vertices[i++] *= depth / 2;
}
indices = new short[]{
0, 1, 2, 0, 2, 3, // front
1, 2, 5, 2, 5, 6, // right
0, 1, 5, 0, 4, 5, // top
4, 5, 6, 4, 6, 7, // back
2, 3, 6, 3, 6, 7, // bottom
0, 3, 4, 3, 4, 7, // left
};
super.create();
}
示例10: create
import com.badlogic.gdx.graphics.VertexAttribute; //导入方法依赖的package包/类
@Override
protected final void create() {
int space = 20;
int VertexCount = ((180 / space) * (360 / space) * 4);
vertices = new float[VertexCount * 3];
float a;
float b;
int i = 0;
// [email protected]
// http://www.swiftless.com/tutorials/opengl/sphere.html
for (b = 0; b <= 180 - space; b += space) {
for (a = 0; a <= 360 - space; a += space) {
vertices[i++] = radius * MathUtils.sinDeg(a) * MathUtils.sinDeg(b);
vertices[i++] = radius * MathUtils.cosDeg(a) * MathUtils.sinDeg(b);
vertices[i++] = radius * MathUtils.cosDeg(b);
vertices[i++] = radius * MathUtils.sinDeg(a) * MathUtils.sinDeg(b + space);
vertices[i++] = radius * MathUtils.cosDeg(a) * MathUtils.sinDeg(b + space);
vertices[i++] = radius * MathUtils.cosDeg(b + space);
vertices[i++] = radius * MathUtils.sinDeg(a + space) * MathUtils.sinDeg(b);
vertices[i++] = radius * MathUtils.cosDeg(a + space) * MathUtils.sinDeg(b);
vertices[i++] = radius * MathUtils.cosDeg(b);
vertices[i++] = radius * MathUtils.sinDeg(a + space) * MathUtils.sinDeg(b + space);
vertices[i++] = radius * MathUtils.cosDeg(a + space) * MathUtils.sinDeg(b + space);
vertices[i++] = radius * MathUtils.cosDeg(b + space);
}
}
mesh = new Mesh(true, VertexCount, 0, VertexAttribute.Position());
indices = new short[0];
super.create();
}
示例11: create
import com.badlogic.gdx.graphics.VertexAttribute; //导入方法依赖的package包/类
@Override
public void create () {
Preferences pref = Gdx.app.getPreferences("test");
boolean resultb = pref.getBoolean("test");
int resulti = pref.getInteger("test");
shader = new ShaderProgram(Gdx.files.internal("data/shaders/shader-vs.glsl"),
Gdx.files.internal("data/shaders/shader-fs.glsl"));
if (!shader.isCompiled()) throw new GdxRuntimeException(shader.getLog());
mesh = new Mesh(VertexDataType.VertexBufferObject, true, 6, 0, VertexAttribute.Position(), VertexAttribute.TexCoords(0));
mesh.setVertices(new float[] {-0.5f, -0.5f, 0, 0, 1, 0.5f, -0.5f, 0, 1, 1, 0.5f, 0.5f, 0, 1, 0, 0.5f, 0.5f, 0, 1, 0, -0.5f,
0.5f, 0, 0, 0, -0.5f, -0.5f, 0, 0, 1});
texture = new Texture(new Pixmap(Gdx.files.internal("data/badlogic.jpg")), true);
texture.setFilter(TextureFilter.MipMap, TextureFilter.Linear);
String params = Gdx.files.internal("data/gwttestparams.txt").readString();
numSprites = Integer.parseInt(params);
batch = new SpriteBatch();
positions = new ArrayList<Vector2>();
for (int i = 0; i < numSprites; i++) {
positions.add(new Vector2(MathUtils.random() * Gdx.graphics.getWidth(), MathUtils.random() * Gdx.graphics.getHeight()));
}
sprite = new Sprite(texture);
sprite.setSize(64, 64);
sprite.setOrigin(32, 32);
font = new BitmapFont(Gdx.files.internal("data/arial-15.fnt"), false);
cache = new BitmapFontCache(font);
cache.setColor(Color.RED);
cache.setMultiLineText("This is a Test", 0, 0);
atlas = new TextureAtlas(Gdx.files.internal("data/pack"));
}
示例12: initVertices
import com.badlogic.gdx.graphics.VertexAttribute; //导入方法依赖的package包/类
@Override
protected void initVertices() {
/** STARS **/
meshes = new MeshData[1];
curr = new MeshData();
meshes[0] = curr;
aux1 = new Vector3();
maxVertices = 3000000;
VertexAttribute[] attribs = buildVertexAttributes();
curr.mesh = new Mesh(false, maxVertices, 0, attribs);
curr.vertices = new float[maxVertices * (curr.mesh.getVertexAttributes().vertexSize / 4)];
curr.vertexSize = curr.mesh.getVertexAttributes().vertexSize / 4;
curr.colorOffset = curr.mesh.getVertexAttribute(Usage.ColorPacked) != null ? curr.mesh.getVertexAttribute(Usage.ColorPacked).offset / 4 : 0;
pmOffset = curr.mesh.getVertexAttribute(Usage.Tangent) != null ? curr.mesh.getVertexAttribute(Usage.Tangent).offset / 4 : 0;
additionalOffset = curr.mesh.getVertexAttribute(Usage.Generic) != null ? curr.mesh.getVertexAttribute(Usage.Generic).offset / 4 : 0;
/** NEBULA **/
// Max of 5000 nebula clouds
int maxQuads = 5000;
int maxQuadVertices = maxQuads * 4;
int maxQuadIndices = maxQuads * 6;
quad = new MeshData();
quad.mesh = new Mesh(false, maxQuadVertices, maxQuadIndices, VertexAttribute.Position(), VertexAttribute.Normal(), VertexAttribute.TexCoords(0), new VertexAttribute(Usage.Generic, 2, "a_additional"));
quad.vertices = new float[maxQuadVertices * (quad.mesh.getVertexAttributes().vertexSize / 4)];
quad.vertexSize = quad.mesh.getVertexAttributes().vertexSize / 4;
quad.indices = new short[maxQuadIndices];
}
示例13: load
import com.badlogic.gdx.graphics.VertexAttribute; //导入方法依赖的package包/类
public void load() {
if (indices == null) {
int len = SIZE * SIZE * SIZE * 6 * 6 / 3;
indices = new short[len];
short j = 0;
for (int i = 0; i < len; i += 6, j += 4) {
indices[i + 0] = (short) (j + 0);
indices[i + 1] = (short) (j + 1);
indices[i + 2] = (short) (j + 2);
indices[i + 3] = (short) (j + 2);
indices[i + 4] = (short) (j + 3);
indices[i + 5] = (short) (j + 0);
}
}
opaque = new Mesh(true, SIZE * SIZE * SIZE * 6 * 4, SIZE * SIZE * SIZE * 36 / 3, VertexAttribute.Position(), VertexAttribute.Normal(), VertexAttribute.ColorPacked(), VertexAttribute.TexCoords(0), VertexAttribute.TexCoords(1) /*
* how
* many
* faces
* together
* ?
*/);
opaque.setIndices(indices);
transp = new Mesh(true, SIZE * SIZE * SIZE * 6 * 4, SIZE * SIZE * SIZE * 36 / 3, VertexAttribute.Position(), VertexAttribute.Normal(), VertexAttribute.ColorPacked(), VertexAttribute.TexCoords(0), VertexAttribute.TexCoords(1) /*
* how
* many
* faces
* together
* ?
*/);
transp.setIndices(indices);
opaqueMeshData = new FloatArray();
transpMeshData = new FloatArray();
loaded = true;
onceLoaded = true;
drawn = false;
}
示例14: genCubeWireframe
import com.badlogic.gdx.graphics.VertexAttribute; //导入方法依赖的package包/类
public static Mesh genCubeWireframe(float size) {
Mesh mesh = new Mesh(true, 24, 36, VertexAttribute.Position(), VertexAttribute.Normal(), VertexAttribute.TexCoords(0), VertexAttribute.TexCoords(1) /*
* how
* many
* faces
* together
* ?
*/);
float[] cubeVerts = { 0, 0, 0, 0, 0, size, 0, 0, size, 0, size, size, 0, size, size, 0, size, 0, 0, size, 0, 0, 0, 0, size, 0, 0, size, 0, size, size, 0, size, size, size, size, size, size, size, size, size, 0, size, size, 0, size, 0, 0, size, 0, 0, 0, 0, 0, size, size, 0, 0, size, 0, size, 0, size, 0, 0, size, size, size, size, 0, size, size, };
float[] vertices = new float[cubeVerts.length / 3 * 10];
int pIdx = 0;
for (int i = 0; i < vertices.length;) {
vertices[i++] = cubeVerts[pIdx++];
vertices[i++] = cubeVerts[pIdx++];
vertices[i++] = cubeVerts[pIdx++];
vertices[i++] = 0;
vertices[i++] = 1;
vertices[i++] = 0;
vertices[i++] = 0;
vertices[i++] = 0;
vertices[i++] = 1;
vertices[i++] = 1;
}
mesh.setVertices(vertices);
return mesh;
}
示例15: ao
import com.badlogic.gdx.graphics.VertexAttribute; //导入方法依赖的package包/类
public ao()
{
float[] arrayOfFloat = { -10.0F, -10.0F, 0.5F, -10.0F, 10.0F, 0.5F, 10.0F, 10.0F, 0.5F, -10.0F, -10.0F, 0.5F, 10.0F, -10.0F, 0.5F, 10.0F, 10.0F, 0.5F };
VertexAttribute[] arrayOfVertexAttribute = new VertexAttribute[1];
arrayOfVertexAttribute[0] = VertexAttribute.Position();
this.n = new ai(arrayOfFloat, new VertexAttributes(arrayOfVertexAttribute));
}