Java 类org.lwjgl.util.vector.Vector4f 实例源码

项目:open-world    文件:World.java   
public void renderWithoutWater(final PerspectiveCamera camera, final boolean renderReflected) {
shader.bind();
shader.update(camera, directionalLight);

if(renderReflected) {
    shader.setUniform("clip_plane", new Vector4f(0, 1, 0, -WaterRegion.WATER_HEIGHT));
} else {
    shader.setUniform("clip_plane", new Vector4f(0, 0, 0, 0));
}

if(skybox != null) {
    skybox.render(camera);
}

for(Entry<String, Region> region : regions.entrySet()) {
    region.getValue().render(shader);
}
   }
项目:Solar    文件:QuadBuilder.java   
private BakedQuad createQuad(QuadHolder holder, EnumFacing facing) {
    Vector4f uv = holder.uv;
    Vector3 a = holder.a;
    Vector3 b = holder.b;
    Vector3 c = holder.c;
    Vector3 d = holder.d;

    Vector3 normal = c.copy().subtract(b).cross(a.copy().subtract(b)).normalize();
    UnpackedBakedQuad.Builder builder = new UnpackedBakedQuad.Builder(format);
    putVertex(builder, normal, a.x, a.y, a.z, holder.sprite, uv.y, uv.w, hasBrightness);
    putVertex(builder, normal, b.x, b.y, b.z, holder.sprite, uv.y, uv.z, hasBrightness);
    putVertex(builder, normal, c.x, c.y, c.z, holder.sprite, uv.x, uv.z, hasBrightness);
    putVertex(builder, normal, d.x, d.y, d.z, holder.sprite, uv.x, uv.w, hasBrightness);
    builder.setQuadOrientation(facing);
    builder.setTexture(holder.sprite);
    return builder.build();
}
项目:3d-Engine    文件:MasterRenderer.java   
public void render(List<Light> lights, Camera camera, Vector4f clipPlane) {
    prepare();
    shader.start();
    shader.loadClipPlane(clipPlane);
    shader.loadSkyColour(RED, GREEN, BLUE);
    shader.loadLights(lights);
    shader.loadViewMatrix(camera);
    renderer.render(entities);
    shader.stop();
    normalMapRenderer.render(normalMapEntities, clipPlane, lights, camera);
    terrainShader.start();
    terrainShader.loadClipPlane(clipPlane);
    terrainShader.loadSkyColour(RED, GREEN, BLUE);
    terrainShader.loadLights(lights);
    terrainShader.loadViewMatrix(camera);
    terrainRenderer.render(terrains);
    terrainShader.stop();
    skyboxRenderer.render(camera, RED, GREEN, BLUE);
    terrains.clear();
    entities.clear();
    normalMapEntities.clear();
}
项目:3d-Engine    文件:ParticleSystem.java   
private static Vector3f generateRandomUnitVectorWithinCone(Vector3f coneDirection, float angle) {
    float cosAngle = (float) Math.cos(angle);
    Random random = new Random();
    float theta = (float) (random.nextFloat() * 2f * Math.PI);
    float z = cosAngle + (random.nextFloat() * (1 - cosAngle));
    float rootOneMinusZSquared = (float) Math.sqrt(1 - z * z);
    float x = (float) (rootOneMinusZSquared * Math.cos(theta));
    float y = (float) (rootOneMinusZSquared * Math.sin(theta));

    Vector4f direction = new Vector4f(x, y, z, 1);
    if (coneDirection.x != 0 || coneDirection.y != 0 || (coneDirection.z != 1 && coneDirection.z != -1)) {
        Vector3f rotateAxis = Vector3f.cross(coneDirection, new Vector3f(0, 0, 1), null);
        rotateAxis.normalise();
        float rotateAngle = (float) Math.acos(Vector3f.dot(coneDirection, new Vector3f(0, 0, 1)));
        Matrix4f rotationMatrix = new Matrix4f();
        rotationMatrix.rotate(-rotateAngle, rotateAxis);
        Matrix4f.transform(rotationMatrix, direction, direction);
    } else if (coneDirection.z == -1) {
        direction.z *= -1;
    }
    return new Vector3f(direction);
}
项目:sandbox    文件:MasterRenderer.java   
public void render(List<Light> lights, Camera camera, Vector4f clipPlane) {
    prepare();
    shader.start();
    shader.loadClipPlane(clipPlane);
    shader.loadSkyClourVariable(fogColour.x, fogColour.y, fogColour.z);
    shader.loadLights(lights);
    shader.loadViewMatrix(camera);
    entityRenderer.render(entities, shadowMapRenderer.getToShadowMapSpaceMatrix());
    shader.stop();
    terrainShader.start();
    terrainShader.loadClipPlane(clipPlane);
    terrainShader.loadSkyColorVariable(fogColour.x, fogColour.y, fogColour.z);
    terrainShader.loadLights(lights);
    terrainShader.loadViewMatrix(camera);
    terrainRenderer.render(terrains, shadowMapRenderer.getToShadowMapSpaceMatrix());
    terrainShader.stop();
    skyboxRenderer.render(camera, fogColour.x, fogColour.y, fogColour.z);

    GL11.glShadeModel(GL11.GL_SMOOTH);
    entities.clear();
    terrains.clear();
}
项目:sandbox    文件:ParticleSystem.java   
private static Vector3f generateRandomUnitVectorWithinCone(Vector3f coneDirection, float angle) {
    float cosAngle = (float) Math.cos(angle);
    Random random = new Random();
    float theta = (float) (random.nextFloat() * 2f * Math.PI);
    float z = cosAngle + (random.nextFloat() * (1 - cosAngle));
    float rootOneMinusZSquared = (float) Math.sqrt(1 - z * z);
    float x = (float) (rootOneMinusZSquared * Math.cos(theta));
    float y = (float) (rootOneMinusZSquared * Math.sin(theta));

    Vector4f direction = new Vector4f(x, y, z, 1);
    if (coneDirection.x != 0 || coneDirection.y != 0 || (coneDirection.z != 1 && coneDirection.z != -1)) {
        Vector3f rotateAxis = Vector3f.cross(coneDirection, new Vector3f(0, 0, 1), null);
        rotateAxis.normalise();
        float rotateAngle = (float) Math.acos(Vector3f.dot(coneDirection, new Vector3f(0, 0, 1)));
        Matrix4f rotationMatrix = new Matrix4f();
        rotationMatrix.rotate(-rotateAngle, rotateAxis);
        Matrix4f.transform(rotationMatrix, direction, direction);
    } else if (coneDirection.z == -1) {
        direction.z *= -1;
    }
    return new Vector3f(direction);
}
项目:sandbox    文件:ShadowBox.java   
private Vector4f[] calculateFrustumVertices(Matrix4f rotation, Vector3f forwardVector, Vector3f centerNear, Vector3f centerFar) {
    Vector3f upVector = new Vector3f(Matrix4f.transform(rotation, UP, null));
    Vector3f rightVector = Vector3f.cross(forwardVector, upVector, null);
    Vector3f downVector = new Vector3f(-upVector.x, -upVector.y, -upVector.z);
    Vector3f leftVector = new Vector3f(-rightVector.x, -rightVector.y, -rightVector.z);
    Vector3f farTop = Vector3f.add(centerFar, new Vector3f(upVector.x * farHeight, upVector.y * farHeight, upVector.z * farHeight), null);
    Vector3f farBottom = Vector3f.add(centerFar, new Vector3f(downVector.x * farHeight, downVector.y * farHeight, downVector.z * farHeight), null);
    Vector3f nearTop = Vector3f.add(centerNear, new Vector3f(upVector.x * nearHeight, upVector.y * nearHeight, upVector.z * nearHeight), null);
    Vector3f nearBottom = Vector3f.add(centerNear, new Vector3f(downVector.x * nearHeight, downVector.y * nearHeight, downVector.z * nearHeight), null);
    Vector4f[] points = new Vector4f[8];
    points[0] = calculateLightSpaceFrustumCorner(farTop, rightVector, farWidth);
    points[1] = calculateLightSpaceFrustumCorner(farTop, leftVector, farWidth);
    points[2] = calculateLightSpaceFrustumCorner(farBottom, rightVector, farWidth);
    points[3] = calculateLightSpaceFrustumCorner(farBottom, leftVector, farWidth);
    points[4] = calculateLightSpaceFrustumCorner(nearTop, rightVector, nearWidth);
    points[5] = calculateLightSpaceFrustumCorner(nearTop, leftVector, nearWidth);
    points[6] = calculateLightSpaceFrustumCorner(nearBottom, rightVector, nearWidth);
    points[7] = calculateLightSpaceFrustumCorner(nearBottom, leftVector, nearWidth);
    return points;
}
项目:Mystic-Bastion    文件:ShadowBox.java   
/**
 * Calculates the position of the vertex at each corner of the view frustum
 * in light space (8 vertices in total, so this returns 8 positions).
 * 
 * @param rotation
 *            - camera's rotation.
 * @param forwardVector
 *            - the direction that the camera is aiming, and thus the
 *            direction of the frustum.
 * @param centerNear
 *            - the center point of the frustum's near plane.
 * @param centerFar
 *            - the center point of the frustum's (possibly adjusted) far
 *            plane.
 * @return The positions of the vertices of the frustum in light space.
 */
