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 / - DBPro Coding Challenges -

Author
Message
RiiDii
19
Years of Service
User Offline
Joined: 20th Jan 2005
Location: Inatincan
Posted: 1st Sep 2005 08:37 Edited at: 1st Sep 2005 08:39
Okay. Here's my stab at a fractal tree. I used a wierd 4-poly thingy object as the branch to save on total poly-counts, which makes the tree little Nightmare Before Christmas-ishy looking. Overall, I give the tree a 6. But this is my first recursive function!! Woohoo! Okay - Imanerd for getting excited over such things.

Un-rem the Sync command around line 39 to watch the tree being made. On my slow pc at work, it was like watching grass grow, so I remmed it out.

Enjoy




Open MMORPG: It's your game!
Nicholas Thompson
20
Years of Service
User Offline
Joined: 6th Sep 2004
Location: Bognor Regis, UK
Posted: 1st Sep 2005 10:56
any chance that could be compiled and attached? I keep forgetting to bring DBP into work and I'd like to see what my work PC can make of it (P4 2.8Ghz, 1gb DDR, Intel *shudder* GFX)

My Website:
RiiDii
19
Years of Service
User Offline
Joined: 20th Jan 2005
Location: Inatincan
Posted: 1st Sep 2005 20:37
Here you go Nicholas.


Open MMORPG: It's your game!

Attachments

Login to view attachments
Ric
20
Years of Service
User Offline
Joined: 11th Jul 2004
Location: object position x
Posted: 1st Sep 2005 20:41
Nice work Rii. Hmmm.... think I better start attempt number 2.....

RiiDii
19
Years of Service
User Offline
Joined: 20th Jan 2005
Location: Inatincan
Posted: 1st Sep 2005 21:07
And here are some leaves...



With a .exe attachment...


Open MMORPG: It's your game!

Attachments

Login to view attachments
Ric
20
Years of Service
User Offline
Joined: 11th Jul 2004
Location: object position x
Posted: 2nd Sep 2005 03:20 Edited at: 2nd Sep 2005 03:24
Still working on my tree code, but here's a screenshot so far:-



