Search in sources :

Example 6 with Vector4f

use of org.terasology.math.geom.Vector4f in project Terasology by MovingBlocks.

the class Block method calcColorOffsetFor.

/**
 * Calculates the color offset for a given block type and a specific
 * side of the block.
 *
 * @param part  The block side
 * @param biome The block's biome
 * @return The color offset
 */
public Vector4f calcColorOffsetFor(BlockPart part, Biome biome) {
    BlockColorSource source = getColorSource(part);
    Vector4f color = source.calcColor(biome);
    Vector4f colorOffset = colorOffsets.get(part);
    color.x *= colorOffset.x;
    color.y *= colorOffset.y;
    color.z *= colorOffset.z;
    color.w *= colorOffset.w;
    return color;
}
Also used : Vector4f(org.terasology.math.geom.Vector4f)

Example 7 with Vector4f

use of org.terasology.math.geom.Vector4f in project Terasology by MovingBlocks.

the class BackdropNode method getAllWeatherZenith.

static Vector3f getAllWeatherZenith(float thetaSunAngle, float turbidity) {
    float thetaSun = (float) Math.acos(thetaSunAngle);
    Vector4f cx1 = new Vector4f(0.0f, 0.00209f, -0.00375f, 0.00165f);
    Vector4f cx2 = new Vector4f(0.00394f, -0.03202f, 0.06377f, -0.02903f);
    Vector4f cx3 = new Vector4f(0.25886f, 0.06052f, -0.21196f, 0.11693f);
    Vector4f cy1 = new Vector4f(0.0f, 0.00317f, -0.00610f, 0.00275f);
    Vector4f cy2 = new Vector4f(0.00516f, -0.04153f, 0.08970f, -0.04214f);
    Vector4f cy3 = new Vector4f(0.26688f, 0.06670f, -0.26756f, 0.15346f);
    float t2 = turbidity * turbidity;
    float chi = (4.0f / 9.0f - turbidity / 120.0f) * ((float) Math.PI - 2.0f * thetaSun);
    Vector4f theta = new Vector4f(1, thetaSun, thetaSun * thetaSun, thetaSun * thetaSun * thetaSun);
    float why = (4.0453f * turbidity - 4.9710f) * (float) Math.tan(chi) - 0.2155f * turbidity + 2.4192f;
    float x = t2 * cx1.dot(theta) + turbidity * cx2.dot(theta) + cx3.dot(theta);
    float y = t2 * cy1.dot(theta) + turbidity * cy2.dot(theta) + cy3.dot(theta);
    return new Vector3f(why, x, y);
}
Also used : Vector4f(org.terasology.math.geom.Vector4f) Vector3f(org.terasology.math.geom.Vector3f)

Example 8 with Vector4f

use of org.terasology.math.geom.Vector4f in project Terasology by MovingBlocks.

the class InitialiseGraphics method step.

@Override
public boolean step() {
    // Refresh widget library after modules got laoded:
    NUIManager nuiManager = context.get(NUIManager.class);
    ((NUIManagerInternal) nuiManager).refreshWidgetsLibrary();
    // TODO: This should be elsewhere
    // Create gelatinousCubeMesh
    Tessellator tessellator = new Tessellator();
    TessellatorHelper.addBlockMesh(tessellator, new Vector4f(1.0f, 1.0f, 1.0f, 1.0f), 0.8f, 0.8f, 0.6f, 0f, 0f, 0f);
    TessellatorHelper.addBlockMesh(tessellator, new Vector4f(1.0f, 1.0f, 1.0f, 0.6f), 1.0f, 1.0f, 0.8f, 0f, 0f, 0f);
    tessellator.generateMesh(new ResourceUrn(TerasologyConstants.ENGINE_MODULE, new Name("gelatinousCube")));
    return true;
}
Also used : Tessellator(org.terasology.rendering.primitives.Tessellator) Vector4f(org.terasology.math.geom.Vector4f) NUIManager(org.terasology.rendering.nui.NUIManager) ResourceUrn(org.terasology.assets.ResourceUrn) NUIManagerInternal(org.terasology.rendering.nui.internal.NUIManagerInternal) Name(org.terasology.naming.Name)

Aggregations

Vector4f (org.terasology.math.geom.Vector4f)8 Vector3f (org.terasology.math.geom.Vector3f)3 Tessellator (org.terasology.rendering.primitives.Tessellator)3 Vector2f (org.terasology.math.geom.Vector2f)2 ByteBuffer (java.nio.ByteBuffer)1 ResourceUrn (org.terasology.assets.ResourceUrn)1 Side (org.terasology.math.Side)1 Rect2i (org.terasology.math.geom.Rect2i)1 Vector3i (org.terasology.math.geom.Vector3i)1 Name (org.terasology.naming.Name)1 NUIManager (org.terasology.rendering.nui.NUIManager)1 NUIManagerInternal (org.terasology.rendering.nui.internal.NUIManagerInternal)1 Biome (org.terasology.world.biomes.Biome)1 Block (org.terasology.world.block.Block)1 BlockAppearance (org.terasology.world.block.BlockAppearance)1