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.

Newcomers DBPro Corner / Help with Random Light Objects....

Author
Message
Servant Saber
16
Years of Service
User Offline
Joined: 8th Aug 2008
Location:
Posted: 21st Jan 2009 22:13
I'm currently using some pre-made source code for my project, and I'm still learning what it all does, but one thing that I have edited in my program is a rotating Light orb sprite applied to a sphere object.
It rotates around a spining textured sphere in a complete circle on my map.
Now my question is, is there a way to say...add or "spawn" more light orbs on my map, and randomize their floating pattern in a specific area,like lights in a magical forest so to speak?

Heres my code that I believe apply s to my Light Sprites

rem Make Light
load image "Media/Flare.JPG",20
make object plain 20,10,10
texture object 20,20
ghost object on 20
set object light 20,0
vec = make vector4(1)
rem Make Light 2
load image "Media/Flare.JPG",20
make object plain 21,10,10
texture object 21,20
ghost object on 21
set object light 21,0
vec = make vector4(1)


`Move Light LIGHT ROTATION SCRIPT
if KEYSTATE(38)=1 and MoveLight=1 and nopress=0 then MoveLight=0:nopress=1
if KEYSTATE(38)=1 and MoveLight=0 and nopress=0 then MoveLight=1:nopress=1
if MoveLight=0
ang#=wrapvalue(ang#+0.25)
ang2#=wrapvalue(ang2#+-0.25)
position object 20,cos(ang#)*90,cos(ang#)*25,sin(ang#)*90
position object 21,cos(ang2#)*90,cos(ang2#)*25,sin(ang2#)*90
set vector4 1,object position x(20),object position y(20),object position z(20),0
set vector4 1,object position x(21),object position y(21),object position z(21),0
set effect constant vector 1,"LightPosition",1
set effect constant vector 2,"LightPosition",1
endif
point object 20,camera position x(),camera position y(),camera position z()
point object 21,camera position x(),camera position y(),camera position z()

Thanks in advance
Kira Vakaan
15
Years of Service
User Offline
Joined: 1st Dec 2008
Location: MI, United States
Posted: 22nd Jan 2009 08:07
It's funny you should mention lights in a magical forest.. I think I might have just what you're looking for.

A while ago I wrote this little scene with an infinite landscape filled with really tall tree-like columns, thick fog, falling particles, and randomly drifting lighted orbs. It's a bit of an odd scene, but the methods I used to control the orbs might be what you're looking for. I've attached my project.

Basically, I give each orb a target, which is picked at random around the player. After that, I make it slowly turn towards the target while moving forward and bobbing up and down. If the orb get's close to its target, I pick a new target for it around the player.

Anyhoo, I figured the code could help you. Take a look.

Attachments

Login to view attachments
Pillarofire
20
Years of Service
User Offline
Joined: 31st Dec 2003
Location: Good Question, <looks around.>
Posted: 22nd Jan 2009 11:59
@Kira Thats pretty neat. Nice atmosphere. And I like the way you use sin/cos maths to calculate new positions instead of the common, rotate, move, rotate back, method.
Servant Saber
16
Years of Service
User Offline
Joined: 8th Aug 2008
Location:
Posted: 22nd Jan 2009 19:13
All I can say is, perfect.
Kira's forest is almost exactly the scene in my mind when i started this project, although I lacked the ability to simply code it Until Kira came along.
I have yet to see how you coded it, But I'm sure I'll learn alot from your program.
Much Thanks Kira.
Kira Vakaan
15
Years of Service
User Offline
Joined: 1st Dec 2008
Location: MI, United States
Posted: 22nd Jan 2009 23:08
Glad I could help.

I think that scene was in some strange dream I had... weird, but I suppose that's how most of my scenes start.

Feel free to ask if you have any quesitons.
Virtual Nomad
Moderator
18
Years of Service
User Offline
Joined: 14th Dec 2005
Location: SF Bay Area, USA
Posted: 22nd Jan 2009 23:13 Edited at: 22nd Jan 2009 23:16
@kira,

the demo is purdy but i don't know how practical it is given the 60 fps i'm getting (added sync rate 0 at the top (didn't know what the default sync rate is ), same result).

so, i'm curious as to what's keeping the fps down? i didn't study the code thoroughly but i started dropping "counts" variables (orbs, lights, columns, etc...) and the fps remained at 60. did i miss something somewhere? (i'm prepared to be embarassed if it was something obvious )



Virtual Nomad @ California, USA
AMD Phenomâ„¢ X4 9750 Quad-Core @ 2.4 GHz . 8 GB PC2-6400 RAM
ATI Radeon HD 3650 @ 512 MB . Vista Home Premium 64 Bit

Attachments

Login to view attachments
Kira Vakaan
15
Years of Service
User Offline
Joined: 1st Dec 2008
Location: MI, United States
Posted: 22nd Jan 2009 23:52
That'd be the VSync flag on set display mode at the top. Just change the one to a zero and it'll deactivate it.
Virtual Nomad
Moderator
18
Years of Service
User Offline
Joined: 14th Dec 2005
Location: SF Bay Area, USA
Posted: 23rd Jan 2009 00:00
i never use the flags so didn't think to check there. all better now (250-300fps) thanks.

Virtual Nomad @ California, USA
AMD Phenomâ„¢ X4 9750 Quad-Core @ 2.4 GHz . 8 GB PC2-6400 RAM
ATI Radeon HD 3650 @ 512 MB . Vista Home Premium 64 Bit

Login to post a reply

Server time is: 2024-11-25 12:15:08
Your offset time is: 2024-11-25 12:15:08