本文整理了Java中org.lwjglb.engine.graph.Mesh
类的一些代码示例,展示了Mesh
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Mesh
类的具体详情如下:
包路径:org.lwjglb.engine.graph.Mesh
类名称:Mesh
暂无
代码示例来源:origin: lwjglgamedev/lwjglbook
@Override
public void init() throws Exception {
renderer.init();
float[] positions = new float[]{
-0.5f, 0.5f, 0.0f,
-0.5f, -0.5f, 0.0f,
0.5f, -0.5f, 0.0f,
0.5f, 0.5f, 0.0f,};
int[] indices = new int[]{
0, 1, 3, 3, 1, 2,};
mesh = new Mesh(positions, indices);
}
代码示例来源:origin: lwjglgamedev/lwjglbook
public void cleanup() {
int numMeshes = this.meshes != null ? this.meshes.length : 0;
for (int i = 0; i < numMeshes; i++) {
this.meshes[i].cleanUp();
}
}
代码示例来源:origin: lwjglgamedev/lwjglbook
public void render() {
initRender();
glDrawElements(GL_TRIANGLES, getVertexCount(), GL_UNSIGNED_INT, 0);
endRender();
}
代码示例来源:origin: lwjglgamedev/lwjglbook
public void render() {
// Draw the mesh
glBindVertexArray(getVaoId());
glEnableVertexAttribArray(0);
glEnableVertexAttribArray(1);
glDrawElements(GL_TRIANGLES, getVertexCount(), GL_UNSIGNED_INT, 0);
// Restore state
glDisableVertexAttribArray(0);
glDisableVertexAttribArray(1);
glBindVertexArray(0);
}
代码示例来源:origin: lwjglgamedev/lwjglbook
private void renderHud(Window window, IHud hud) {
hudShaderProgram.bind();
Matrix4f ortho = transformation.getOrthoProjectionMatrix(0, window.getWidth(), window.getHeight(), 0);
for (GameItem gameItem : hud.getGameItems()) {
Mesh mesh = gameItem.getMesh();
// Set ortohtaphic and model matrix for this HUD item
Matrix4f projModelMatrix = transformation.getOrtoProjModelMatrix(gameItem, ortho);
hudShaderProgram.setUniform("projModelMatrix", projModelMatrix);
hudShaderProgram.setUniform("colour", gameItem.getMesh().getMaterial().getAmbientColour());
hudShaderProgram.setUniform("hasTexture", gameItem.getMesh().getMaterial().isTextured() ? 1 : 0);
// Render the mesh for this HUD item
mesh.render();
}
hudShaderProgram.unbind();
}
代码示例来源:origin: lwjglgamedev/lwjglbook
private static Mesh processMesh(AIMesh aiMesh, List<Material> materials) {
List<Float> vertices = new ArrayList<>();
List<Float> textures = new ArrayList<>();
List<Float> normals = new ArrayList<>();
List<Integer> indices = new ArrayList();
processVertices(aiMesh, vertices);
processNormals(aiMesh, normals);
processTextCoords(aiMesh, textures);
processIndices(aiMesh, indices);
Mesh mesh = new Mesh(Utils.listToArray(vertices), Utils.listToArray(textures),
Utils.listToArray(normals), Utils.listIntToArray(indices));
Material material;
int materialIdx = aiMesh.mMaterialIndex();
if (materialIdx >= 0 && materialIdx < materials.size()) {
material = materials.get(materialIdx);
} else {
material = new Material();
}
mesh.setMaterial(material);
return mesh;
}
代码示例来源:origin: lwjglgamedev/lwjglbook
public SkyBox(String objModel, Vector4f colour) throws Exception {
super();
Mesh skyBoxMesh = OBJLoader.loadMesh(objModel);
Material material = new Material(colour, 0);
skyBoxMesh.setMaterial(material);
setMesh(skyBoxMesh);
setPosition(0, 0, 0);
}
}
代码示例来源:origin: lwjglgamedev/lwjglbook
public Hud(String statusText) throws Exception {
this.statusTextItem = new TextItem(statusText, FONT_TEXTURE, FONT_COLS, FONT_ROWS);
this.statusTextItem.getMesh().getMaterial().setAmbientColour(new Vector4f(1, 1, 1, 1));
gameItems = new GameItem[]{statusTextItem};
}
代码示例来源:origin: lwjglgamedev/lwjglbook
public void setText(String text) {
this.text = text;
this.getMesh().deleteBuffers();
this.setMesh(buildMesh());
}
}
代码示例来源:origin: lwjglgamedev/lwjglbook
public void setText(String text) {
this.text = text;
Texture texture = this.getMesh().getMaterial().getTexture();
this.getMesh().deleteBuffers();
this.setMesh(buildMesh(texture, numCols, numRows));
}
}
代码示例来源:origin: lwjglgamedev/lwjglbook
public void renderTest(ShadowBuffer shadowMap) {
testShaderProgram.bind();
testShaderProgram.setUniform("texture_sampler[0]", 0);
glActiveTexture(GL_TEXTURE0);
glBindTexture(GL_TEXTURE_2D, shadowMap.getDepthMapTexture().getIds()[0]);
quadMesh.render();
testShaderProgram.unbind();
}
代码示例来源:origin: lwjglgamedev/lwjglbook
private void initRender() {
Texture texture = material.getTexture();
if (texture != null) {
// Activate firs texture bank
glActiveTexture(GL_TEXTURE0);
// Bind the texture
glBindTexture(GL_TEXTURE_2D, texture.getId());
}
// Draw the mesh
glBindVertexArray(getVaoId());
glEnableVertexAttribArray(0);
glEnableVertexAttribArray(1);
glEnableVertexAttribArray(2);
}
代码示例来源:origin: lwjglgamedev/lwjglbook
public void render() {
// Draw the mesh
glBindVertexArray(getVaoId());
glEnableVertexAttribArray(0);
glEnableVertexAttribArray(1);
glDrawElements(GL_TRIANGLES, getVertexCount(), GL_UNSIGNED_INT, 0);
// Restore state
glDisableVertexAttribArray(0);
glDisableVertexAttribArray(1);
glBindVertexArray(0);
}
代码示例来源:origin: lwjglgamedev/lwjglbook
private void renderHud(Window window, IHud hud) {
hudShaderProgram.bind();
Matrix4f ortho = transformation.getOrthoProjectionMatrix(0, window.getWidth(), window.getHeight(), 0);
for (GameItem gameItem : hud.getGameItems()) {
Mesh mesh = gameItem.getMesh();
// Set ortohtaphic and model matrix for this HUD item
Matrix4f projModelMatrix = transformation.buildOrtoProjModelMatrix(gameItem, ortho);
hudShaderProgram.setUniform("projModelMatrix", projModelMatrix);
hudShaderProgram.setUniform("colour", gameItem.getMesh().getMaterial().getAmbientColour());
hudShaderProgram.setUniform("hasTexture", gameItem.getMesh().getMaterial().isTextured() ? 1 : 0);
// Render the mesh for this HUD item
mesh.render();
}
hudShaderProgram.unbind();
}
代码示例来源:origin: lwjglgamedev/lwjglbook
private static Mesh processMesh(AIMesh aiMesh, List<Material> materials) {
List<Float> vertices = new ArrayList<>();
List<Float> textures = new ArrayList<>();
List<Float> normals = new ArrayList<>();
List<Integer> indices = new ArrayList();
processVertices(aiMesh, vertices);
processNormals(aiMesh, normals);
processTextCoords(aiMesh, textures);
processIndices(aiMesh, indices);
Mesh mesh = new Mesh(Utils.listToArray(vertices), Utils.listToArray(textures),
Utils.listToArray(normals), Utils.listIntToArray(indices));
Material material;
int materialIdx = aiMesh.mMaterialIndex();
if (materialIdx >= 0 && materialIdx < materials.size()) {
material = materials.get(materialIdx);
} else {
material = new Material();
}
mesh.setMaterial(material);
return mesh;
}
代码示例来源:origin: lwjglgamedev/lwjglbook
public SkyBox(String objModel, Vector4f colour) throws Exception {
super();
Mesh skyBoxMesh = OBJLoader.loadMesh(objModel);
Material material = new Material(colour, 0);
skyBoxMesh.setMaterial(material);
setMesh(skyBoxMesh);
setPosition(0, 0, 0);
}
}
代码示例来源:origin: lwjglgamedev/lwjglbook
public Hud(String statusText) throws Exception {
FontTexture fontTexture = new FontTexture(FONT, CHARSET);
this.statusTextItem = new TextItem(statusText, fontTexture);
this.statusTextItem.getMesh().getMaterial().setAmbientColour(new Vector4f(0.5f, 0.5f, 0.5f, 10f));
// Create list that holds the items that compose the HUD
gameItems = new GameItem[]{statusTextItem};
}
代码示例来源:origin: lwjglgamedev/lwjglbook
public void setText(String text) {
this.text = text;
this.getMesh().deleteBuffers();
this.setMesh(buildMesh());
}
}
代码示例来源:origin: lwjglgamedev/lwjglbook
public void setText(String text) {
this.text = text;
Texture texture = this.getMesh().getMaterial().getTexture();
this.getMesh().deleteBuffers();
this.setMesh(buildMesh(texture, numCols, numRows));
}
}
代码示例来源:origin: lwjglgamedev/lwjglbook
public void renderTest(ShadowBuffer shadowMap) {
testShaderProgram.bind();
testShaderProgram.setUniform("texture_sampler[0]", 0);
glActiveTexture(GL_TEXTURE0);
glBindTexture(GL_TEXTURE_2D, shadowMap.getDepthMapTexture().getIds()[0]);
quadMesh.render();
testShaderProgram.unbind();
}
内容来源于网络,如有侵权,请联系作者删除!