Refactoring and Commenting
This commit is contained in:
+19
-4
@@ -17,8 +17,11 @@
|
||||
*/
|
||||
package com.seibel.lod.builders.lodNodeTemplates;
|
||||
|
||||
import java.awt.Color;
|
||||
|
||||
import com.seibel.lod.objects.LodQuadTreeDimension;
|
||||
import com.seibel.lod.objects.LodQuadTreeNode;
|
||||
import com.seibel.lod.util.LodUtil;
|
||||
|
||||
import net.minecraft.client.renderer.BufferBuilder;
|
||||
|
||||
@@ -32,9 +35,9 @@ import net.minecraft.client.renderer.BufferBuilder;
|
||||
public abstract class AbstractLodNodeTemplate
|
||||
{
|
||||
public abstract void addLodToBuffer(BufferBuilder buffer,
|
||||
LodQuadTreeDimension lodDim, LodQuadTreeNode lod,
|
||||
double xOffset, double yOffset, double zOffset,
|
||||
boolean debugging);
|
||||
LodQuadTreeDimension lodDim, LodQuadTreeNode lod,
|
||||
double xOffset, double yOffset, double zOffset,
|
||||
boolean debugging);
|
||||
|
||||
/** add the given position and color to the buffer */
|
||||
protected void addPosAndColor(BufferBuilder buffer,
|
||||
@@ -46,8 +49,20 @@ public abstract class AbstractLodNodeTemplate
|
||||
|
||||
/** Returns in bytes how much buffer memory is required
|
||||
* for one LOD object */
|
||||
public abstract int getBufferMemoryForSingleLod(int level);
|
||||
public abstract int getBufferMemoryForSingleNode(int level);
|
||||
|
||||
|
||||
/**
|
||||
* Edit the given color as a HSV (Hue Saturation Value) color.
|
||||
*/
|
||||
protected Color applySaturationAndBrightnessMultipliers(Color color, float saturationMultiplier, float brightnessMultiplier)
|
||||
{
|
||||
float[] hsv = Color.RGBtoHSB(color.getRed(), color.getGreen(), color.getBlue(), null);
|
||||
return Color.getHSBColor(
|
||||
hsv[0], // hue
|
||||
LodUtil.clamp(0.0f, hsv[1] * saturationMultiplier, 1.0f),
|
||||
LodUtil.clamp(0.0f, hsv[2] * brightnessMultiplier, 1.0f));
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -22,7 +22,6 @@ import com.seibel.lod.enums.ShadingMode;
|
||||
import com.seibel.lod.handlers.LodConfig;
|
||||
import com.seibel.lod.objects.LodQuadTreeDimension;
|
||||
import com.seibel.lod.objects.LodQuadTreeNode;
|
||||
import com.seibel.lod.util.LodUtil;
|
||||
|
||||
import net.minecraft.client.renderer.BufferBuilder;
|
||||
import net.minecraft.util.math.AxisAlignedBB;
|
||||
@@ -107,7 +106,7 @@ public class CubicLodNodeTemplate extends AbstractLodNodeTemplate
|
||||
northSouthColor = new Color(Math.max(0, c.getRed() - northSouthDarkenAmount), Math.max(0, c.getGreen() - northSouthDarkenAmount), Math.max(0, c.getBlue() - northSouthDarkenAmount), c.getAlpha());
|
||||
eastWestColor = new Color(Math.max(0, c.getRed() - eastWestDarkenAmount), Math.max(0, c.getGreen() - eastWestDarkenAmount), Math.max(0, c.getBlue() - eastWestDarkenAmount), c.getAlpha());
|
||||
bottomColor = new Color(Math.max(0, c.getRed() - bottomDarkenAmount), Math.max(0, c.getGreen() - bottomDarkenAmount), Math.max(0, c.getBlue() - bottomDarkenAmount), c.getAlpha());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// apply the user specified saturation and brightness
|
||||
@@ -153,29 +152,14 @@ public class CubicLodNodeTemplate extends AbstractLodNodeTemplate
|
||||
addPosAndColor(buffer, bb.maxX, bb.minY, bb.maxZ, eastWestColor.getRed(), eastWestColor.getGreen(), eastWestColor.getBlue(), eastWestColor.getAlpha());
|
||||
addPosAndColor(buffer, bb.maxX, bb.minY, bb.minZ, eastWestColor.getRed(), eastWestColor.getGreen(), eastWestColor.getBlue(), eastWestColor.getAlpha());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Edit the given color as a HSV (Hue Saturation Value) color.
|
||||
*/
|
||||
private Color applySaturationAndBrightnessMultipliers(Color color, float saturationMultiplier, float brightnessMultiplier)
|
||||
{
|
||||
float[] hsv = Color.RGBtoHSB(color.getRed(), color.getGreen(), color.getBlue(), null);
|
||||
return Color.getHSBColor(
|
||||
hsv[0], // hue
|
||||
LodUtil.clamp(0.0f, hsv[1] * saturationMultiplier, 1.0f),
|
||||
LodUtil.clamp(0.0f, hsv[2] * brightnessMultiplier, 1.0f));
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public int getBufferMemoryForSingleLod(int detailLevel) // TODO maybe multiply by how many would be per chunk?
|
||||
public int getBufferMemoryForSingleNode(int detailLevel)
|
||||
{
|
||||
// (sidesOnACube * pointsInASquare * (positionPoints + colorPoints))) * howManyPointsPerLodChunk
|
||||
return (6 * 4 * (3 + 4));
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -43,7 +43,7 @@ public class DynamicLodNodeTemplate extends AbstractLodNodeTemplate
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getBufferMemoryForSingleLod(int detailLevel)
|
||||
public int getBufferMemoryForSingleNode(int detailLevel)
|
||||
{
|
||||
// TODO Auto-generated method stub
|
||||
return 0;
|
||||
|
||||
+1
-1
@@ -41,7 +41,7 @@ public class TriangularLodNodeTemplate extends AbstractLodNodeTemplate
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getBufferMemoryForSingleLod(int detailLevel)
|
||||
public int getBufferMemoryForSingleNode(int detailLevel)
|
||||
{
|
||||
// TODO Auto-generated method stub
|
||||
return 0;
|
||||
|
||||
@@ -33,7 +33,7 @@ import net.minecraft.util.math.AxisAlignedBB;
|
||||
* Builds LODs as rectangular prisms.
|
||||
*
|
||||
* @author James Seibel
|
||||
* @version 07-25-2021
|
||||
* @version 8-8-2021
|
||||
*/
|
||||
public class CubicLodTemplate extends AbstractLodTemplate
|
||||
{
|
||||
|
||||
@@ -56,6 +56,6 @@ public enum LodTemplate
|
||||
|
||||
public int getBufferMemoryForSingleLod(int detailLevel)
|
||||
{
|
||||
return template.getBufferMemoryForSingleLod(detailLevel);
|
||||
return template.getBufferMemoryForSingleNode(detailLevel);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -222,6 +222,7 @@ public class LodQuadTreeNode
|
||||
throw new IllegalArgumentException("LodQuadTreeNode constructor givin an invalid string. The data given had " + count + " delimiters when it should have had " + DATA_DELIMITER_COUNT + ".");
|
||||
|
||||
|
||||
// start reading the data string
|
||||
|
||||
int index = 0;
|
||||
int lastIndex = 0;
|
||||
|
||||
@@ -138,39 +138,34 @@ public class LodUtil
|
||||
|
||||
|
||||
|
||||
public static String getCurrentDimensionID()
|
||||
/**
|
||||
* If on single player this will return the name of the user's
|
||||
* world, if in multiplayer it will return the server name, IP,
|
||||
* and game version.
|
||||
*/
|
||||
public static String getWorldID(IWorld world)
|
||||
{
|
||||
|
||||
Minecraft mc = Minecraft.getInstance();
|
||||
|
||||
if(mc.hasSingleplayerServer())
|
||||
{
|
||||
// this will return the world save location
|
||||
// and the dimension folder
|
||||
// chop off the dimension ID as it is not needed/wanted
|
||||
String dimId = getDimensionIDFromWorld(world);
|
||||
|
||||
if(mc.level == null)
|
||||
return "";
|
||||
|
||||
ServerWorld serverWorld = LodUtil.getServerWorldFromDimension(mc.level.dimensionType());
|
||||
if(serverWorld == null)
|
||||
return "";
|
||||
|
||||
ServerChunkProvider provider = serverWorld.getChunkSource();
|
||||
if(provider == null)
|
||||
return "";
|
||||
|
||||
return provider.dataStorage.dataFolder.toString();
|
||||
// get the world name
|
||||
int saveIndex = dimId.indexOf("saves") + 1 + "saves".length();
|
||||
int slashIndex = dimId.indexOf(File.separatorChar, saveIndex);
|
||||
dimId = dimId.substring(saveIndex, slashIndex);
|
||||
return dimId;
|
||||
}
|
||||
else
|
||||
{
|
||||
ServerData server = mc.getCurrentServer();
|
||||
return server.name + ", IP " +
|
||||
server.ip + ", GameVersion " +
|
||||
server.version.getString() + File.separatorChar
|
||||
+ "dim_" + mc.level.dimensionType().effectsLocation().getPath() + File.separatorChar;
|
||||
server.version.getString();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* If on single player this will return the name of the user's
|
||||
@@ -209,33 +204,6 @@ public class LodUtil
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* If on single player this will return the name of the user's
|
||||
* world, if in multiplayer it will return the server name
|
||||
* and game version.
|
||||
*/
|
||||
public static String getWorldID(IWorld world)
|
||||
{
|
||||
if(mc.hasSingleplayerServer())
|
||||
{
|
||||
// chop off the dimension ID as it is not needed/wanted
|
||||
String dimId = getDimensionIDFromWorld(world);
|
||||
|
||||
// get the world name
|
||||
int saveIndex = dimId.indexOf("saves") + 1 + "saves".length();
|
||||
int slashIndex = dimId.indexOf(File.separatorChar, saveIndex);
|
||||
dimId = dimId.substring(saveIndex, slashIndex);
|
||||
return dimId;
|
||||
}
|
||||
else
|
||||
{
|
||||
ServerData server = mc.getCurrentServer();
|
||||
return server.name + ", IP " +
|
||||
server.ip + ", GameVersion " +
|
||||
server.version.getString();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user