Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

DarkBASIC Discussion / 3d model only shows up at certain distances

Author
Message
puppyofkosh
19
Years of Service
User Offline
Joined: 9th Jan 2007
Location:
Posted: 6th May 2008 20:40
Hi, I'm new to DB and I'm making a game in which the player is a helicopter that flies around a little world...So, my idea was to make walls for the world and then add scenery etc. But, when the player moves, one of the walls kind of disappears. See screeny.


Any help is appreciated.

Robert The Robot
19
Years of Service
User Offline
Joined: 8th Jan 2007
Location: Fireball XL5
Posted: 6th May 2008 21:35
The key point here is your command "set camera range 1, 1000". This tells DB to NOT draw anything on screen that is more than 1000 units away from the camera. Now, your four walls form a kind of cube that is exactly 1000x1000 units. Move backwards by just one unit, and the wall directly in front of you is 1001 units away - and so isn't drawn on screen.

Now, the solution, which is pretty straightforward - just say "Set Camera Range 1, 2000". That way, you can move backwards 1000 units to where your rear wall is, and your front wall will still be in view. You could just delete the command entirely, and leave DB to use its default range of 1, 5000!

I would just like to say, though, that there is a better (well, I think it's better) way of creating your walls, though a little more complex. Instead of making a box out of 4 walls, make a single "Skybox" from one object: Make Object Cube 2, 1000

This will give you an object that is textured when you look at it from the outside. But the helicopter is inside the cube, so to make your walls texture visible, we have to turn the cube inside out: Scale Object 2, -100, -100, -100

This is a bit easier on polygons (each wall you had was a cuboid made up of 12 polygons, giving a total of 48 polys, but this method only uses 12!). However, the bottom of the cube is now in collision with your land matrix. A better piece of code would be:



where the cuboid is a little taller than actually needed, and so can be dropped below your matrix to prevent any interference.

Hope this is of some use! (And by the way, I really like your textures!)
RTR

It is said there are 10 types of people in this world - those who understand binary, and those who have friends!
puppyofkosh
19
Years of Service
User Offline
Joined: 9th Jan 2007
Location:
Posted: 6th May 2008 22:44
Thanks so much!

Quote: "Now, the solution, which is pretty straightforward - just say "Set Camera Range 1, 2000""
Thank you! I used 1415 or 1414.213562373095 to be precise(good 'ol pathagoreum theorum).

As for your idea for the single box, thank you! I am trying it now.

Quote: "And by the way, I really like your textures!"

LOL!

puppyofkosh
19
Years of Service
User Offline
Joined: 9th Jan 2007
Location:
Posted: 6th May 2008 23:16
Hi, I used your code and now I can't see the box sometimes. Here's the code.


Screeny attached.

Robert The Robot
19
Years of Service
User Offline
Joined: 8th Jan 2007
Location: Fireball XL5
Posted: 7th May 2008 18:31
Quote: "Hi, I used your code and now I can't see the box sometimes."

Sorry, my fault (I didn't have DB with me when I posted, so I couldn't test at the time). You don't actually need the "Scale Object" command, and calling it was messing everything up . You can actually turn the skybox inside out at the moment you create it by specifying negative dimensions:



I've also added the Set Object command - the only relevant bit is the final 0, which makes DB draw every polygon on screen. This just means you can see the box when you're outside it. You'll also notice I've modified the Position Object command. By positioning the skybox at -10, I was actually putting 490 units above the matric and 510 units below (object positions go from the object's centre, which would actually have to be well above zero).

One other thing I noticed (I only got a chance to run your code earlier today) was that the matrix didn't line up with the skybox. Again, this is coordiantes - X=0, Z=0 will centre an object about 0, 0 but X=0 and z=0 positions one corner of a matrix to 0, 0 (can't think which one off the top of my head). Anyway, try running this:


Hope it works!

Quote: ""And by the way, I really like your textures!"
LOL!"

Yes, I realise now that they're actually supplied with DB - or at least, the walls stone effect is. I can't find your seascape (and that's the one I really liked!)

It is said there are 10 types of people in this world - those who understand binary, and those who have friends!
puppyofkosh
19
Years of Service
User Offline
Joined: 9th Jan 2007
Location:
Posted: 7th May 2008 22:34
Thank you very much! I ran the code and it works perfectly. As for the texture it was in Darkmatter 1, textures\bmp\natural\water2...lol...
Anyways thanks so much!

Login to post a reply

Server time is: 2026-07-05 13:38:23
Your offset time is: 2026-07-05 13:38:23