Search in sources :

Example 1 with Tuple3f

use of javax.vecmath.Tuple3f in project BuildCraft by BuildCraft.

the class PipeWireRenderer method getQuads.

private static MutableQuad[] getQuads(EnumWirePart part) {
    MutableQuad[] quads = new MutableQuad[6];
    Tuple3f center = new // 
    Point3f(// 
    0.5f + (part.x.getOffset() * 4.51f / 16f), // 
    0.5f + (part.y.getOffset() * 4.51f / 16f), // 
    0.5f + (part.z.getOffset() * 4.51f / 16f));
    Tuple3f radius = new Point3f(1 / 32f, 1 / 32f, 1 / 32f);
    UvFaceData uvs = new UvFaceData();
    int off = func(part.x) * 4 + func(part.y) * 2 + func(part.z);
    uvs.minU = off / 16f;
    uvs.maxU = (off + 1) / 16f;
    uvs.minV = 0;
    uvs.maxV = 1 / 16f;
    for (EnumFacing face : EnumFacing.VALUES) {
        quads[face.ordinal()] = ModelUtil.createFace(face, center, radius, uvs);
    }
    return quads;
}
Also used : UvFaceData(buildcraft.lib.client.model.ModelUtil.UvFaceData) Tuple3f(javax.vecmath.Tuple3f) Point3f(javax.vecmath.Point3f) EnumFacing(net.minecraft.util.EnumFacing) MutableQuad(buildcraft.lib.client.model.MutableQuad)

Example 2 with Tuple3f

use of javax.vecmath.Tuple3f in project BuildCraft by BuildCraft.

the class PipeWireRenderer method getQuads.

private static MutableQuad[] getQuads(EnumWireBetween between) {
    // 4 rather than 6 -- don't render the end caps
    MutableQuad[] quads = new MutableQuad[4];
    int i = 0;
    Vec3d center;
    Vec3d radius;
    boolean ax = between.mainAxis == Axis.X;
    boolean ay = between.mainAxis == Axis.Y;
    boolean az = between.mainAxis == Axis.Z;
    if (between.to == null) {
        double cL = 0.5f - 4.51f / 16f;
        double cU = 0.5f + 4.51f / 16f;
        center = new // 
        Vec3d(// 
        ax ? 0.5f : (between.xy ? cU : cL), // 
        ay ? 0.5f : ((ax ? between.xy : between.yz) ? cU : cL), // 
        az ? 0.5f : (between.yz ? cU : cL));
        double rC = 4.01f / 16f;
        double rN = 1f / 16f / 2;
        radius = new // 
        Vec3d(// 
        ax ? rC : rN, // 
        ay ? rC : rN, // 
        az ? rC : rN);
    } else {
        // we are a connection
        double cL = (8 - 4.51) / 16;
        double cU = (8 + 4.51) / 16;
        radius = new // 
        Vec3d(// 
        ax ? 2.99 / 32 : 1 / 32.0, // 
        ay ? 2.99 / 32 : 1 / 32.0, // 
        az ? 2.99 / 32 : 1 / 32.0);
        center = new // 
        Vec3d(// 
        ax ? (0.5 + 6.505 / 16 * between.to.getFrontOffsetX()) : (between.xy ? cU : cL), // 
        ay ? (0.5 + 6.505 / 16 * between.to.getFrontOffsetY()) : ((ax ? between.xy : between.yz) ? cU : cL), // 
        az ? (0.5 + 6.505 / 16 * between.to.getFrontOffsetZ()) : (between.yz ? cU : cL));
    }
    UvFaceData uvBase = new UvFaceData();
    uvBase.minU = (float) VecUtil.getValue(center.subtract(radius), between.mainAxis);
    uvBase.maxU = (float) VecUtil.getValue(center.add(radius), between.mainAxis);
    uvBase.minV = 0;
    uvBase.maxV = 1 / 16f;
    Tuple3f centerFloat = VecUtil.convertFloat(center);
    Tuple3f radiusFloat = VecUtil.convertFloat(radius);
    for (EnumFacing face : EnumFacing.VALUES) {
        if (face.getAxis() == between.mainAxis) {
            continue;
        }
        UvFaceData uvs = new UvFaceData(uvBase);
        Axis aAxis = between.mainAxis;
        Axis fAxis = face.getAxis();
        boolean fPositive = face.getAxisDirection() == AxisDirection.POSITIVE;
        int rotations = 0;
        boolean swapU = false;
        boolean swapV = false;
        if (aAxis == Axis.X) {
            swapV = fPositive;
        } else if (aAxis == Axis.Y) {
            rotations = 1;
            swapU = (fAxis == Axis.X) != fPositive;
            swapV = fAxis == Axis.Z;
        } else {
            // aAxis == Axis.Z
            if (fAxis == Axis.Y) {
                rotations = 1;
            }
            swapU = face == EnumFacing.DOWN;
            swapV = face != EnumFacing.EAST;
        }
        if (swapU) {
            float t = uvs.minU;
            uvs.minU = uvs.maxU;
            uvs.maxU = t;
        }
        if (swapV) {
            float t = uvs.minV;
            uvs.minV = uvs.maxV;
            uvs.maxV = t;
        }
        MutableQuad quad = ModelUtil.createFace(face, centerFloat, radiusFloat, uvs);
        if (rotations > 0)
            quad.rotateTextureUp(rotations);
        quads[i++] = quad;
    }
    return quads;
}
Also used : UvFaceData(buildcraft.lib.client.model.ModelUtil.UvFaceData) Tuple3f(javax.vecmath.Tuple3f) EnumFacing(net.minecraft.util.EnumFacing) Vec3d(net.minecraft.util.math.Vec3d) Axis(net.minecraft.util.EnumFacing.Axis) MutableQuad(buildcraft.lib.client.model.MutableQuad)

Aggregations

UvFaceData (buildcraft.lib.client.model.ModelUtil.UvFaceData)2 MutableQuad (buildcraft.lib.client.model.MutableQuad)2 Tuple3f (javax.vecmath.Tuple3f)2 EnumFacing (net.minecraft.util.EnumFacing)2 Point3f (javax.vecmath.Point3f)1 Axis (net.minecraft.util.EnumFacing.Axis)1 Vec3d (net.minecraft.util.math.Vec3d)1