It's animated too, so it has a kind of 'blowing in the wind' effect, and it's fully 3-d, so you could walk around it.
Still based around my swirling mist concept, (I'm not one to give up on what seemed like a lost cause!), but now uses fractalian mathematics for the foliage generation. Not sure it actually helps that much, but it was fun coding it - I love fractals!

Code to follow.

Attachments

Login to view attachments
Ric
20
Years of Service
User Offline
Joined: 11th Jul 2004
Location: object position x
Posted: 2nd Sep 2005 04:33 Edited at: 2nd Sep 2005 04:35
Well, I've ditched the fractal generator from my code, because I realised it wasn't any better than some random green dots when it came to the final tree, although it took about a million times longer to generate. But, in the interests of sharing, this was it:



<edit> the look of the tree has changed a bit now, as you can see:



(recognise that landscape?!)

Attachments

Login to view attachments
Ric
20
Years of Service
User Offline
Joined: 11th Jul 2004
Location: object position x
Posted: 2nd Sep 2005 04:53 Edited at: 2nd Sep 2005 04:54
And gradually, it's getting a little bit more tree-like!



Attachments

Login to view attachments
Ric
20
Years of Service
User Offline
Joined: 11th Jul 2004
Location: object position x
Posted: 2nd Sep 2005 05:10 Edited at: 2nd Sep 2005 05:29
OK, here's my code. Sorry for the quadruple post, I got caried away with the screenshots!

Each time you run the code you will get a different tree - and of course, a different landscape. The tree varies in it's 'bushiness' (ie. number of branches) and it's roundness - they're just random. Notice that the branches don't just move in the wind, they actually bend into smooth curves one way and then another . Quite pleased with that!



I didn't remark the tree creation code, but here's a brief explanation of how I did it:

Rather than making solid branches coming from the trunk, the tree is made from multiple concentric spheres (like onion layers). Each sphere has the same transparent texture, made up of some random green dots. These dots have the appearance of extending out from the smallest inner sphere to the largest, outer sphere, to form branches. Then, to get the branches to curve one way or another, the outer spheres need to be rotated back and forth slightly more than the inner spheres - in fact, the further out, the bigger the rotation. I don't know if this method has been done before - I expect not because there must be millions of polygons on the one tree - but then, I thought it would be more interesting to go a non-conventional route!



Attachments

Login to view attachments
Tinkergirl
21
Years of Service
User Offline
Joined: 1st Jul 2003
Location: United Kingdom
Posted: 2nd Sep 2005 05:22
Looking good Ric! Without being able to run DB at work, I can't see them in action yet, but so far I've liked the 'misty' one the best from your three. However, I'd like to see them all moving - I look forward to getting home to run some of these!

So so far, there seems to be three contenders for the tree - I wonder if we'll have any later entries?

Great stuff so far from everyone!
Nicholas Thompson
20
Years of Service
User Offline
Joined: 6th Sep 2004
Location: Bognor Regis, UK
Posted: 2nd Sep 2005 11:22
Hopefully you will - time permitting

My Website:
RiiDii
19
Years of Service
User Offline
Joined: 20th Jan 2005
Location: Inatincan
Posted: 2nd Sep 2005 19:09
That is a very creative route to go, and the effect is as if you have a 100 or so flexible fronds all waiving. While that may be a high polycount, I'll bet it would be much more if you tried to make each frond. And then try to handle the "waiving in the wind" with individual fronds - no way. 1000 points for being clever (-900 for reusing the terrain code? ).

Seriously - great effect Ric! I can see lots of uses for that technique.


Open MMORPG: It's your game!
CPU
21
Years of Service
User Offline
Joined: 4th Jul 2003
Location: Carlsbad, CA
Posted: 2nd Sep 2005 23:30 Edited at: 2nd Sep 2005 23:33
Ok here's my go at a tree... Fractal generated, kinda Lengthy code, and most of the constants at the top can be tweaked for, ah... shall I say... interesting effect...

Saddly I didn't have time to input animation and other such things as I'm leaving for the weekend and just managed to finish the texture generation and rain as an added feature just a little bit ago.

da codz:



A few explination of the constants:



so, enjoy, and I look forward to seing tinkergirl decide between all these good entries...


Happy Codding!!
CPU

edit
Thought I'd mention that the tree has a "progressive" mesh, the first and biggest trunks has the most polys, while each consecutive one drops two polys per layer (since there cylinders) untill the last smallest branch which is a cone, and has only 4 polys. Just thought I'd mention it in case it matters to anyone, the memblock stuff in there has got to be usefull to someone, even if its only me...

[center]K-OS Battlefields
IS
///---///---///---UNDER CONSTRUCTION---\\\---\\\---\\\
[center]
Ric
20
Years of Service
User Offline
Joined: 11th Jul 2004
Location: object position x
Posted: 2nd Sep 2005 23:30 Edited at: 2nd Sep 2005 23:32
Quote: "I can see lots of uses for that technique.
"


.... yes, I'm thinking hair - especially since modifying the code to enable the fronds (great word!) to 'hang down' more:



Update: - Added the ability to regenerate the tree (almost instantly) by pressing the spacebar.

Now included the following random variables:

Bushiness
Droopiness
Roundness
Redness
Fuzziness
Height

Keep regenerating until you find your favourite and post a screeny!



Attachments

Login to view attachments
Ric
20
Years of Service
User Offline
Joined: 11th Jul 2004
Location: object position x
Posted: 2nd Sep 2005 23:39
@CPU - Wow, that's really good. Love the bark texture, as it looks incredibly realistic. Nice rain, too! I took the liberty of reposting your code, as, unless it's only me, some of the commands were incomplete:



Tinkergirl
21
Years of Service
User Offline
Joined: 1st Jul 2003
Location: United Kingdom
Posted: 2nd Sep 2005 23:57
Darn it! You're all going to make this difficult for me, aren't you...
Ric
20
Years of Service
User Offline
Joined: 11th Jul 2004
Location: object position x
Posted: 3rd Sep 2005 03:23 Edited at: 3rd Sep 2005 03:23
<Small Update>

Realised the 'fuzziness' variable wasn't actually working - now fixed, so you can get some more natural (imho) looking trees:



Also added another variable - 'density', which isn't the number of branches (bushiness), but the distance between them. Also increased the range of bushiness, so it's now possible to have 40,000 branches on the tree - and because it's all done within the texturing, 40,000 branches are no more polygons than 3 branches. The potential for simulating hair is looking even better. Also modified the range of droopiness, to avoid overly droopy trees.



Attachments

Login to view attachments
Tinkergirl
21
Years of Service
User Offline
Joined: 1st Jul 2003
Location: United Kingdom
Posted: 3rd Sep 2005 03:55
And, if you were so inclined, you could put lots of flat plains on the ground using a similar technique and have grass.

Good job, Ric. Doing well.
RiiDii
19
Years of Service
User Offline
Joined: 20th Jan 2005
Location: Inatincan
Posted: 3rd Sep 2005 04:33 Edited at: 3rd Sep 2005 04:35
Quote: "And, if you were so inclined, you could put lots of flat plains on the ground using a similar technique and have grass. "


I was, and I did.

Anyway, it's a wip, so be gentle.



Great minds think alike?


Open MMORPG: It's your game!
Ric
20
Years of Service
User Offline
Joined: 11th Jul 2004
Location: object position x
Posted: 3rd Sep 2005 16:44 Edited at: 3rd Sep 2005 18:50
Good thinking.

Something funny going on where the blades overlap in the distance - I don't think it's clipping - more some kind of interference effect.

<uptdate>

Managed to optimize my tree code to cut the poly count from about 20,000 polys to about 1,000 polys without any disasterous looses in treelikeness. Going to have an attempt at a small forest now ....

Ric
20
Years of Service
User Offline
Joined: 11th Jul 2004
Location: object position x
Posted: 3rd Sep 2005 21:30 Edited at: 3rd Sep 2005 21:31
Woah - didn't honestly think this would be possible. Just reoptimised the code and tested with 150 unique trees, and still had just enough frames per second to play with (on my ancient GF2!).
All the trees blow in the wind in theory, although I had to disable that with anything above 50 or so trees on my pc.



Attachments

Login to view attachments
Ric
20
Years of Service
User Offline
Joined: 11th Jul 2004
Location: object position x
Posted: 3rd Sep 2005 22:00 Edited at: 3rd Sep 2005 22:01
Eek! Re-re-optimised, and got 200 trees working - it's almost a forest!



Attachments

Login to view attachments
Phaelax
DBPro Master
21
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 3rd Sep 2005 22:40
Ric is really on this challenge, looking nice. Good to see the fps went up in the second shot, 7 wasn't a very pretty number.

Your signature has been erased by a mod because it's larger than 600x120...
Tinkergirl
21
Years of Service
User Offline
Joined: 1st Jul 2003
Location: United Kingdom
Posted: 3rd Sep 2005 23:33 Edited at: 3rd Sep 2005 23:35
Wow Ric - doing amazing there. The whole forest thing is most impressive!

And only one and a half days to go in the challenge.
RiiDii
19
Years of Service
User Offline
Joined: 20th Jan 2005
Location: Inatincan
Posted: 4th Sep 2005 03:06
Here's some better grass.




Open MMORPG: It's your game!
Ric
20
Years of Service
User Offline
Joined: 11th Jul 2004
Location: object position x
Posted: 4th Sep 2005 03:32 Edited at: 4th Sep 2005 03:53
Thanks for the comments - here's the code. I've adjusted the settings to give you twenty trees (with animation on) at a fair quality, and should allow for a reasonable frame rate on most pc's.



This'll be the final update here - if I do take this further, like adding media, load/save options, and giving control of the variables to the user, then I'll update my progress in the WIP forum.

<edit> Looking better Rii. Like the tapering effect of the blades of grass you get by shrinking the planes as they get higher. Unfortunately my ageing pc struggles when the whole thing is in view - down to 3 fps. Although the poly count can't be much at all, I guess it's a large portion of the screen that needs rendering, plus the image is quite large. How did you get rid of the interference pattern - or did it just go by itself?

Tinkergirl
21
Years of Service
User Offline
Joined: 1st Jul 2003
Location: United Kingdom
Posted: 4th Sep 2005 08:11 Edited at: 4th Sep 2005 08:13
Ric: Nice. Very nice indeed. 20 trees ran at a not-horrendous 32fps on this little laptop, and 50 trees brought it down to 25fps in the worst case. Very nicely done, though I think some of your trees come out better than others Such is randomness.

RiiDii: Much better grass, Rics right - the tapering is much better. I'm getting the feeling that it's more trouble than it's worth, however (or more frametime). It's an interesting effect and modification of Ric's trees though! (But not a tree itself )
I don't think I mentioned, and I should have, that I really liked your spheres of foliage for your tree. Reduced the 'Nightmare'ness quite significantly and gave it a bit more of a cartoony feel, which was nice. Maybe two 'layers' of green on it would help a little? Just an idea.
Tinkergirl
21
Years of Service
User Offline
Joined: 1st Jul 2003
Location: United Kingdom
Posted: 5th Sep 2005 21:45
15 minutes to go
Nicholas Thompson
20
Years of Service
User Offline
Joined: 6th Sep 2004
Location: Bognor Regis, UK
Posted: 5th Sep 2005 23:34
she says 1 hour and 50 minutes ago hehe

I'm upset I never got a chance to do this.. I've always been fascinated by fractals and some real gems have come out in this. Rics return to the challenges is VERY impressive!! I love those tree's!! It may have taken my 2.5Ghz machine about 3-4 minutes to generate them but it was certainly worth it!

My Website:
Tinkergirl
21
Years of Service
User Offline
Joined: 1st Jul 2003
Location: United Kingdom
Posted: 5th Sep 2005 23:52 Edited at: 6th Sep 2005 01:11
Tree Challenge Results!

[edit]Retracted quickly because I was a numpty and missed an important entry. Sorry - verdict and more apologies due in approx 7hrs when I can get home from work and look at it properly.

SO SORRY!
Tinkergirl
21
Years of Service
User Offline
Joined: 1st Jul 2003
Location: United Kingdom
Posted: 5th Sep 2005 23:53
I was having lunch! A girls gotta eat, doesn't she?
RiiDii
19
Years of Service
User Offline
Joined: 20th Jan 2005
Location: Inatincan
Posted: 6th Sep 2005 00:54
Hey TG, did you miss CPU's entry (about 19-20 posts back)?


Open MMORPG: It's your game!
Tinkergirl
21
Years of Service
User Offline
Joined: 1st Jul 2003
Location: United Kingdom
Posted: 6th Sep 2005 01:09
Oh NO!! Oh my mince! Knickers!

I am SO sorry!

I completely missed that entry, amongst all the Ric pictures! I'm so so sorry everyone. I'm going to have to retract my verdict until I can look at CPU's entry.

I'm really sorry! (Thanks RiiDii!)
Nicholas Thompson
20
Years of Service
User Offline
Joined: 6th Sep 2004
Location: Bognor Regis, UK
Posted: 6th Sep 2005 01:11
hehe poop happens (I'd prefer to say the proper phrase, but I dont wanna get noob slaped for swearing )

My Website:
CPU
21
Years of Service
User Offline
Joined: 4th Jul 2003
Location: Carlsbad, CA
Posted: 6th Sep 2005 01:20 Edited at: 6th Sep 2005 01:39
wow, I must be the invisible man... saddly, I didn't have time to optamize and add aditional stuff during the weekend, I just got back from a short labor day weekend up in WI only to find about two retractions from the final vote...

Good luck tinkergirl, glad we gave you a chalange in return to your own and whatever happens, good job everyone!

CPU

[edit]

Sorry to do this but after toying with the rain a bit it looks a LOT better if you replace the functions in the code with the two below, it makes the rain look a lot less, in-your-face type of feeling...



and since its after the deadline its more just for people wanting to duplicate the rain effect so as to make it better, in the spirit of the competition it shouldn't count toward the final opinion.

[center]K-OS Battlefields
IS
///---///---///---UNDER CONSTRUCTION---\\\---\\\---\\\
[center]
Ric
20
Years of Service
User Offline
Joined: 11th Jul 2004
Location: object position x
Posted: 6th Sep 2005 01:26
Quote: "It may have taken my 2.5Ghz machine about 3-4 minutes to generate them"


Wow - really? How many trees? My 1.8 GHz machine doesn't take that long I don't think - but I'll have a look at optimizing the texture creation routine if I take the program any further.

Phaelax
DBPro Master
21
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 6th Sep 2005 02:53
my P2.8e took less than 20 seconds to render Ric's whole scene. I got a constant 45fps.

Your signature has been erased by a mod because it's larger than 600x120...
xCept
21
Years of Service
User Offline
Joined: 15th Dec 2002
Location:
Posted: 6th Sep 2005 04:01 Edited at: 6th Sep 2005 04:03
Is anyone else having trouble running CPU's entry or am I the only one? The code CPU posted generated several errors and couldn't run, and the code Ric re-posted for CPU gave me a "Command out of place at line 262" error. Line 262 is:

"DrawLimbedLeaf(obj, limb, RndBchPos, RndBchDir, 6, 3)"

Ric, your demo took about 11 seconds to generate the scene with 20 trees and gave me a constant 32 FPS (P2.4, 512MB DDR Ram, ATI Radeon 9800 Pro), very cool too!

P.S., Using DBPro 1.058 and default GUI
Tinkergirl
21
Years of Service
User Offline
Joined: 1st Jul 2003
Location: United Kingdom
Posted: 6th Sep 2005 08:57
Alas!

I also find that CPU's code won't compile

There's a typo of 'syn' for 'sync', then 'il' for 'if' and then it has trouble with some loop - I wasn't able to correct that one (I know, I suck) otherwise I'd have loved to have run it.

CPU, if you're around and have time, can you fix it soon? I'd like to give the (proper) results by about 9AM California (5PM GMT) before I go to work (I can't run DB at work).

It would be a terrible shame if because I didn't notice your post in the flood, that no-one spotted your typos and you didn't get a chance to fix them.
Nicholas Thompson
20
Years of Service
User Offline
Joined: 6th Sep 2004
Location: Bognor Regis, UK
Posted: 6th Sep 2005 10:50
Ric fixed CPU's code about 2-3 posts down from CPU's entry as I recall..

I'll try Rics code again tonight to see how long it takes.. Maybe I was just impatient and counting 3 to 4 times faster than I should have been

My Website:
Tinkergirl
21
Years of Service
User Offline
Joined: 1st Jul 2003
Location: United Kingdom
Posted: 6th Sep 2005 10:56
I still get a 'Command out of place at line 262', and it highlights the endif on 263.
I can't figure out why that would be the case, unless I need to have my DB super-updated. I've not done so since I bought it, it's as it was downloaded.
Nicholas Thompson
20
Years of Service
User Offline
Joined: 6th Sep 2004
Location: Bognor Regis, UK
Posted: 6th Sep 2005 11:10
You might want to look into getting 5.8 and the latest IDE update - it does make a difference...

I recall using Rics corrected version and it worked fine, but the problems you speak of sound like the ones I experience when I used CPU's origional code...

My Website:
Ric
20
Years of Service
User Offline
Joined: 11th Jul 2004
Location: object position x
Posted: 6th Sep 2005 13:39
The 'endif out of place' error is a bug I've come across several times before when trying to compile code with un-updated software. I'm at work atm, but can anyone compile an exe of cpu's code for TG to look at?

CPU
21
Years of Service
User Offline
Joined: 4th Jul 2003
Location: Carlsbad, CA
Posted: 6th Sep 2005 17:52
Ok, don't know why its not posting right but, I'll post the code in the code box, and I'll post a zipped exe in the next post.

CPU

[center]K-OS Battlefields
IS
///---///---///---UNDER CONSTRUCTION---\\\---\\\---\\\
[center]
Ric
20
Years of Service
User Offline
Joined: 11th Jul 2004
Location: object position x
Posted: 6th Sep 2005 18:54
Done it for you CPU - I've stuck it on my server temporarily:

http://www.sector-1.net/misc/tree.zip

CPU
21
Years of Service
User Offline
Joined: 4th Jul 2003
Location: Carlsbad, CA
Posted: 6th Sep 2005 19:02 Edited at: 6th Sep 2005 19:05
thanks ric,
I've been having trouble uploading it... (4 meg file over dial up is ahh... painfull...)

CPU

edit

Tinkergirl - It might be good to just download the last patch, that should fix any problems other than the ones I'm having where half of the sync is disapearing along with the first part of the untill statements and all that good stuff...

[center]K-OS Battlefields
IS
///---///---///---UNDER CONSTRUCTION---\\\---\\\---\\\
[center]
Tinkergirl
21
Years of Service
User Offline
Joined: 1st Jul 2003
Location: United Kingdom
Posted: 6th Sep 2005 19:40


A thousand apologies for being such a dunce. CPU thanks for being patient with me, Ric thanks for posting that .exe.

In fourth place - FDC! Well done, FDC, I really liked what you'd done for your palmtree. The fact that you had modifiable wind and waves counted in your favour. The only thing that let you down was the fact that it was just a trunk. With leaves it could have been much better.

In third is RiiDii! Loved your 'Nightmare Before Christmas' tree - and pleased that you did your first recursive function (nerd ). Good to see you try to save a few polys with clever crosssections - you were just outfeatured by the other guys. With the leaves, however, you created a graphical style all your own - twisted cartoony.

In second place.... darn this was hard... Ric. Ric, I know you were put top of the pile before, and I hope you don't see this as punishment for your good deed. Your trees were excellent - you went at it in a whole new way that no-one expected, optimised it to within an inch of its life and had whole groves of trees populating the wondeful Blue Island. You know how good your trees are - but they are a little fluffy

So in first place, and not through guilt - CPU. Your tree was treelike. Your rain, while nice, wasn't counted in the final verdict - but your no-media textures, your individual leaves and the accurate tapering of the branches was. I am very sorry I didn't see this before - if only so I could have started learning from it sooner Very well done, CPU - an excellent tree, though I'm sure a hit to any system

*steps down gladly and lets him take the floor*
Phaelax
DBPro Master
21
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 6th Sep 2005 20:41
Quote: "A thousand apologies for being such a dunce. "

Its not you, I couldn't run CPU's code either. I tried to fix it, but it was missing countless commands. So many loops were left open, I don't know how he was even running it.

Your signature has been erased by a mod because it's larger than 600x120...
Ric
20
Years of Service
User Offline
Joined: 11th Jul 2004
Location: object position x
Posted: 7th Sep 2005 14:10
Well done CPU, and good work TG on the reviews - we might let you win another one. It was a good challenge for me because it made me think laterally, and explore an area I never would have bothered with otherwise.

Hope you know your responsibilities now, CPU?

Nicholas Thompson
20
Years of Service
User Offline
Joined: 6th Sep 2004
Location: Bognor Regis, UK
Posted: 7th Sep 2005 14:56
I really would have liked to get in on that one.. Oh well - CPU, lets make the next one even more fun! (no pressure whatsoever.. I know exactly how damned hard it is to pick a topic )

Ric.. You still got that table of idea's you made ages ago?

At some point, I wanna finish that section of my site for these challenges.. Its just that by the time I get home from work I'm all PHP and MySQL-ed out (Its my job too.. From 9am to 5:30pm, I'm a PHP and MySQL Webmaster... ))

My Website:

Login to post a reply

Server time is: 2024-11-23 12:47:30
Your offset time is: 2024-11-23 12:47:30