Пример #1
0
    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]));
    }
Пример #2
0
    public Color32 lightDataForQuad(Quad quad, Direction dir, int normalOffset)
    {
//		if (debugLinesAssistant == null)
//			debugLinesAssistant = ChunkManager.debugLinesAssistant;

        if (m_noisePatch == null)
        {
            m_noisePatch = m_chunk.m_noisePatch;
        }

        if (m_noisePatch == null)
        {
            throw new Exception("what? noisepatch still null?");
        }

        Coord chunkRelCoOfOrigin = chunkRelativeCoordFrom(quad, dir, normalOffset);

        if (dir != Direction.xpos && dir != Direction.zpos)
        {
            chunkRelCoOfOrigin += DirectionUtil.NudgeCoordForDirection(dir);
        }

        // check the nine blocks right in front.
        // for those that are not solid
        // check the windows.

//		Coord noisePatchRelCo = CoordUtil.PatchRelativeCoordWithChunkCoordOffset(chunkRelCoOfOrigin, new Coord(0));

        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);
//				int  lightValue = (int) ( m_noisePatch.lightValueAtPatchRelativeCoord(noisePatchRelCo + quadOffset) * LIGHT_VALUE_CONVERTER);
//
//			}
//		}


//		Coord chunkWoco = CoordUtil.WorldCoordForChunkCoord(this.chunkCoord);

        CoordSurfaceStatus surfaceStatus = m_noisePatch.coordIsAboveSurface(this.chunkCoord, chunkRelCoOfOrigin);

//		if (surfaceStatus == CoordSurfaceStatus.ABOVE_SURFACE)
        if (surfaceStatus == CoordSurfaceStatus.ABOVE_SURFACE)
        {
            return(new Color32(255, 255, 255, 255));
            //for now...origin above == all above
        }

        //for now....
        return(new Color32(0, 0, 0, 0));

        // ********************************* //

//		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);
                byte  lightVal   = lightValueAt(this.chunkCoord, chunkRelCoOfOrigin + quadOffset, dir);
                rows[i] |= colorValueWith(j, lightVal);
            }
        }

        return(new Color32((byte)rows[0], (byte)rows[1], (byte)rows[2], (byte)rows[3]));
    }