use of net.drewke.tdme.math.Vector3 in project tdme by andreasdr.
the class LevelEditorEntityLibrary method addTrigger.
/**
* Add a trigger
* @param name
* @param description
* @param width
* @param height
* @param depth
* @return level editor entity
* @throws Exception
*/
public LevelEditorEntity addTrigger(int id, String name, String description, float width, float height, float depth) throws Exception {
String cacheId = "leveleditor.trigger." + width + "mx" + height + "mx" + depth + "m";
LevelEditorEntity levelEditorEntity = null;
BoundingBox boundingBox = new BoundingBox(new Vector3(-width / 2f, 0f, -depth / 2f), new Vector3(+width / 2f, height, +depth / 2f));
Model model = PrimitiveModel.createModel(boundingBox, cacheId + "_bv");
levelEditorEntity = new LevelEditorEntity(id == ID_ALLOCATE ? allocateEntityId() : id, EntityType.TRIGGER, name, description, null, cacheId, model.getId().replace("\\", "_").replace("/", "_").replace(":", "_") + ".png", model, new Vector3());
levelEditorEntity.addBoundingVolume(0, new LevelEditorEntityBoundingVolume(0, levelEditorEntity));
levelEditorEntity.getBoundingVolumeAt(0).setupAabb(boundingBox.getMin(), boundingBox.getMax());
id = levelEditorEntity.getId();
// add trigger
addEntity(levelEditorEntity);
//
return levelEditorEntity;
}
use of net.drewke.tdme.math.Vector3 in project tdme by andreasdr.
the class LevelEditorLevel method computeCenter.
/**
* @return level center
*/
public Vector3 computeCenter() {
Vector3 center = new Vector3();
int objectCount = 0;
for (LevelEditorObject levelEditorObject : objects) {
if (levelEditorObject.getEntity().getType() != EntityType.MODEL)
continue;
center.add(levelEditorObject.getTransformations().getTranslation());
objectCount++;
}
if (objectCount != 0)
center.scale(1f / objectCount);
return center;
}
use of net.drewke.tdme.math.Vector3 in project tdme by andreasdr.
the class TriggerView method updateGUIElements.
/**
* Init GUI elements
*/
public void updateGUIElements() {
if (entity != null) {
triggerScreenController.setScreenCaption("Trigger - " + entity.getName());
PropertyModelClass preset = entity.getProperty("preset");
triggerScreenController.setEntityProperties(preset != null ? preset.getValue() : null, entity.getProperties(), null);
triggerScreenController.setEntityData(entity.getName(), entity.getDescription());
// trigger
Vector3 dimension = new Vector3();
dimension.set(entity.getModel().getBoundingBox().getMax());
dimension.sub(entity.getModel().getBoundingBox().getMin());
triggerScreenController.setTrigger(dimension.getX(), dimension.getY(), dimension.getZ());
} else {
triggerScreenController.setScreenCaption("Trigger - no trigger loaded");
triggerScreenController.unsetEntityProperties();
triggerScreenController.unsetEntityData();
triggerScreenController.unsetTrigger();
}
}
use of net.drewke.tdme.math.Vector3 in project tdme by andreasdr.
the class Tools method computeMaxAxisDimension.
/**
* Compute max axis dimension b given bounding box
* @param model bounding box
* @return max axis dimension
*/
public static float computeMaxAxisDimension(BoundingVolume modelBoundingVolume) {
float maxAxisDimension = 0.0f;
// model dimension
Vector3 dimension = new Vector3(modelBoundingVolume.computeDimensionOnAxis(new Vector3(1f, 0f, 0f)), modelBoundingVolume.computeDimensionOnAxis(new Vector3(0f, 1f, 0f)), modelBoundingVolume.computeDimensionOnAxis(new Vector3(0f, 0f, 1f)));
// determine max axis dimension
if (dimension.getX() > maxAxisDimension)
maxAxisDimension = dimension.getX();
if (dimension.getY() > maxAxisDimension)
maxAxisDimension = dimension.getY();
if (dimension.getZ() > maxAxisDimension)
maxAxisDimension = dimension.getZ();
return maxAxisDimension;
}
use of net.drewke.tdme.math.Vector3 in project tdme by andreasdr.
the class Tools method convertToVector3.
/**
* Convert to vector 3
* @param text
* @return vector3
*/
public static Vector3 convertToVector3(String text) throws NumberFormatException {
Vector3 v = new Vector3();
convertToArray(text, 3, v.getArray());
return v;
}
Aggregations