private Vector4f[] calculateFrustumVertices(Matrix4f rotation, Vector3f forwardVector, Vector3f centerNear,
        Vector3f centerFar) {
    Vector3f upVector = new Vector3f(Matrix4f.transform(rotation, UP, null));
    Vector3f rightVector = Vector3f.cross(forwardVector, upVector, null);
    Vector3f downVector = new Vector3f(-upVector.x, -upVector.y, -upVector.z);
    Vector3f leftVector = new Vector3f(-rightVector.x, -rightVector.y, -rightVector.z);
    Vector3f farTop = Vector3f.add(centerFar,
            new Vector3f(upVector.x * farHeight, upVector.y * farHeight, upVector.z * farHeight), null);
    Vector3f farBottom = Vector3f.add(centerFar,
            new Vector3f(downVector.x * farHeight, downVector.y * farHeight, downVector.z * farHeight), null);
    Vector3f nearTop = Vector3f.add(centerNear,
            new Vector3f(upVector.x * nearHeight, upVector.y * nearHeight, upVector.z * nearHeight), null);
    Vector3f nearBottom = Vector3f.add(centerNear,
            new Vector3f(downVector.x * nearHeight, downVector.y * nearHeight, downVector.z * nearHeight), null);
    Vector4f[] points = new Vector4f[8];
    points[0] = calculateLightSpaceFrustumCorner(farTop, rightVector, farWidth);
    points[1] = calculateLightSpaceFrustumCorner(farTop, leftVector, farWidth);
    points[2] = calculateLightSpaceFrustumCorner(farBottom, rightVector, farWidth);
    points[3] = calculateLightSpaceFrustumCorner(farBottom, leftVector, farWidth);
    points[4] = calculateLightSpaceFrustumCorner(nearTop, rightVector, nearWidth);
    points[5] = calculateLightSpaceFrustumCorner(nearTop, leftVector, nearWidth);
    points[6] = calculateLightSpaceFrustumCorner(nearBottom, rightVector, nearWidth);
    points[7] = calculateLightSpaceFrustumCorner(nearBottom, leftVector, nearWidth);
    return points;
}
项目:Mystic-Bastion    文件:MasterRenderer.java   
public void render(List<Light> lights, Camera camera, Vector4f clipPlane) {
    prepare();
    shader.start();
    shader.loadClipPlane(clipPlane);
    shader.loadSkyColour(RED, GREEN, BLUE);
    shader.loadLights(lights);
    shader.loadViewMatrix(camera);
    renderer.render(entities, shadowMapRenderer.getToShadowMapSpaceMatrix());
    shader.stop();
    normalMapRenderer.render(normalMapEntities, clipPlane, lights, camera);
    terrainShader.start();
    terrainShader.loadClipPlane(clipPlane);
    terrainShader.loadSkyColour(RED, GREEN, BLUE);
    terrainShader.loadLights(lights);
    terrainShader.loadViewMatrix(camera);
    terrainRenderer.render(terrains, shadowMapRenderer.getToShadowMapSpaceMatrix());
    terrainShader.stop();
    skyboxRenderer.render(camera, RED, GREEN, BLUE);
    terrains.clear();
    entities.clear();
    normalMapEntities.clear();
}
项目:Mystic-Bastion    文件:ParticleSystem.java   
private static Vector3f generateRandomUnitVectorWithinCone(Vector3f coneDirection, float angle) {
    float cosAngle = (float) Math.cos(angle);
    Random random = new Random();
    float theta = (float) (random.nextFloat() * 2f * Math.PI);
    float z = cosAngle + (random.nextFloat() * (1 - cosAngle));
    float rootOneMinusZSquared = (float) Math.sqrt(1 - z * z);
    float x = (float) (rootOneMinusZSquared * Math.cos(theta));
    float y = (float) (rootOneMinusZSquared * Math.sin(theta));

    Vector4f direction = new Vector4f(x, y, z, 1);
    if (coneDirection.x != 0 || coneDirection.y != 0 || (coneDirection.z != 1 && coneDirection.z != -1)) {
        Vector3f rotateAxis = Vector3f.cross(coneDirection, new Vector3f(0, 0, 1), null);
        rotateAxis.normalise();
        float rotateAngle = (float) Math.acos(Vector3f.dot(coneDirection, new Vector3f(0, 0, 1)));
        Matrix4f rotationMatrix = new Matrix4f();
        rotationMatrix.rotate(-rotateAngle, rotateAxis);
        Matrix4f.transform(rotationMatrix, direction, direction);
    } else if (coneDirection.z == -1) {
        direction.z *= -1;
    }
    return new Vector3f(direction);
}
项目:Save-The-Ball    文件:Wall.java   
public Vector4f isAbove(Vector3f pointToCheck) {
    float len = (this.length - 2*margin) * wl;
    float wid = (Wall.width - 2*margin) * wl;

    Vector2f p1 = new Vector2f(this.position.x,this.position.z-margin);
    Vector2f p2,p3,p4;
    if(isLeftWall()){
        p2 = new Vector2f(p1.x + wid, p1.y - wid);
        p3 = new Vector2f(p2.x - len, p2.y - len);
        p4 = new Vector2f(p1.x - len, p1.y - len);
    }
    else{
        p2 = new Vector2f(p1.x + wid, p1.y + wid);
        p3 = new Vector2f(p2.x + len, p2.y - len);
        p4 = new Vector2f(p1.x + len, p1.y - len);
    }
    Vector2f point = new Vector2f(pointToCheck.x,pointToCheck.z);

    int x1 = Maths.orientation(p1, p2, point);
    int x2 = Maths.orientation(p2, p3, point);
    int x3 = Maths.orientation(p3, p4, point);
    int x4 = Maths.orientation(p4, p1, point);

    Vector4f pointPosition = new Vector4f(x1,x2,x3,x4);
    return pointPosition; 
}
项目:ldparteditor    文件:Manipulator.java   
public void copyState(Manipulator origin) {
    this.accuratePosition = origin.accuratePosition.clone();
    this.position = new Vector4f(origin.position);
    this.xAxis = new Vector4f(origin.xAxis);
    this.yAxis = new Vector4f(origin.yAxis);
    this.zAxis = new Vector4f(origin.zAxis);
    this.accurateXaxis = origin.accurateXaxis.clone();
    this.accurateYaxis = origin.accurateYaxis.clone();
    this.accurateZaxis = origin.accurateZaxis.clone();

    this.result.load(origin.result);
    this.scale.load(origin.scale);
    this.accurateResult = new Matrix(origin.accurateResult);
    this.accurateScale = new Matrix(origin.accurateScale);
    this.accurateRotationX = origin.accurateRotationX;
    this.accurateRotationY = origin.accurateRotationY;
    this.accurateRotationZ = origin.accurateRotationZ;
    this.modified = origin.modified;
}
项目:ldparteditor    文件:GData3.java   
public void drawProtractorGL33(Composite3D c3d, GLShader shader, BigDecimal x1c, BigDecimal y1c, BigDecimal z1c, BigDecimal x2c, BigDecimal y2c, BigDecimal z2c, BigDecimal x3c, BigDecimal y3c, BigDecimal z3c) {
    GL20.glUniform3f(shader.getUniformLocation("color"), r, g, b); //$NON-NLS-1$

    final java.text.DecimalFormat NUMBER_FORMAT2F = new java.text.DecimalFormat(View.NUMBER_FORMAT2F, new DecimalFormatSymbols(MyLanguage.LOCALE));
    final float zoom = 1f / c3d.getZoom();

    final Vector4f textOrigin = new Vector4f(x1, y1, z1, 1f);
    Matrix4f.transform(c3d.getRotation(), textOrigin, textOrigin);

    Vector3d va = new Vector3d(x1c, y1c, z1c);
    Vector3d vb = new Vector3d(x2c, y2c, z2c);
    Vector3d vc = new Vector3d(x3c, y3c, z3c);
    vb = Vector3d.sub(va, vb);
    vc = Vector3d.sub(va, vc);
    double angle = Vector3d.angle(vb, vc);
    BigDecimal ang = new BigDecimal(angle);
    String angle_s = NUMBER_FORMAT2F.format(ang) + "°"; //$NON-NLS-1$

    drawNumberGL33(angle_s, textOrigin.x, textOrigin.y, textOrigin.z, zoom);
}
项目:ldparteditor    文件:VM08SlicerPro.java   
private GData3 checkNormal(GData3 g3, Matrix4f vport) {
    Vertex[] v = triangles.get(g3);

    Vector4f n = new Vector4f();
    n.setW(1f);
    n.setX((v[2].y - v[0].y) * (v[1].z - v[0].z) - (v[2].z - v[0].z) * (v[1].y - v[0].y));
    n.setY((v[2].z - v[0].z) * (v[1].x - v[0].x) - (v[2].x - v[0].x) * (v[1].z - v[0].z));
    n.setZ((v[2].x - v[0].x) * (v[1].y - v[0].y) - (v[2].y - v[0].y) * (v[1].x - v[0].x));
    Matrix4f.transform(vport, n, n);
    Vector4f.sub(n, new Vector4f(vport.m03, vport.m13, vport.m23, 0f), n);
    if (n.z > 0f ^ Editor3DWindow.getWindow().hasBfcToggle()) {
        return new GData3(g3.colourNumber, g3.r, g3.g, g3.b, g3.a, v[0], v[2], v[1], View.DUMMY_REFERENCE, linkedDatFile, g3.isTriangle);
    } else {
        return null;
    }

}
项目:ldparteditor    文件:GData5.java   
public void isShown(Matrix4f viewport, ThreadsafeHashMap<GData1, Matrix4f> CACHE_viewByProjection, float zoom) {

        if (wasShown) {
            return;
        }

        final Matrix4f M2 = CACHE_viewByProjection.get(parent);
        if (M2 == null) {
            Matrix4f.mul(viewport, parent.productMatrix, M);
            CACHE_viewByProjection.put(parent, M);
        } else {
            M = M2;
        }

        // Calculate the real coordinates
        Matrix4f.transform(M, A2, A);
        Matrix4f.transform(M, B2, B);
        Matrix4f.transform(M, C2, C);
        Matrix4f.transform(M, D2, D);

        N.x = A.y - B.y;
        N.y = B.x - A.x;
        N.z = 0f;
        N.w = 1f;
        wasShown = zoom / Vector4f.dot(N, Vector4f.sub(C, A, null)) * Vector4f.dot(N, Vector4f.sub(D, A, null)) > -1e-20f;
    }
