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
Green Gandalf
VIP Member
19
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 22nd May 2006 15:37
Quote: "Nicholases entry worked for me!"


What concatenation symbol are you using for long commands that need to be split over two or more lines?
Nicholas Thompson
20
Years of Service
User Offline
Joined: 6th Sep 2004
Location: Bognor Regis, UK
Posted: 22nd May 2006 15:59
I'll sort out the concat issue later...

I've also updated the dbp-site.com with the last entries - GG, that was a brilliant archive of entries there!! 11/10 for you! I'd give you a gold star, but there isn't one - so here is an apple for you:

[center]
Cash Curtis II
19
Years of Service
User Offline
Joined: 8th Apr 2005
Location: Corpus Christi Texas
Posted: 22nd May 2006 17:47
It wouldn't work in the DBP editor, but it did compile in Blue IDE.




Come see the WIP!
Green Gandalf
VIP Member
19
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 22nd May 2006 18:13
Yeah, I'm using the DBP editor. I'm used to its quirks therefore I'm reluctant to move. Sign of age I suppose ...

@Nicholas Thompson

Thanks. "Golden Delicious" I suppose (in lieu of gold star).
Nicholas Thompson
20
Years of Service
User Offline
Joined: 6th Sep 2004
Location: Bognor Regis, UK
Posted: 22nd May 2006 18:20
Quote: ""Golden Delicious" I suppose"

*shakes head as inner child dies (again)...*
Dude - that was poor..

[center]
Ric
20
Years of Service
User Offline
Joined: 11th Jul 2004
Location: object position x
Posted: 22nd May 2006 23:49
@Nick: just noticed, I think Daemon won the last challenge, although on your site it shows DDR as the winner. Are you going to add a leaderboard?

Green Gandalf
VIP Member
19
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 23rd May 2006 00:20
@Nick

Ric's right. Daemon was the winner.

Just had a look at your DBP-SITE.COM Great work. All we need now is for someone to do the same for the all the shader threads going on at the moment - and perhaps the modelling challenge as well. Now there's another challenge!
Phaelax
DBPro Master
21
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 23rd May 2006 00:39
I think most ppl have an option in the IDE to change their string concat symbol, '...' by default. In rare cases, like me, no such option is shown in the IDE.

"Using Unix is the computing equivalent of listening only to music by David Cassidy" - Rob Pike
Nicholas Thompson
20
Years of Service
User Offline
Joined: 6th Sep 2004
Location: Bognor Regis, UK
Posted: 23rd May 2006 00:54
Ooopsy!!! Cheers guys.

Ric: I'm working on a leaderboard...

[center]
Darth Vader
19
Years of Service
User Offline
Joined: 10th May 2005
Location: Adelaide SA, I am the only DB user here!
Posted: 23rd May 2006 07:58
Nice site Nic, no wait... Excellent site!!! I love the design! I thing I am going to sign up!
Quote: "11/10 for you! I'd give you a gold star, "


When in Trouble with anything visit here your number one stop for help
McLaine
18
Years of Service
User Offline
Joined: 20th Feb 2006
Location:
Posted: 24th May 2006 20:39 Edited at: 24th May 2006 22:05
Doesn't do a great deal yet, but you can see my approach.

[Updated code snippet below]

oh, and if anyone can sus out why the camera is doing silly things when you click it on and off then do let me know.

To move the camera, use the traditional FPS keys ... W,S,A,D

To turn the camera movement off, simply right click.

Next version will have some spiffy height modifying functions.

It's not my fault!
Green Gandalf
VIP Member
19
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 24th May 2006 21:27
Compiler doesn't like the following at the beginning of your code. There don't seem to be any subroutines with those names.

McLaine
18
Years of Service
User Offline
Joined: 20th Feb 2006
Location:
Posted: 24th May 2006 22:04
Gah, like I said, it's been a while.

I tend to use include files, and forgot to add them into the code snippet.

Here is the complete code.



It's not my fault!
Chris Franklin
19
Years of Service
User Offline
Joined: 2nd Aug 2005
Location: UK
Posted: 24th May 2006 23:56
My entry
Warning Uber long source code


Ric
20
Years of Service
User Offline
Joined: 11th Jul 2004
Location: object position x
Posted: 25th May 2006 00:33
@Mclaine: nice gui - although I didn't see any terrain - just an empty window.

