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 / object-limb collision

Author
Message
shadey
16
Years of Service
User Offline
Joined: 25th Jan 2010
Location:
Posted: 22nd Jun 2013 21:27 Edited at: 22nd Jun 2013 21:32
I am trying to write my own 3d level editor using a limb based approach,so i can save the whole model out as well a other eventual info... but the main problem is not being able to position a limb where one already exists, I have this code so far:



I have tried a for next loop to see if the cursor objects position is equal to an existing limbs position, if so i set the variable c to 1 but only able to place a limb if it is equal to 0, but it doesnt work! As you see displayed the variable limbnum keeps going up in value

Hail to the king, baby!

http://davidjohnwheeler.blogspot.co.uk
Chris Tate
DBPro Master
17
Years of Service
User Offline
Joined: 29th Aug 2008
Location: London, England
Posted: 22nd Jun 2013 21:46 Edited at: 22nd Jun 2013 21:49
Well there are a million ways to approach map editor development, you seem to be taking the keyboard cursor approach.

There are some mistakes and problems with your code; but as you get better you will spot issues more easily.

Firstly, never compare floating point numbers for equality if you did not initialize them with an absolute or accurate value; floating point numbers, or real numbers can be inconsistent especially when comparing a limb position to a real number; or in your cast, the position of the selector.

Consider that these two floating point coordinates are not equal:
X1 = 100.1, Y2 = 100.0
x2 = 100.1002, Y2 = 99.99999

Converting them to integers (whole numbers) will increase the likelihood of equality; but the approach you are taking is like trying to create a push button the size of an ant.

When programming 3D tools or games, collision or radii are used to determine if one thing interacts with another; giving the user comfort and freedom to pick things without having to be overly precise.

Secondly, it will be good to learn from examples posted in the snippets forum section, code base, Dark SOURCE and follow a number of tutorials related to each and every feature you intend to implement in the editor. Doing so will lead you in the right direction, at the moment you are doing things the hard way.

There are some great examples in the Sparkys collision plugin which may help you. Dark Dynamix features limb based collisions.

shadey
16
Years of Service
User Offline
Joined: 25th Jan 2010
Location:
Posted: 22nd Jun 2013 21:53 Edited at: 22nd Jun 2013 21:53
Ok thanks, I was trying to do things by dark basic alone and not rely on 3rd party plugins, it is a shame they didn't include collision groups for limbs as that would've made things easier!

Hail to the king, baby!

http://davidjohnwheeler.blogspot.co.uk
Chris Tate
DBPro Master
17
Years of Service
User Offline
Joined: 29th Aug 2008
Location: London, England
Posted: 22nd Jun 2013 23:48
Well, why is it bad idea to not use third party plugins? Are they not created for good reasons? Collision groups can be handled in plugins or manually created with arrays. I am sure there are non-plugin code snippets that might help.

Login to post a reply

Server time is: 2026-07-07 20:23:01
Your offset time is: 2026-07-07 20:23:01