Search in sources :

Example 21 with Vector3d

use of com.enderio.core.common.vecmath.Vector3d in project EnderIO by SleepyTrousers.

the class HalfBakedQuad method recomputeNormals.

public void recomputeNormals() {
    Vector3d T1 = new Vector3d();
    Vector3d T2 = new Vector3d();
    Vector3d T3 = new Vector3d();
    T1.set(corners.get(1).xyz);
    T1.sub(corners.get(0).xyz);
    T2.set(corners.get(2).xyz);
    T2.sub(corners.get(0).xyz);
    T3.cross(T1, T2);
    T3.normalize();
    for (Vertex vertex : corners) {
        vertex.setNormal(T3.x, T3.y, T3.z);
    }
}
Also used : Vertex(com.enderio.core.common.vecmath.Vertex) Vector3d(com.enderio.core.common.vecmath.Vector3d)

Example 22 with Vector3d

use of com.enderio.core.common.vecmath.Vector3d in project EnderIO by SleepyTrousers.

the class TileElectricLight method addDiaganals.

private void addDiaganals(Vector3d[] diags, Vector3d trans, Set<BlockPos> result) {
    Vector3d offset = new Vector3d();
    offset.set(diags[0]);
    offset.add(diags[1]);
    addNodeInDirection(offset.add(trans), result);
    offset.set(diags[0]);
    offset.sub(diags[1]);
    addNodeInDirection(offset.add(trans), result);
    offset.set(diags[0]);
    offset.negate();
    offset.add(diags[1]);
    addNodeInDirection(offset.add(trans), result);
    offset.set(diags[0]);
    offset.negate();
    offset.sub(diags[1]);
    addNodeInDirection(offset.add(trans), result);
}
Also used : Vector3d(com.enderio.core.common.vecmath.Vector3d)

Example 23 with Vector3d

use of com.enderio.core.common.vecmath.Vector3d in project EnderIO by SleepyTrousers.

the class KillerJoeRenderMapper method renderHead.

private List<BakedQuad> renderHead(@Nullable IBlockStateWrapper state) {
    EnumFacing facing = EnumFacing.NORTH;
    if (state != null) {
        TileEntity tileEntity = state.getTileEntity();
        if (tileEntity instanceof AbstractMachineEntity) {
            facing = ((AbstractMachineEntity) tileEntity).getFacing();
            if (facing.getAxis() == EnumFacing.Axis.X) {
                facing = facing.getOpposite();
            }
        }
    }
    VertexRotationFacing rot = new VertexRotationFacing(EnumFacing.NORTH);
    rot.setCenter(CENTER);
    rot.setRotation(facing);
    BoundingBox bb = new BoundingBox(4 * px, 4 * px, 4 * px, 12 * px, 12 * px, 12 * px);
    VertexTransform sca = new VertexScale(.9, .9, .9, CENTER);
    VertexTransform rotx = new VertexRotation(0.03054326, new Vector3d(1, 0, 0), CENTER);
    VertexTransform roty = new VertexRotation(0.17453290, new Vector3d(0, 1, 0), CENTER);
    VertexTransform rotz = new VertexRotation(0.23928460, new Vector3d(0, 0, 1), CENTER);
    VertexTransform mov = new VertexTranslation(0.25 * px, -1 * px, 0);
    TextureAtlasSprite tex1 = head1.get(TextureAtlasSprite.class);
    TextureAtlasSprite tex2 = head2.get(TextureAtlasSprite.class);
    HalfBakedList buffer = new HalfBakedList();
    buffer.add(bb, EnumFacing.NORTH, 0f, .5f, 0f, .5f, tex1, null);
    buffer.add(bb, EnumFacing.EAST, .5f, 1f, 0f, .5f, tex1, null);
    buffer.add(bb, EnumFacing.SOUTH, 0f, .5f, .5f, 1f, tex1, null);
    buffer.add(bb, EnumFacing.WEST, .5f, 1f, .5f, 1f, tex1, null);
    buffer.add(bb, EnumFacing.UP, 0f, .5f, 0f, .5f, tex2, null);
    buffer.add(bb, EnumFacing.DOWN, .5f, 1f, 0f, .5f, tex2, null);
    List<BakedQuad> quads = new ArrayList<BakedQuad>();
    buffer.bake(quads, sca, rotx, roty, rotz, mov, rot);
    for (double angle : ROTS) {
        buffer = new HalfBakedList();
        BoundingBox bb1 = new BoundingBox(4.5 * px, 10.5 * px, 3 * px, 5.5 * px, 11.5 * px, 4 * px);
        BoundingBox bb2 = new BoundingBox(7.5 * px, 9.5 * px, 3 * px, 8.5 * px, 10.5 * px, 4 * px);
        BoundingBox bb3 = new BoundingBox(10.5 * px, 10.5 * px, 3 * px, 11.5 * px, 11.5 * px, 4 * px);
        for (EnumFacing face : EnumFacing.values()) {
            buffer.add(bb1, face, (face.ordinal() + 1) * px, (face.ordinal() + 2) * px, 9 * px, 10 * px, tex2, null);
            buffer.add(bb2, face, (face.ordinal() + 1) * px, (face.ordinal() + 2) * px, 10 * px, 11 * px, tex2, null);
            buffer.add(bb3, face, (face.ordinal() + 1) * px, (face.ordinal() + 2) * px, 11 * px, 12 * px, tex2, null);
        }
        VertexTransform rota = new VertexRotation(angle, new Vector3d(0, 1, 0), CENTER);
        buffer.bake(quads, sca, rota, rotx, roty, rotz, mov, rot);
    }
    return quads;
}
Also used : BakedQuad(net.minecraft.client.renderer.block.model.BakedQuad) TextureAtlasSprite(net.minecraft.client.renderer.texture.TextureAtlasSprite) EnumFacing(net.minecraft.util.EnumFacing) ArrayList(java.util.ArrayList) VertexScale(com.enderio.core.client.render.VertexScale) VertexTransform(com.enderio.core.api.client.render.VertexTransform) HalfBakedList(crazypants.enderio.base.render.util.HalfBakedQuad.HalfBakedList) TileEntity(net.minecraft.tileentity.TileEntity) VertexTranslation(com.enderio.core.client.render.VertexTranslation) VertexRotationFacing(com.enderio.core.client.render.VertexRotationFacing) VertexRotation(com.enderio.core.client.render.VertexRotation) AbstractMachineEntity(crazypants.enderio.base.machine.base.te.AbstractMachineEntity) Vector3d(com.enderio.core.common.vecmath.Vector3d) BoundingBox(com.enderio.core.client.render.BoundingBox)