@Chris: Getting the user to input every x, z and height value via the keyboard would take forever - a 100 by 100 matrix would need ten thousand x, y and h values. It would be better if you could figure out how the mouse position could be used to input the values. I think it was CPU who posted a very useful 3dmouse function in the 3d modeller challenge - use Nicks http://www.dbp-site.com to look it up.

Also, you must credit any authors whose code you have borrowed. It's a rule of these challenges, but it's also good etiquette. I think that matrix to mesh function is Lost in Thought's, isn't it? It's a great piece of work - may use it myself.

Chris Franklin
19
Years of Service
User Offline
Joined: 2nd Aug 2005
Location: UK
Posted: 25th May 2006 00:34 Edited at: 25th May 2006 00:37
Yea it is lost in thoughts i spoke to him on msn about it

Thanks LiT

Edit:
Ric this bit here?

do
mx#=mousemovex()
my#=mousemovey()
3dmouse()
sync
loop

McLaine
18
Years of Service
User Offline
Joined: 20th Feb 2006
Location:
Posted: 25th May 2006 01:52 Edited at: 25th May 2006 02:01
Hit the 'NEW' button, it asks for Segments and Segment Size. (Segments is basically your x,z size of the matrix. I test with 50. Segment size is the size of each individual tile, I test with 10.) This will then creat a matrix to be viewed.

Now, hit the 'CAMERA' button, and you will be able to fly around the matrix using mouse and above mentioned keys. Right mouse button exits camera flight mode.

As I said, it doesn't do much, infact that's all it does at the moment. But it will have height manipulation soon.

I'm just working on using an object from a mesh from a memblock at the moment to replace the matrix which was only intended for testing.

Thread was going quiet so I just wanted to post my progress.



It's not my fault!
Segan
19
Years of Service
User Offline
Joined: 28th Aug 2005
Location: Canada
Posted: 25th May 2006 03:10 Edited at: 25th May 2006 03:11
Well, version 1 of my program (well, I guess not much has been done at all... But who cares?)



No editing features yet. I spent my little programming time fine tuning the camera positioning system so it all works now! Use the arrow keys to move around. Shift+arrow keys will rotate camera/raise lower camera, and the scroll wheel on the mouse zooms in and out.

P.S. For those who have IanM's Matrix1Utility.dll, you can check out this code for what my project should look like in a couple of days. Unfortunately, this uses DLL commands, and thus I need to scrap this progress and change to a different system. (Just click the segments to raise/lower them)

Lost in Thought
20
Years of Service
User Offline
Joined: 4th Feb 2004
Location: U.S.A. : Douglas, Georgia
Posted: 25th May 2006 04:55
A good way to do a matrix/terrain editor would be an intersect object to hit the terrain with a mouse. And then you could have multiple brushes to use for raising and lowering. Such as circle, square, or even a single vert location. You can use the vertex manipulation commands to both check and change the verts, which is pretty fast. Maybe one day I'll get caught up enough to do some of these challenges. Even when I leave the forums, I'll try and come back to look at some of these, as they are quite nice alot of times. Great job guys.

I'll try and optimize that matrix to object code as well when I get time. It was rushed and threw together for my matrix to object converter for DBC users turning magic world matrixs into object. that code can be shortened and optimized a great deal I think, as well as simplified.

Nicholas Thompson
20
Years of Service
User Offline
Joined: 6th Sep 2004
Location: Bognor Regis, UK
Posted: 25th May 2006 11:10
My entry uses the mouse to edit the vertices... I use object screen (?) to get the object under the mouse, then I add the pick vector to the camera coords to find where the mouse is "hitting" the object. Then I convert that coord to the coord of the vertex.

[center]
Zotoaster
19
Years of Service
User Offline
Joined: 20th Dec 2004
Location: Scotland
Posted: 25th May 2006 14:47
@Nic

Wouldn't it work if you just used the pick vector?

Nicholas Thompson
20
Years of Service
User Offline
Joined: 6th Sep 2004
Location: Bognor Regis, UK
Posted: 25th May 2006 16:00
Pick Vector is relative to the camera.

[center]
Daemon
18
Years of Service
User Offline
Joined: 16th Dec 2005
Location: Everywhere
Posted: 25th May 2006 17:04 Edited at: 25th May 2006 17:05
I am at school right now and because of homework I haven't had a chance to look at the code yet. I have final exams next week, but by next friday school will be over and it will be a lot easier to look at code.

