Search in sources :

Example 1 with Joint

use of spacegraph.space2d.phys.dynamics.joints.Joint in project narchy by automenta.

the class SwingDraw method draw.

public void draw(World w) {
    graphics = panel.getDBGraphics();
    // for (LayerDraw l : layers) l.drawGround(this, w);
    int flags = getFlags();
    if ((flags & DebugDraw.e_shapeBit) != 0) {
        for (Body b = w.getBodyList(); b != null; b = b.getNext()) {
            drawBody(b);
        }
    // drawParticleSystem(m_particleSystem);
    }
    if ((flags & DebugDraw.e_jointBit) != 0) {
        for (Joint j = w.getJointList(); j != null; j = j.getNext()) {
            drawJoint(j);
        }
    }
// if ((flags & DebugDraw.e_pairBit) != 0) {
// color.set(0.3f, 0.9f, 0.9f);
// for (Contact c = m_contactManager.m_contactList; c != null; c = c.getNext()) {
// Fixture fixtureA = c.getFixtureA();
// Fixture fixtureB = c.getFixtureB();
// fixtureA.getAABB(c.getChildIndexA()).getCenterToOut(cA);
// fixtureB.getAABB(c.getChildIndexB()).getCenterToOut(cB);
// drawSegment(cA, cB, color);
// }
// }
// 
// if ((flags & DebugDraw.e_aabbBit) != 0) {
// color.set(0.9f, 0.3f, 0.9f);
// 
// for (Body b = m_bodyList; b != null; b = b.getNext()) {
// if (b.isActive() == false) {
// continue;
// }
// 
// for (Fixture f = b.getFixtureList(); f != null; f = f.getNext()) {
// for (int i = 0; i < f.m_proxyCount; ++i) {
// FixtureProxy proxy = f.m_proxies[i];
// AABB aabb = m_contactManager.m_broadPhase.getFatAABB(proxy.proxyId);
// if (aabb != null) {
// Vec2[] vs = avs.get(4);
// vs[0].set(aabb.lowerBound.x, aabb.lowerBound.y);
// vs[1].set(aabb.upperBound.x, aabb.lowerBound.y);
// vs[2].set(aabb.upperBound.x, aabb.upperBound.y);
// vs[3].set(aabb.lowerBound.x, aabb.upperBound.y);
// drawPolygon(vs, 4, color);
// }
// }
// }
// }
// }
// 
// if ((flags & DebugDraw.e_centerOfMassBit) != 0) {
// for (Body b = m_bodyList; b != null; b = b.getNext()) {
// xf.set(b.getTransform());
// xf.p.set(b.getWorldCenter());
// drawTransform(xf);
// }
// }
// 
// if ((flags & DebugDraw.e_dynamicTreeBit) != 0) {
// m_contactManager.m_broadPhase.drawTree(m_debugDraw);
// }
// for (LayerDraw l : layers) l.drawSky(this, w);
// flush();
}
Also used : PulleyJoint(spacegraph.space2d.phys.dynamics.joints.PulleyJoint) Joint(spacegraph.space2d.phys.dynamics.joints.Joint) Body(spacegraph.space2d.phys.dynamics.Body) PulleyJoint(spacegraph.space2d.phys.dynamics.joints.PulleyJoint) Joint(spacegraph.space2d.phys.dynamics.joints.Joint)

Example 2 with Joint

use of spacegraph.space2d.phys.dynamics.joints.Joint in project narchy by automenta.

the class Island method init.

void init(int bodyCapacity, int contactCapacity, int jointCapacity, ContactListener listener) {
    // System.out.println("Initializing Island");
    m_bodyCapacity = bodyCapacity;
    m_contactCapacity = contactCapacity;
    m_jointCapacity = jointCapacity;
    m_bodyCount = 0;
    m_contactCount = 0;
    m_jointCount = 0;
    m_listener = listener;
    if (bodies == null || m_bodyCapacity > bodies.length) {
        bodies = new Body2D[m_bodyCapacity];
    }
    if (joints == null || m_jointCapacity > joints.length) {
        joints = new Joint[m_jointCapacity];
    }
    if (contacts == null || m_contactCapacity > contacts.length) {
        contacts = new Contact[m_contactCapacity];
    }
    // dynamic array
    if (velocities == null || m_bodyCapacity > velocities.length) {
        final Velocity[] old = velocities == null ? new Velocity[0] : velocities;
        velocities = new Velocity[m_bodyCapacity];
        System.arraycopy(old, 0, velocities, 0, old.length);
        for (int i = old.length; i < velocities.length; i++) {
            velocities[i] = new Velocity();
        }
    }
    // dynamic array
    if (positions == null || m_bodyCapacity > positions.length) {
        final Position[] old = positions == null ? new Position[0] : positions;
        positions = new Position[m_bodyCapacity];
        System.arraycopy(old, 0, positions, 0, old.length);
        for (int i = old.length; i < positions.length; i++) {
            positions[i] = new Position();
        }
    }
}
Also used : Joint(spacegraph.space2d.phys.dynamics.joints.Joint)

Example 3 with Joint

use of spacegraph.space2d.phys.dynamics.joints.Joint in project narchy by automenta.

the class JoglAbstractDraw method draw.

public void draw(World w, float time) {
    if (w == null)
        return;
    PhysicsCamera p = getPhysicsCamera();
    if (p != null) {
        Vec2 center = p.getTransform().getCenter();
        viewportTransform.setCenter(center);
        viewportTransform.setExtents(p.getTargetScale(), p.getTargetScale());
    }
    for (SwingDraw.LayerDraw l : layers) l.drawGround(this, w);
    int flags = getFlags();
    // if ((flags & DebugDraw.e_shapeBit) != 0) {
    for (Body b = w.getBodyList(); b != null; b = b.getNext()) {
        drawBody(b, time);
    }
    for (Joint j = w.getJointList(); j != null; j = j.getNext()) {
    // drawJoint(j);
    }
    for (SwingDraw.LayerDraw l : layers) l.drawSky(this, w);
// flush();
}
Also used : PhysicsCamera(nars.rover.physics.PhysicsCamera) SwingDraw(nars.rover.physics.j2d.SwingDraw) Joint(spacegraph.space2d.phys.dynamics.joints.Joint) Body(spacegraph.space2d.phys.dynamics.Body) Joint(spacegraph.space2d.phys.dynamics.joints.Joint)

Aggregations

Joint (spacegraph.space2d.phys.dynamics.joints.Joint)3 Body (spacegraph.space2d.phys.dynamics.Body)2 PhysicsCamera (nars.rover.physics.PhysicsCamera)1 SwingDraw (nars.rover.physics.j2d.SwingDraw)1 PulleyJoint (spacegraph.space2d.phys.dynamics.joints.PulleyJoint)1