Java-Gaming.org    
Featured games (91)
games approved by the League of Dukes
Games in Showcase (579)
games submitted by our members
Games in WIP (500)
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  
  Model and camera  (Read 941 times)
0 Members and 1 Guest are viewing this topic.
Offline gamerfan

Junior Newbie





« Posted 2011-12-13 06:22:41 »

Hi ,
I am new to this forum and noob in 3d programming.I have loaded my model and set camera.The model is nothing but a quake level.So when the appplication is loading, the first person view is inside the level.Now the issue is here that when I move camera away from the model, I am able to see the surrounding world.I want to disable that behaviour.How can I do that? Also, in the level, there are some stairs and steps.When the camera is hit on the wall or steps while moving, I falls through it.should I enable collision detection? What is the general solution to this? Thanks in advance.
Offline lhkbob

JGO Knight


Medals: 32



« Reply #1 - Posted 2011-12-13 07:21:22 »

Yes, you would need to handle collision detection to prevent the camera from moving through the walls, floor and ceiling.  This would also fix your problem where if you move the camera away, you can see the whole level.  If they can't back the camera through the ceiling, they won't be able to see everything.

However, you could also compute where the floor is, and constrain the camera to being 6 feet above the floor and always within it (e.g. a person standing).  This would act like a limited FPS character that they could move around.  You would need some special code to work for the stairs, though or they might get stuck on the first step.

Offline gamerfan

Junior Newbie





« Reply #2 - Posted 2011-12-13 07:34:57 »

How can I identify whether I hit on a wall or stair case or something like that? Because when I hit on a wall, I should get a behaviour like to stand still or on stair case, the player should be able to climb up the stairs.so when we do it programatically how do we do this in a generic way?
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline lhkbob

JGO Knight


Medals: 32



« Reply #3 - Posted 2011-12-15 08:00:39 »

You would classify each polygon in the map as wall or stair.  Or you would look at the height of the wall, and if it's the height of a single step, assume it can be walked over or on and allow the player to move up.  This may also depend on the information available in the Quake levels, they may already identify the stairs for you.

Offline gamerfan

Junior Newbie





« Reply #4 - Posted 2011-12-15 10:25:35 »

@lhkbob thanks for the reply. Can you paste some small quake file format content? Because, in my case, I am using a .3ds file,not quake and it is not human readable.So where can I search this information in the .3ds file?
Offline lhkbob

JGO Knight


Medals: 32



« Reply #5 - Posted 2011-12-15 17:11:09 »

Unfortunately no, I have not used quake files before.  I don't think 3ds has that kind of info in it. What you should do instead is preprocess the level after you have loaded to try and find stairs.

First look for all of the vertical polygons, these will be the walls.  You can compute the height of the wall, and if it's a very small value, then it's a step of a stair.  When you find a stair, you have to search for all horizontal polygons that connect to it so you can find the ground segments that you would move the character to when they step up or step down.

Alternatively, you can have one model that represents the physics world and one that is rendered.  This is common practice in video games.  When you detect a stair case, you can replace it with a sloped ramp in the physics representation.

I have not programmed this myself, but you can try googling "stair collision detection" to see how people have solved it before, there might even be some good tutorials.

Offline Orangy Tang

JGO Kernel


Medals: 51
Projects: 11


Monkey for a head


« Reply #6 - Posted 2011-12-15 17:29:40 »

IIRC quake levels don't do any preprocessing or special flagging of surfaces to determine wall/floor/stair, it's just done at collision time. A quake player is allowed to step up if a suitably horizontal surface is found within a height threshold, otherwise they'll be blocked by it's lip.

No need to make things more complicated than that. Smiley

[ TriangularPixels.com - Play Growth Spurt, Rescue Squad and Snowman Village ] [ Rebirth - game resource library ]
Offline Orangy Tang

JGO Kernel


Medals: 51
Projects: 11


Monkey for a head


« Reply #7 - Posted 2011-12-15 17:44:21 »

Alternatively, you can have one model that represents the physics world and one that is rendered.  This is common practice in video games.  When you detect a stair case, you can replace it with a sloped ramp in the physics representation.

Quake level files already have this built in - the designer can add invisible 'clip' polys to smooth out collision (which go in the bsp tree but not the poly list), and there's a brush flag for 'detail' brushes (which go in the poly list but are not inserted into the bsp tree). Basically you just need to perform collision against the bsp tree and render the polys.

[ TriangularPixels.com - Play Growth Spurt, Rescue Squad and Snowman Village ] [ Rebirth - game resource library ]
Offline lhkbob

JGO Knight


Medals: 32



« Reply #8 - Posted 2011-12-15 18:16:26 »

I figured quake levels did something like this, but he's using a quake level that's been converted to a 3ds file.

Offline Orangy Tang

JGO Kernel


Medals: 51
Projects: 11


Monkey for a head


« Reply #9 - Posted 2011-12-15 18:32:04 »

Unless there's a compelling reason not to, I'd just go back and load the original bsp file. It's a well documented file format and it's got lots of metadata for optimised collision and rendering. Throwing all that good data away seems like a waste.

[ TriangularPixels.com - Play Growth Spurt, Rescue Squad and Snowman Village ] [ Rebirth - game resource library ]
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline gamerfan

Junior Newbie





« Reply #10 - Posted 2011-12-16 05:46:43 »

I do not have original quake file.All I have is a converted .3ds file.But I used this model in other games where already the collision detection(againist wall, stars etc) has been taken care in it.So what I want to know is that when I implement a collision detection here in first person controller scenario, I need to do create a camera node and  when the camera node touches the model wall, I should calculate collision.Is that all I want to do now, right? Also, one more thing.When the application starts, the model is placed in such a way that the camera is inside the model facing the wall.And if I provide collision detection, then I can control the camera movement as well, right? Suppose, if I am able to provide collision detection in this case,  can I re-use the same code in other scenario as well(without doing any  modifications)? Let us say I have a different .3ds model that was converted from quake level.Do I need to modify my the model manually before  loading it through application? Sorry for troubling you so much.Just want to know how it is done generally.
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.

xsi3rr4x (38 views)
2014-04-15 18:08:23

BurntPizza (34 views)
2014-04-15 03:46:01

UprightPath (50 views)
2014-04-14 17:39:50

UprightPath (32 views)
2014-04-14 17:35:47

Porlus (49 views)
2014-04-14 15:48:38

tom_mai78101 (71 views)
2014-04-10 04:04:31

BurntPizza (130 views)
2014-04-08 23:06:04

tom_mai78101 (230 views)
2014-04-05 13:34:39

trollwarrior1 (193 views)
2014-04-04 12:06:45

CJLetsGame (200 views)
2014-04-01 02:16:10
List of Learning Resources
by SHC
2014-04-18 03:17:39

List of Learning Resources
by Longarmx
2014-04-08 03:14:44

Good Examples
by matheus23
2014-04-05 13:51:37

Good Examples
by Grunnt
2014-04-03 15:48:46

Good Examples
by Grunnt
2014-04-03 15:48:37

Good Examples
by matheus23
2014-04-01 18:40:51

Good Examples
by matheus23
2014-04-01 18:40:34

Anonymous/Local/Inner class gotchas
by Roquen
2014-03-11 15:22:30
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!