protected void computeWorldPos(){ Vec2f chunkCenter = location.add(gap/2f); Vec4f worldPosition = getWorldTransform().getWorldMatrixRTS().mul( new Vec4f(chunkCenter.getX(),0,chunkCenter.getY(),1)); worldPosition = worldPosition.normalize(); worldPosition = worldPosition.mul(terrainProperties.getHorizontalScaling()); // TODO displacment // Vec3f displacement = TerrainHelper.getTerrainHeight(terrainProperties, loc.getX(), loc.getY()); // System.out.println(worldPosition); worldPos = worldPosition.xyz(); }
public UIElement(int xPos, int yPos, int xScaling, int yScaling){ super(); setOrthographicMatrix(new Matrix4f().Orthographic2D()); getWorldTransform().setTranslation(xPos, yPos, 0); getWorldTransform().setScaling(xScaling, yScaling, 0); setOrthographicMatrix(getOrthographicMatrix().mul(getWorldTransform().getWorldMatrix())); }
public QuadtreeChunk(Map<NodeComponentType, NodeComponent> components, QuadtreeCache quadtreeCache, Transform worldTransform, Vec2f location, int lod, Vec2f index){ addComponent(NodeComponentType.CONFIGURATION, components.get(NodeComponentType.CONFIGURATION)); terrainProperties = getComponent(NodeComponentType.CONFIGURATION); this.quadtreeCache = quadtreeCache; this.isleaf = true; this.index = index; this.lod = lod; this.location = location; this.gap = 1f/(terrainProperties.getRootChunkCount() * (float)(Math.pow(2, lod))); Vec3f localScaling = new Vec3f(gap,0,gap); Vec3f localTranslation = new Vec3f(location.getX(),0,location.getY()); getLocalTransform().setScaling(localScaling); getLocalTransform().setTranslation(localTranslation); setWorldTransform(worldTransform); computeWorldPos(); }
public Ocean() { super(128, OceanBRDFShader.getInstance(), OceanWireframeShader.getInstance()); getWorldTransform().setScaling(Constants.ZFAR,1,Constants.ZFAR); getWorldTransform().setTranslation(-Constants.ZFAR/2,0,-Constants.ZFAR/2); setClip_offset(4); setClipplane(new Vec4f(0,-1,0,getWorldTransform().getTranslation().getY() + getClip_offset())); }
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))); } } }
@Override public void updateUBOs(){ getHighPolyIndices().clear(); int index = 0; for (Matrix4f transform : getWorldMatrices()){ if (transform.getTranslation().sub(BaseContext.getCamera().getPosition()).length() < 220){ getHighPolyIndices().add(index); } index++; } getHighPolyInstances().setValue(getHighPolyIndices().size()); }
public void update() { setCameraUnderwater(BaseContext.getCamera().getPosition().getY() < (getWorldTransform().getTranslation().getY())); }
public LensFlareTexturePanel() { super(); orthographicMatrix = new Matrix4f().Orthographic2D(); orthoTransform = new Transform(); setConfig(new AdditiveBlending()); setShader(LensFlareShader.getInstance()); }
public void update() { getWorldTransform().setScaling(getWorldTransform().getLocalScaling()); for(Node child: getChildren()) child.update(); }
public void updateUniforms(Renderable object) { setUniform("modelViewProjectionMatrix", object.getWorldTransform().getModelViewProjectionMatrix()); setUniform("worldMatrix", object.getWorldTransform().getWorldMatrix()); } }
public void updateUniforms(int windowWidth, int windowHeight, Matrix4f viewProjectionMatrix) { setUniformf("windowWidth", windowWidth); setUniformf("windowHeight", windowHeight); setUniform("viewProjectionMatrix", viewProjectionMatrix); setUniform("sunWorldPosition", GLDirectionalLight.getInstance().getDirection().mul(-2800)); } }
public SkySphere() { Skydome top = new Skydome(); top.getWorldTransform().setLocalScaling(Constants.ZFAR*0.5f, Constants.ZFAR*0.5f, Constants.ZFAR*0.5f); Skydome bot = new Skydome(); bot.getWorldTransform().setLocalTranslation(0,-30,0); bot.getWorldTransform().setLocalScaling(Constants.ZFAR*0.5f, -Constants.ZFAR*0.5f, Constants.ZFAR*0.5f); addChild(top); addChild(bot); } }