use of gaiasky.interafce.AddShapeDialog.Primitive in project gaiasky by langurmonkey.
the class EventScriptingInterface method addShapeAroundObject.
@Override
public void addShapeAroundObject(String shapeName, String shape, String primitive, double size, String objectName, float r, float g, float b, float a, boolean showLabel, boolean trackObject) {
if (checkString(shapeName, "shapeName") && checkStringEnum(shape, Shape.class, "shape") && checkStringEnum(primitive, Primitive.class, "primitive") && checkNum(size, 0, Double.MAX_VALUE, "size") && checkObjectName(objectName)) {
GaiaSky.postRunnable(() -> {
IFocus object = getFocus(objectName);
float[] color = new float[] { r, g, b, a };
int primitiveInt = Primitive.valueOf(primitive.toUpperCase()).equals(Primitive.LINES) ? GL20.GL_LINES : GL20.GL_TRIANGLES;
final ShapeObject shapeObj;
if (trackObject) {
shapeObj = new ShapeObject(new String[] { shapeName.trim() }, "Universe", object, objectName, showLabel, color);
} else {
shapeObj = new ShapeObject(new String[] { shapeName.trim() }, "Universe", object.getAbsolutePosition(objectName, new Vector3b()), objectName, showLabel, color);
}
shapeObj.ct = new ComponentTypes(ComponentType.Others.ordinal());
shapeObj.size = (float) (size * Constants.KM_TO_U);
Map<String, Object> params = new HashMap<>();
params.put("quality", 25L);
params.put("divisions", shape.equals("octahedronsphere") ? 3L : 15L);
params.put("recursion", 3L);
params.put("diameter", 1.0);
params.put("width", 1.0);
params.put("height", 1.0);
params.put("depth", 1.0);
params.put("innerradius", 0.6);
params.put("outerradius", 1.0);
params.put("sphere-in-ring", false);
params.put("flip", false);
shapeObj.setModel(shape, primitiveInt, params);
shapeObj.doneLoading(GaiaSky.instance.assetManager);
EventManager.publish(Event.SCENE_GRAPH_ADD_OBJECT_NO_POST_CMD, this, shapeObj, false);
});
}
}
Aggregations