项目:ldparteditor    文件:CompositePrimitive.java   
private void adjustTranslate(float old, float zoom2) {
    float dx = 0;
    float dy = 0;
    dx = 0f / viewport_pixel_per_ldu;
    dy = 0f / viewport_pixel_per_ldu;
    Vector4f xAxis4f_translation = new Vector4f(dx, 0, 0, 1.0f);
    Vector4f yAxis4f_translation = new Vector4f(0, dy, 0, 1.0f);
    Vector3f xAxis3 = new Vector3f(xAxis4f_translation.x, xAxis4f_translation.y, xAxis4f_translation.z);
    Vector3f yAxis3 = new Vector3f(yAxis4f_translation.x, yAxis4f_translation.y, yAxis4f_translation.z);

    Matrix4f.load(old_viewport_translation, viewport_translation);
    Matrix4f.translate(xAxis3, old_viewport_translation, viewport_translation);
    Matrix4f.translate(yAxis3, viewport_translation, viewport_translation);

    viewport_translation.m30 = 0f;
    if (viewport_translation.m13 > 0f) viewport_translation.m13 = 0f;
    if (-viewport_translation.m31 > maxY) viewport_translation.m31 = -maxY;
}
项目:ldparteditor    文件:CompositePrimitive.java   
public void scroll(boolean down) {

        float dy = 0;

        Matrix4f.load(getTranslation(), old_viewport_translation);

        if (down) {
            dy = -37f /  viewport_pixel_per_ldu;
        } else {
            dy = 37f /  viewport_pixel_per_ldu;
        }

        Vector4f yAxis4f_translation = new Vector4f(0, dy, 0, 1.0f);
        Vector3f yAxis3 = new Vector3f(yAxis4f_translation.x, yAxis4f_translation.y, yAxis4f_translation.z);
        Matrix4f.load(old_viewport_translation, viewport_translation);
        Matrix4f.translate(yAxis3, old_viewport_translation, viewport_translation);

        if (viewport_translation.m31 > 0f) viewport_translation.m31 = 0f;
        if (-viewport_translation.m31 > maxY) viewport_translation.m31 = -maxY;

        openGL.drawScene(-1, -1);
    }
