当前位置: 首页>>代码示例>>Java>>正文


Java VertexAttributes类代码示例

本文整理汇总了Java中com.badlogic.gdx.graphics.VertexAttributes的典型用法代码示例。如果您正苦于以下问题:Java VertexAttributes类的具体用法?Java VertexAttributes怎么用?Java VertexAttributes使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


VertexAttributes类属于com.badlogic.gdx.graphics包,在下文中一共展示了VertexAttributes类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: create

import com.badlogic.gdx.graphics.VertexAttributes; //导入依赖的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();
}
 
开发者ID:game-libgdx-unity,项目名称:GDX-Engine,代码行数:27,代码来源:TestCamera.java

示例2: createPrefix

import com.badlogic.gdx.graphics.VertexAttributes; //导入依赖的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;
}
 
开发者ID:MovementSpeed,项目名称:nhglib,代码行数:19,代码来源:DepthMapShader.java

示例3: create

import com.badlogic.gdx.graphics.VertexAttributes; //导入依赖的package包/类
@Override
public void create() {
    super.create();

    geometryPass = new ShaderProgram(
            Gdx.files.internal("shaders/g_buffer.vert"),
            Gdx.files.internal("shaders/g_buffer.frag"));

    lightingPass = new ShaderProgram(
            Gdx.files.internal("shaders/deferred_shader.vert"),
            Gdx.files.internal("shaders/deferred_shader.frag"));

    ModelBuilder mb = new ModelBuilder();
    Model cube = mb.createBox(1, 1, 1, new Material(),
            VertexAttributes.Usage.Position |
                    VertexAttributes.Usage.Normal |
                    VertexAttributes.Usage.TextureCoordinates);
    cubeMesh = cube.meshes.first();
}
 
开发者ID:MovementSpeed,项目名称:nhglib,代码行数:20,代码来源:MainDef.java

示例4: getAttributeLocations

import com.badlogic.gdx.graphics.VertexAttributes; //导入依赖的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;
}
 
开发者ID:PWorlds,项目名称:LibGDX-PBR,代码行数:19,代码来源:PBRShader.java

示例5: makeMesh

import com.badlogic.gdx.graphics.VertexAttributes; //导入依赖的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();
}
 
开发者ID:Osaris31,项目名称:exterminate,代码行数:23,代码来源:Ground.java

示例6: SimulationRunner

import com.badlogic.gdx.graphics.VertexAttributes; //导入依赖的package包/类
public SimulationRunner() {
    logger.info("Loading models");
    ModelBuilder builder = new ModelBuilder();
    models.put("box", builder.createBox(5f, 5f, 5f,
            new Material(ColorAttribute.createDiffuse(new Color(0.8f, 0f, 0f, 0f))),
            VertexAttributes.Usage.Position | VertexAttributes.Usage.Normal));

    G3dModelLoader loader = new G3dModelLoader(new JsonReader());
    models.put("hub", loader.loadModel(Gdx.files.internal("data/hubreal.g3dj")));
    models.put("rim", loader.loadModel(Gdx.files.internal("data/rimreal.g3dj")));
    models.put("spoke", loader.loadModel(Gdx.files.internal("data/spoke.g3dj")));


    Bullet.init();
    logger.info("Initialized Bullet");
}
 
开发者ID:Matsemann,项目名称:eamaster,代码行数:17,代码来源:SimulationRunner.java

示例7: Terrain

import com.badlogic.gdx.graphics.VertexAttributes; //导入依赖的package包/类
private Terrain(int vertexResolution) {
    this.transform = new Matrix4();
    this.attribs = MeshBuilder.createAttributes(VertexAttributes.Usage.Position | VertexAttributes.Usage.Normal
            | VertexAttributes.Usage.TextureCoordinates);
    this.posPos = attribs.getOffset(VertexAttributes.Usage.Position, -1);
    this.norPos = attribs.getOffset(VertexAttributes.Usage.Normal, -1);
    this.uvPos = attribs.getOffset(VertexAttributes.Usage.TextureCoordinates, -1);
    this.stride = attribs.vertexSize / 4;

    this.vertexResolution = vertexResolution;
    this.heightData = new float[vertexResolution * vertexResolution];

    this.terrainTexture = new TerrainTexture();
    this.terrainTexture.setTerrain(this);
    material = new Material();
    material.set(new TerrainTextureAttribute(TerrainTextureAttribute.ATTRIBUTE_SPLAT0, terrainTexture));
}
 
