public float ligtValueAtWorldCoord(Coord woco, Direction dir) { NoisePatch np = noisePatchAtWorldCoord(woco); if (np == null) { throw new Exception("trying to get a heights list for which we don't have a noise patch"); return(0f); } return(np.lightValueAtPatchRelativeCoord(CoordUtil.PatchRelativeBlockCoordForWorldBlockCoord(woco), dir)); }
public Vector4 lightDataForQuadFloat(Quad quad, Direction dir, int normalOffset) { // if (debugLinesAssistant == null) // debugLinesAssistant = ChunkManager.debugLinesAssistant; //BUG ON SEP THREAD // CompareBaseObjectsInternal can only be called from the main thread if (m_noisePatch == null) { m_noisePatch = m_chunk.m_noisePatch; } // AssertUtil.Assert(m_noisePatch != null, "what? noisepatch still null?"); Coord chunkRelCoOfOrigin = chunkRelativeCoordFrom(quad, dir, normalOffset) + DirectionUtil.NudgeCoordForDirection(dir); // check the nine blocks right in front. // for those that are not solid // check the windows. CoordSurfaceStatus surfaceStatus; int[] rows = new int[4]; for (int i = 0; i < quad.dimensions.s; ++i) { for (int j = 0; j < quad.dimensions.t; ++j) { Coord quadOffset = DirectionUtil.CoordForPTwoAndNormalDirectionWithFaceAggregatorRules(new PTwo(i, j), dir); Coord thePatchRelCo = CoordUtil.PatchRelativeChunkCoordForChunkCoord(this.chunkCoord) * (int)ChunkManager.CHUNKLENGTH + chunkRelCoOfOrigin + quadOffset; surfaceStatus = m_noisePatch.patchRelativeCoordIsAboveSurface(thePatchRelCo); int lightValue = NUM_LIGHT_LEVELS - 1; if (surfaceStatus != CoordSurfaceStatus.ABOVE_SURFACE) { lightValue = (int)(m_noisePatch.lightValueAtPatchRelativeCoord(thePatchRelCo, dir) * LIGHT_VALUE_CONVERTER); } //SET THE VALUES IN THE WAY THAT THE SHADER EXPECTS THEM //EXAMPLE: IF QUAD.ORIGIN.S = 7, I = 0, //THE SHADER WILL TAKE THE VALUE FROM COMPONENT WITH 'INDEX' 3 (7 % 4 => 3) rows[(quad.origin.s + i) % FaceSet.MAX_DIMENSIONS.s] |= colorValueFloatWith((quad.origin.t + j) % FaceSet.MAX_DIMENSIONS.t, lightValue); } } return(new Vector4((float)rows[0], (float)rows[1], (float)rows[2], (float)rows[3])); }