Anders,
To use Java 3D collision detection you want to use a Behavior with a
WakeupOnCollisionEntry / Exit condition. Create some geometry to represent
the viewer (an avatar) and check for collisions between this geometry and
the geometry in your scene.
You either have to manually assign collision bounds
(Group.setCollisionBounds - faster) or set the WakeupOnCollisionEntry object
to use the USE_GEOMETRY mode.
This should work but your problem will be that you will only detect a
collision once it is too late, and if your framerate is low you will miss
collisions. The current Java 3D implementation is not velocity based and is
really "collision notification" (if you're lucky!).
One of the longer examples in my book implements collision detection for a
Doom style game. Essentially I cheat and within my key navigation behavior
check whether the new position of the viewer would put them within one of
the solid objects. I use an array to quickly look up the positions of solid
objects. This works as the world is essentially 2D and in a simple maze
environment the look up and transformation from world to "maze" coordinates
is very fast and robust.
An alternate (and maybe more general) scheme might be to use pick rays to
check how far you are from the objects within your scene. You can do this
within your navigation behavior and again allow or disallow the movement.
This would be an "abuse" of picking though so performance might be an issue
so write test code.
It sounds like you are a little fuzzy about some general Java 3D topics.
Perhaps a good place to start would be the tutorial, and then approach the
collision detection.
That's all I can think of!
Sincerely,
Daniel Selman
[EMAIL PROTECTED]
http://www.tornadolabs.com
> -----Original Message-----
> From: Anders Breivik [mailto:[EMAIL PROTECTED]]
> Sent: 06 February 2000 20:35
> To: [EMAIL PROTECTED]
> Subject: Collision Detection - walking through walls.
>
>
> Hello Daniel,
>
> Tanks for your reply to my previous question! The j3dtree application now
> works fine together with my customised classes.
>
> I’m having some more problems though. This time its got to do
> with collision
> detection (!). I’ve tried the Java 3D – Interest mailing list,
> but haven’t
> received any response about this.
>
> I’m trying to implement a collision detection scheme where the
> player of my
> game does not walk through the walls when navigating around in different
> rooms. I wish to detect when the view co-ordinates collides with
> any object
> in the scene. I find it difficult to do because it is hard to find any
> detailed information about java3d’s collision detection schemes.
> The sun’s
> java3d web site is very useful, but I sometimes need more detailed
> information.
>
> Anyway, I am writing to you (again) to see if you can give me some new
> ideas. (I hope you don’t mind)
>
> My first idea was to use WakeupOnViewPlatformEntry/Exit(Bounds region) to
> detect when the view co-ordinates collides with an object, and
> then to alter
> the key navigation accordingly. However, (as I understand it)
> this requires
> that the bounds region must fit/rap the collidable object as
> accurately as
> possible. I don’t know how to specify such a region for each
> object in the
> scene. Do you?
> Besides, I think this scheme is not so good because specifying
> such a region
> for each object in the scene might be a big hassle.
>
> My other idea was to attach a small object very close to the view
> co-ordinates and at run time update the co-ordinates of this object such
> that it always is very close to the current view co-ordinates. I
> could then
> use WakeupOnCollisionEntry/Exit(Shape3D)
> to detect if any other object collides with the “view object”. This view
> object (the object close to the view co-ordinates) would be
> positioned such
> that the user never can see it. Is this a valid/better approach? I would
> very much like to hear your opinion. (I haven’t managed to get
> this working.
> I can’t get the view object co-ordinates updated.)
>
>
> I’m sure there are better ways to approach this problem, but I have not
> figured them out. There must be someone who has implemented this
> earlier and
> I would like to learn how it is done. If you have any advise I would (as
> usual) greatly appreciate your feedback.
>
>
>
> Sincerely
> Anders Breivik
>
>
> >From: "Daniel Selman" <[EMAIL PROTECTED]>
> >Reply-To: <[EMAIL PROTECTED]>
> >To: "Anders Breivik" <[EMAIL PROTECTED]>
> >Subject: RE: j3dtree.jar
> >Date: Thu, 3 Feb 2000 12:23:13 -0000
> >
> >Anders,
> >
> >You need to separate the names of the JAR files on the command
> line with a
> >semi-colon. E.g.
> >
> >javac -classpath j3dtree.jar;myother.jar *.java
> >
> >Check the API docs for javac for more options.
> >
> >Sincerely,
> >
> >Daniel
> >
> >[EMAIL PROTECTED]
> >http://www.tornadolabs.com
> >
> > > -----Original Message-----
> > > From: Anders Breivik [mailto:[EMAIL PROTECTED]]
> > > Sent: 03 February 2000 13:14
> > > To: [EMAIL PROTECTED]
> > > Subject: j3dtree.jar
> > >
> > >
> > > Hello Daniel,
> > >
> > > I'm having a small problem with the j3dtree program which is
> > > integrated with
> > > the rest of my code. Its all got to do with the classpath
> > > settings: When I
> > > compile with
> > >
> > > javac -classpath j3dtree.jar World.java
> > >
> > > it will not find my other customised java classes (UI.java for
> > > instance)which are used within World.java. This is obviously
> because the
> > > classpath is altered. My question is: do you know what command line
> > > arguments (MS-DOS)I should use in order to include both the
> > > j3dtree.jar and
> > > my additional java classes when compiling.
> > >
> > > Finally, thanks for your answers to all the questions I have
> emailed you
> > > earlied.
> > >
> > > Hope to hear from you again.
> > >
> > > Sincerely
> > > Anders.
> > >
> > >
> > > ______________________________________________________
> > > Get Your Private, Free Email at http://www.hotmail.com
> > >
> > >
> >
> >
>
> ______________________________________________________
> Get Your Private, Free Email at http://www.hotmail.com
>
>
===========================================================================
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff JAVA3D-INTEREST". For general help, send email to
[EMAIL PROTECTED] and include in the body of the message "help".