use of codechicken.lib.render.CCModel in project GregTech by GregTechCE.
the class StonePileModelGenerator method generatePebblePileModel.
public static CCModel generatePebblePileModel(Random random) {
List<IndexedCuboid6> cuboid6s = generateCuboidList(random);
CCModel ccModel = CCModel.quadModel(cuboid6s.size() * 24);
for (int i = 0; i < cuboid6s.size(); i++) {
IndexedCuboid6 cuboid6 = cuboid6s.get(i);
ccModel.generateBlock(i * 24, cuboid6);
int b = (int) cuboid6.data;
int[] colours = ccModel.getOrAllocate(ColourAttribute.attributeKey);
int color = (b & 0xFF) << 24 | (b & 0xFF) << 16 | (b & 0xFF) << 8 | (0xFF);
Arrays.fill(colours, i * 24, i * 24 + 24, color);
}
return ccModel.computeNormals();
}
use of codechicken.lib.render.CCModel in project GregTech by GregTechCE.
the class ShapeModelGenerator method generateModel.
public static CCModel generateModel(int angles, double height, double radius, double segmentHeight) {
int amountOfSegments = (int) Math.ceil(height / segmentHeight);
CCModel initialModel = CCModel.quadModel(angles * 4 * amountOfSegments);
double radiansPerAngle = (Math.PI * 2) / (angles * 1.0);
for (int i = 0; i < angles; i++) {
Vector3 first = generatePoint(radiansPerAngle, i, radius);
Vector3 second = generatePoint(radiansPerAngle, i + 1, radius);
Vector3 firstTop = first.copy().add(0.0, segmentHeight, 0.0);
Vector3 secondTop = second.copy().add(0.0, segmentHeight, 0.0);
double width = first.copy().subtract(second).mag();
double heightLeft = height;
for (int j = 0; j < amountOfSegments; j++) {
double actualHeight = firstTop.y - first.y;
double textureHeight = 1.0 * (actualHeight / segmentHeight);
double textureWidth = (textureHeight / actualHeight) * width;
int offset = i * amountOfSegments * 4 + j * 4;
initialModel.verts[offset] = new Vertex5(first.copy(), 0.0, 0.0);
initialModel.verts[offset + 1] = new Vertex5(firstTop.copy(), 0.0, textureHeight);
initialModel.verts[offset + 2] = new Vertex5(secondTop.copy(), textureWidth, textureHeight);
initialModel.verts[offset + 3] = new Vertex5(second.copy(), textureWidth, 0.0);
heightLeft -= actualHeight;
double nextSegmentHeight = Math.min(segmentHeight, heightLeft);
first.add(0.0, actualHeight, 0.0);
second.add(0.0, actualHeight, 0.0);
firstTop.y = first.y + nextSegmentHeight;
secondTop.y = second.y + nextSegmentHeight;
}
}
return initialModel.computeNormals();
}
use of codechicken.lib.render.CCModel in project GregTech by GregTechCE.
the class ShapeModelGenerator method generateFullBlockVariants.
public static CCModel[] generateFullBlockVariants(CCModel originalModel) {
CCModel[] result = new CCModel[3];
for (int i = 0; i < 3; i++) {
Transformation rotation = Rotation.sideRotations[i * 2].at(Vector3.center);
CCModel rotatedModel = originalModel.copy().apply(rotation);
result[i] = rotatedModel;
}
return result;
}
use of codechicken.lib.render.CCModel in project GregTech by GregTechCE.
the class StoneRenderer method getActualModel.
private static CCModel getActualModel(IBlockAccess world, BlockPos pos) {
TileEntitySurfaceRock tileEntity = BlockSurfaceRockNew.getTileEntity(world, pos);
if (tileEntity != null) {
if (tileEntity.cachedModel == null) {
Random random = new Random(MathHelper.getPositionRandom(pos));
tileEntity.cachedModel = generateModel(random);
}
return (CCModel) tileEntity.cachedModel;
}
return placeholderModels[0];
}
Aggregations