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 Professional Discussion / Hiding Object When It's behind Specific Object

Author
Message
puppysss
19
Years of Service
User Offline
Joined: 13th Mar 2007
Location: UnCyber Space
Posted: 17th Nov 2009 17:33
I'm Crazy for This Problem.
My Way is that check collision when moving to specific object bump specific object.

I know in 3D Objects,they have BackBuffer Data for order rendering.
So I wanted that if object was behind something,then it was hidden.
But I feel hard.

How way is it for that?

[I uploaded my w.i.p source]

DEFCON CRISIS comming soon 2009~~!
baxslash
Valued Member
Bronze Codemaster
19
Years of Service
User Offline
Joined: 26th Dec 2006
Location: Duffield
Posted: 20th Nov 2009 14:10 Edited at: 20th Nov 2009 14:13
OK, from a quick look at your source code (and a run of your program) I'm guessing you need to use ray casting but slightly different to how you are using it at the moment.

You ray cast from the camera position to the object position and if the object is not the first thing the ray hits then it is not in view.

This is only really 100% relevant for your lens flare idea, other parts of the object might still be visible to the camera. As you are trying to show the lens flare only when the sun/light source is visible this is probably good enough for what you want to achieve.

There are ray cast commands in DBP but I would suggest using Sparky's collision for Ray Casting (found here):
http://forum.thegamecreators.com/?m=forum_view&t=74762&b=5

The command is more or less:


objNum is the object you are searching for a collision with (or zero for all objects)
returned integer is either 1 for collision or 0 for no collision, if you used zero then it will provide the object number of the first object it collided with.

my suggestion is to add something like this in your code to check if the sun is in sight:


Then if visible returns as 1 you position your lens flare object a set distance between the camera and the SunObject, point it at the camera then apply some kind of offset based on how far from the centre of the screen the SunObject is.

I hope this helps!

EDIT: Another way might be to use a sprite as the lens flare and place it based on the position of the sun object.
baxslash
Valued Member
Bronze Codemaster
19
Years of Service
User Offline
Joined: 26th Dec 2006
Location: Duffield
Posted: 20th Nov 2009 15:00
Attached is a fudge on your work.
It's just a quick example but it might help get you going.

Anyway I added a GOSUB routine for the lens flare using sprites (which I made really quickly).

I know it's not great but I hope it helps!
baxslash
Valued Member
Bronze Codemaster
19
Years of Service
User Offline
Joined: 26th Dec 2006
Location: Duffield
Posted: 20th Nov 2009 15:35
Edited this slightly and added some more/better media...

puppysss
19
Years of Service
User Offline
Joined: 13th Mar 2007
Location: UnCyber Space
Posted: 21st Nov 2009 15:13
Wow!! Very Nice!
Good job! Thank you So Much!!

p.s.
Thank for your helps!
I adding your sample and sc functions to FPSC!
But I have some problems.
It's that After finished Sc_SetupObject to world,
when some objects deleted,then laggy & error.


DEFCON CRISIS comming soon 2009~~!
puppysss
19
Years of Service
User Offline
Joined: 13th Mar 2007
Location: UnCyber Space
Posted: 22nd Nov 2009 09:24
YEAH!! I Solve It with DBPro Stock Commands use Ray Beam Collision !! Thank you!!!


DEFCON CRISIS comming soon 2009~~!
baxslash
Valued Member
Bronze Codemaster
19
Years of Service
User Offline
Joined: 26th Dec 2006
Location: Duffield
Posted: 23rd Nov 2009 09:43
Glad to help!

Login to post a reply

Server time is: 2026-06-11 13:32:49
Your offset time is: 2026-06-11 13:32:49