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 rotating cube

Author
Message
Phantom 2590
17
Years of Service
User Offline
Joined: 19th Apr 2007
Location: Earth...
Posted: 28th Dec 2007 23:28
Ok so i'm going to try to explain this as best as possible. But i am including the source code so u can take a look at it. after using it for a bit you'll quickly see the problem i'm having. so basicaly i hav a cube ive created with limbs so i could color each face seperatly did this with the help of TDK thank you very much, and i have a sphere which i set into motion once i click the arrow buttons, wen the sphere reaches the edge of the cube the cube rotates and it does, at first everything seems to work until you rotate once any direction and then again another direction (ex. rotate left then down) enough said just take a look and see if you can please help


Phantom 2590
17
Years of Service
User Offline
Joined: 19th Apr 2007
Location: Earth...
Posted: 30th Dec 2007 07:37
*bump*
plz help!
i can't figure it out

Dabbler
17
Years of Service
User Offline
Joined: 3rd Mar 2007
Location: Minnesota
Posted: 30th Dec 2007 15:36 Edited at: 30th Dec 2007 15:43
try this:

after the for/next loop in each of your rotate cube subroutines.

Sorry: that isn't quite it. I'll keep looking.


Whatever...
Phantom 2590
17
Years of Service
User Offline
Joined: 19th Apr 2007
Location: Earth...
Posted: 31st Dec 2007 02:55 Edited at: 31st Dec 2007 03:35
heh yeah that bit of code helps with the rotation problem i was havign but adds another one but thanks anyways
do u think it would b easier to rotate and change the camera angle instead of the cube
so each tiem the sphere gets to the edge ill make the sphere move down and fix the camera to give the effect of the cube rotating?
well ill wait a few more days and if no one can figure this out for me ill see if i can do the camera thing
im nto sure if thats a bad way of doing it though

Edit*
or should i just stay with that bit of code you gave me and just cheat and just recolor the cube everytime it rotates, that might work but it would b a pain
ahhh i hope someone can help me

BMacZero
18
Years of Service
User Offline
Joined: 30th Dec 2005
Location: E:/ NA / USA
Posted: 2nd Jan 2008 17:12 Edited at: 2nd Jan 2008 17:22
First of all, do you really need to check whether the sphere is off the cube twice?


As for your problem, I think the object is rotating around its OWN axis, rather than around the global axis as you want it to. You can see that if you roll over the top and then over a side, the cube rotates around what appears to be the Y axis - however, nowhere in your program have you made any y axis rotation at all. So you can see that the cube IS rotating around the z axis, but the z axis has been rotated 90 degrees up.

Wow, I think I confused myself...
I know there's a way to fix this, but I can't remember...I'll keep looking.

Edit: This is using the fix object pivot method.


"Ok, so that wasn't funny. I don' have any good Christmas jokes."
Dabbler
17
Years of Service
User Offline
Joined: 3rd Mar 2007
Location: Minnesota
Posted: 3rd Jan 2008 03:25
@bmaczero
You have to fix the object pivot of object 1, then the rotation works(kinda works). Limbs get messed up after a couple of rotations. I am confused too.


Whatever...
Sven B
19
Years of Service
User Offline
Joined: 5th Jan 2005
Location: Belgium
Posted: 3rd Jan 2008 18:07 Edited at: 3rd Jan 2008 18:07
I attached LowerLogic's rotation functions in a text file. Just save it in a dba, and include it to your project.

Of course, it has too much functions, but the ones you should focus on are:

Rotate_GX(obj, amount#)
Rotate_GY(obj, amount#)
Rotate_GZ(obj, amount#)

which increases the object angle of obj around the global axis with an angle of amount#. Which are exactly what you need right?
Though you'll have to alter your code a little. Like when the Z coordinate is > cube size/2 or < -cube size/2, rotate around the global X axis and when X coordinate > cube size/2 or < -cube size/2, rotate around the global Z axis.

Thank you LowerLogic...

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

Attachments

Login to view attachments
Phantom 2590
17
Years of Service
User Offline
Joined: 19th Apr 2007
Location: Earth...
Posted: 4th Jan 2008 00:05 Edited at: 4th Jan 2008 01:57
@bmaczero
wow i see what you mean i got that code from an example TDK gave me back in April wen i saw stuck in coloring and rotating the cube
he gave me the code for rotating and he told me there were a few bugs with it, but unfortunately i left for a while and the thread closed before he ever figured out the rotation problem
@Sven B
I haven't tried that yet but i will soon. i just need to know will there be a way to make that code into steps kinda of like a i have so it shows the cube rotating slowly? heh i guess thats really my job to figure out, i gotta give it a better look when i have time

-and i don't see why i would have to alter my code at all other then adding the new commands because my code already calls the cube to rotate around the X-axis if its greater then or less then the Z coordinates I specified

*Edit I tried including that code into my project and i took off the extra checks with the if statement and all but now i cannot build the exe. i get an error that says Could not create (full directory path) my file is in
heres the new code same file included for download or download it form the post above


Edit*
Turns out its a computer problem
the folder the file is saved is restricted some how it wont let me edit anything it or even delete anything. even though i have done nothing to that folder. oh well i just saved everything into another folder and it worked
the new codes ran perfectly
@Sven B if i go into that file and just take out the two functions i need will that work and is it allowed need to know in advanced

thank you very much for everything i've been having this problem for ever and now its fixed

Attachments

Login to view attachments
Sven B
19
Years of Service
User Offline
Joined: 5th Jan 2005
Location: Belgium
Posted: 4th Jan 2008 11:38 Edited at: 8th Jan 2008 18:48
Quote: "@Sven B if i go into that file and just take out the two functions i need will that work and is it allowed need to know in advanced"


The source code is LowerLogic's. He didn't say anything about it being copyrighted, and secondly, he hasn't posted a thread for a long time, so I think he isn't active anymore on this forum... edit] He just posted some code on the code snippet forum, so he is still active

I'd say: yes, you can. But I'd put him in the credits if I'd ever release a game

Secondly, look at the source code to see what functions you need. I don't think those functions use other functions in the file. If else, just add them too in your code.

And thirdly:
I think you should include a DBA file, not a text file. I uploaded a text file, but you need to save it as a dba file first...
That could be causing your errors

It's the programmer's life:
Have a problem, solve the problem, and have a new problem to solve.
Phantom 2590
17
Years of Service
User Offline
Joined: 19th Apr 2007
Location: Earth...
Posted: 6th Jan 2008 07:18
Quote: "And thirdly:
I think you should include a DBA file, not a text file. I uploaded a text file, but you need to save it as a dba file first...
That could be causing your errors"

oh ok thx i didnt even think of that
and yeah this particular game probably will never b released but if it is ill include him in the credits
well once again thankyou for all ur help

Login to post a reply

Server time is: 2024-11-25 10:32:28
Your offset time is: 2024-11-25 10:32:28