Search in sources :

Example 1 with ActivationState

use of io.github.voidzombie.nhglib.data.models.serialization.physics.ActivationState in project nhglib by VoidZombie.

the class RigidBodyComponentJson method parse.

@Override
public void parse(JsonValue jsonValue) {
    RigidBodyComponent rigidBodyComponent = entities.createComponent(entity, RigidBodyComponent.class);
    JsonValue shapeJson = jsonValue.get("shape");
    String activationStateString = jsonValue.getString("activationState", "wantsDeactivation");
    ActivationState activationStateJson = ActivationState.fromString(activationStateString);
    btCollisionShape collisionShape = getCollisionShape(shapeJson);
    int activationState = activationStateJson.state;
    float mass = jsonValue.getFloat("mass", 1.0f);
    float friction = jsonValue.getFloat("friction", 0.5f);
    float restitution = jsonValue.getFloat("restitution", 0f);
    rigidBodyComponent.build(collisionShape, activationState, mass, friction, restitution);
    output = rigidBodyComponent;
}
Also used : RigidBodyComponent(io.github.voidzombie.nhglib.runtime.ecs.components.physics.RigidBodyComponent) JsonValue(com.badlogic.gdx.utils.JsonValue) ActivationState(io.github.voidzombie.nhglib.data.models.serialization.physics.ActivationState) com.badlogic.gdx.physics.bullet.collision.btCollisionShape(com.badlogic.gdx.physics.bullet.collision.btCollisionShape)

Aggregations

com.badlogic.gdx.physics.bullet.collision.btCollisionShape (com.badlogic.gdx.physics.bullet.collision.btCollisionShape)1 JsonValue (com.badlogic.gdx.utils.JsonValue)1 ActivationState (io.github.voidzombie.nhglib.data.models.serialization.physics.ActivationState)1 RigidBodyComponent (io.github.voidzombie.nhglib.runtime.ecs.components.physics.RigidBodyComponent)1