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 / Pro code for DBC easy to use and powerful

Author
Message
Stig Design Stig Magne
19
Years of Service
User Offline
Joined: 23rd Mar 2006
Location: Norway
Posted: 28th Apr 2008 20:57 Edited at: 28th Apr 2008 21:11
hi im nott soure if this code is so power full that i think but i give it a try. lett say that you have created a GTA like game with DBC and you whant to add moast details as possible ok the horison acts by the camera range code that is ok and fog of course but then you cant have detalied bulding`s Cars Humans,Miscaleus,ect so then this code comes upp



i now this code only demonstrate front/Back moves and a Cube object butt you have given an idea on how it works

ps. the code

need to change on eatche object in your 3Dworld
hope this helped to create wast streets.and so on
oh soory for my bad english

and right now i am working on a bether exampel on the camera x,y,z cordinates with more basic object`s

Stig Design (Free Games,Sources,Textures,Photo`s)
Lisence Free at http://StigDesign.piczo.com
Latch
18
Years of Service
User Offline
Joined: 23rd Jul 2006
Location:
Posted: 28th Apr 2008 21:33
So any objects out of range, hide to help increase performance. It's a good idea if handled well. You may want to avoid objects suddenly disappearing and reappearing by trying out variations.

Although I haven't used it, maybe experiment with

ATTACH OBJECT TO STATIC <object> .

This is supposed to attach a regular object to the static world and increase performance. The advantage is you can keep the object in view longer if you like, but you can no longer move or change the object until you

DETTACH OBJECT FROM STATIC <obj>

Also try



That means if an object is out of the cameras field of view, it will be hidden. That also eliminates the need for a range behind the camera.

Enjoy your day.
Stig Design Stig Magne
19
Years of Service
User Offline
Joined: 23rd Mar 2006
Location: Norway
Posted: 28th Apr 2008 22:31
thanks latch can u plees make an exampel like my.
so that i can test your code in action.

oh
i tryed to make my examepl to work on camera x,y,z cordinates butt only Camera z cordinate worked

i need a code that make eatche object at position (x)0,(y)0,(z)0
after the org position is maked so that it has its own area like tdk`s collision tutorial then ithink my code works greate

Stig Design (Free Games,Sources,Textures,Photo`s)
Lisence Free at http://StigDesign.piczo.com
Latch
18
Years of Service
User Offline
Joined: 23rd Jul 2006
Location:
Posted: 1st May 2008 00:43
For static objects, there are two good examples that come with DBC. exam19.dba and exam23.dba

Here's an example for the hiding and showing of objects. There is a ring of 360 boxes around the camera position (I have them bouncing randomly so it looks kinda like an energy field for fun). In the upper left corner you'll see the current polygon count and the screen FPS. Press space to hide the objects that are out of view. Press it again to show all objects. Use arrow keys to move around.



Enjoy your day.
TheComet
17
Years of Service
User Offline
Joined: 18th Oct 2007
Location: I`m under ur bridge eating ur goatz.
Posted: 1st May 2008 15:39


I`m not sure if you forgot the endif...

Oooooops!!! I accidentally formated drive c.
Libervurto
18
Years of Service
User Offline
Joined: 30th Jun 2006
Location: On Toast
Posted: 6th May 2008 01:29
Can you make one that replaces distant objects with simplified version of objects before hiding at very great distance?
Begginings of a game engine here

It is far better to complete a 10 line program than to start a 10,000 line program.
Stig Design Stig Magne
19
Years of Service
User Offline
Joined: 23rd Mar 2006
Location: Norway
Posted: 10th May 2008 23:06
maby i am trying to get a code dat hide a object on x,y,z distance and maby then it can replace a 3Dtree to a plain tree

Stig Design (Free Games,Sources,Textures,Photo`s)
Lisence Free at http://StigDesign.piczo.com
Latch
18
Years of Service
User Offline
Joined: 23rd Jul 2006
Location:
Posted: 21st May 2008 11:28
Use the distance formula:

distance#=sqrt((x2-x1)^2 + (y2-y1)^2 + (z2-z1)^2)

where (x1,y1,z1) is the starting position and (x2,y2,z2) is the ending position.

to speed things up, there's been discussion in several other threads regarding this, eliminate the square root and square the distance.

Enjoy your day.
Stig Design Stig Magne
19
Years of Service
User Offline
Joined: 23rd Mar 2006
Location: Norway
Posted: 22nd May 2008 03:46
i din`t under stand that but ok thanks i try that

Stig Design (Free Games,Sources,Textures,Photo`s)
Lisence Free at http://StigDesign.piczo.com
Latch
18
Years of Service
User Offline
Joined: 23rd Jul 2006
Location:
Posted: 22nd May 2008 05:21
Sorry about that. The distance formula is a way to find the distance between two points. If your camera is located at (100,0,50), and some object is located at (90,50,55), you can use the formula to find the distance between the two.

distance#=sqrt((x2-x1)^2 + (y2-y1)^2 + (z2-z1)^2)
distance#=51.2348

In this case, the camera is our starting position so
x1#=camera position x()
y1#=camera position y()
z1#=camera position z()

And our ending position is the object
x2#=object position x(obj)
y2#=object position y(obj)
z2#=object position z(obj)

If we put those values into the equation we can find the distance between them:
distance#=sqrt((x2#-x1#)^2 + (y2#-y1#)^2 + (z2#-z1#)^2)

This gives the exact distance between the camera and the object. This works fine if you need that exact distance, but maybe you just want to find out if the object is farther than a distance you set.

Let's say you want all objects that are 500 units away from the camera to disappear or to be a picture on a plain to speed up processing like has been posted earlier. You don't necessarily need the exact distance so you can optimize the formula a little bit by getting rid of the square root SQRT() and squaring the distance distance#^2 . This has been gone over many times in different threads over the years. Check out:

http://forum.thegamecreators.com/?m=forum_view&t=129017&b=6
http://forum.thegamecreators.com/?m=forum_view&t=106492&b=6
http://forum.thegamecreators.com/?m=forum_view&t=91856&b=6
There are many others. Basically, if you know what distance you want to check for, you can optimize the distance formula like so:



Enjoy your day.
Stig Design Stig Magne
19
Years of Service
User Offline
Joined: 23rd Mar 2006
Location: Norway
Posted: 22nd May 2008 05:24
ok thank you it gives me a idea

Stig Design (Free Games,Sources,Textures,Photo`s)
Lisence Free at http://StigDesign.piczo.com

Login to post a reply

Server time is: 2025-06-05 21:22:36
Your offset time is: 2025-06-05 21:22:36