Hello, I’m trying to create a pretty simple world (i’m still a programming nube!), basically taking the HelloCollision tutorial and switching in my own mesh (think a box with the top cut off). However after turning on the collision debug, I find that there is a proper mesh in place, but also a smaller second mesh, and a bunch of random lines.
Can the CollisionShapeFactory not handle concave shapes? Or am I doing somthing wrong?
Thanks!
Alpha-4? Then you can just ignore the lines, its a debug view issue. Should be fixed in nightly since quite a while.
Thanks for the reply! I do have one other problem, I have a cylinder in the world (using the CapsuleCollisionShape, cause I couldn’t figure out what halfextents are for the CylinderCollisionShape). However the collision mesh and the Spatial are in different locations. setLocalTransform and setPysicsLocation doesn’t seem to move it. Is there a way to get these two to line up?
Thanks again.
Probably you generate the collisionshape while the spatial has a localTranslation. This doesn’t happen in nightly either. In alpha-4 simply create the collisionshape with a non-attached and null-translation object.
Hmm, I can’t even seem to get the collision mesh to appear in a new file. I copied the HelloCollision tutorial, and created a second character (called baton) and turned on the debug. However the collision mesh doesn’t seem to have been created.
pre type="php"
public class HelloCollision extends SimpleApplication
implements ActionListener {
private Spatial sceneModel;
private Material white;
private BulletAppState bulletAppState;
private RigidBodyControl landscape;
private CharacterControl player;
private CharacterControl baton;
private Vector3f walkDirection = new Vector3f();
private boolean left = false, right = false, up = false, down = false;
public static void main(String[] args) {
HelloCollision app = new HelloCollision();
app.start();
}
public void simpleInitApp() {
bulletAppState = new BulletAppState();
stateManager.attach(bulletAppState);
white = new Material(assetManager, “Common/MatDefs/Light/Lighting.j3md”);
white.setTexture(“DiffuseMap”,
assetManager.loadTexture(“Textures/white.png”));
white.setFloat(“Shininess”, 5f);
viewPort.setBackgroundColor(new ColorRGBA(0.7f,0.8f,1f,1f));
flyCam.setMoveSpeed(100);
setUpKeys();
setUpLight();
sceneModel = assetManager.loadModel(“Models/landscape.j3o”);
sceneModel.setLocalScale(2f);
CollisionShape sceneShape =
CollisionShapeFactory.createMeshShape((Node) sceneModel);
landscape = new RigidBodyControl(sceneShape, 0);
sceneModel.addControl(landscape);
sceneModel.setMaterial(white);
CapsuleCollisionShape batonShape = new CapsuleCollisionShape(1.5f, 6f, 1);
baton = new CharacterControl(batonShape, 0.05f);
baton.setGravity(0);
baton.setPhysicsLocation(new Vector3f(0, 0, 0));
CapsuleCollisionShape capsuleShape = new CapsuleCollisionShape(1.5f, 6f, 1);
player = new CharacterControl(capsuleShape, 0.05f);
player.setGravity(0);
player.setPhysicsLocation(new Vector3f(0, 10, -20));
rootNode.attachChild(sceneModel);
bulletAppState.getPhysicsSpace().add(landscape);
bulletAppState.getPhysicsSpace().add(player);
bulletAppState.getPhysicsSpace().add(baton);
bulletAppState.getPhysicsSpace().enableDebug(assetManager);
}
/pre
What am I missing?
Spatials. You just have controls hanging in thin air basically.
Thanks for your patience, I found the problem. The object wasn’t centered at 0,0,0 in Maya when I made it. I had assumed that didn’t matter after exporting it with OgreMax. At least I have a little hair left that I haven’t torn out!