public void setUniform(String uniformName, Material material) { setUniform(uniformName + ".ambient", material.getAmbientColour()); setUniform(uniformName + ".diffuse", material.getDiffuseColour()); setUniform(uniformName + ".specular", material.getSpecularColour()); setUniform(uniformName + ".hasTexture", material.isTextured() ? 1 : 0); setUniform(uniformName + ".hasNormalMap", material.hasNormalMap() ? 1 : 0); setUniform(uniformName + ".reflectance", material.getReflectance()); }
private void initRender() { Texture texture = material.getTexture(); if (texture != null) { // Activate first texture bank glActiveTexture(GL_TEXTURE0); // Bind the texture glBindTexture(GL_TEXTURE_2D, texture.getId()); } Texture normalMap = material.getNormalMap(); if ( normalMap != null ) { // Activate first texture bank glActiveTexture(GL_TEXTURE1); // Bind the texture glBindTexture(GL_TEXTURE_2D, normalMap.getId()); } // Draw the mesh glBindVertexArray(getVaoId()); glEnableVertexAttribArray(0); glEnableVertexAttribArray(1); glEnableVertexAttribArray(2); }
public Particle(Mesh mesh, Vector3f speed, long ttl, long updateTextureMillis) { super(mesh); this.speed = new Vector3f(speed); this.ttl = ttl; this.updateTextureMillis = updateTextureMillis; this.currentAnimTimeMillis = 0; Texture texture = this.getMesh().getMaterial().getTexture(); this.animFrames = texture.getNumCols() * texture.getNumRows(); }
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); } }
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)); // Create compass Mesh mesh = OBJLoader.loadMesh("/models/compass.obj"); Material material = new Material(); material.setAmbientColour(new Vector4f(1, 0, 0, 1)); mesh.setMaterial(material); compassItem = new GameItem(mesh); compassItem.setScale(40.0f); // Rotate to transform it to screen coordinates compassItem.setRotation(0f, 0f, 180f); // Create list that holds the items that compose the HUD gameItems = new GameItem[]{statusTextItem, compassItem}; }
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}; }
private void initRender() { Texture texture = material.getTexture(); if (texture != null) { // Activate first texture bank glActiveTexture(GL_TEXTURE0); // Bind the texture glBindTexture(GL_TEXTURE_2D, texture.getId()); } Texture normalMap = material.getNormalMap(); if ( normalMap != null ) { // Activate first texture bank glActiveTexture(GL_TEXTURE1); // Bind the texture glBindTexture(GL_TEXTURE_2D, normalMap.getId()); } // Draw the mesh glBindVertexArray(getVaoId()); glEnableVertexAttribArray(0); glEnableVertexAttribArray(1); glEnableVertexAttribArray(2); }
public Particle(Mesh mesh, Vector3f speed, long ttl, long updateTextureMillis) { super(mesh); this.speed = new Vector3f(speed); this.ttl = ttl; this.updateTextureMillis = updateTextureMillis; this.currentAnimTimeMillis = 0; Texture texture = this.getMesh().getMaterial().getTexture(); this.animFrames = texture.getNumCols() * texture.getNumRows(); }
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); } }
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(1, 1, 1, 1)); // Create compass Mesh mesh = OBJLoader.loadMesh("/models/compass.obj"); Material material = new Material(); material.setAmbientColour(new Vector4f(1, 0, 0, 1)); mesh.setMaterial(material); compassItem = new GameItem(mesh); compassItem.setScale(40.0f); // Rotate to transform it to screen coordinates compassItem.setRotation(0f, 0f, 180f); // Create list that holds the items that compose the HUD gameItems = new GameItem[]{statusTextItem, compassItem}; }
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}; }
public void setUniform(String uniformName, Material material) { setUniform(uniformName + ".ambient", material.getAmbientColour()); setUniform(uniformName + ".diffuse", material.getDiffuseColour()); setUniform(uniformName + ".specular", material.getSpecularColour()); setUniform(uniformName + ".hasTexture", material.isTextured() ? 1 : 0); setUniform(uniformName + ".hasNormalMap", material.hasNormalMap() ? 1 : 0); setUniform(uniformName + ".reflectance", material.getReflectance()); }
private void initRender() { Texture texture = material.getTexture(); if (texture != null) { // Activate first texture bank glActiveTexture(GL_TEXTURE0); // Bind the texture glBindTexture(GL_TEXTURE_2D, texture.getId()); } Texture normalMap = material.getNormalMap(); if ( normalMap != null ) { // Activate first texture bank glActiveTexture(GL_TEXTURE1); // Bind the texture glBindTexture(GL_TEXTURE_2D, normalMap.getId()); } // Draw the mesh glBindVertexArray(getVaoId()); glEnableVertexAttribArray(0); glEnableVertexAttribArray(1); glEnableVertexAttribArray(2); }
public Particle(Mesh mesh, Vector3f speed, long ttl, long updateTextureMillis) { super(mesh); this.speed = new Vector3f(speed); this.ttl = ttl; this.updateTextureMillis = updateTextureMillis; this.currentAnimTimeMillis = 0; Texture texture = this.getMesh().getMaterial().getTexture(); this.animFrames = texture.getNumCols() * texture.getNumRows(); }
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); } }
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(1, 1, 1, 1)); // Create compass Mesh mesh = OBJLoader.loadMesh("/models/compass.obj"); Material material = new Material(); material.setAmbientColour(new Vector4f(1, 0, 0, 1)); mesh.setMaterial(material); compassItem = new GameItem(mesh); compassItem.setScale(40.0f); // Rotate to transform it to screen coordinates compassItem.setRotation(0f, 0f, 180f); // Create list that holds the items that compose the HUD gameItems = new GameItem[]{statusTextItem, compassItem}; }
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}; }
public void setUniform(String uniformName, Material material) { setUniform(uniformName + ".ambient", material.getAmbientColour()); setUniform(uniformName + ".diffuse", material.getDiffuseColour()); setUniform(uniformName + ".specular", material.getSpecularColour()); setUniform(uniformName + ".hasTexture", material.isTextured() ? 1 : 0); setUniform(uniformName + ".hasNormalMap", material.hasNormalMap() ? 1 : 0); setUniform(uniformName + ".reflectance", material.getReflectance()); }
private void initRender() { Texture texture = material.getTexture(); if (texture != null) { // Activate first texture bank glActiveTexture(GL_TEXTURE0); // Bind the texture glBindTexture(GL_TEXTURE_2D, texture.getId()); } Texture normalMap = material.getNormalMap(); if ( normalMap != null ) { // Activate first texture bank glActiveTexture(GL_TEXTURE1); // Bind the texture glBindTexture(GL_TEXTURE_2D, normalMap.getId()); } // Draw the mesh glBindVertexArray(getVaoId()); glEnableVertexAttribArray(0); glEnableVertexAttribArray(1); glEnableVertexAttribArray(2); }
public Particle(Mesh mesh, Vector3f speed, long ttl, long updateTextureMillis) { super(mesh); this.speed = new Vector3f(speed); this.ttl = ttl; this.updateTextureMillis = updateTextureMillis; this.currentAnimTimeMillis = 0; Texture texture = this.getMesh().getMaterial().getTexture(); this.animFrames = texture.getNumCols() * texture.getNumRows(); }