Example 24 with Vector3d

use of com.enderio.core.common.vecmath.Vector3d in project EnderIO by SleepyTrousers.

the class TileKillerJoe method getHooverBounds.

@Nonnull
private AxisAlignedBB getHooverBounds() {
    if (hooverBounds == NULL_AABB) {
        double killerJoeHooverXpHeight = KillerJoeConfig.killerJoeHooverXpHeight.get();
        double killerJoeHooverXpLength = KillerJoeConfig.killerJoeHooverXpLength.get();
        double killerJoeHooverXpWidth = KillerJoeConfig.killerJoeHooverXpWidth.get();
        BoundingBox bb = new BoundingBox(getLocation());
        Vector3d min = bb.getMin();
        Vector3d max = bb.getMax();
        max.y += killerJoeHooverXpHeight;
        min.y -= killerJoeHooverXpHeight;
        EnumFacing facingDir = facing;
        if (ForgeDirectionOffsets.isPositiveOffset(facingDir)) {
            max.add(ForgeDirectionOffsets.offsetScaled(facingDir, killerJoeHooverXpLength));
            min.add(ForgeDirectionOffsets.forDir(facingDir));
        } else {
            min.add(ForgeDirectionOffsets.offsetScaled(facingDir, killerJoeHooverXpLength));
            max.add(ForgeDirectionOffsets.forDir(facingDir));
        }
        if (facingDir.getFrontOffsetX() == 0) {
            min.x -= killerJoeHooverXpWidth * 2;
            max.x += killerJoeHooverXpWidth * 2;
        } else {
            min.z -= killerJoeHooverXpWidth * 2;
            max.z += killerJoeHooverXpWidth * 2;
        }
        hooverBounds = new AxisAlignedBB(min.x, min.y, min.z, max.x, max.y, max.z);
    }
    return hooverBounds;
}
Also used : AxisAlignedBB(net.minecraft.util.math.AxisAlignedBB) Vector3d(com.enderio.core.common.vecmath.Vector3d) BoundingBox(com.enderio.core.client.render.BoundingBox) EnumFacing(net.minecraft.util.EnumFacing) Nonnull(javax.annotation.Nonnull)

Example 25 with Vector3d

use of com.enderio.core.common.vecmath.Vector3d in project EnderIO by SleepyTrousers.

the class ConduitGeometryUtil method getTranslation.

@Nonnull
public Vector3d getTranslation(EnumFacing dir, @Nonnull Offset offset) {
    Vector3d result = new Vector3d(offset.xOffset, offset.yOffset, offset.zOffset);
    result.scale(WIDTH);
    return result;
}
Also used : Vector3d(com.enderio.core.common.vecmath.Vector3d) Nonnull(javax.annotation.Nonnull)

Aggregations

Vector3d (com.enderio.core.common.vecmath.Vector3d)35 BoundingBox (com.enderio.core.client.render.BoundingBox)9 EnumFacing (net.minecraft.util.EnumFacing)7 BlockPos (net.minecraft.util.math.BlockPos)7 Nonnull (javax.annotation.Nonnull)6 Vertex (com.enderio.core.common.vecmath.Vertex)4 ArrayList (java.util.ArrayList)4 SideOnly (net.minecraftforge.fml.relauncher.SideOnly)4 TextureAtlasSprite (net.minecraft.client.renderer.texture.TextureAtlasSprite)3 TileEntity (net.minecraft.tileentity.TileEntity)3 RayTraceResult (net.minecraft.util.math.RayTraceResult)3 Vec3d (net.minecraft.util.math.Vec3d)3 VertexRotationFacing (com.enderio.core.client.render.VertexRotationFacing)2 Vector2d (com.enderio.core.common.vecmath.Vector2d)2 Vector4f (com.enderio.core.common.vecmath.Vector4f)2 IBlockState (net.minecraft.block.state.IBlockState)2 Minecraft (net.minecraft.client.Minecraft)2 BufferBuilder (net.minecraft.client.renderer.BufferBuilder)2 BlockRenderLayer (net.minecraft.util.BlockRenderLayer)2 AxisAlignedBB (net.minecraft.util.math.AxisAlignedBB)2