项目:IngressCraft    文件:EffectLink.java   
void fillChunk(float[] vertices, int index, float positionX, float positionY, float positionZ, float u, float v, Vector3f normal, float f6, Vector4f color) {

        int offset = index * VERTEX_FLOAT_COUNT;
        vertices[offset + 0] = positionX;
        vertices[offset + 1] = positionY;
        vertices[offset + 2] = positionZ;
        vertices[offset + 3] = f6;
        vertices[offset + 4] = u;
        vertices[offset + 5] = v;
        vertices[offset + 6] = normal.x;
        vertices[offset + 7] = normal.z;
        vertices[offset + 8] = color.x;
        vertices[offset + 9] = color.y;
        vertices[offset + 10] = color.z;
        vertices[offset + 11] = color.w;

    }
项目:tribaltrouble    文件:Lightning.java   
public Lightning(World world, Vector3f src, Vector3f dst, float width,
        int num_particles, Vector4f color, Vector4f delta_color,
        TextureKey texture, float energy,
        AnimationManager manager) {
    super(world.getElementRoot());
    this.world = world;
    this.src = src;
    this.dst = dst;
    this.width = width;
    this.num_particles = num_particles;
    this.color = color;
    this.delta_color = delta_color;
    this.texture = texture;
    this.energy = energy;
    this.manager = manager;
    initParticles();
    register();
}
项目:tectonicus    文件:BlockUtil.java   
public static void addBottom(BlockContext world, RawChunk rawChunk, Mesh mesh, final int blockX, final int blockY, final int blockZ, Colour4f colour, SubTexture texture, BlockTypeRegistry registry)
{
//  final int belowId = world.getBlockId(rawChunk.getChunkCoord(), blockX, blockY-1, blockZ);
//  BlockType below = registry.find(belowId);
    BlockType below = world.getBlockType(rawChunk.getChunkCoord(), blockX, blockY-1, blockZ);
    if (!below.isSolid())
    {
        final float lightness = world.getLight(rawChunk.getChunkCoord(), blockX, blockY-1, blockZ, LightFace.Top);
//      final float lightness = world.getLight(rawChunk.getChunkCoord(), blockX, 128, blockZ, LightFace.Top);

        MeshUtil.addQuad(mesh,  new Vector3f(blockX,    blockY,     blockZ+1),
                                new Vector3f(blockX+1,  blockY,     blockZ+1),
                                new Vector3f(blockX+1,  blockY,     blockZ),
                                new Vector3f(blockX,    blockY,     blockZ),
                                new Vector4f(colour.r * lightness, colour.g * lightness, colour.b * lightness, colour.a),
                                texture);
    }
}
项目:tribaltrouble    文件:RandomAccelerationEmitter.java   
protected int initParticle(Vector3f position, Vector3f velocity, Vector3f acceleration, Vector4f color, Vector4f delta_color, Vector3f particle_radius, Vector3f growth_rate, float energy) {
    randomizeAcceleration();

    LinearParticle particle = new LinearParticle();
    Vector3f pos = randomPosition();
    particle.setPos(pos.getX(), pos.getY(), pos.getZ());
    particle.setVelocity(velocity.getX(), velocity.getY(), velocity.getZ());
    particle.setAcceleration(acceleration.getX(), acceleration.getY(), acceleration.getZ());
    particle.setColor(color.getX(), color.getY(), color.getZ(), color.getW());
    particle.setDeltaColor(delta_color.getX(), delta_color.getY(), delta_color.getZ(), delta_color.getW());
    particle.setRadius(particle_radius.getX(), particle_radius.getY(), particle_radius.getZ());
    particle.setGrowthRate(growth_rate.getX(), growth_rate.getY(), growth_rate.getZ());
    particle.setEnergy(energy);
    particle.setType(random.nextInt(getTypes()));
    add(particle);
    return 1;
}
项目:tribaltrouble    文件:RingEmitter.java   
protected int initParticle(Vector3f position, Vector3f velocity, Vector3f acceleration, Vector4f color, Vector4f delta_color, Vector3f particle_radius, Vector3f growth_rate, float energy) {
    float angle = 2*(float)StrictMath.PI/num_particles;
    for (int i = 0; i < num_particles; i++) {
        LinearParticle particle = new LinearParticle();
        Vector3f pos = position;
        particle.setPos(pos.getX(), pos.getY(), pos.getZ());
        // in this special case velocity.getZ() is the actual velocity. not the velocity in the z direction
        particle.setVelocity(velocity.getZ()*(float)StrictMath.cos(angle*i), velocity.getZ()*(float)StrictMath.sin(angle*i), 0);
        particle.setAcceleration(acceleration.getX(), acceleration.getY(), acceleration.getZ());
        particle.setColor(color.getX(), color.getY(), color.getZ(), color.getW());
        particle.setDeltaColor(delta_color.getX(), delta_color.getY(), delta_color.getZ(), delta_color.getW());
        particle.setRadius(particle_radius.getX(), particle_radius.getY(), particle_radius.getZ());
        particle.setGrowthRate(growth_rate.getX(), growth_rate.getY(), growth_rate.getZ());
        particle.setEnergy(energy);
        particle.setType(0);
        add(particle);
    }
    return num_particles;
}
项目:tribaltrouble    文件:ParametricEmitter.java   
public ParametricEmitter(World world, ParametricFunction function, Vector3f position,
               float area_xy, float area_z, float velocity_u, float velocity_v, float velocity_random_margin,
               int num_particles, float particles_per_second,
               Vector4f color, Vector4f delta_color,
               Vector3f particle_radius, Vector3f growth_rate, float energy,
               int src_blend_func, int dst_blend_func, TextureKey[] textures,
               AnimationManager manager) {
    super(world, position, src_blend_func, dst_blend_func, textures, null, textures.length, manager);
    this.function = function;
    this.area_xy = area_xy;
    this.area_z = area_z;
    this.velocity_u = velocity_u;
    this.velocity_v = velocity_v;
    this.velocity_random_margin = velocity_random_margin;
    this.num_particles = num_particles;
    this.particles_per_second = particles_per_second;
    this.color = color;
    this.delta_color = delta_color;
    this.particle_radius = particle_radius;
    this.growth_rate = growth_rate;
    this.energy = energy;
    random = world.getRandom();

    register();
}
项目:tectonicus    文件:BlockUtil.java   
public static void addInteriorSouth(BlockContext world, RawChunk rawChunk, Mesh mesh, final int x, final int y, final int z, Colour4f colour, SubTexture texture, BlockTypeRegistry registry)
{
    final int southId = rawChunk.getBlockId(x+1, y, z);
    final int southData = rawChunk.getBlockData(x+1, y, z);
    BlockType south = registry.find(southId, southData);
    if (!south.isSolid())
    {
        final float lightness = Chunk.getLight(world.getLightStyle(), LightFace.NorthSouth, rawChunk, x+1, y, z);

        MeshUtil.addQuad(mesh,  new Vector3f(x+1,       y+1,    z+1),
                                new Vector3f(x+1,       y+1,    z),
                                new Vector3f(x+1,       y,      z),
                                new Vector3f(x+1,       y,      z+1),
                                new Vector4f(colour.r * lightness, colour.g * lightness, colour.b * lightness, colour.a),
                                texture);
    }
}
项目:tectonicus    文件:Plant.java   
@Override
public void addEdgeGeometry(int x, int y, int z, BlockContext world, BlockTypeRegistry registry, RawChunk rawChunk, Geometry geometry)
{
    Mesh mesh = geometry.getMesh(texture.texture, Geometry.MeshType.AlphaTest);

    final float lightVal = world.getLight(rawChunk.getChunkCoord(), x, y, z, LightFace.Top);
    final int data = rawChunk.getBlockData(x, y, z);
    Colour4f baseColour = getColour(x, y, z, data, world, rawChunk);
    Vector4f colour = new Vector4f(baseColour.r * lightVal, baseColour.g * lightVal, baseColour.b * lightVal, baseColour.a);

    //Vector4f colour = new Vector4f(lightVal, lightVal, lightVal, 1.0f);
    if(blockId == BlockIds.LARGE_FLOWERS)
    {
        Mesh bottomMesh = geometry.getMesh(bottomTexture.texture, Geometry.MeshType.AlphaTest);
        addPlantGeometry(x, y, z, 0, bottomMesh, colour, bottomTexture);
        addPlantGeometry(x, y, z, 1, mesh, colour, texture);
    }
    else
    {
        addPlantGeometry(x, y, z, 0, mesh, colour, texture);
    }
}
项目:tectonicus    文件:BlockUtil.java   
public static void addSouth(BlockContext world, RawChunk rawChunk, Mesh mesh, final int x, final int y, final int z, Colour4f colour, SubTexture texture, BlockTypeRegistry registry)
{
//  final int southId = world.getBlockId(rawChunk.getChunkCoord(), x+1, y, z);
//  BlockType south = registry.find(southId);
    BlockType south = world.getBlockType(rawChunk.getChunkCoord(), x+1, y, z);
    if (!south.isSolid())
    {
        final float lightness = world.getLight(rawChunk.getChunkCoord(), x+1, y, z, LightFace.NorthSouth);

        MeshUtil.addQuad(mesh,  new Vector3f(x+1,       y+1,    z+1),
                                new Vector3f(x+1,       y+1,    z),
                                new Vector3f(x+1,       y,      z),
                                new Vector3f(x+1,       y,      z+1),
                                new Vector4f(colour.r * lightness, colour.g * lightness, colour.b * lightness, colour.a),
                                texture);
    }
}
项目:tectonicus    文件:BlockUtil.java   
public static void addInteriorNorth(BlockContext world, RawChunk rawChunk, Mesh mesh, final int x, final int y, final int z, Colour4f colour, SubTexture texture, BlockTypeRegistry registry)
{
    final int northId = rawChunk.getBlockId(x-1, y, z);
    final int northData = rawChunk.getBlockData(x-1, y, z);
    BlockType north = registry.find(northId, northData);
    if (!north.isSolid())
    {
        final float lightness = Chunk.getLight(world.getLightStyle(), LightFace.NorthSouth, rawChunk, x-1, y, z);

        MeshUtil.addQuad(mesh,  new Vector3f(x,     y+1,    z),
                                new Vector3f(x,     y+1,    z+1),
                                new Vector3f(x,     y,      z+1),
                                new Vector3f(x,     y,      z),
                                new Vector4f(colour.r * lightness, colour.g * lightness, colour.b * lightness, colour.a),
                                texture);
    }
}
项目:LibLDD    文件:FlexElement.java   
private static void loadTransformationMatrixByCoordinate(Vector3f[] boneLinkBoundaries, Matrix4f[] transformationMatrices, Matrix4f currentTransformationMatrix, Vector4f currentCoordinate) {
    int i = transformationMatrices.length - 2;
    Vector3f boundary = null;
    while(i >= 0) {
        boundary = boneLinkBoundaries[i];
        if(currentCoordinate.x >= boundary.x) {
            break;
        }
        i--;
    }
    if((i > 0) || (boundary.x < currentCoordinate.x)) {
        currentCoordinate.x -= boundary.x;              
        i++;
    }

    i = Math.min(transformationMatrices.length - 1, i);
    i = Math.max(0, i);
    Matrix4f.load(transformationMatrices[i], currentTransformationMatrix);
    return;
}
项目:tectonicus    文件:BlockUtil.java   
public static void addEast(BlockContext world, RawChunk rawChunk, Mesh mesh, final int x, final int y, final int z, Colour4f colour, SubTexture texture, BlockTypeRegistry registry)
{
//  final int eastId = world.getBlockId(rawChunk.getChunkCoord(), x, y, z-1);
//  BlockType east = registry.find(eastId);
    BlockType east = world.getBlockType(rawChunk.getChunkCoord(), x, y, z-1);
    if (!east.isSolid())
    {
        final float lightness = world.getLight(rawChunk.getChunkCoord(), x, y, z-1, LightFace.EastWest);

        MeshUtil.addQuad(mesh,  new Vector3f(x+1,   y+1,    z),
                                new Vector3f(x,     y+1,    z),
                                new Vector3f(x,     y,      z),
                                new Vector3f(x+1,   y,      z),
                                new Vector4f(colour.r * lightness, colour.g * lightness, colour.b * lightness, colour.a),
                                texture);
    }
}
项目:tectonicus    文件:Fire.java   
@Override
public void addEdgeGeometry(int x, int y, int z, BlockContext world, BlockTypeRegistry registry, RawChunk rawChunk, Geometry geometry)
{
    int newFrame;
    if(numTiles > 1 && frame == 0)
    {
        Random rand = new Random();
        newFrame = rand.nextInt(numTiles)+1;
    }
    else
    {
        newFrame = frame;
    }

    SubTexture randomTexture = new SubTexture(texture.texture, texture.u0, texture.v0+(float)((newFrame-1)*texWidth)/texHeight, texture.u1, texture.v0+(float)(newFrame*texWidth)/texHeight);

    Mesh mesh = geometry.getMesh(randomTexture.texture, Geometry.MeshType.AlphaTest);

    Vector4f colour = new Vector4f(1, 1, 1, 1);

    addFireGeometry(x, y, z, mesh, colour, randomTexture);
}
项目:tectonicus    文件:BlockUtil.java   
public static void addTop(BlockContext world, RawChunk rawChunk, Mesh mesh, final int blockX, final int blockY, final int blockZ, Colour4f colour, SubTexture texture, BlockTypeRegistry registry)
{
//  final int aboveId = world.getBlockId(rawChunk.getChunkCoord(), blockX, blockY+1, blockZ);
//  BlockType above = registry.find(aboveId);
    BlockType above = world.getBlockType(rawChunk.getChunkCoord(), blockX, blockY+1, blockZ);
    if (!above.isSolid())
    {
        final float lightness = world.getLight(rawChunk.getChunkCoord(), blockX, blockY+1, blockZ, LightFace.Top);

        MeshUtil.addQuad(mesh,  new Vector3f(blockX,    blockY+1,   blockZ),
                                new Vector3f(blockX+1,  blockY+1,   blockZ),
                                new Vector3f(blockX+1,  blockY+1,   blockZ+1),
                                new Vector3f(blockX,    blockY+1,   blockZ+1),
                                new Vector4f(colour.r * lightness, colour.g * lightness, colour.b * lightness, colour.a),
                                texture);
    }
}
项目:tectonicus    文件:BlockUtil.java   
public static void addInteriorEast(BlockContext world, RawChunk rawChunk, Mesh mesh, final int x, final int y, final int z, Colour4f colour, SubTexture texture, BlockTypeRegistry registry)
{
    final int eastId = rawChunk.getBlockId(x, y, z-1);
    final int eastData = rawChunk.getBlockData(x, y, z-1);
    BlockType east = registry.find(eastId, eastData);
    if (!east.isSolid())
    {
        final float lightness = Chunk.getLight(world.getLightStyle(), LightFace.EastWest, rawChunk, x, y, z-1);

        MeshUtil.addQuad(mesh,  new Vector3f(x+1,   y+1,    z),
                                new Vector3f(x,     y+1,    z),
                                new Vector3f(x,     y,      z),
                                new Vector3f(x+1,   y,      z),
                                new Vector4f(colour.r * lightness, colour.g * lightness, colour.b * lightness, colour.a),
                                texture);
    }
}
项目:tectonicus    文件:ProcessingMesh.java   
@Override
public void addVertex(Vector3f position, Vector4f colour, float u, float v)
{
    if (numVerts+1 == xPositions.length)
        ensureCapacity(numVerts + 1024);

    xPositions[numVerts] = position.x;
    yPositions[numVerts] = position.y;
    zPositions[numVerts] = position.z;

    reds[numVerts] = colour.x;
    greens[numVerts] = colour.y;
    blues[numVerts] = colour.z;
    alphas[numVerts] = colour.w;

    uCoords[numVerts] = u;
    vCoords[numVerts] = v;

    numVerts++;
}
项目:tectonicus    文件:BlockUtil.java   
public static void addNorth(BlockContext world, RawChunk rawChunk, Mesh mesh, final int x, final int y, final int z, Colour4f colour, SubTexture texture, BlockTypeRegistry registry)
{
//  final int northId = world.getBlockId(rawChunk.getChunkCoord(), x-1, y, z);
//  BlockType north = registry.find(northId);
    BlockType north = world.getBlockType(rawChunk.getChunkCoord(), x-1, y, z);
    if (!north.isSolid())
    {
        final float lightness = world.getLight(rawChunk.getChunkCoord(), x-1, y, z, LightFace.NorthSouth);

        MeshUtil.addQuad(mesh,  new Vector3f(x,     y+1,    z),
                                new Vector3f(x,     y+1,    z+1),
                                new Vector3f(x,     y,      z+1),
                                new Vector3f(x,     y,      z),
                                new Vector4f(colour.r * lightness, colour.g * lightness, colour.b * lightness, colour.a),
                                texture);
    }
}
项目:tectonicus    文件:SubMesh.java   
public void pushTo(SubMesh destMesh, final float xOffset, final float yOffset, final float zOffset, Rotation horizRotation, final float horizAngleDeg, Rotation vertRotation, final float vertAngleDeg)
{
    Matrix4f transform = createTransform(horizRotation, horizAngleDeg, vertRotation, vertAngleDeg);

    for (int i=0; i<positions.size(); i++)
    {
        Vector3f pos = new Vector3f( positions.get(i) );

        if (transform != null)
        {
            Vector4f dest = new Vector4f();
            Matrix4f.transform(transform, new Vector4f(pos.x, pos.y, pos.z, 1.0f), dest);

            pos.x = dest.x / dest.w;
            pos.y = dest.y / dest.w;
            pos.z = dest.z / dest.w;
        }

        destMesh.positions.add( new Vector3f(positions.get(i) ));
        destMesh.colours.add( new Vector4f(colours.get(i) ));
        destMesh.texCoords.add( new Vector2f(texCoords.get(i) ));
    }
}
项目:tectonicus    文件:BlockUtil.java   
public static void addInteriorBottom(BlockContext world, RawChunk rawChunk, Mesh mesh, final int blockX, final int blockY, final int blockZ, Colour4f colour, SubTexture texture, BlockTypeRegistry registry)
{
    final int belowId = rawChunk.getBlockId(blockX, blockY-1, blockZ);
    final int belowData = rawChunk.getBlockData(blockX, blockY-1, blockZ);
    BlockType below = registry.find(belowId, belowData);
    if (!below.isSolid())
    {
        final float lightness = Chunk.getLight(world.getLightStyle(), LightFace.Top, rawChunk, blockX, blockY-1, blockZ);

        MeshUtil.addQuad(mesh,  new Vector3f(blockX,    blockY,     blockZ+1),
                                new Vector3f(blockX+1,  blockY,     blockZ+1),
                                new Vector3f(blockX+1,  blockY,     blockZ),
                                new Vector3f(blockX,    blockY,     blockZ),
                                new Vector4f(colour.r * lightness, colour.g * lightness, colour.b * lightness, colour.a),
                                texture);
    }
}
项目:tectonicus    文件:DaylightSensor.java   
@Override
public void addEdgeGeometry(int x, int y, int z, BlockContext world, BlockTypeRegistry registry, RawChunk rawChunk, Geometry geometry)
{
    final float lightness = Chunk.getLight(world.getLightStyle(), LightFace.Top, rawChunk, x, y, z);
    Vector4f colour = new Vector4f(lightness, lightness, lightness, 1);

    final float offSet = 1.0f / 16.0f;

    SubMesh topMesh = new SubMesh();
    SubMesh bottomMesh = new SubMesh();

    SubMesh.addBlockSimple(bottomMesh, 0, 0, 0, 1, offSet*6, 1, colour, side, null, bottom);

    // Top
    topMesh.addQuad(new Vector3f(1, offSet*6, 0),
                    new Vector3f(1, offSet*6, 1),
                    new Vector3f(0, offSet*6, 1),
                    new Vector3f(0, offSet*6, 0),
                    colour, top);

    topMesh.pushTo(geometry.getMesh(top.texture, Geometry.MeshType.Solid), x, y, z, Rotation.None, 0);
    bottomMesh.pushTo(geometry.getMesh(bottom.texture, Geometry.MeshType.Solid), x, y, z, Rotation.None, 0);
}
项目:tectonicus    文件:ChorusFlower.java   
@Override
public void addEdgeGeometry(int x, int y, int z, BlockContext world, BlockTypeRegistry registry, RawChunk rawChunk, Geometry geometry)
{
    final float lightVal = world.getLight(rawChunk.getChunkCoord(), x, y, z, LightFace.Top);
    Vector4f colour = new Vector4f(lightVal, lightVal, lightVal, 1.0f);

    final int data = rawChunk.getBlockData(x, y, z);        
    SubTexture tex = null;
    if(data == 5)
        tex = dead;
    else
        tex = alive;

    final float offSet = 1.0f / 16.0f;
    SubMesh flowerMesh = new SubMesh();
    SubMesh.addBlock(flowerMesh, offSet*2, offSet*2, 0, offSet*12, offSet*12, offSet*16, colour, tex, tex, tex); // north-south
    SubMesh.addBlock(flowerMesh, 0, offSet*2, offSet*2, offSet*16, offSet*12, offSet*12, colour, tex, tex, tex); // east-west
    SubMesh.addBlock(flowerMesh, offSet*2, 0, offSet*2, offSet*12, offSet*16, offSet*12, colour, tex, tex, tex); // up-down

    flowerMesh.pushTo(geometry.getMesh(tex.texture, Geometry.MeshType.Solid), x, y, z, Rotation.None, 0);
}
项目:OpenGL-Bullet-engine    文件:Camera.java   
public void update(){
        viewDistance.update();
        prevPos.set(pos);

        MOVE.set(0, 0, 0);
        if(Keyboard.isKeyDown(Keyboard.KEY_D)) MOVE.addX(1);
        if(Keyboard.isKeyDown(Keyboard.KEY_A)) MOVE.addX(-1);

        if(Keyboard.isKeyDown(Keyboard.KEY_SPACE)) MOVE.addY(1);
        if(Keyboard.isKeyDown(Keyboard.KEY_LSHIFT)) MOVE.addY(-1);

        if(Keyboard.isKeyDown(Keyboard.KEY_S)) MOVE.addZ(1);
        if(Keyboard.isKeyDown(Keyboard.KEY_W)) MOVE.addZ(-1);

        Vector4f vec4=new Vector4f(MOVE.x, MOVE.y, MOVE.z, 1);
        Matrix4f mat=new Matrix4f();
        EFF_POS.set(rot).mul(-1);
        EFF_POS.x=0;
        MatrixUtil.rotate(mat, EFF_POS);

        Matrix4f.transform(mat, vec4, vec4);
        MOVE.x=vec4.x;
        MOVE.y=vec4.y;
        MOVE.z=vec4.z;
//      MOVE.mul(100);
//      if(EntityCrazyCube.CAM!=null&&false){
//          pos.set(EntityCrazyCube.CAM.pos);
//      }else
        pos.add(MOVE);
        viewDistance.setValue((viewDistance.getValue()+viewDistanceWanted)/2);
    }
项目:ForgeHax    文件:VectorUtils.java   
private static void VecTransformCoordinate(Vector4f vec, Matrix4f matrix) {
    float x = vec.x;
    float y = vec.y;
    float z = vec.z;
    vec.x = (x * matrix.m00) + (y * matrix.m10) + (z * matrix.m20) + matrix.m30;
    vec.y = (x * matrix.m01) + (y * matrix.m11) + (z * matrix.m21) + matrix.m31;
    vec.z = (x * matrix.m02) + (y * matrix.m12) + (z * matrix.m22) + matrix.m32;
    vec.w = (x * matrix.m03) + (y * matrix.m13) + (z * matrix.m23) + matrix.m33;
}