java类com.badlogic.gdx.graphics.VertexAttributes的实例源码

TestCamera.java 文件源码 项目:GDX-Engine 阅读 21 收藏 0 点赞 0 评论 0
@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();
}
DepthMapShader.java 文件源码 项目:nhglib 阅读 22 收藏 0 点赞 0 评论 0
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;
}
MainDef.java 文件源码 项目:nhglib 阅读 19 收藏 0 点赞 0 评论 0
@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();
}
PBRShader.java 文件源码 项目:LibGDX-PBR 阅读 27 收藏 0 点赞 0 评论 0
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;
}
PBRSadherTexture.java 文件源码 项目:LibGDX-PBR 阅读 23 收藏 0 点赞 0 评论 0
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;
}
Ground.java 文件源码 项目:exterminate 阅读 30 收藏 0 点赞 0 评论 0
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();
}
SimulationRunner.java 文件源码 项目:eamaster 阅读 29 收藏 0 点赞 0 评论 0
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");
}
Terrain.java 文件源码 项目:Mundus 阅读 27 收藏 0 点赞 0 评论 0
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));
}
UsefulMeshs.java 文件源码 项目:Mundus 阅读 20 收藏 0 点赞 0 评论 0
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();
}
ScaleTool.java 文件源码 项目:Mundus 阅读 21 收藏 0 点赞 0 评论 0
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 };
}
NavMeshGraph.java 文件源码 项目:GdxDemo3D 阅读 22 收藏 0 点赞 0 评论 0
/**
 * 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;
}
DecalBatch.java 文件源码 项目:libgdxcn 阅读 20 收藏 0 点赞 0 评论 0
/** 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);
}
MeshBuilder.java 文件源码 项目:libgdxcn 阅读 20 收藏 0 点赞 0 评论 0
/** @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);
}
IndexBufferObjectShaderTest.java 文件源码 项目:libgdxcn 阅读 22 收藏 0 点赞 0 评论 0
@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"));
}
TileHighlightDisplayable.java 文件源码 项目:HelixEngine 阅读 26 收藏 0 点赞 0 评论 0
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);
}
MeshBuilder2.java 文件源码 项目:gaiasky 阅读 28 收藏 0 点赞 0 评论 0
/** @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);
}
LibraryTest.java 文件源码 项目:libgdx-opencl 阅读 19 收藏 0 点赞 0 评论 0
@Override
public void create ()
{
    // Init camera
    this.camera = new PerspectiveCamera(70, Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
    this.camera.position.set(0,0,-20);
    this.camera.lookAt(0,0,0);
    this.camera.near = 0.05f;
    this.camera.far = 600.0f;
    this.camera.update();

    // Init test shader
    this.testShader = ShaderLoader.loadShader("test");

    // Init test buffer
    this.testBufferObject = new DynamicVertexBufferObject(3, new VertexAttributes(new VertexAttribute(Usage.Position, 4, "a_position")));
    float[] vertices = new float[]
    {
            -10,0,0,1,0,2.5f,0,1,10,0,0,1
    };
    this.testBufferObject.setVertices(vertices, 0, vertices.length);    
}
MeshAssembler.java 文件源码 项目:BotLogic 阅读 19 收藏 0 点赞 0 评论 0
public VertexAttribute[] getVertexAttributes() {
  if (attributes == null){
    this.attributes = new ArrayList<VertexAttribute>();
  }
  this.attributes.clear();

  if (isUsing(MeshVertexData.AttributeType.Position)) {
    attributes.add(new VertexAttribute(VertexAttributes.Usage.Position, 3, ShaderProgram.POSITION_ATTRIBUTE));
  }

  if (isUsing(MeshVertexData.AttributeType.Normal)) {
    attributes.add(new VertexAttribute(VertexAttributes.Usage.Normal, 3, ShaderProgram.NORMAL_ATTRIBUTE));
  }

  if (isUsing(MeshVertexData.AttributeType.TextureCord)) {
    attributes.add(new VertexAttribute(VertexAttributes.Usage.TextureCoordinates, 2, ShaderProgram.TEXCOORD_ATTRIBUTE+ "0"));
  }

  if (isUsing(MeshVertexData.AttributeType.Color)) {
    attributes.add(new VertexAttribute(VertexAttributes.Usage.ColorPacked, 4, ShaderProgram.COLOR_ATTRIBUTE));
  }

  return attributes.toArray(new VertexAttribute[attributes.size()]);
}
VertexBufferObjectSubData.java 文件源码 项目:ingress-indonesia-dev 阅读 31 收藏 0 点赞 0 评论 0
public VertexBufferObjectSubData(boolean paramBoolean, int paramInt, VertexAttribute[] paramArrayOfVertexAttribute)
{
  this.isStatic = paramBoolean;
  this.attributes = new VertexAttributes(paramArrayOfVertexAttribute);
  this.byteBuffer = BufferUtils.newByteBuffer(paramInt * this.attributes.vertexSize);
  this.isDirect = true;
  if (paramBoolean);
  for (int i = 35044; ; i = 35048)
  {
    this.usage = i;
    this.buffer = this.byteBuffer.asFloatBuffer();
    this.bufferHandle = createBufferObject();
    this.buffer.flip();
    this.byteBuffer.flip();
    return;
  }
}
VertexBufferObject.java 文件源码 项目:ingress-indonesia-dev 阅读 26 收藏 0 点赞 0 评论 0
public VertexBufferObject(boolean paramBoolean, int paramInt, VertexAttributes paramVertexAttributes)
{
  this.isStatic = paramBoolean;
  this.attributes = paramVertexAttributes;
  this.attributeIndexCache = new int[paramVertexAttributes.size()];
  this.byteBuffer = BufferUtils.newUnsafeByteBuffer(paramInt * this.attributes.vertexSize);
  this.buffer = this.byteBuffer.asFloatBuffer();
  this.buffer.flip();
  this.byteBuffer.flip();
  if (paramBoolean);
  for (int i = 35044; ; i = 35048)
  {
    this.usage = i;
    this.bufferHandle = createBufferObject();
    return;
  }
}
n.java 文件源码 项目:ingress-indonesia-dev 阅读 22 收藏 0 点赞 0 评论 0
private static s a(int paramInt, VertexAttributes paramVertexAttributes, FloatBuffer paramFloatBuffer, ShortBuffer paramShortBuffer1, ShortBuffer paramShortBuffer2)
{
  paramFloatBuffer.flip();
  paramShortBuffer1.flip();
  paramShortBuffer2.flip();
  Mesh localMesh = new Mesh(true, paramFloatBuffer.limit() / paramInt, paramShortBuffer1.limit(), paramVertexAttributes);
  localMesh.setVertices(paramFloatBuffer.array(), 0, paramFloatBuffer.limit());
  localMesh.setIndices(paramShortBuffer1.array(), 0, paramShortBuffer1.limit());
  short[] arrayOfShort = new short[paramShortBuffer2.limit()];
  System.arraycopy(paramShortBuffer2.array(), 0, arrayOfShort, 0, arrayOfShort.length);
  s locals = new s(localMesh, arrayOfShort);
  paramFloatBuffer.clear();
  paramShortBuffer1.clear();
  paramShortBuffer2.clear();
  return locals;
}
AreaMesh.java 文件源码 项目:Cubes_2 阅读 22 收藏 0 点赞 0 评论 0
public AreaMesh(VertexAttributes vertexAttributes) {
    mesh = new Mesh(true, MAX_VERTICES, MAX_INDICES, vertexAttributes);
    meshPart = new MeshPart();
    meshPart.mesh = mesh;
    meshPart.primitiveType = GL20.GL_TRIANGLES;
    meshPart.offset = 0;
    mesh.setIndices(indices);
}
AreaMesh.java 文件源码 项目:Cubes 阅读 18 收藏 0 点赞 0 评论 0
public AreaMesh(VertexAttributes vertexAttributes) {
  mesh = new Mesh(true, MAX_VERTICES, MAX_INDICES, vertexAttributes);
  meshPart = new MeshPart();
  meshPart.mesh = mesh;
  meshPart.primitiveType = GL20.GL_TRIANGLES;
  meshPart.offset = 0;
  mesh.setIndices(indices);
}
UniVertexBufferObject.java 文件源码 项目:exterminate 阅读 23 收藏 0 点赞 0 评论 0
/** Constructs a new interleaved VertexBufferObject.
 * 
 * @param isStatic whether the vertex data is static.
 * @param numVertices the maximum number of vertices
 * @param attributes the {@link VertexAttributes}. */
