Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Topics - Gvrv89

Pages: [1]
1
Support / Collision strange behaviour
« on: October 03, 2011, 02:15:40 pm »
Hi all !

It's been two days I try to make collisions works. Unsuccessfully...

I load a 3ds terrain and want to stick 3ds trees on it.

Here's the project (simplified) : https://docs.google.com/viewer?a=v&pid=explorer&chrome=true&srcid=0B34S8VzVRdKMMGQxY2UwNDItNWM2OC00YzdkLTlmZmEtMjNjNDg3NmIwZWMz&hl=fr

The important code parts are :

Code: [Select]
ground = Loader.load3DS("res" + c + "ground.3ds", 70f)[0];
ground.rotateX((float) (-Math.PI / 2));
ground.translate(-100f, 10f, 2f);
ground.setSpecularLighting(true);
ground.setShadingMode(Object3D.SHADING_GOURAUD);
ground.setTexture("ground");
ground.setCollisionMode(Object3D.COLLISION_CHECK_OTHERS);
ground.setCollisionOptimization(Object3D.COLLISION_DETECTION_OPTIMIZED);
ground.build();
world.addObject(ground);

And :

Code: [Select]
public TreeEngine(World world, Object3D ground)
{
char c = File.separatorChar;

Object3D tree = Loader.load3DS("res" + c + "tree.3ds", 3f)[0];
tree.setSpecularLighting(true);
tree.setShadingMode(Object3D.SHADING_GOURAUD);

trees = new Vector<Object3D>();
for (int i = 0; i < 25; i++)
{
trees.add(tree.cloneObject());
trees.get(i).rotateX((float) (-Math.PI / 2));
trees.get(i).rotateY((float) (-Math.PI / Math.random() * 2));
//trees.get(i).scale((float) Math.random() * 2f);
trees.get(i).setCenter(ground.getTransformedCenter());
trees.get(i).translate(new SimpleVector(Math.random() * 800f - 400f, 0, Math.random() * 800f - 400f));
trees.get(i).setCollisionMode(Object3D.COLLISION_CHECK_SELF);
trees.get(i).setCollisionOptimization(Object3D.COLLISION_DETECTION_OPTIMIZED);
trees.get(i).build();
world.addObject(trees.get(i));

dir = trees.get(i).checkForCollisionEllipsoid(dir, new SimpleVector(1, 1, 1), 1);
//System.out.print(dir);
trees.get(i).translate(dir);
}
}

Did your expert eyes seen something wrong on this ? :)

Btw I set "Config.collideOffset = 40;".

Thanks in advance.

Pages: [1]