本文整理汇总了Java中com.badlogic.gdx.graphics.g3d.ModelInstance.calculateBoundingBox方法的典型用法代码示例。如果您正苦于以下问题:Java ModelInstance.calculateBoundingBox方法的具体用法?Java ModelInstance.calculateBoundingBox怎么用?Java ModelInstance.calculateBoundingBox使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.badlogic.gdx.graphics.g3d.ModelInstance
的用法示例。
在下文中一共展示了ModelInstance.calculateBoundingBox方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: GameModel
import com.badlogic.gdx.graphics.g3d.ModelInstance; //导入方法依赖的package包/类
/**
* Holds a an instance of the model.
*
* @param name Name of model
* @param model Model to instantiate
* @param location World position at which to place the model instance
* @param rotation The rotation of the model instance in degrees
* @param scale Scale of the model instance
*/
public GameModel(Model model,
String name,
Vector3 location,
Vector3 rotation,
Vector3 scale) {
super(name);
modelInstance = new ModelInstance(model);
applyTransform(location, rotation, scale, modelInstance);
try {
modelInstance.calculateBoundingBox(boundingBox);
} catch (Exception e) {
Gdx.app.debug(TAG, "Error when calculating bounding box.", e);
}
boundingBox.getCenter(center);
boundingBox.getDimensions(dimensions);
boundingBoxRadius = dimensions.len() / 2f;
modelTransform = modelInstance.transform;
halfExtents.set(dimensions).scl(0.5f);
}
示例2: onLoaded
import com.badlogic.gdx.graphics.g3d.ModelInstance; //导入方法依赖的package包/类
@Override
protected void onLoaded () {
if (currentlyLoading == null || currentlyLoading.length() == 0) return;
instances.clear();
animationControllers.clear();
final ModelInstance instance = new ModelInstance(assets.get(currentlyLoading, Model.class));
instance.transform = transform;
instances.add(instance);
if (instance.animations.size > 0) animationControllers.put(instance, new AnimationController(instance));
currentlyLoading = null;
instance.calculateBoundingBox(bounds);
cam.position.set(1, 1, 1).nor().scl(bounds.getDimensions().len() * 0.75f + bounds.getCenter().len());
cam.up.set(0, 1, 0);
cam.lookAt(0, 0, 0);
cam.far = 50f + bounds.getDimensions().len() * 2.0f;
cam.update();
}
示例3: Entity
import com.badlogic.gdx.graphics.g3d.ModelInstance; //导入方法依赖的package包/类
public Entity(Matrix4 transform, int hp, int health, EnumSet<Types> types, EnumSet<Effects> effects, ModelInstance instance, btCollisionShape shape, btCollisionWorld world, IntMap<Entity> entities, Map<String, Sound> sounds){
this.instance = instance;
this.transform = transform;
this.hp = hp;
this.types = types;
this.health = health;
this.effects = effects;
this.sounds = sounds;
animation = new AnimationController(instance);
this.instance.transform.set(transform);
this.shape = shape;
body = new btCollisionObject();
body.setCollisionShape(shape);
body.setWorldTransform(this.instance.transform);
this.world = world;
tempVector = new Vector3();
tempVector2 = new Vector3();
this.entities = entities;
tempQuaternion = new Quaternion();
quaternion = new Quaternion();
if(this instanceof Enemy || this instanceof Projectile)
body.setCollisionFlags(body.getCollisionFlags());
int index = getNextIndex();
entities.put(index, this);
body.setUserValue(index);
world.addCollisionObject(body);
boundingBox = instance.calculateBoundingBox(new BoundingBox());
//for(Node node: instance.nodes)
//System.out.println();
}
示例4: onInitialize
import com.badlogic.gdx.graphics.g3d.ModelInstance; //导入方法依赖的package包/类
@Override
protected void onInitialize() {
this.levelEnv = new LevelEnv();
this.camera = new PerspectiveCamera(67, Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
camera.near = 0.1f;
camera.position.set(5, 5, 5);
camera.lookAt(0.1f, 0.1f, 0.1f);
environment = new Environment();
environment.set(new ColorAttribute(ColorAttribute.AmbientLight, 0.4f, 0.4f, 0.4f, 1.f));
environment.add(new DirectionalLight().set(0.8f, 0.8f, 0.8f, -0.5f, -1.0f, -0.8f));
this.modelBatch = new ModelBatch();
//this.voxelBatch = new VoxelBatch(new RenderContext(new DefaultTextureBinder(DefaultTextureBinder.WEIGHTED)));
ModelLoader g3djLoader = new G3dModelLoader(new UBJsonReader());
model = g3djLoader.loadModel(ForgE.files.internal("raw/models/test.g3db"));
modelInstance = new ModelInstance(model);
modelInstance.calculateBoundingBox(bounds);
camera.position.set(1, 1, 1).nor().scl(bounds.getDimensions(tmpV1).len() * 1.75f + bounds.getCenter(tmpV2).len());
camera.up.set(0, 1, 0);
camera.lookAt(0, 0, 0);
camera.far = 50f + bounds.getDimensions(tmpV1).len() * 3.0f;
camera.update(true);
}
示例5: Entity
import com.badlogic.gdx.graphics.g3d.ModelInstance; //导入方法依赖的package包/类
public Entity(float x, float y, float z, String model) {
id = classToIdMap.get(getClass());
modelInstance = new ModelInstance(Vloxlands.assets.get("models/" + model, Model.class));
modelInstance.calculateBoundingBox(boundingBox = new BoundingBox());
if (boundingBox.getDimensions().x % 1 != 0 || boundingBox.getDimensions().y % 1 != 0 || boundingBox.getDimensions().z % 1 != 0) {
blockTrn.set(((float) Math.ceil(boundingBox.getDimensions().x) - boundingBox.getDimensions().x) / 2, 1 - boundingBox.getCenter().y, ((float) Math.ceil(boundingBox.getDimensions().z) - boundingBox.getDimensions().z) / 2);
}
blockTrn.add(boundingBox.getDimensions().cpy().scl(0.5f));
modelInstance.transform.translate(x, y, z).translate(blockTrn);
animationController = new AnimationController(modelInstance);
markedForRemoval = false;
subs = new Array<ModelInstance>();
for (Node n : modelInstance.nodes.get(0).children) {
if (n.id.startsWith("model:")) {
subs.add(new ModelInstance(Vloxlands.assets.get("models/" + model.replace(model.substring(model.lastIndexOf("/") + 1), n.id.replace("model:", "")) + ".vxi", Model.class), n.translation));
}
}
modelInstance.transform.getTranslation(posCache);
level = 0;
modelVisible = true;
additionalVisible = true;
visible = true;
dimensions.set(Math.max(Math.round(boundingBox.getDimensions().x), 1), Math.max(Math.round(boundingBox.getDimensions().y), 1), Math.max(Math.round(boundingBox.getDimensions().z), 1));
Game.instance.addListener(this);
}
示例6: onLoaded
import com.badlogic.gdx.graphics.g3d.ModelInstance; //导入方法依赖的package包/类
@Override
public void onLoaded() {
ModelInstance mi = new ModelInstance(Vloxlands.assets.get("models/item/" + model, Model.class));
mi.calculateBoundingBox(boundingBox = new BoundingBox());
}