Follow along with the video below to see how to install our site as a web app on your home screen.
Примечание: This feature may not be available in some browsers.
Да, соеденялись.AlexSocol написал(а):Скорее, чтобы отдельно она была кубиком, а если рядом есть такая же - они соединялись
А с освещением как?AlexSocol написал(а):Скорей всего...
Я в своё время делал трубы с модельками, тампроще- 63 (или около того) варианта трубы, получая соседние блоки менял метадату и, соответственно, модель...
Думаешь это нормально? Нет. Как минимум лучше сделать один кусок изображения и рендерить по каждую сторону особым способом.там проще - 63
Поройся что-ли. Или вот.Ну как модель отрендерить через чикен либ на форуме есть, но всё-таки хотелось бы через простые квадратики.
private static void renderPipe(PipeRenderState render, List<BakedQuad> quads, Map<EnumFacing, TextureAtlasSprite> spriteMap, boolean smaller) {
float min = CoreConstants.PIPE_MIN_POS;
float max = CoreConstants.PIPE_MAX_POS;
float minUV = min * 16;
float maxUV = max * 16;
// Center bit
{
TextureAtlasSprite sprite = spriteMap.get(null);
float[] uvs = new float[4];
uvs[U_MIN] = sprite.getInterpolatedU(minUV);
uvs[U_MAX] = sprite.getInterpolatedU(maxUV);
uvs[V_MIN] = sprite.getInterpolatedV(minUV);
uvs[V_MAX] = sprite.getInterpolatedV(maxUV);
for (EnumFacing face : EnumFacing.VALUES) {
if (!render.pipeConnectionMatrix.isConnected(face) || !render.pipeConnectionBanned.isConnected(face)) {
Vec3 radius = Utils.vec3(0.25);
if (smaller) {
double smallerValue = Utils.getValue(radius, face.getAxis()) - 0.01f;
radius = Utils.withValue(radius, face.getAxis(), smallerValue);
}
bakeDoubleFace(quads, face, Utils.vec3f(0.5f), Utils.convertFloat(radius), uvs);
}
}
}
// All the connected bits
for (EnumFacing connect : EnumFacing.VALUES) {
if (render.pipeConnectionMatrix.isConnected(connect) && render.pipeConnectionBanned.isConnected(connect)) {
float extension = render.customConnections[connect.ordinal()];
TextureAtlasSprite sprite = spriteMap.get(connect);
Vec3 actualCenter = Utils.convert(connect, 0.375f + extension / 2).add(Utils.VEC_HALF);
Vec3 smallerFace = null;
if (connect.getAxisDirection() == AxisDirection.POSITIVE) {
smallerFace = Utils.convert(connect, 4 / 16d - extension);
} else {
smallerFace = Utils.convert(connect.getOpposite(), 4 / 16d - extension);
}
Vec3 actualSize = Utils.VEC_HALF.subtract(smallerFace);
if (smaller) {
// Decrease the entire size
Vec3 allSmaller = actualSize.subtract(Utils.vec3(0.02));
// Increase the size of axis the connection is in.
actualSize = allSmaller.add(Utils.convert(Utils.convertPositive(connect), 0.02));
}
Vec3 pos = actualCenter.subtract(Utils.multiply(actualSize, 1 / 2d));
EntityResizableCuboid cuboid = new EntityResizableCuboid(null);
cuboid.texture = sprite;
cuboid.makeClient();
double start = connect.getAxisDirection() == AxisDirection.POSITIVE ? 12 : 0;
cuboid.textureStartX = connect.getAxis() == Axis.X ? start : 4;
cuboid.textureStartY = connect.getAxis() == Axis.Y ? start : 4;
cuboid.textureStartZ = connect.getAxis() == Axis.Z ? start : 4;
cuboid.textureSizeX = connect.getAxis() == Axis.X ? 4 : 8;
cuboid.textureSizeY = connect.getAxis() == Axis.Y ? 4 : 8;
cuboid.textureSizeZ = connect.getAxis() == Axis.Z ? 4 : 8;
cuboid.textures[connect.ordinal()] = null;
cuboid.textures[connect.getOpposite().ordinal()] = null;
cuboid.setSize(actualSize);
cuboid.setPosition(pos.xCoord, pos.yCoord, pos.zCoord);
RenderResizableCuboid.INSTANCE.renderCubeStatic(quads, cuboid, true);
}
}
}
AlexSocol написал(а):Скорей всего...
Я в своё время делал трубы с модельками, тампроще- 63 (или около того) варианта трубы, получая соседние блоки менял метадату и, соответственно, модель...
Он отключает GlLightning, разве вся эта хня не будет светится в темноте?Agravaine написал(а):Хороший туториал:
[youtube]-bqP-UmZXjo[/youtube]
public class ModelWire extends ModelBase
{
//fields
ModelRenderer center;
ModelRenderer north;
ModelRenderer south;
ModelRenderer up;
ModelRenderer down;
ModelRenderer west;
ModelRenderer east;
public ModelWire() {
textureWidth = 32;
textureHeight = 32;
center = new ModelRenderer(this, 0, 0);
center.addBox(-3F, -3F, -3F, 6, 6, 6);
center.setRotationPoint(0F, 16F, 0F);
center.setTextureSize(32, 32);
center.mirror = true;
setRotation(center, 0F, 0F, 0F);
north = new ModelRenderer(this, 0, 12);
north.addBox(-3F, -3F, -3F, 6, 6, 5);
north.setRotationPoint(0F, 16F, -5F);
north.setTextureSize(32, 32);
north.mirror = true;
setRotation(north, 0F, 0F, 0F);
south = new ModelRenderer(this, 0, 12);
south.addBox(-3F, -3F, -3F, 6, 6, 5);
south.setRotationPoint(0F, 16F, 6F);
south.setTextureSize(32, 32);
south.mirror = true;
setRotation(south, 0F, 0F, 0F);
up = new ModelRenderer(this, 0, 12);
up.addBox(-3F, -3F, -3F, 6, 5, 6);
up.setRotationPoint(0F, 11F, 0F);
up.setTextureSize(32, 32);
up.mirror = true;
setRotation(up, 0F, 0F, 0F);
down = new ModelRenderer(this, 0, 12);
down.addBox(-3F, -3F, -3F, 6, 5, 6);
down.setRotationPoint(0F, 22F, 0F);
down.setTextureSize(32, 32);
down.mirror = true;
setRotation(down, 0F, 0F, 0F);
west = new ModelRenderer(this, 0, 12);
west.addBox(-3F, -3F, -3F, 5, 6, 6);
west.setRotationPoint(6F, 16F, 0F);
west.setTextureSize(32, 32);
west.mirror = true;
setRotation(west, 0F, 0F, 0F);
east = new ModelRenderer(this, 0, 12);
east.addBox(-4F, -3F, -3F, 5, 6, 6);
east.setRotationPoint(-4F, 16F, 0F);
east.setTextureSize(32, 32);
east.mirror = true;
setRotation(east, 0F, 0F, 0F);
}
public void render(Entity entity, float f, float f1, float f2, float f3, float f4, float f5)
{
super.render(entity, f, f1, f2, f3, f4, f5);
}
public void render(TileEntityWire tile)
{
center.render(0.0625F);
boolean[] connections = tile.getConnections();
if(connections[0]){
//DOWN
down.render(0.0625F);
}
if(connections[1]){
//UP
up.render(0.0625F);
}
if(connections[2]){
//NORTH
north.render(0.0625F);
}
if(connections[3]){
//SOUTH
south.render(0.0625F);
}
if(connections[4]){
//WEST
west.render(0.0625F);
}
if(connections[5]){
//EAST
east.render(0.0625F);
}
}
private void setRotation(ModelRenderer model, float x, float y, float z)
{
model.rotateAngleX = x;
model.rotateAngleY = y;
model.rotateAngleZ = z;
}
public void render() {
center.render(0.0625F);
}
}
Отлично, буду осваивать модельки.MegaINS написал(а):Я у себя через модельку делал, майн сам с освещением работает:
Ночь
День
Код:public class ModelWire extends ModelBase { //fields ModelRenderer center; ModelRenderer north; ModelRenderer south; ModelRenderer up; ModelRenderer down; ModelRenderer west; ModelRenderer east; public ModelWire() { textureWidth = 32; textureHeight = 32; center = new ModelRenderer(this, 0, 0); center.addBox(-3F, -3F, -3F, 6, 6, 6); center.setRotationPoint(0F, 16F, 0F); center.setTextureSize(32, 32); center.mirror = true; setRotation(center, 0F, 0F, 0F); north = new ModelRenderer(this, 0, 12); north.addBox(-3F, -3F, -3F, 6, 6, 5); north.setRotationPoint(0F, 16F, -5F); north.setTextureSize(32, 32); north.mirror = true; setRotation(north, 0F, 0F, 0F); south = new ModelRenderer(this, 0, 12); south.addBox(-3F, -3F, -3F, 6, 6, 5); south.setRotationPoint(0F, 16F, 6F); south.setTextureSize(32, 32); south.mirror = true; setRotation(south, 0F, 0F, 0F); up = new ModelRenderer(this, 0, 12); up.addBox(-3F, -3F, -3F, 6, 5, 6); up.setRotationPoint(0F, 11F, 0F); up.setTextureSize(32, 32); up.mirror = true; setRotation(up, 0F, 0F, 0F); down = new ModelRenderer(this, 0, 12); down.addBox(-3F, -3F, -3F, 6, 5, 6); down.setRotationPoint(0F, 22F, 0F); down.setTextureSize(32, 32); down.mirror = true; setRotation(down, 0F, 0F, 0F); west = new ModelRenderer(this, 0, 12); west.addBox(-3F, -3F, -3F, 5, 6, 6); west.setRotationPoint(6F, 16F, 0F); west.setTextureSize(32, 32); west.mirror = true; setRotation(west, 0F, 0F, 0F); east = new ModelRenderer(this, 0, 12); east.addBox(-4F, -3F, -3F, 5, 6, 6); east.setRotationPoint(-4F, 16F, 0F); east.setTextureSize(32, 32); east.mirror = true; setRotation(east, 0F, 0F, 0F); } public void render(Entity entity, float f, float f1, float f2, float f3, float f4, float f5) { super.render(entity, f, f1, f2, f3, f4, f5); } public void render(TileEntityWire tile) { center.render(0.0625F); boolean[] connections = tile.getConnections(); if(connections[0]){ //DOWN down.render(0.0625F); } if(connections[1]){ //UP up.render(0.0625F); } if(connections[2]){ //NORTH north.render(0.0625F); } if(connections[3]){ //SOUTH south.render(0.0625F); } if(connections[4]){ //WEST west.render(0.0625F); } if(connections[5]){ //EAST east.render(0.0625F); } } private void setRotation(ModelRenderer model, float x, float y, float z) { model.rotateAngleX = x; model.rotateAngleY = y; model.rotateAngleZ = z; } public void render() { center.render(0.0625F); } }
@Override
public boolean renderWorldBlock(IBlockAccess world, int x, int y, int z, Block block, int modelId, RenderBlocks renderer)
{
Tessellator tessellator = Tessellator.instance;
tessellator.draw();
GL11.glPushMatrix();
GL11.glTranslatef(x, y, z);
modelWire.render(0);
GL11.glPopMatrix();
tessellator.startDrawingQuads();
return true;
}
package com.svk.addItems.client.models;
import net.minecraft.client.model.ModelBase;
import net.minecraft.client.model.ModelRenderer;
public class ModelWire extends ModelBase
{
ModelRenderer center;
ModelRenderer north;
ModelRenderer south;
ModelRenderer up;
ModelRenderer down;
ModelRenderer west;
ModelRenderer east;
public ModelWire()
{
textureWidth = 32;
textureHeight = 32;
center = new ModelRenderer(this, 0, 0);
center.addBox(-3F, -3F, -3F, 6, 6, 6);
center.setRotationPoint(0F, 16F, 0F);
center.setTextureSize(32, 32);
center.mirror = true;
setRotation(center, 0F, 0F, 0F);
north = new ModelRenderer(this, 0, 12);
north.addBox(-3F, -3F, -3F, 6, 6, 5);
north.setRotationPoint(0F, 16F, -5F);
north.setTextureSize(32, 32);
north.mirror = true;
setRotation(north, 0F, 0F, 0F);
south = new ModelRenderer(this, 0, 12);
south.addBox(-3F, -3F, -3F, 6, 6, 5);
south.setRotationPoint(0F, 16F, 6F);
south.setTextureSize(32, 32);
south.mirror = true;
setRotation(south, 0F, 0F, 0F);
up = new ModelRenderer(this, 0, 12);
up.addBox(-3F, -3F, -3F, 6, 5, 6);
up.setRotationPoint(0F, 11F, 0F);
up.setTextureSize(32, 32);
up.mirror = true;
setRotation(up, 0F, 0F, 0F);
down = new ModelRenderer(this, 0, 12);
down.addBox(-3F, -3F, -3F, 6, 5, 6);
down.setRotationPoint(0F, 22F, 0F);
down.setTextureSize(32, 32);
down.mirror = true;
setRotation(down, 0F, 0F, 0F);
west = new ModelRenderer(this, 0, 12);
west.addBox(-3F, -3F, -3F, 5, 6, 6);
west.setRotationPoint(6F, 16F, 0F);
west.setTextureSize(32, 32);
west.mirror = true;
setRotation(west, 0F, 0F, 0F);
east = new ModelRenderer(this, 0, 12);
east.addBox(-4F, -3F, -3F, 5, 6, 6);
east.setRotationPoint(-4F, 16F, 0F);
east.setTextureSize(32, 32);
east.mirror = true;
setRotation(east, 0F, 0F, 0F);
}
public void render(int connectID)
{
center.render(0.0625F);
}
private void setRotation(ModelRenderer model, float x, float y, float z)
{
model.rotateAngleX = x;
model.rotateAngleY = y;
model.rotateAngleZ = z;
}
}