public UniVertexBufferObject (boolean isStatic, int numVertices, VertexAttributes attributes) {
    this.isStatic = isStatic;
    this.attributes = attributes;

    capacity = this.attributes.vertexSize * numVertices;

    bufferHandle = createBufferObject();
    usage = isStatic ? GL20.GL_STATIC_DRAW : GL20.GL_DYNAMIC_DRAW;
}
WorldObjectCharacter.java 文件源码 项目:Argent 阅读 23 收藏 0 点赞 0 评论 0
public static WorldObjectCharacter createDefaultPlayerCharacter(GameWorld.Generic world) {
    modelBuilder.begin();
    MeshPartBuilder builder = modelBuilder.part("player_body", GL30.GL_TRIANGLES, VertexAttributes.Usage.Position | VertexAttributes.Usage.Normal | VertexAttributes.Usage.TextureCoordinates, Reference.Defaults.Models.material());
    CapsuleShapeBuilder.build(builder, 75, 500, 64);
    WorldObject obj = new WorldObject(world, new ModelInstance(modelBuilder.end()));
    if(world instanceof GameWorld.Physics) {
        world.addInstance(new BulletEntity<>(world, obj.transform(), obj));
    }else{
        world.addInstance(obj);
    }
    return new WorldObjectCharacter(obj);
}
Hydrogen.java 文件源码 项目:Chemtris 阅读 18 收藏 0 点赞 0 评论 0
public Hydrogen(int ve, boolean[][][] mtx, PerspectiveCamera cam) {
    super(ve, mtx, cam);

    //begin building the model
    hydrogen_builder.begin();

    //first node
    Node electron_1 = hydrogen_builder.node();
    electron_1.id = Hydrogen.VE_1;

    //make the cube
    hydrogen_builder.part(Hydrogen.VE_1, GL20.GL_TRIANGLES, VertexAttributes.Usage.Position | VertexAttributes.Usage.Normal,
            new Material(ColorAttribute.createDiffuse(new Color(195f/255f,207f/255f,255f/255f,1f))))
            .box(1f, 1f, 1f);

    //end the model
    Model hModel = hydrogen_builder.end();

    atom = new ModelInstance(hModel,2,10,2);
    shadow = new ModelInstance(hModel,2,10,2);
    frame = new ModelInstance(hModel,2,10,2);
    frame.transform.scl(.01f);

    for(int i = 0; i < shadow.materials.size; ++i){
        shadow.materials.get(i).set(ColorAttribute.createDiffuse(105/255f,105/255f,105/255f,1f));
        frame.materials.get(i).set(ColorAttribute.createDiffuse(Color.WHITE));
    }
}
Icosahedron.java 文件源码 项目:origin 阅读 25 收藏 0 点赞 0 评论 0
/**
     * создать икосаэдр
     * @param depth глубина для деления треугольников
     * @param mult на это умножаем кажду вершину (радиус)
     */
    public Icosahedron(int depth, float mult)
    {
        _mult = mult;
        for (int i = 0; i < indices.length; i++)
        {
            subdivide(
                    vdata[indices[i][0]],
                    vdata[indices[i][1]],
                    vdata[indices[i][2]],
                    depth
            );
        }
        _mesh = new Mesh(
                true, _vertices.size(), 0,
                new VertexAttribute(
                        VertexAttributes.Usage.Position, 3, ShaderProgram.POSITION_ATTRIBUTE
                )
//              new VertexAttribute(VertexAttributes.Usage.Normal, 3, ShaderProgram.NORMAL_ATTRIBUTE)
        );

        float[] v = new float[_vertices.size()];
        for (int i = 0; i < v.length; i++)
        {
            v[i] = _vertices.get(i);
        }
        _mesh.setVertices(v);
    }