开发者ID:mbrlabs,项目名称:Mundus,代码行数:18,代码来源:Terrain.java

示例8: createAxes

import com.badlogic.gdx.graphics.VertexAttributes; //导入依赖的package包/类
public static Model createAxes() {
    final float GRID_MIN = -10f;
    final float GRID_MAX = 10f;
    final float GRID_STEP = 1f;
    ModelBuilder modelBuilder = new ModelBuilder();
    modelBuilder.begin();
    MeshPartBuilder builder = modelBuilder.part("grid", GL20.GL_LINES,
            VertexAttributes.Usage.Position | VertexAttributes.Usage.ColorUnpacked, new Material());
    builder.setColor(Color.LIGHT_GRAY);
    for (float t = GRID_MIN; t <= GRID_MAX; t += GRID_STEP) {
        builder.line(t, 0, GRID_MIN, t, 0, GRID_MAX);
        builder.line(GRID_MIN, 0, t, GRID_MAX, 0, t);
    }
    builder = modelBuilder.part("axes", GL20.GL_LINES,
            VertexAttributes.Usage.Position | VertexAttributes.Usage.ColorUnpacked, new Material());
    builder.setColor(Color.RED);
    builder.line(0, 0, 0, 100, 0, 0);
    builder.setColor(Color.GREEN);
    builder.line(0, 0, 0, 0, 100, 0);
    builder.setColor(Color.BLUE);
    builder.line(0, 0, 0, 0, 0, 100);
    return modelBuilder.end();
}
 
开发者ID:mbrlabs,项目名称:Mundus,代码行数:24,代码来源:UsefulMeshs.java

示例9: ScaleTool

import com.badlogic.gdx.graphics.VertexAttributes; //导入依赖的package包/类
public ScaleTool(ProjectManager projectManager, GameObjectPicker goPicker, ToolHandlePicker handlePicker,
        ShapeRenderer shapeRenderer, ModelBatch batch, CommandHistory history) {
    super(projectManager, goPicker, handlePicker, batch, history);

    this.shapeRenderer = shapeRenderer;

    ModelBuilder modelBuilder = new ModelBuilder();
    Model xPlaneHandleModel = UsefulMeshs.createArrowStub(new Material(ColorAttribute.createDiffuse(COLOR_X)),
            Vector3.Zero, new Vector3(15, 0, 0));
    Model yPlaneHandleModel = UsefulMeshs.createArrowStub(new Material(ColorAttribute.createDiffuse(COLOR_Y)),
            Vector3.Zero, new Vector3(0, 15, 0));
    Model zPlaneHandleModel = UsefulMeshs.createArrowStub(new Material(ColorAttribute.createDiffuse(COLOR_Z)),
            Vector3.Zero, new Vector3(0, 0, 15));
    Model xyzPlaneHandleModel = modelBuilder.createBox(3, 3, 3,
            new Material(ColorAttribute.createDiffuse(COLOR_XYZ)),
            VertexAttributes.Usage.Position | VertexAttributes.Usage.Normal);

    xHandle = new ScaleHandle(X_HANDLE_ID, xPlaneHandleModel);
    yHandle = new ScaleHandle(Y_HANDLE_ID, yPlaneHandleModel);
    zHandle = new ScaleHandle(Z_HANDLE_ID, zPlaneHandleModel);
    xyzHandle = new ScaleHandle(XYZ_HANDLE_ID, xyzPlaneHandleModel);

    handles = new ScaleHandle[] { xHandle, yHandle, zHandle, xyzHandle };
}
 
开发者ID:mbrlabs,项目名称:Mundus,代码行数:25,代码来源:ScaleTool.java

示例10: createVertexVectors

import com.badlogic.gdx.graphics.VertexAttributes; //导入依赖的package包/类
/**
 * Creates Vector3 objects from the vertices of the mesh. The resulting array follows the ordering of the provided
 * index array.
 *
 * @param mesh
 * @param indices
 * @return
 */