I did read the posts and I like Lost in Thoughts idea of being able to select a single vertex, circle, or square. And to nick, can't you add the camera position to the pick vector to get the world position?

Sorry I can't look at the code yet.

Insanity is just a state of mind
Nicholas Thompson
20
Years of Service
User Offline
Joined: 6th Sep 2004
Location: Bognor Regis, UK
Posted: 25th May 2006 18:32
@Daemon - you are indeed correct, Camera Coords + Pick Vector = World Coords. Thats how I do the vertex manipulation in my editor.

[center]
Sven B
19
Years of Service
User Offline
Joined: 5th Jan 2005
Location: Belgium
Posted: 25th May 2006 18:50 Edited at: 25th May 2006 18:51
I think i'll give it a go too...



I am VERY glad I got the mouse pointer working.

For the ppl that want to know how:


Short explanation:


It's the programmer's life:
Have a problem, solve the problem, and have a new problem to solve.
Sven B
19
Years of Service
User Offline
Joined: 5th Jan 2005
Location: Belgium
Posted: 25th May 2006 22:51 Edited at: 25th May 2006 22:51
Update:



Right you have the current height indicator. Click on it and drag to change the height (Top-right number is the current height).

Ctrl to disable editing and move the camera. wasd keys for movemend, mouse for rotating.

Click anywhere on the terrain to edit.

It's the programmer's life:
Have a problem, solve the problem, and have a new problem to solve.
Chris Franklin
19
Years of Service
User Offline
Joined: 2nd Aug 2005
Location: UK
Posted: 25th May 2006 23:29
Sven B how can i adapt that 3d mouse function to a matrix?

Daemon
18
Years of Service
User Offline
Joined: 16th Dec 2005
Location: Everywhere
Posted: 26th May 2006 04:29
It looks to me that Sven B is furthest right now. I haven't had a chance to read the code, just look at the program.

That's all I really have time for.

Good night.

Insanity is just a state of mind
Phaelax
DBPro Master
21
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 26th May 2006 06:22 Edited at: 26th May 2006 10:36
Well, I just had a lightning storm while working on a paper and as soon as I clicked save, the power went out. The file saved, but was written completely with blank spaces. (arghhh) Never should've happened anyway, but apparently my UPS no longer works. So I need a small break from school.


convert 3D points into 2D coordinates. I believe the only time you need to recall the view matrix is when you rotate the camera. I doubt anyone here is changing the world and projection matrix in their program.


The point of the code is for anyone who wants to draw a 2D selection box and check which verts (by converting the vertex position into 2D) are inside of it.


I just checked out Sven's entry. Its funny how much of his variables use the same names as mine, even though I hadn't even seen his yet. Great minds think alike

Here's a shot of my cursor molding onto the terrain. I left it un-ghosted to better show it morphing.


"Using Unix is the computing equivalent of listening only to music by David Cassidy" - Rob Pike

Attachments

Login to view attachments
Sven B
19
Years of Service
User Offline
Joined: 5th Jan 2005
Location: Belgium
Posted: 26th May 2006 14:16 Edited at: 26th May 2006 14:19
Quote: "Sven B how can i adapt that 3d mouse function to a matrix?"


You can't . You'll need some kind of raycasting function.

Or something like this:



But you can imagine that this is pretty inaccurate + sometimes pretty slow...

It's the programmer's life:
Have a problem, solve the problem, and have a new problem to solve.
Nicholas Thompson
20
Years of Service
User Offline
Joined: 6th Sep 2004
Location: Bognor Regis, UK
Posted: 26th May 2006 14:34
That is a nasty and slow method - but like you say, the only real way to do that with a matrix... hence nobody using matrices anymore!

[center]
Phaelax
DBPro Master
21
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 26th May 2006 15:11
This only gets the points on a flat plane so you cant really use it to get an exact point on the bumpy matrix, only a flat one. I'm sure somewhere in this code you can extract the casted ray and then just perform some ray/plane intersection for each segment of the matrix. Then it'd work perfectly.




"Using Unix is the computing equivalent of listening only to music by David Cassidy" - Rob Pike
Sven B
19
Years of Service
User Offline
Joined: 5th Jan 2005
Location: Belgium
Posted: 26th May 2006 19:51 Edited at: 26th May 2006 20:01
Update... again



