i need help in Collision
i want to make Collision detection that make the view point not go on any object
i make a simple program tat contain only one object Cylinder i want to make collision where the view pont when hit the object not go inside it i want it to stop
this is my code
publicclass Hello4extends Applet
{
Texture2D texture;
public Hello4()
{
setLayout(new BorderLayout());
GraphicsConfiguration config = SimpleUniverse.getPreferredConfiguration();
Canvas3D canvas3D =new Canvas3D(config);
add(canvas3D,BorderLayout.CENTER);
BranchGroup scene = createSceneGraph();
scene.compile();
SimpleUniverse simpleu =new SimpleUniverse(canvas3D);
simpleu.getViewingPlatform().setNominalViewingTransform();
simpleu.addBranchGraph(scene);
}
public BranchGroup createSceneGraph()
{
BranchGroup objroot =new BranchGroup();
TextureLoader loader =new TextureLoader("house_auto_mosaic1.jpg",this);
ImageComponent2D image = loader.getImage();
//System.out.println(" width "+image.getWidth());
texture =new Texture2D(Texture.BASE_LEVEL,Texture.RGB,image.getWidth(),image.getHeight(),1);
texture.setImage(0,image);
texture.setEnable(true);
Appearance appear =new Appearance();
appear.setTexture(texture);
Cylinder cy =new Cylinder(0.70f,3.50f,Primitive.GENERATE_TEXTURE_COORDS,appear);
//TextureAttributes mta = new TextureAttributes();
Transform3D rotate =new Transform3D();
rotate.rotY(Math.toRadians(45));
rotate.setTranslation(new Vector3d(0,0,-15));
TransformGroup objrotate =new TransformGroup(rotate);
objrotate.addChild(cy);
objroot.addChild(objrotate);
return objroot;
}
}