private static Vector3[] createVertexVectors(Mesh mesh, short[] indices) {
	FloatBuffer verticesBuffer = mesh.getVerticesBuffer();
	int positionOffset = mesh.getVertexAttributes().findByUsage(VertexAttributes.Usage.Position).offset / 4;
	int vertexSize = mesh.getVertexSize() / 4;
	Vector3[] vertexVectors = new Vector3[mesh.getNumIndices()];
	for (int i = 0; i < indices.length; i++) {
		short index = indices[i];
		int a = index * vertexSize + positionOffset;
		float x = verticesBuffer.get(a++);
		float y = verticesBuffer.get(a++);
		float z = verticesBuffer.get(a);
		vertexVectors[index] = new Vector3(x, y, z);
	}
	return vertexVectors;
}
 
开发者ID:jsjolund,项目名称:GdxDemo3D,代码行数:24,代码来源:NavMeshGraph.java

示例11: initialize

import com.badlogic.gdx.graphics.VertexAttributes; //导入依赖的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);
}
 
开发者ID:basherone,项目名称:libgdxcn,代码行数:23,代码来源:DecalBatch.java

示例12: createAttributes

import com.badlogic.gdx.graphics.VertexAttributes; //导入依赖的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);
}
 
开发者ID:basherone,项目名称:libgdxcn,代码行数:19,代码来源:MeshBuilder.java

示例13: create

import com.badlogic.gdx.graphics.VertexAttributes; //导入依赖的package包/类
@Override
public void create () {
	String vertexShader = "attribute vec4 a_position;    \n" + "attribute vec4 a_color;\n" + "attribute vec2 a_texCoords;\n"
		+ "varying vec4 v_color;" + "varying vec2 v_texCoords;" + "void main()                  \n"
		+ "{                            \n" + "   v_color = vec4(a_color.x, a_color.y, a_color.z, 1); \n"
		+ "   v_texCoords = a_texCoords; \n" + "   gl_Position =  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);
	vbo = new VertexBufferObject(true, 3, new VertexAttribute(VertexAttributes.Usage.Position, 2, "a_position"),
		new VertexAttribute(VertexAttributes.Usage.TextureCoordinates, 2, "a_texCoords"), new VertexAttribute(
			VertexAttributes.Usage.ColorPacked, 4, "a_color"));
	float[] vertices = new float[] {-1, -1, 0, 0, Color.toFloatBits(1f, 0f, 0f, 1f), 0, 1, 0.5f, 1.0f,
		Color.toFloatBits(0f, 1f, 0f, 1f), 1, -1, 1, 0, Color.toFloatBits(0f, 0f, 1f, 1f)};
	vbo.setVertices(vertices, 0, vertices.length);

	ibo = new IndexBufferObject(true, 3);
	ibo.setIndices(new short[] {0, 1, 2}, 0, 3);

	texture = new Texture(Gdx.files.internal("data/badlogic.jpg"));
}
 
开发者ID:basherone,项目名称:libgdxcn,代码行数:25,代码来源:IndexBufferObjectShaderTest.java

示例14: TileHighlightDisplayable

import com.badlogic.gdx.graphics.VertexAttributes; //导入依赖的package包/类
public TileHighlightDisplayable() {
  ModelBuilder modelBuilder = new ModelBuilder();

  Model model
      = modelBuilder.createRect(0, 0, Z_OFFSET,
                                1, 0, Z_OFFSET,
                                1, 1, Z_OFFSET,
                                0, 1, Z_OFFSET,
                                0, 0, 1,
                                GL20.GL_TRIANGLES,
                                new Material(
                                    new ColorAttribute(
                                        ColorAttribute.createDiffuse(color)),
                                    new BlendingAttribute(
                                        GL20.GL_SRC_ALPHA,
                                        GL20.GL_ONE_MINUS_SRC_ALPHA)),
                                VertexAttributes.Usage.Position |
                                VertexAttributes.Usage.TextureCoordinates);

  instance = new ModelInstance(model);
}
 
开发者ID:fauu,项目名称:HelixEngine,代码行数:22,代码来源:TileHighlightDisplayable.java

示例15: createAttributes

import com.badlogic.gdx.graphics.VertexAttributes; //导入依赖的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.ColorUnpacked) == Usage.ColorUnpacked)
        attrs.add(new VertexAttribute(Usage.ColorUnpacked, 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);
}
 
开发者ID:langurmonkey,项目名称:gaiasky,代码行数:20,代码来源:MeshBuilder2.java


注:本文中的com.badlogic.gdx.graphics.VertexAttributes类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。