Search in sources :

Example 1 with ParticleColor

use of org.jbox2d.particle.ParticleColor in project libgdx by libgdx.

the class WorldRayCastWrapper method drawParticleSystem.

private void drawParticleSystem(ParticleSystem system) {
    boolean wireframe = (m_debugDraw.getFlags() & DebugDraw.e_wireframeDrawingBit) != 0;
    int particleCount = system.getParticleCount();
    if (particleCount != 0) {
        float particleRadius = system.getParticleRadius();
        Vec2[] positionBuffer = system.getParticlePositionBuffer();
        ParticleColor[] colorBuffer = null;
        if (system.m_colorBuffer.data != null) {
            colorBuffer = system.getParticleColorBuffer();
        }
        if (wireframe) {
            m_debugDraw.drawParticlesWireframe(positionBuffer, particleRadius, colorBuffer, particleCount);
        } else {
            m_debugDraw.drawParticles(positionBuffer, particleRadius, colorBuffer, particleCount);
        }
    }
}
Also used : Vec2(org.jbox2d.common.Vec2) ParticleColor(org.jbox2d.particle.ParticleColor) Joint(org.jbox2d.dynamics.joints.Joint) PulleyJoint(org.jbox2d.dynamics.joints.PulleyJoint)

Example 2 with ParticleColor

use of org.jbox2d.particle.ParticleColor in project opennars by opennars.

the class DrawPhy2D method drawParticlesWireframe.

@Override
public void drawParticlesWireframe(Vec2[] centers, float radius, ParticleColor[] colors, int count) {
    Graphics2D g = getGraphics();
    saveState(g);
    transformGraphics(g, zero);
    g.setStroke(stroke);
    for (int i = 0; i < count; i++) {
        Vec2 center = centers[i];
        Color color;
        // No alpha channel, it slows everything down way too much.
        if (colors == null) {
            color = pcolor;
        } else {
            ParticleColor c = colors[i];
            color = new Color(c.r * 1f / 127, c.g * 1f / 127, c.b * 1f / 127, 1);
        }
        AffineTransform old = g.getTransform();
        g.translate(center.x, center.y);
        g.scale(radius, radius);
        g.setColor(color);
        g.draw(circle);
        g.setTransform(old);
    }
    restoreState(g);
}
Also used : Vec2(org.jbox2d.common.Vec2) Color(java.awt.Color) ParticleColor(org.jbox2d.particle.ParticleColor) ParticleColor(org.jbox2d.particle.ParticleColor) AffineTransform(java.awt.geom.AffineTransform) Joint(org.jbox2d.dynamics.joints.Joint) PulleyJoint(org.jbox2d.dynamics.joints.PulleyJoint) Graphics2D(java.awt.Graphics2D)

Example 3 with ParticleColor

use of org.jbox2d.particle.ParticleColor in project opennars by opennars.

the class DrawPhy2D method drawParticles.

@Override
public void drawParticles(final Vec2[] centers, final float radius, ParticleColor[] colors, final int count) {
    Graphics2D g = getGraphics();
    saveState(g);
    transformGraphics(g, zero);
    g.setStroke(stroke);
    for (int i = 0; i < count; i++) {
        Vec2 center = centers[i];
        Color color;
        if (colors == null) {
            color = pcolorA;
        } else {
            ParticleColor c = colors[i];
            color = new Color(c.r * 1f / 127, c.g * 1f / 127, c.b * 1f / 127, c.a * 1f / 127);
        }
        AffineTransform old = g.getTransform();
        g.translate(center.x, center.y);
        g.scale(radius, radius);
        g.setColor(color);
        g.fill(circle);
        g.setTransform(old);
    }
    restoreState(g);
}
Also used : Vec2(org.jbox2d.common.Vec2) Color(java.awt.Color) ParticleColor(org.jbox2d.particle.ParticleColor) ParticleColor(org.jbox2d.particle.ParticleColor) AffineTransform(java.awt.geom.AffineTransform) Joint(org.jbox2d.dynamics.joints.Joint) PulleyJoint(org.jbox2d.dynamics.joints.PulleyJoint) Graphics2D(java.awt.Graphics2D)

Aggregations

Vec2 (org.jbox2d.common.Vec2)3 Joint (org.jbox2d.dynamics.joints.Joint)3 PulleyJoint (org.jbox2d.dynamics.joints.PulleyJoint)3 ParticleColor (org.jbox2d.particle.ParticleColor)3 Color (java.awt.Color)2 Graphics2D (java.awt.Graphics2D)2 AffineTransform (java.awt.geom.AffineTransform)2