GridChunk.java 文件源码 项目:origin 阅读 19 收藏 0 点赞 0 评论 0
private void makeWater()
{
    final float x = _gx + _cx;
    final float y = _gy + _cy;

    _waterMesh = new Mesh(
            true,
            4,
            6,
            new VertexAttribute(VertexAttributes.Usage.Position, 3, ShaderProgram.POSITION_ATTRIBUTE),
            new VertexAttribute(VertexAttributes.Usage.Normal, 3, ShaderProgram.NORMAL_ATTRIBUTE),
            new VertexAttribute(VertexAttributes.Usage.TextureCoordinates, 2, ShaderProgram.TEXCOORD_ATTRIBUTE)
    );

    float[] vertices = new float[]{
            x, WATER_LEVEL, y, 0, 1, 0, 0, 0,
            x + CHUNK_SIZE, WATER_LEVEL, y, 0, 1, 0, 1, 0,
            x, WATER_LEVEL, y + CHUNK_SIZE, 0, 1, 0, 0, 1,
            x + CHUNK_SIZE, WATER_LEVEL, y + CHUNK_SIZE, 0, 1, 0, 1, 1

    };

    short[] indices = new short[]{
            0, 2, 1,
            1, 2, 3
    };
    _waterMesh.setVertices(vertices);
    _waterMesh.setIndices(indices);

}
BillboardDecalBatch.java 文件源码 项目:DoubleHelix 阅读 25 收藏 0 点赞 0 评论 0
public void initialize (int size) {
    vertices = new float[size * BillboardDecal.VERTEX_SIZE];

    Mesh.VertexDataType vertexDataType = Mesh.VertexDataType.VertexArray;
    if(Gdx.gl30 != null) {
        vertexDataType = Mesh.VertexDataType.VertexBufferObjectWithVAO;
    }
    mesh = new Mesh(vertexDataType, false, size, 0, new VertexAttribute(
            VertexAttributes.Usage.Position, 3, ShaderProgram.POSITION_ATTRIBUTE), new VertexAttribute(
            VertexAttributes.Usage.ColorPacked, 4, ShaderProgram.COLOR_ATTRIBUTE), new VertexAttribute(
            VertexAttributes.Usage.Generic, 1, SIZE_ATTRIBUTE), new VertexAttribute(
            VertexAttributes.Usage.Generic, 1, ROTATION_ATTRIBUTE));
}
FrameBufferScreen.java 文件源码 项目:libgdx-shaders 阅读 22 收藏 0 点赞 0 评论 0
private void build() {
    region = new TextureRegion(assetManager.<Texture>get("img/lena.png"));

    shaderManager.createFrameBuffer("frameBuffer01");

    final MeshBuilder meshBuilder = new MeshBuilder();
    meshBuilder.begin(VertexAttributes.Usage.Position | VertexAttributes.Usage.ColorUnpacked | VertexAttributes.Usage.TextureCoordinates, GL20.GL_TRIANGLES);
    meshBuilder.rect(
            0f, 200f, 0f,
            200f, 200f, 0f,
            200f, 0f, 0f,
            0f, 0f, 0f,
            0f, 0f, 0f);
    rectangle = meshBuilder.end();
}


问题


面经


文章

微信
公众号

扫码关注公众号