本文整理汇总了Java中com.badlogic.gdx.graphics.VertexAttribute.TexCoords方法的典型用法代码示例。如果您正苦于以下问题:Java VertexAttribute.TexCoords方法的具体用法?Java VertexAttribute.TexCoords怎么用?Java VertexAttribute.TexCoords使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.badlogic.gdx.graphics.VertexAttribute
的用法示例。
在下文中一共展示了VertexAttribute.TexCoords方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: 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);
}
}
示例6: 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);
}
示例7: 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"));
}
示例8: 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];
}
示例9: 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;
}
示例10: 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;
}
示例11: loadRenderModel
import com.badlogic.gdx.graphics.VertexAttribute; //导入方法依赖的package包/类
private Model loadRenderModel(String name) {
if (models.containsKey(name)) return models.get(name);
// FIXME we load the models synchronously cause we are lazy
int error = 0;
PointerBuffer modelPointer = PointerBuffer.allocateDirect(1);
while (true) {
error = VRRenderModels.VRRenderModels_LoadRenderModel_Async(name, modelPointer);
if (error != VR.EVRRenderModelError_VRRenderModelError_Loading) break;
}
if (error != VR.EVRRenderModelError_VRRenderModelError_None) return null;
RenderModel renderModel = new RenderModel(modelPointer.getByteBuffer(RenderModel.SIZEOF));
error = 0;
PointerBuffer texturePointer = PointerBuffer.allocateDirect(1);
while (true) {
error = VRRenderModels.VRRenderModels_LoadTexture_Async(renderModel.diffuseTextureId(), texturePointer);
if (error != VR.EVRRenderModelError_VRRenderModelError_Loading) break;
}
if (error != VR.EVRRenderModelError_VRRenderModelError_None) {
VRRenderModels.VRRenderModels_FreeRenderModel(renderModel);
return null;
}
RenderModelTextureMap renderModelTexture = new RenderModelTextureMap(texturePointer.getByteBuffer(RenderModelTextureMap.SIZEOF));
// convert to a Model
Mesh mesh = new Mesh(true, renderModel.unVertexCount(), renderModel.unTriangleCount() * 3, VertexAttribute.Position(), VertexAttribute.Normal(), VertexAttribute.TexCoords(0));
MeshPart meshPart = new MeshPart(name, mesh, 0, renderModel.unTriangleCount() * 3, GL20.GL_TRIANGLES);
RenderModelVertex.Buffer vertices = renderModel.rVertexData();
float[] packedVertices = new float[8 * renderModel.unVertexCount()];
int i = 0;
while(vertices.remaining() > 0) {
RenderModelVertex v = vertices.get();
packedVertices[i++] = v.vPosition().v(0);
packedVertices[i++] = v.vPosition().v(1);
packedVertices[i++] = v.vPosition().v(2);
packedVertices[i++] = v.vNormal().v(0);
packedVertices[i++] = v.vNormal().v(1);
packedVertices[i++] = v.vNormal().v(2);
packedVertices[i++] = v.rfTextureCoord().get(0);
packedVertices[i++] = v.rfTextureCoord().get(1);
}
mesh.setVertices(packedVertices);
short[] indices = new short[renderModel.unTriangleCount() * 3];
renderModel.IndexData().get(indices);
mesh.setIndices(indices);
Pixmap pixmap = new Pixmap(renderModelTexture.unWidth(), renderModelTexture.unHeight(), Format.RGBA8888);
byte[] pixels = new byte[renderModelTexture.unWidth() * renderModelTexture.unHeight() * 4];
renderModelTexture.rubTextureMapData(pixels.length).get(pixels);
pixmap.getPixels().put(pixels);
pixmap.getPixels().position(0);
Texture texture = new Texture(new PixmapTextureData(pixmap, pixmap.getFormat(), true, true));
Material material = new Material(new TextureAttribute(TextureAttribute.Diffuse, texture));
Model model = new Model();
model.meshes.add(mesh);
model.meshParts.add(meshPart);
model.materials.add(material);
Node node = new Node();
node.id = name;
node.parts.add(new NodePart(meshPart, material));
model.nodes.add(node);
model.manageDisposable(mesh);
model.manageDisposable(texture);
VRRenderModels.VRRenderModels_FreeRenderModel(renderModel);
VRRenderModels.VRRenderModels_FreeTexture(renderModelTexture);
models.put(name, model);
return model;
}
示例12: genCube
import com.badlogic.gdx.graphics.VertexAttribute; //导入方法依赖的package包/类
public static Mesh genCube(float size, float texX, float texY, float texSize) {
Mesh mesh = new Mesh(true, 24, 36, VertexAttribute.Position(), VertexAttribute.Normal(), VertexAttribute.ColorPacked(), VertexAttribute.TexCoords(0), VertexAttribute.TexCoords(1) /*
* how
* many
* faces
* together
* ?
*/);
float[] cubeVerts = { 0, 0, 0, 0, 0, size, size, 0, size, size, 0, 0, 0, size, 0, 0, size, size, size, size, size, size, size, 0, 0, 0, 0, 0, size, 0, size, size, 0, size, 0, 0, 0, 0, size, 0, size, size, size, size, size, size, 0, size, 0, 0, 0, 0, 0, size, 0, size, size, 0, size, 0, size, 0, 0, size, 0, size, size, size, size, size, size, 0, };
float[] cubeNormals = { 0.0f, -1.0f, 0.0f, 0.0f, -1.0f, 0.0f, 0.0f, -1.0f, 0.0f, 0.0f, -1.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 0.0f, -1.0f, 0.0f, 0.0f, -1.0f, 0.0f, 0.0f, -1.0f, 0.0f, 0.0f, -1.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 1.0f, -1.0f, 0.0f, 0.0f, -1.0f, 0.0f, 0.0f, -1.0f, 0.0f, 0.0f, -1.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, };
float[] cubeTex = { 0.0f, 0.0f, 0.0f, 1.0f, 1.0f, 1.0f, 1.0f, 0.0f, 1.0f, 0.0f, 1.0f, 1.0f, 0.0f, 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 1.0f, 1.0f, 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 1.0f, 1.0f, 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 1.0f, 1.0f, 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 1.0f, 1.0f, 1.0f, 0.0f, };
float b = Color.toFloatBits(1f, 1f, 1f, 1f);
float[] vertices = new float[24 * 11];
int pIdx = 0;
int nIdx = 0;
int tIdx = 0;
for (int i = 0; i < vertices.length;) {
vertices[i++] = cubeVerts[pIdx++];
vertices[i++] = cubeVerts[pIdx++];
vertices[i++] = cubeVerts[pIdx++];
vertices[i++] = cubeNormals[nIdx++];
vertices[i++] = cubeNormals[nIdx++];
vertices[i++] = cubeNormals[nIdx++];
vertices[i++] = b;
vertices[i++] = cubeTex[tIdx++] * texSize + texX;
vertices[i++] = cubeTex[tIdx++] * texSize + texY;
vertices[i++] = 1;
vertices[i++] = 1;
}
short[] indices = { 0, 2, 1, 0, 3, 2, 4, 5, 6, 4, 6, 7, 8, 9, 10, 8, 10, 11, 12, 15, 14, 12, 14, 13, 16, 17, 18, 16, 18, 19, 20, 23, 22, 20, 22, 21 };
mesh.setVertices(vertices);
mesh.setIndices(indices);
return mesh;
}