本文整理汇总了Java中com.badlogic.gdx.graphics.VertexAttribute类的典型用法代码示例。如果您正苦于以下问题:Java VertexAttribute类的具体用法?Java VertexAttribute怎么用?Java VertexAttribute使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
VertexAttribute类属于com.badlogic.gdx.graphics包,在下文中一共展示了VertexAttribute类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: unbind
import com.badlogic.gdx.graphics.VertexAttribute; //导入依赖的package包/类
public void unbind()
{
GL11 localGL11 = Gdx.gl11;
int i = this.attributes.size();
int j = 0;
int k = 0;
if (j < i)
{
VertexAttribute localVertexAttribute = this.attributes.get(j);
switch (localVertexAttribute.usage)
{
case 4:
default:
throw new GdxRuntimeException("unkown vertex attribute type: " + localVertexAttribute.usage);
case 1:
case 5:
localGL11.glDisableClientState(32886);
case 0:
case 2:
case 3:
}
while (true)
{
j++;
break;
localGL11.glDisableClientState(32885);
continue;
localGL11.glClientActiveTexture(33984 + k);
localGL11.glDisableClientState(32888);
k++;
}
}
localGL11.glBindBuffer(34962, 0);
this.isBound = false;
}
示例2: create
import com.badlogic.gdx.graphics.VertexAttribute; //导入依赖的package包/类
@Override
public void create() {
rotationSpeed = 0.5f;
mesh = new Mesh(true, 4, 6,
new VertexAttribute(VertexAttributes.Usage.Position, 3,"attr_Position"),
new VertexAttribute(Usage.TextureCoordinates, 2, "attr_texCoords"));
texture = new Texture(Gdx.files.internal("data/Jellyfish.jpg"));
mesh.setVertices(new float[] {
-1024f, -1024f, 0, 0, 1,
1024f, -1024f, 0, 1, 1,
1024f, 1024f, 0, 1, 0,
-1024f, 1024f, 0, 0, 0
});
mesh.setIndices(new short[] { 0, 1, 2, 2, 3, 0 });
cam = new OrthographicCamera(Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
xScale = Gdx.graphics.getWidth()/(float)TARGET_WIDTH;
yScale = Gdx.graphics.getHeight()/(float)TARGET_HEIGHT;
font = loadBitmapFont("default.fnt", "default.png");
scale = Math.min(xScale, yScale);
cam.zoom = 1/scale;
// cam.project(start_position);
cam.position.set(0, 0, 0);
batch = new SpriteBatch();
}
示例3: ShaderEffect
import com.badlogic.gdx.graphics.VertexAttribute; //导入依赖的package包/类
/**
* Instantiates a new ShaderEffect. The ShaderEffect will NOT own shader
* program, so it will not dispose it either!
*
* @param program
* the ShaderProgram to use for this effect
*/
public ShaderEffect(ShaderProgram program) {
this.program = program;
if (meshRefCount++ <= 0) {
mesh = new Mesh(VertexDataType.VertexArray, true, 4, 0,
new VertexAttribute(Usage.Position, 2, ShaderProgram.POSITION_ATTRIBUTE),
new VertexAttribute(Usage.TextureCoordinates, 2, ShaderProgram.TEXCOORD_ATTRIBUTE + "0"));
// @formatter:off
float[] verts = {
// vertex texture
-1, -1, 0f, 0f,
1, -1, 1f, 0f,
1, 1, 1f, 1f,
-1, 1, 0f, 1f,
};
// @formatter:on
mesh.setVertices(verts);
}
}
示例4: createPrefix
import com.badlogic.gdx.graphics.VertexAttribute; //导入依赖的package包/类
private String createPrefix(Renderable renderable) {
String prefix = "";
if (params.useBones) {
prefix += "#define numBones " + 12 + "\n";
final int n = renderable.meshPart.mesh.getVertexAttributes().size();
for (int i = 0; i < n; i++) {
final VertexAttribute attr = renderable.meshPart.mesh.getVertexAttributes().get(i);
if (attr.usage == VertexAttributes.Usage.BoneWeight) {
prefix += "#define boneWeight" + attr.unit + "Flag\n";
}
}
}
return prefix;
}
示例5: getAttributeLocations
import com.badlogic.gdx.graphics.VertexAttribute; //导入依赖的package包/类
protected final int[] getAttributeLocations(Renderable renderable) {
final IntIntMap attributes = new IntIntMap();
final VertexAttributes attrs = renderable.meshPart.mesh.getVertexAttributes();
final int c = attrs.size();
for (int i = 0; i < c; i++) {
final VertexAttribute attr = attrs.get(i);
final int location = program.getAttributeLocation(attr.alias);
if (location >= 0)
attributes.put(attr.getKey(), location);
}
tempArray.clear();
final int n = attrs.size();
for (int i = 0; i < n; i++) {
tempArray.add(attributes.get(attrs.get(i).getKey(), -1));
}
return tempArray.items;
}
示例6: 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();
}
示例7: PositionalLight
import com.badlogic.gdx.graphics.VertexAttribute; //导入依赖的package包/类
public PositionalLight (RayHandler rayHandler, int rays, Color color, float distance, float x, float y, float directionDegree) {
super(rayHandler, rays, color, directionDegree, distance);
start.x = x;
start.y = y;
sin = new float[rays];
cos = new float[rays];
endX = new float[rays];
endY = new float[rays];
lightMesh = new Mesh(VertexDataType.VertexArray, false, vertexNum, 0, new VertexAttribute(Usage.Position, 2,
"vertex_positions"), new VertexAttribute(Usage.ColorPacked, 4, "quad_colors"),
new VertexAttribute(Usage.Generic, 1, "s"));
softShadowMesh = new Mesh(VertexDataType.VertexArray, false, vertexNum * 2, 0, new VertexAttribute(Usage.Position, 2,
"vertex_positions"), new VertexAttribute(Usage.ColorPacked, 4, "quad_colors"),
new VertexAttribute(Usage.Generic, 1, "s"));
setMesh();
}
示例8: DirectionalLight
import com.badlogic.gdx.graphics.VertexAttribute; //导入依赖的package包/类
/** Directional lights simulate light source that locations is at infinite distance. Direction and intensity is same everywhere.
* -90 direction is straight from up.
*
* @param rayHandler
* @param rays
* @param color
* @param directionDegree */
public DirectionalLight (RayHandler rayHandler, int rays, Color color, float directionDegree) {
super(rayHandler, rays, color, directionDegree, Float.POSITIVE_INFINITY);
vertexNum = (vertexNum - 1) * 2;
start = new Vector2[rayNum];
end = new Vector2[rayNum];
for (int i = 0; i < rayNum; i++) {
start[i] = new Vector2();
end[i] = new Vector2();
}
setDirection(direction);
lightMesh = new Mesh(VertexDataType.VertexArray, staticLight, vertexNum, 0, new VertexAttribute(Usage.Position, 2,
"vertex_positions"), new VertexAttribute(Usage.ColorPacked, 4, "quad_colors"),
new VertexAttribute(Usage.Generic, 1, "s"));
softShadowMesh = new Mesh(VertexDataType.VertexArray, staticLight, vertexNum, 0, new VertexAttribute(Usage.Position, 2,
"vertex_positions"), new VertexAttribute(Usage.ColorPacked, 4, "quad_colors"),
new VertexAttribute(Usage.Generic, 1, "s"));
update();
}
示例9: RavChainLight
import com.badlogic.gdx.graphics.VertexAttribute; //导入依赖的package包/类
/** Creates chain light from specified vertices
*
* @param rayHandler not {@code null} instance of RayHandler
* @param rays number of rays - more rays make light to look more realistic but will decrease performance, can't be less than
* MIN_RAYS
* @param color color, set to {@code null} to use the default color
* @param distance distance of light
* @param rayDirection direction of rays
* <ul>
* <li>1 = left</li>
* <li>-1 = right</li>
* </ul>
* @param chain float array of (x, y) vertices from which rays will be evenly distributed */
public RavChainLight (RayHandler rayHandler, int rays, Color color, float distance, int rayDirection, float[] chain) {
super(rayHandler, rays, color, distance, 0f);
rayStartOffset = ChainLight.defaultRayStartOffset;
this.rayDirection = rayDirection;
vertexNum = (vertexNum - 1) * 2;
endX = new float[rays];
endY = new float[rays];
startX = new float[rays];
startY = new float[rays];
this.chain = (chain != null) ? new FloatArray(chain) : new FloatArray();
lightMesh = new Mesh(VertexDataType.VertexArray, false, vertexNum, 0,
new VertexAttribute(Usage.Position, 2, "vertex_positions"), new VertexAttribute(Usage.ColorPacked, 4, "quad_colors"),
new VertexAttribute(Usage.Generic, 1, "s"));
softShadowMesh = new Mesh(VertexDataType.VertexArray, false, vertexNum * 2, 0,
new VertexAttribute(Usage.Position, 2, "vertex_positions"), new VertexAttribute(Usage.ColorPacked, 4, "quad_colors"),
new VertexAttribute(Usage.Generic, 1, "s"));
setMesh();
}
示例10: 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);
}
示例11: 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;
}
示例12: ImmediateModeRenderer20
import com.badlogic.gdx.graphics.VertexAttribute; //导入依赖的package包/类
public ImmediateModeRenderer20 (int maxVertices, boolean hasNormals, boolean hasColors, int numTexCoords, ShaderProgram shader) {
this.maxVertices = maxVertices;
this.numTexCoords = numTexCoords;
this.shader = shader;
VertexAttribute[] attribs = buildVertexAttributes(hasNormals, hasColors, numTexCoords);
mesh = new Mesh(false, maxVertices, 0, attribs);
vertices = new float[maxVertices * (mesh.getVertexAttributes().vertexSize / 4)];
vertexSize = mesh.getVertexAttributes().vertexSize / 4;
normalOffset = mesh.getVertexAttribute(Usage.Normal) != null ? mesh.getVertexAttribute(Usage.Normal).offset / 4 : 0;
colorOffset = mesh.getVertexAttribute(Usage.ColorPacked) != null ? mesh.getVertexAttribute(Usage.ColorPacked).offset / 4
: 0;
texCoordOffset = mesh.getVertexAttribute(Usage.TextureCoordinates) != null ? mesh
.getVertexAttribute(Usage.TextureCoordinates).offset / 4 : 0;
shaderUniformNames = new String[numTexCoords];
for (int i = 0; i < numTexCoords; i++) {
shaderUniformNames[i] = "u_sampler" + i;
}
}
示例13: canRender
import com.badlogic.gdx.graphics.VertexAttribute; //导入依赖的package包/类
@Override
public boolean canRender (Renderable renderable) {
if (renderable.material.has(BlendingAttribute.Type)) {
if ((materialMask & BlendingAttribute.Type) != BlendingAttribute.Type)
return false;
if (renderable.material.has(TextureAttribute.Diffuse) != ((materialMask & TextureAttribute.Diffuse) == TextureAttribute.Diffuse))
return false;
}
final boolean skinned = ((renderable.mesh.getVertexAttributes().getMask() & Usage.BoneWeight) == Usage.BoneWeight);
if (skinned != (numBones > 0)) return false;
if (!skinned) return true;
int w = 0;
final int n = renderable.mesh.getVertexAttributes().size();
for (int i = 0; i < n; i++) {
final VertexAttribute attr = renderable.mesh.getVertexAttributes().get(i);
if (attr.usage == Usage.BoneWeight) w |= (1 << attr.unit);
}
return w == weights;
}
示例14: initialize
import com.badlogic.gdx.graphics.VertexAttribute; //导入依赖的package包/类
/** Initializes the batch with the given amount of decal objects the buffer is able to hold when full.
*
* @param size Maximum size of decal objects to hold in memory */
public void initialize (int size) {
vertices = new float[size * Decal.SIZE];
mesh = new Mesh(Mesh.VertexDataType.VertexArray, false, size * 4, size * 6, new VertexAttribute(
VertexAttributes.Usage.Position, 3, ShaderProgram.POSITION_ATTRIBUTE), new VertexAttribute(
VertexAttributes.Usage.ColorPacked, 4, ShaderProgram.COLOR_ATTRIBUTE), new VertexAttribute(
VertexAttributes.Usage.TextureCoordinates, 2, ShaderProgram.TEXCOORD_ATTRIBUTE + "0"));
short[] indices = new short[size * 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);
}
示例15: createAttributes
import com.badlogic.gdx.graphics.VertexAttribute; //导入依赖的package包/类
/** @param usage bitwise mask of the {@link com.badlogic.gdx.graphics.VertexAttributes.Usage}, only Position, Color, Normal and
* TextureCoordinates is supported. */
public static VertexAttributes createAttributes (long usage) {
final Array<VertexAttribute> attrs = new Array<VertexAttribute>();
if ((usage & Usage.Position) == Usage.Position)
attrs.add(new VertexAttribute(Usage.Position, 3, ShaderProgram.POSITION_ATTRIBUTE));
if ((usage & Usage.Color) == Usage.Color) attrs.add(new VertexAttribute(Usage.Color, 4, ShaderProgram.COLOR_ATTRIBUTE));
if ((usage & Usage.ColorPacked) == Usage.ColorPacked)
attrs.add(new VertexAttribute(Usage.ColorPacked, 4, ShaderProgram.COLOR_ATTRIBUTE));
if ((usage & Usage.Normal) == Usage.Normal)
attrs.add(new VertexAttribute(Usage.Normal, 3, ShaderProgram.NORMAL_ATTRIBUTE));
if ((usage & Usage.TextureCoordinates) == Usage.TextureCoordinates)
attrs.add(new VertexAttribute(Usage.TextureCoordinates, 2, ShaderProgram.TEXCOORD_ATTRIBUTE + "0"));
final VertexAttribute attributes[] = new VertexAttribute[attrs.size];
for (int i = 0; i < attributes.length; i++)
attributes[i] = attrs.get(i);
return new VertexAttributes(attributes);
}