public TerrainQuadtree(HashMap<NodeComponentType, NodeComponent> components){ for (int i=0; i<rootPatches; i++){ for (int j=0; j<rootPatches; j++){ addChild(new TerrainNode(components, new Vec2f(1f * i/(float)rootPatches,1f * j/(float)rootPatches), 0, new Vec2f(i,j))); } } thread = new Thread(this); }
L = Integer.valueOf(properties.getProperty("fft.L")); amplitude = Float.valueOf(properties.getProperty("fft.amplitude")); windDirection = new Vec2f(Float.valueOf(properties.getProperty("wind.x")), Float.valueOf(properties.getProperty("wind.y"))).normalize(); windSpeed = Float.valueOf(properties.getProperty("wind.speed"));
public TerrainQuadtree(Map<NodeComponentType, NodeComponent> components, int rootChunkCount, float horizontalScaling) { super(); Transform worldTransformFace0 = new Transform(); worldTransformFace0.setTranslation(-0.5f * horizontalScaling, 0, -0.5f * horizontalScaling); worldTransformFace0.setScaling(horizontalScaling); for (int i=0; i<rootChunkCount; i++){ for (int j=0; j<rootChunkCount; j++){ addChild(createChildChunk(components, quadtreeCache, worldTransformFace0, new Vec2f(1f * i/(float)rootChunkCount,1f * j/(float)rootChunkCount), 0, new Vec2f(i,j))); } } }
float strength = Float.valueOf(properties.getProperty("fractal" + i + ".strength")); int random = Integer.valueOf(properties.getProperty("fractal" + i + ".random")); Vec2f direction = new Vec2f(Float.valueOf(properties.getProperty("fractal" + i + ".direction.x")), Float.valueOf(properties.getProperty("fractal" + i + ".direction.y"))); float intensity = Float.valueOf(properties.getProperty("fractal" + i + ".intensity"));
for (int j=0; j<rootChunkCount; j++){ QuadtreeChunk newChunk = createChildChunk(components, quadtreeCache, worldTransformFace0, new Vec2f(1f * i/(float)rootChunkCount,1f * j/(float)rootChunkCount), 0, new Vec2f(i,j)); leafChunks.put(newChunk.getId(), newChunk); addChild(newChunk); for (int j=0; j<rootChunkCount; j++){ QuadtreeChunk newChunk = createChildChunk(components, quadtreeCache, worldTransformFace1, new Vec2f(1f * i/(float)rootChunkCount,1f * j/(float)rootChunkCount), 0, new Vec2f(i,j)); leafChunks.put(newChunk.getId(), newChunk); addChild(newChunk); for (int j=0; j<rootChunkCount; j++){ QuadtreeChunk newChunk = createChildChunk(components, quadtreeCache, worldTransformFace2, new Vec2f(1f * i/(float)rootChunkCount,1f * j/(float)rootChunkCount), 0, new Vec2f(i,j)); leafChunks.put(newChunk.getId(), newChunk); addChild(newChunk); for (int j=0; j<rootChunkCount; j++){ QuadtreeChunk newChunk = createChildChunk(components, quadtreeCache, worldTransformFace3, new Vec2f(1f * i/(float)rootChunkCount,1f * j/(float)rootChunkCount), 0, new Vec2f(i,j)); leafChunks.put(newChunk.getId(), newChunk); addChild(newChunk); for (int j=0; j<rootChunkCount; j++){
Vec2f pos = new Vec2f(); pos.setX(x); pos.setY(z); pos = pos.add(config.getHorizontalScaling()/2f); pos = pos.div(config.getHorizontalScaling()); Vec2f floor = new Vec2f((int) Math.floor(pos.getX()), (int) Math.floor(pos.getY())); pos = pos.sub(floor); pos = pos.mul(config.getHeightmap().getMetaData().getWidth());
public GLButton(int xPos, int yPos, int xScaling, int yScaling, Mesh panelMesh){ super(xPos, yPos, xScaling, yScaling); pos = new Vec2f[4]; shader = UITextPanelShader.getInstance(); vao = new GUIVAO(); config = new DefaultRenderParams(); vao.addData(panelMesh); Vec4f q0 = new Vec4f(0,0,0,0); Vec4f q1 = new Vec4f(0,0,0,0); Vec4f q2 = new Vec4f(0,0,0,0); Vec4f q3 = new Vec4f(0,0,0,0); q0 = getWorldTransform().getWorldMatrix().mul(new Vec4f(panelMesh.getVertices()[0].getPosition(),1)); q1 = getWorldTransform().getWorldMatrix().mul(new Vec4f(panelMesh.getVertices()[1].getPosition(),1)); q2 = getWorldTransform().getWorldMatrix().mul(new Vec4f(panelMesh.getVertices()[2].getPosition(),1)); q3 = getWorldTransform().getWorldMatrix().mul(new Vec4f(panelMesh.getVertices()[3].getPosition(),1)); pos[0] = new Vec2f(q0.getX(),q0.getY()+5); pos[1] = new Vec2f(q1.getX(),q1.getY()+5); pos[2] = new Vec2f(q2.getX()-7,q2.getY()-5); pos[3] = new Vec2f(q3.getX()-7,q3.getY()-5); }
public boolean onClick() { DoubleBuffer xPos = BufferUtils.createDoubleBuffer(1); DoubleBuffer yPos = BufferUtils.createDoubleBuffer(1); glfwGetCursorPos(BaseContext.getWindow().getId(), xPos, yPos); Vec2f mousePos = new Vec2f((float) xPos.get(),(float) yPos.get()); if(pos[0].getX() < mousePos.getX() && pos[1].getX() < mousePos.getX() && pos[2].getX() > mousePos.getX() && pos[3].getX() > mousePos.getX() && pos[0].getY() < BaseContext.getWindow().getHeight() - mousePos.getY() && pos[3].getY() < BaseContext.getWindow().getHeight() - mousePos.getY() && pos[1].getY() > BaseContext.getWindow().getHeight() - mousePos.getY() && pos[2].getY() > BaseContext.getWindow().getHeight() - mousePos.getY()) { return true; } else return false; }
DoubleBuffer yPos = BufferUtils.createDoubleBuffer(1); glfwGetCursorPos(BaseContext.getWindow().getId(), xPos, yPos); Vec2f screenPos = new Vec2f((float) xPos.get(),(float) yPos.get()); Vec2f w = new Vec2f(screenPos.getX()/BaseContext.getWindow().getWidth(), screenPos.getY()/BaseContext.getWindow().getHeight());
float brightness = 1 - sunToWindowCenter.div(new Vec2f(BaseContext.getWindow().getWidth(), BaseContext.getWindow().getHeight())).length();