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 / Drawing a box, kinda

Author
Message
Melancholic
16
Years of Service
User Offline
Joined: 26th Nov 2009
Location:
Posted: 9th Aug 2010 09:39
So here is my problem, I thought this would be pretty simple but I seem to have been proved wrong. I need to draw a box on screen in 3d, though I am not sure how this is done, I have tried a few methods but none have worked, below is some code of mine



As you can see I am storing the 3d position of the mouse just as the mouse was clicked(in the mosx and mosy variables). Then as the mouse is being held down I am recording its position in mosx2 and mosy2, plus I have 2d screen coordinates just for good measure.

This is for a 2.5d project so the z axis doesn’t matter, all object are positioned at o on the z axis. I am very thankful for any help


I can count to banana...
baxslash
Valued Member
Bronze Codemaster
19
Years of Service
User Offline
Joined: 26th Dec 2006
Location: Duffield
Posted: 9th Aug 2010 11:52 Edited at: 9th Aug 2010 11:55
Quote: "MOSX2 = Get Pick Vector X()
MOSY2 = Get Pick Vector y()"

This will only get the vectors from the camera position. Also you are only getting an X and Y (3D needs Z too). To get the world 3D coordinates you need to have this:



...then you could use the points you are storing and the points from the 'current' position of the mouse to scale and position a plain...



Hope that works or at least helps!

EDIT: Just added the rotation correction for the plain!

Melancholic
16
Years of Service
User Offline
Joined: 26th Nov 2009
Location:
Posted: 9th Aug 2010 13:57
Thanks, that seemed to work somewhat. But i get a sort of sharp edge on the created plane. My code is



I have no idea why this is happening


I can count to banana...
baxslash
Valued Member
Bronze Codemaster
19
Years of Service
User Offline
Joined: 26th Dec 2006
Location: Duffield
Posted: 9th Aug 2010 14:06
I don't get anything from that code, is something missing from it? Where are the objects we are picking using "pick object"?

Melancholic
16
Years of Service
User Offline
Joined: 26th Nov 2009
Location:
Posted: 9th Aug 2010 14:16
The only reason "pick object" is in there is because it needs to be called in order to generate the vector data I use mosx, mosy and mosz for. The rest(the function) is basically getting the coordinates of the mouse whilst its being pressed down. The rest is your code to actually create the plane.

I know the code is messy and badly commented, but that’s because I just stripped down my whole program to only that part(though I retained some code so that the pick commands still functioned).


I can count to banana...
baxslash
Valued Member
Bronze Codemaster
19
Years of Service
User Offline
Joined: 26th Dec 2006
Location: Duffield
Posted: 9th Aug 2010 14:20
My code is often messy and badly commented, that's not what I meant. Try running the code you posted on its own, it doesn't do anything.

Pick object will only return valid data to the pick vector command if you actually pick an object.

I can only assume you haven't run the code you posted exactly as you posted it (not in your game code but exclusive of it).

Melancholic
16
Years of Service
User Offline
Joined: 26th Nov 2009
Location:
Posted: 9th Aug 2010 16:32 Edited at: 9th Aug 2010 18:25
I have solved my problem using a different method, which works just fine. Ill provide the code if anyones intrested, though it is messy




EDIT: Unrelated question here but didnt want to make a new thread. Is there anyway to update a objects scale information as xeno physics seems to be reading the original size and my phyics are messed up. Ive got this code to try fix it



but for some reason i still get the standard cube, im guessing this is also down to not updating the scale info when saving the file


I can count to banana...
Melancholic
16
Years of Service
User Offline
Joined: 26th Nov 2009
Location:
Posted: 9th Aug 2010 22:43
Okay, I am sorry for posting so much but i have fixed my problem. Though I am now faced with a much more confusing problem. It might even be a bug. My problem is that DBPro will not recognize any function calls and marks them as syntax errors, i would provide code, but at this point my program is pushing 600 lines.

I have tried both the standard IDE and code surge, any ideas?


I can count to banana...
Mobiius
Valued Member
23
Years of Service
User Offline
Joined: 27th Feb 2003
Location: The Cold North
Posted: 10th Aug 2010 09:50
Quote: "Is there anyway to update a objects scale information as xeno physics seems to be reading the original size and my phyics are messed up."


Quote: "I am sorry for posting so much but i have fixed my problem."

Do please tell what the fix to this issue is! I'd love to hear it!

My signature is NOT a moderator plaything! Stop changing it!
Melancholic
16
Years of Service
User Offline
Joined: 26th Nov 2009
Location:
Posted: 10th Aug 2010 10:14 Edited at: 10th Aug 2010 10:15
All credit goes to Lost In Though and Cash curtis for writing this nice function to replace the scale command. It works in allmost the same way as DBPro's scale command. It supposedly slow but i havent noticed any slow down yet, and im calling it 30 times a second

EDIT: forgot to include link lol http://forum.thegamecreators.com/?m=forum_view&t=111419&b=6


I can count to banana...
baxslash
Valued Member
Bronze Codemaster
19
Years of Service
User Offline
Joined: 26th Dec 2006
Location: Duffield
Posted: 10th Aug 2010 10:36
That's a great scale code, I've been using it for a while now.

Login to post a reply

Server time is: 2026-07-25 07:02:10
Your offset time is: 2026-07-25 07:02:10