Java-Gaming.org    
Featured games (81)
games approved by the League of Dukes
Games in Showcase (499)
Games in Android Showcase (118)
games submitted by our members
Games in WIP (568)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  About java3d collision detection  (Read 2264 times)
0 Members and 1 Guest are viewing this topic.
Offline oldmao_2001

Senior Newbie





« Posted 2005-11-28 09:02:25 »

I import a 3ds model.
I want to use keyboard to view the model by first person view.
How can I use the collision detectiont to prevent I go though the wall of model
Offline hvor2

Junior Member




Beyond mind, there is an awareness...


« Reply #1 - Posted 2005-11-28 09:28:43 »

You can (as you move) test distance between camera position and  the centre of imaginary sphere around your object. Not the best solution for non - sphere - shaped objects, but as first implementation of collision will suffice....
EDIT: if your next move is about to shorten distance, don't allow it! else - go ...

Offline oldmao_2001

Senior Newbie





« Reply #2 - Posted 2005-11-28 13:56:58 »

You can (as you move) test distance between camera position and  the centre of imaginary sphere around your object. Not the best solution for non - sphere - shaped objects, but as first implementation of collision will suffice....
EDIT: if your next move is about to shorten distance, don't allow it! else - go ...
But the model is a building,the cann't regard as a imaginary sphere so...
By the way ,how can i get the camera position.
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline tom
« Reply #3 - Posted 2005-11-28 17:16:27 »

I'm not a Java3D expert, but I don't think it has got that kind of collision detection and response buildt in. You might have to code it yourself.

Offline oldmao_2001

Senior Newbie





« Reply #4 - Posted 2005-11-29 05:47:58 »

I'm not a Java3D expert, but I don't think it has got that kind of collision detection and response buildt in. You might have to code it yourself.
I am a freshman in java3d,and i am not good at collision arithmetic  such as bsp...So I want to know how can I complete the function by java3d build in class.
Offline Jeff

JGO Coder




Got any cats?


« Reply #5 - Posted 2005-11-29 06:07:31 »

Oka, firs off, forget all about what Java3D calls "collision detection".  It doesnt do what you want to know when a collision occurs  on the frame it occurs, or even ebfore so you can stop it. This is soemtimes called "collision avoidance."

Its not simple, even to cheat.  Its even harder to do right.

But the smplest cheat is this:  When you get a command to move the character, you project a pick-ray from the character in the direction of m otion.  You test it against the environment to find the first point of collision of that ray against the environment and use that to limit the motion.

Now you will have to add some "fudge" to the starting position of the ray, which we assume will be at model center, to get you to the outside edge of the model. Effectively what you are doing by subtracting this fudge is treating the character like a cylinder around the center point.

There are plenty of examples aroudn of pick-rays, so look in tyhe docs, the J3D exampels, and then doa  google on "Java3D pick-ray " if you still can't figure it out.

As I said, this is a cheat.  It will work for simple situations but fail for many complex ones.  The only complete solution is a real physics based solution with multiple bounding volumes and "push-back" from object inter-penetration but that frankly soudns way beyond what you want to get into.




Got a question about Java and game programming?  Just new to the Java Game Development Community?  Try my FAQ.  Its likely you'll learn something!

http://wiki.java.net/bin/view/Games/JeffFAQ
Offline oldmao_2001

Senior Newbie





« Reply #6 - Posted 2005-11-30 00:56:38 »

I know the collision detection by picking,and i know the principle by the book "java3d programing",i want to know i use keyboardbehavior to move my view,whether the principle is the same?
Offline Jeff

JGO Coder




Got any cats?


« Reply #7 - Posted 2005-11-30 23:52:47 »

Sure.  No difference.  Even if you dont have an obejct rerpesenting your body the camera has a position in the world and there is a physical radius around that which I would assume you want to keep free so you dont run the camera right into the wall.


Got a question about Java and game programming?  Just new to the Java Game Development Community?  Try my FAQ.  Its likely you'll learn something!

http://wiki.java.net/bin/view/Games/JeffFAQ
Offline DzzD
« Reply #8 - Posted 2005-12-01 08:19:42 »

For smooth collision detection and response, you can implement that algorithm, it works very well:

http://www.peroxide.dk/download/tutorials/tut10/pxdtut10.html

Bruno

Offline Conzar

Junior Member




There is nothing common about common sense


« Reply #9 - Posted 2006-01-30 17:57:19 »

Here is a good example of doing collision detection in j3d
http://java3d.j3d.org/tutorials/collision/index.html

Ubuntu
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline Jeff

JGO Coder




Got any cats?


« Reply #10 - Posted 2006-02-02 00:58:59 »

Another approach, used by games such as NWN, is a walk-mesh.  This is basically a free-form blockign map made up of triangles.

The down-side is you have to create that map as a seperate asset for all your 3D spatial geometry.  It also only works for worlds where your feet are stuck to the ground.

The upside is it scales great as its a very very low cost way to do blocking.

Im just about done integrating NWN's walkmeshes into JNWN.  Theres an early versio nin the code-base now.

Got a question about Java and game programming?  Just new to the Java Game Development Community?  Try my FAQ.  Its likely you'll learn something!

http://wiki.java.net/bin/view/Games/JeffFAQ
Pages: [1]
  ignore  |  Print  
 
 
You cannot reply to this message, because it is very, very old.

 

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

Pippogeek (39 views)
2014-09-24 16:13:29

Pippogeek (30 views)
2014-09-24 16:12:22

Pippogeek (20 views)
2014-09-24 16:12:06

Grunnt (46 views)
2014-09-23 14:38:19

radar3301 (28 views)
2014-09-21 23:33:17

BurntPizza (64 views)
2014-09-21 02:42:18

BurntPizza (36 views)
2014-09-21 01:30:30

moogie (42 views)
2014-09-21 00:26:15

UprightPath (51 views)
2014-09-20 20:14:06

BurntPizza (54 views)
2014-09-19 03:14:18
List of Learning Resources
by Longor1996
2014-08-16 10:40:00

List of Learning Resources
by SilverTiger
2014-08-05 19:33:27

Resources for WIP games
by CogWheelz
2014-08-01 16:20:17

Resources for WIP games
by CogWheelz
2014-08-01 16:19:50

List of Learning Resources
by SilverTiger
2014-07-31 16:29:50

List of Learning Resources
by SilverTiger
2014-07-31 16:26:06

List of Learning Resources
by SilverTiger
2014-07-31 11:54:12

HotSpot Options
by dleskov
2014-07-08 01:59:08
java-gaming.org is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑gaming.org
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!