Same controls

Added:
- press t to turn the tile:

(only works in 4 point tool)

- press w to toggle wireframe on/off
- press g to toggle ghost on/off
--> shortkeys only work in edit mode.
- Tool button: Fill terrain and randomize terrain.
- 2 tools for editing. 1 point and 4 point mode.
- A little adjustement to see the cursor points better. Instead of big piles sticking out of the ground...



@phaelax
Quote: "I just checked out Sven's entry. Its funny how much of his variables use the same names as mine, even though I hadn't even seen his yet. Great minds think alike"


[think]Great minds think alike[/think]

It's the programmer's life:
Have a problem, solve the problem, and have a new problem to solve.
Phaelax
DBPro Master
21
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 26th May 2006 21:53 Edited at: 26th May 2006 21:54
"memblock error at 659"
I got that twice while editing.

I still haven't figured out what you mean by "turn the tile".

"Using Unix is the computing equivalent of listening only to music by David Cassidy" - Rob Pike
Sven B
19
Years of Service
User Offline
Joined: 5th Jan 2005
Location: Belgium
Posted: 26th May 2006 23:21 Edited at: 26th May 2006 23:27
The forum editor doesn't support backslash.

By turning a tile, i meant this:


Quote: ""memblock error at 659"
I got that twice while editing."


Thx for saying. Let the tweaking begin!

[edit]
I found one bug. But it doesn't give the same error...



If the error still occurs, could you specify it a bit please?

It's the programmer's life:
Have a problem, solve the problem, and have a new problem to solve.
Phaelax
DBPro Master
21
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 27th May 2006 10:15
I cant seem to cause it anymore. I think it threw the error when I tried editing and dragged the mouse off the matrix in certain spots, I can't quite remember.

I know I said I wasn't going to enter this, but I couldn't resist playing around with it. So here's my current entry. I still have yet to get normals properly.



"Using Unix is the computing equivalent of listening only to music by David Cassidy" - Rob Pike
Sven B
19
Years of Service
User Offline
Joined: 5th Jan 2005
Location: Belgium
Posted: 27th May 2006 13:04
Quote: "I cant seem to cause it anymore. I think it threw the error when I tried editing and dragged the mouse off the matrix in certain spots, I can't quite remember."


The bug I found, was an error by just clicking outside the matrix. But it just didn't give the same error.
Solved by just being able to edit, if the cursor is pointing to a world. (var WorldCursor)

Very interesting normals you have there by the way.

It's the programmer's life:
Have a problem, solve the problem, and have a new problem to solve.
Phaelax
DBPro Master
21
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 28th May 2006 22:37
I been looking at other ways to create randomized terrain. Came across particle deposition.
http://www.lighthouse3d.com/opengl/terrain/index.php3?particle

I keep the edges of the matrix clamped down to prevent any "floating" edges from showing above the water level.
I went with the tutorial's simpler method, "sticking".


"Using Unix is the computing equivalent of listening only to music by David Cassidy" - Rob Pike
Daemon
18
Years of Service
User Offline
Joined: 16th Dec 2005
Location: Everywhere
Posted: 28th May 2006 23:05 Edited at: 28th May 2006 23:05
The top runners seem to be Phaelax and Sven B.

@Phaelax - Why is there a diagnal line of brightness which forms across the terrain when I click? Also, is there a way the camera could rotate around so that parts aren't hiddent by mountains when someone is editing a terrain.

@Sven B - I like the tools you have added. I got the error 7001, object does not exist at 659. I got this error when changing the height on the bar at the right after filling map 1 to a height of 0. Another thing is that I think you should add a smooting type of tool which would be especially useful for after randomizing to make a more hilly landscape.

Keep it up.

Insanity is just a state of mind
Green Gandalf
VIP Member
19
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 28th May 2006 23:14
@Phaelax and co

Could you please post the whole of your latest version of your program entry, rather than your latest version of your favourite function? It's not always clear what your posted code is meant to be. (I'm trying to keep an archive which our mutual friend Nicholas Thompson might find useful when the challenge is over.)

I'm sorely tempted to enter this challenge - but other things keep getting in the way.
Nicholas Thompson
20
Years of Service
User Offline
Joined: 6th Sep 2004
Location: Bognor Regis, UK
Posted: 29th May 2006 00:18
hehe, might!

