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 / Help with rotation?

Author
Message
Hannibal
18
Years of Service
User Offline
Joined: 5th Mar 2007
Location:
Posted: 16th Mar 2014 22:53
I only want it to rotate around x or y, but at present it appears to rotate around both, even tho it doesn't !

ie I don't want the cube to appear to rotate like a square in a circle

can I reset the "normal rotation" after each 90 degree rotate or something?

sorry if I am being a plank, but it has eluded me

Attachments

Login to view attachments
Green Gandalf
VIP Member
20
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 17th Mar 2014 01:08
Run this code, then study it and you should see the answer to your question - if I've understood your question correctly.





Powered by Free Banners
Hannibal
18
Years of Service
User Offline
Joined: 5th Mar 2007
Location:
Posted: 17th Mar 2014 02:20
Thanks, that helped a lot
May be I can just...


Green Gandalf
VIP Member
20
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 17th Mar 2014 11:47
If that's the effect you wanted. Note that in your new code the direction of rotation gets reversed every time you return to an axis of rotation.

If you want to keep the direction the same you could do something like this:





Powered by Free Banners
Hannibal
18
Years of Service
User Offline
Joined: 5th Mar 2007
Location:
Posted: 17th Mar 2014 13:07
That's fine until the cube is textured, borrowing some code from the forum....



removing the 2 angle resets at line 88 and 91 makes it ok, except for the 180 degree rotation, would be nice to have 90


cheers
Green Gandalf
VIP Member
20
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 17th Mar 2014 13:12
Well, make it 90 then - as in your original code.

It's still not clear to me what you are trying to achieve exactly.



Powered by Free Banners
Hannibal
18
Years of Service
User Offline
Joined: 5th Mar 2007
Location:
Posted: 17th Mar 2014 14:02
Well it will be a video effect, each cube will have a video playing on each side and I don't want any diagonal movement

See attached

btw it will be a non real time thing, saved out as frames to make a resulting video

Attachments

Login to view attachments
tiffer
19
Years of Service
User Offline
Joined: 6th Apr 2006
Location: Scotland
Posted: 17th Mar 2014 14:05
@Hannibal I think he means what rotation you want to achieve. You haven't been that clear so far.

Cwatson
Green Gandalf
VIP Member
20
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 17th Mar 2014 15:56
Quote: "I think he means what rotation you want to achieve. You haven't been that clear so far."






Powered by Free Banners
Hannibal
18
Years of Service
User Offline
Joined: 5th Mar 2007
Location:
Posted: 17th Mar 2014 17:14
See attachment
For the video effect to look right I need to avoid the cubes rotating "diagonally"

Attachments

Login to view attachments
tiffer
19
Years of Service
User Offline
Joined: 6th Apr 2006
Location: Scotland
Posted: 17th Mar 2014 19:42
Right you mean in relation to the camera. You need to understand that the X,Y,Z axis are in relation to the cubes orientation and not the camera. You need to let the program check the y rotation( whether it's facing right/forward/backward) and then switch between x and z rotation accordingly. Does that make sense?

Cwatson
Green Gandalf
VIP Member
20
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 17th Mar 2014 19:50
Quote: "I need to avoid the cubes rotating "diagonally""


You seem to want something more than that. Otherwise what's wrong with the solutions, i.e. yours and mine, posted earlier?

My guess is that you need to keep track of which axis you want to rotate around. I believe DBPro rotates an object around its own x, y or z axes not around the world x, y or z axes. That was the point of one of my earlier demos. So, if you rotate an object around its Y axis by 90 degrees, think about where its own x axis has moved to. Do you still want to rotate around its x axis (which in world terms is then aligned with the world z axis) or around some other axis? Complete clarity would help.

I'm still guessing what you are really trying to do here.



Powered by Free Banners
Hannibal
18
Years of Service
User Offline
Joined: 5th Mar 2007
Location:
Posted: 17th Mar 2014 20:11
TY both , yes you are right I am really looking for an easy way to rotate the object in the world axes

"then switch between x and z rotation accordingly"

TY that is a good solution

I was looking for a way to reset the axes at the new rotation, to match the original axes
Green Gandalf
VIP Member
20
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 17th Mar 2014 20:25
Quote: "I was looking for a way to reset the axes at the new rotation, to match the original axes"


Not sure, but fix object pivot might do this for you.



Powered by Free Banners
Mobiius
Valued Member
22
Years of Service
User Offline
Joined: 27th Feb 2003
Location: The Cold North
Posted: 17th Mar 2014 20:49
Quote: "Not sure, but fix object pivot might do this for you."

That's what I would suggest. Every time you complete a 90 degree rotation, fix the objects pivot. Then rotate again.

Hannibal
18
Years of Service
User Offline
Joined: 5th Mar 2007
Location:
Posted: 17th Mar 2014 21:37
Thanks

fix object pivot
seems to work, (along with turn object and pitch object) but objects sometimes seem to jump to new positions

is that a known thing and is there a workaround?
Green Gandalf
VIP Member
20
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 17th Mar 2014 22:00
Can you provide a simple snippet demonstrating the problem?



Powered by Free Banners
Hannibal
18
Years of Service
User Offline
Joined: 5th Mar 2007
Location:
Posted: 17th Mar 2014 22:15
Not sure how good an example this is.....
Green Gandalf
VIP Member
20
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 17th Mar 2014 23:51 Edited at: 17th Mar 2014 23:52
I see what you mean.

I'm not sure what's the best approach at the moment [actually I do - I'm going to get a beer from the fridge ].

Can you remind me what the problem is if you use this in your rotation function?



There is sometimes a small jump with the above code which I suspect is due to a small numerical inaccuracy when the rotation variables swap over.



Powered by Free Banners
Hannibal
18
Years of Service
User Offline
Joined: 5th Mar 2007
Location:
Posted: 18th Mar 2014 23:26
Thanks for the help all, in the end I got the free version of EZrotate and with that it was a breeze
Hannibal
18
Years of Service
User Offline
Joined: 5th Mar 2007
Location:
Posted: 23rd Mar 2014 07:16
Here's one of the resulting effects....

https://www.youtube.com/watch?v=KLwX-Lt_lxU&feature=youtu.be

GL all
Hannibal
18
Years of Service
User Offline
Joined: 5th Mar 2007
Location:
Posted: 23rd Mar 2014 07:44
And another....

https://www.youtube.com/watch?v=eCGWh17Zbsk
Green Gandalf
VIP Member
20
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 23rd Mar 2014 12:11
Neat.



Powered by Free Banners

Login to post a reply

Server time is: 2025-05-14 00:24:07
Your offset time is: 2025-05-14 00:24:07