use of io.github.voidzombie.nhglib.runtime.ecs.components.scenes.NodeComponent in project nhglib by VoidZombie.
the class PhysicsSystem method process.
@Override
protected void process(int entityId) {
NodeComponent nodeComponent = nodeMapper.get(entityId);
RigidBodyComponent bodyComponent = rigidBodyMapper.get(entityId);
if (!bodyComponent.isAdded()) {
Matrix4 initialTransform = new Matrix4();
Vector3 trn = nodeComponent.getTranslation();
Vector3 scl = new Vector3(1, 1, 1);
Quaternion rtn = nodeComponent.getRotationQuaternion();
initialTransform.set(trn, rtn, scl);
bodyComponent.addToWorld(dynamicsWorld, initialTransform);
} else {
nodeComponent.setTranslation(bodyComponent.getTranslation());
nodeComponent.setRotation(bodyComponent.getRotation());
nodeComponent.applyTransforms();
}
}
use of io.github.voidzombie.nhglib.runtime.ecs.components.scenes.NodeComponent in project nhglib by VoidZombie.
the class CameraSystem method process.
@Override
protected void process(int entityId) {
CameraComponent cameraComponent = cameraMapper.get(entityId);
NodeComponent nodeComponent = nodeMapper.get(entityId);
Camera camera = cameraComponent.camera;
camera.position.set(nodeComponent.getTranslation());
camera.direction.rotate(camera.up, nodeComponent.getYRotationDelta());
camera.up.rotate(camera.direction, nodeComponent.getZRotationDelta());
vec.set(camera.direction).crs(camera.up).nor();
camera.direction.rotate(vec, nodeComponent.getXRotationDelta());
camera.update();
if (!cameras.contains(camera, true)) {
cameras.add(camera);
}
}
use of io.github.voidzombie.nhglib.runtime.ecs.components.scenes.NodeComponent in project nhglib by VoidZombie.
the class SceneJson method parse.
@Override
public void parse(JsonValue jsonValue) {
String name = jsonValue.getString("name");
JsonValue entitiesJson = jsonValue.get("entities");
output = new Scene(entities, "root");
output.name = name;
int rootEntity = output.sceneGraph.getRootEntity();
if (entitiesJson != null) {
for (JsonValue entity : entitiesJson) {
EntityJson entityJson = new EntityJson(entities);
entityJson.setSceneGraph(output.sceneGraph);
entityJson.setParentEntity(rootEntity);
entityJson.parse(entity);
}
}
NodeComponent nodeComponent = entities.getComponent(rootEntity, NodeComponent.class);
nodeComponent.applyTransforms();
}
use of io.github.voidzombie.nhglib.runtime.ecs.components.scenes.NodeComponent in project nhglib by VoidZombie.
the class GraphicsSystem method process.
@Override
protected void process(int entityId) {
ModelComponent modelComponent = modelMapper.get(entityId);
NodeComponent nodeComponent = nodeMapper.get(entityId);
if (modelComponent.enabled) {
if (modelComponent.animationController != null) {
modelComponent.animationController.update(Gdx.graphics.getDeltaTime());
}
if (modelComponent.type == ModelComponent.Type.DYNAMIC && modelComponent.model != null) {
modelComponent.model.transform.set(nodeComponent.getTransform());
for (ModelCache modelCache : dynamicCaches) {
modelCache.add(modelComponent.model);
}
}
}
}
use of io.github.voidzombie.nhglib.runtime.ecs.components.scenes.NodeComponent in project nhglib by VoidZombie.
the class SceneGraph method addSceneEntity.
public int addSceneEntity(int entity, int parentEntity) {
NodeComponent nodeComponent = entities.getComponent(entity, NodeComponent.class);
nodeComponent.id = entity;
NodeComponent parentNodeComponent = entities.getComponent(parentEntity, NodeComponent.class);
parentNodeComponent.node.addChild(nodeComponent.node);
entitiesArray.add(entity);
return entity;
}
Aggregations