[center]
Phaelax
DBPro Master
21
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 29th May 2006 09:36
I think its quite clear which code snippet is an entry and which one is just a simple function.

"Using Unix is the computing equivalent of listening only to music by David Cassidy" - Rob Pike
Green Gandalf
VIP Member
19
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 29th May 2006 12:55
@Phaelax

I agree it is obvious whether the snippet is a full entry or just a simple function. What is NOT obvious, however, without carefully studying your earlier entries, is whether the snippet is meant to be an updated/corrected version of your earlier entry, or whether it is just a contribution to the general discussion. Unless you make that clear when you post, Nicholas Thompson's much appreciated archive of challenge entries is likely to end up with out-of-date, misleading or even irrelevant material. I'm sure you don't want that to happen.

It's not a big deal - I just think it would help everyone, that's all.
Sven B
19
Years of Service
User Offline
Joined: 5th Jan 2005
Location: Belgium
Posted: 29th May 2006 22:30
New update soon.

Quote: "I think you should add a smooting type of tool which would be especially useful for after randomizing to make a more hilly landscape"


I'll put it under "Tools"

I have added export for now, and some bug fixes. I can't seem to cause any reported bugs posted by you guys...

If I have enough time, I might add textures and adding worlds...

It's the programmer's life:
Have a problem, solve the problem, and have a new problem to solve.
McLaine
18
Years of Service
User Offline
Joined: 20th Feb 2006
Location:
Posted: 30th May 2006 05:29 Edited at: 30th May 2006 05:31
Ok folks,

here's my effort.



It's now got some functionality.



I'll be unlocking the save and load functionality soon, but while there's still time I'm going to try and get normalising, smoothing, and the different raising functions operating.

Feedback is welcome

It's not my fault!

Attachments

Login to view attachments
Phaelax
DBPro Master
21
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 30th May 2006 09:14
the particle deposition post was just a bit of info for the last challenge about the islands. (i forgot to mention that part) If I ever post any updates to an entry I always post a complete entry. I dont expect anyone to load up an old entry of mine then find out where to change a single updated function at.

McLain, interesting tile textures. For a second I thought I was looking at some kinda voxel demo.

"Using Unix is the computing equivalent of listening only to music by David Cassidy" - Rob Pike
Green Gandalf
VIP Member
19
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 30th May 2006 11:17
@Phaelax
Thanks for the explanation.

@McLaine

Tried your entry - but couldn't get it to work properly. In the Mold view, the cursor was in a different place from the mouse so I couldn't tell which part of the terrain was being changed (and none of the clicks seemed to change anything anyway). Tried to take a photo of the screen (so you could see the mouse as well as the cursor) - but my batteries were flat! Will try again later.
McLaine
18
Years of Service
User Offline
Joined: 20th Feb 2006
Location:
Posted: 30th May 2006 17:32 Edited at: 30th May 2006 17:48
@GreenGandalf

Yeah man, I haven't quite nailed the cursor to mouse thing yet. Am working on it. At the mo, the mouse and cursor will be in the same position only at the centre of the viewport. The cursor tends to move from there disproportionately to the mouse.

Currently, you can ...

Change your brush size and magnitude
Raise and lower the terrain under the brush

The buttons for Brush Shape, and Brush Type (Hill, Mound, Peak, Plateau) are not functional at the moment. And given the results I can get with a basic brush I may discard them as unecessary.

I'm currently working on getting the brush to fit to the terrain underneath so that it no longer dissapears underneath raised terrain. This problem can be alleviated a little by working in wire mode (Click the 'Solid' button so that it is off)

It's not my fault!
Ric
20
Years of Service
User Offline
Joined: 11th Jul 2004
Location: object position x
Posted: 30th May 2006 19:16
Looking good McLaine. Impressive looking GUI.

May get a bit of computer time tomorrow to have a go at this challenge.

Sven B
19
Years of Service
User Offline
Joined: 5th Jan 2005
Location: Belgium
Posted: 30th May 2006 20:43
Quote: "Impressive looking GUI"


I second that

It's the programmer's life:
Have a problem, solve the problem, and have a new problem to solve.

Login to post a reply

Server time is: 2024-11-25 00:35:09
Your offset time is: 2024-11-25 00:35:09