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 / rolling a 3d ball

Author
Message
ShaunRW
DBPro Developer
16
Years of Service
User Offline
Joined: 7th Jan 2008
Location: Brisbane, Australia
Posted: 21st Apr 2008 12:24 Edited at: 21st Apr 2008 12:24
hey guys
i would like to know if its possible rotating a 3d ball without it changing the direction of the ball movement?

please help.




shaun ..

winxp-intel core 2 duo 2.00ghz-2.00gb ram
nvidia en7300gt silent 256mb gfx
LBFN
17
Years of Service
User Offline
Joined: 7th Apr 2007
Location: USA
Posted: 21st Apr 2008 13:17
I don't see where an object rotation will affect the direction of a ball, whether you use 'move object #,amount' or move it manually. Check this code out:


As you can see, the objects' y and z angles are unaffected by the x angle rotation while being moved, regardless of which method you choose to move it.

LB
Twinsen
18
Years of Service
User Offline
Joined: 20th Jun 2006
Location: Romania
Posted: 21st Apr 2008 19:18
yes but for more complicated stuff, it's hell on earth that's why EZ Rotate came up ... cause of Euler rotations

Could you help me treat my injured Dino-Fly ?
ShaunRW
DBPro Developer
16
Years of Service
User Offline
Joined: 7th Jan 2008
Location: Brisbane, Australia
Posted: 22nd Apr 2008 08:34 Edited at: 22nd Apr 2008 09:21
Quote: "I don't see where an object rotation will affect the direction of a ball"

i just used a move object up down left & right commands and used roll object command and it effected the z position
Quote: "yes but for more complicated stuff, it's hell on earth that's why EZ Rotate came up ... cause of Euler rotations"

is that the one u have to buy or is there a free one?

i use this code but the rotation is off...


eg the object doesnt spin on the x axis and y axis at the same time.

winxp-intel core 2 duo 2.00ghz-2.00gb ram
nvidia en7300gt silent 256mb gfx
LBFN
17
Years of Service
User Offline
Joined: 7th Apr 2007
Location: USA
Posted: 22nd Apr 2008 13:02
Quote: "i just used a move object up down left & right commands and used roll object command and it effected the z position"


I did not see what you are seeing. I tried rolling the ball and it still did not affect the z angle. Additionally, I modified your code with the example that I gave and it did not affect the z rotation. Here is a snippet:


Quote: "eg the object doesnt spin on the x axis and y axis at the same time.
"

If you hold two keys down at the same time, it will spin and move in both directions. As you can see, the z angle is unaffected. The code does not look at where the ball is currently, so you will eventually go off the screen.

LBFN
ShaunRW
DBPro Developer
16
Years of Service
User Offline
Joined: 7th Jan 2008
Location: Brisbane, Australia
Posted: 22nd Apr 2008 14:05
heres my code..

if u compile it the ball rotation should not rotate x and y axis at the same time.

oh i did get the z position fixed thanx

winxp-intel core 2 duo 2.00ghz-2.00gb ram
nvidia en7300gt silent 256mb gfx
LBFN
17
Years of Service
User Offline
Joined: 7th Apr 2007
Location: USA
Posted: 23rd Apr 2008 00:36
Quote: "if u compile it the ball rotation should not rotate x and y axis at the same time."


You are telling it to rotate both ways at the same time. Your code always has the ball moving at multiple angles (i.e. up and left, down and right, etc.) so you will always rotate on the x an y axis' at the same time. This really is how it should be if you want to texture it and create a rolling effect.

LBFN
ShaunRW
DBPro Developer
16
Years of Service
User Offline
Joined: 7th Jan 2008
Location: Brisbane, Australia
Posted: 23rd Apr 2008 11:13
ummm....well i dont know what im doing wrong....lol

did u compile it? and see what it was doing?
i swear it dont rotate at the same time.

winxp-intel core 2 duo 2.00ghz-2.00gb ram
nvidia en7300gt silent 256mb gfx
LBFN
17
Years of Service
User Offline
Joined: 7th Apr 2007
Location: USA
Posted: 23rd Apr 2008 13:03 Edited at: 23rd Apr 2008 13:04
Oh really? Write a simple debug subroutine and call it from your main loop to print the different object angles, like this:


LBFN

BTW, you should use wrapvalue on all of your angles.
ShaunRW
DBPro Developer
16
Years of Service
User Offline
Joined: 7th Jan 2008
Location: Brisbane, Australia
Posted: 23rd Apr 2008 13:36
ummm debug subroutine??.. sorry im gonna learn what that is
and wrapvalue, iv tried using that onec on a nother project but didnt know what it is

subroutines: is that when u compile it in debug mode or just printing variables?




shaun...

winxp-intel core 2 duo 2.00ghz-2.00gb ram
nvidia en7300gt silent 256mb gfx
LBFN
17
Years of Service
User Offline
Joined: 7th Apr 2007
Location: USA
Posted: 24th Apr 2008 01:32
Sorry, didn't mean to throw you off. It has nothing to do with compiling with the debug option. What I call a debug routine is something that I put in the code that gets executed every loop that gives me the current values for what I am watching. In your case, you could tell the computer to print what the x, y and z angles are of the ball object, like this:



You simply call it from your main do-loop, like this:



Wrapvalue makes sure that the angles stay within range (0.0 to 359.9999 [whatev]). You should always use it when adding/subtracting from an angle. To help you get the idea,


should be coded as



A minor note, since xangle# is a float, you should list it as I have done.

Hope this helps,

LBFN
ShaunRW
DBPro Developer
16
Years of Service
User Offline
Joined: 7th Jan 2008
Location: Brisbane, Australia
Posted: 24th Apr 2008 09:52
hmmm... i see what u mean, how the axises are rotating at the same time, but it honesly doesn't look like a rolling ball.

would it be easeir to face the ball to where it should go and rotate forward?

i will upload a vid of it later
or
you can download code and images here http://files.filefront.com/pong+3dzip/;10068878;/fileinfo.html

i did try upload them here but it was too big!!

shaun...

winxp-intel core 2 duo 2.00ghz-2.00gb ram
nvidia en7300gt silent 256mb gfx
LBFN
17
Years of Service
User Offline
Joined: 7th Apr 2007
Location: USA
Posted: 24th Apr 2008 13:16
Wow! A texture that is almost 4000 X 4000? Do you really need that much? The paddle file is 2.45MB and adds significantly to your load time. I have noticed a trend to turn sync on and off during a game, but I don't get why that is done. Anyway, I would recommend you re-size the paddle texture to 512 X 512; it will take it's size down to 50KB, a much more manageable size.

I would also suggest leaving the sync rate at 0 while loading the files; that way, the user's computer will load it as fast as possible. I doesn't seem like you should have much of a delay just loading four .jpg's.

I personally would not point and move the ball, though you could do that. I think it would be better to get the angles set correctly and then use 'fix object pivot ball' to set them. To help you, I would suggest you make a texture with a line across it so you can more easily see the ball's rotation. Let me know if you need help with this.

LBFN
ShaunRW
DBPro Developer
16
Years of Service
User Offline
Joined: 7th Jan 2008
Location: Brisbane, Australia
Posted: 24th Apr 2008 16:34 Edited at: 25th Apr 2008 08:11
ok thnax
since i didnt make the txts i dnt really look at the size and will reduce it.
i didnt really thing that the sync commamd had any impacted on the loadint..lol... i thought it was the frames per seconds but ill take ur advise.
and about the pionting the ball, i will just see if i could get the angles right.

i have corrected the angles to my liking... well good enough for me lol

shaun,,,

winxp-intel core 2 duo 2.00ghz-2.00gb ram
nvidia en7300gt silent 256mb gfx
ShaunRW
DBPro Developer
16
Years of Service
User Offline
Joined: 7th Jan 2008
Location: Brisbane, Australia
Posted: 25th Apr 2008 09:16
heres it is with some gameplay
up/down to move
1-4 camera angles

winxp-intel core 2 duo 2.00ghz-2.00gb ram
nvidia en7300gt silent 256mb gfx

Attachments

Login to view attachments
LBFN
17
Years of Service
User Offline
Joined: 7th Apr 2007
Location: USA
Posted: 25th Apr 2008 12:47
The loading time is much better and the paddle texture looks fine. I see that you have the collision and AI working. 'Fix object pivot' is not designed to be used like that in every loop, but is used initially or perhaps when a direction change is necessary. The rotation is still off IMO. I will try to take a look at it later today when I have more time.

LB
ShaunRW
DBPro Developer
16
Years of Service
User Offline
Joined: 7th Jan 2008
Location: Brisbane, Australia
Posted: 25th Apr 2008 14:42
ok thanx LBFN
you have helped me alot on this, i might add ur name in the credits...
i have change some textures and some code for collisions...




shaun...

winxp-intel core 2 duo 2.00ghz-2.00gb ram
nvidia en7300gt silent 256mb gfx

Attachments

Login to view attachments
LBFN
17
Years of Service
User Offline
Joined: 7th Apr 2007
Location: USA
Posted: 26th Apr 2008 00:39
Shaun

You are moving the ball much differently than what I thought you would. 'Fix object pivot' will not help you as it is. I was thinking that you would set the angles, fix the pivot and then move the ball in the direction dictated by the angles and the rotation would be right on. IMO the rotation just doesn't come off right currently.

If you would like, I would be willing to try to set up the angles using a direction for the ball if you would like. I don't want to go to that trouble if you plan to keep it as is.

Let me know.

Quote: "i might add ur name in the credits...
"


LBFN
ShaunRW
DBPro Developer
16
Years of Service
User Offline
Joined: 7th Jan 2008
Location: Brisbane, Australia
Posted: 26th Apr 2008 03:30
Quote: "If you would like, I would be willing to try to set up the angles using a direction for the ball if you would like. I don't want to go to that trouble if you plan to keep it as is."

thanx, its ok with me...

winxp-intel core 2 duo 2.00ghz-2.00gb ram
nvidia en7300gt silent 256mb gfx
LBFN
17
Years of Service
User Offline
Joined: 7th Apr 2007
Location: USA
Posted: 27th Apr 2008 04:59
It seems adequate to simply rotate it on the Z axis. I made a few edits:



It is easier to see the rotation with a texture that I made up with grey as the background, a red stripe going across and a green stripe going up and down. I hope this is helpful.

LBFN
ShaunRW
DBPro Developer
16
Years of Service
User Offline
Joined: 7th Jan 2008
Location: Brisbane, Australia
Posted: 27th Apr 2008 07:29
thank u very much!!!...

however, since the ball is rotating on the z axis it doesnt give the effect of a rolling ball, it is spinning on its side. is this what you were meant to do?




shaun...

winxp-intel core 2 duo 2.00ghz-2.00gb ram
nvidia en7300gt silent 256mb gfx
Sven B
19
Years of Service
User Offline
Joined: 5th Jan 2005
Location: Belgium
Posted: 27th Apr 2008 11:12
As a replacement for EZrotate, I once picked this code from the forums since I thought it would be useful. (attached).

It's LowerLogic's rotation functions. They have functions to rotate an object around the global/local/given axis.
Pretty nice I have to say.

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

Attachments

Login to view attachments
LBFN
17
Years of Service
User Offline
Joined: 7th Apr 2007
Location: USA
Posted: 27th Apr 2008 22:21
shaun

I looked at it from view #4 (nice idea BTW) and I see what you mean. This is a lot more difficult than I expected. I have tried for hours to get the angles just right without success.
There is a free version of EZ Rotate available here:

http://www.gametoolshed.com/EZrotate.html

Hope this helps.

LB
chafari
Valued Member
18
Years of Service
User Offline
Joined: 2nd May 2006
Location: Canary Islands
Posted: 28th Apr 2008 00:20
Hallo friends...knowing that an object moves in the direction if face...way donĀ“t rotate just a limb?...the model, keeps being a ball, and all moving aswell but just the limb rotates in a different angle...just the one we need....have a look to this code.

cheers.



oh my god
LBFN
17
Years of Service
User Offline
Joined: 7th Apr 2007
Location: USA
Posted: 28th Apr 2008 04:20
chafari

Very nice and elegant way to solve the problem.

LB
ShaunRW
DBPro Developer
16
Years of Service
User Offline
Joined: 7th Jan 2008
Location: Brisbane, Australia
Posted: 28th Apr 2008 09:59
Quote: "I looked at it from view #4 (nice idea BTW) and I see what you mean. "

thanx, that came to me in a dream....lol seriosly i was dreaming i was a tennis racket...i no weird

ill download that ezrotate later...

and you spent hours on this?, dont waste your time for me...lol
thanx for your help...


i will putting this projet on hold for a while since gta iv coming tommoro....yay...and ill be to addicted to it..lol


shaun...

winxp-intel core 2 duo 2.00ghz-2.00gb ram
nvidia en7300gt silent 256mb gfx
Cloggy
20
Years of Service
User Offline
Joined: 31st Oct 2004
Location: Rayleigh, Essex
Posted: 29th Apr 2008 02:11
I'm doing a little bit of work on this. So far this is what I've come up with. It could be the start of a marble madness type game.



I've added the executable and media. I'll post the source once I've done a bit more work on it. The code uses EZrotate vector rotation.

Attachments

Login to view attachments
calcyman
17
Years of Service
User Offline
Joined: 31st Aug 2007
Location: The Uncertainty Principle
Posted: 30th Apr 2008 19:17
Absolute movement commands:



The optomist's right, The pessimist's right.
Xenocythe
19
Years of Service
User Offline
Joined: 26th May 2005
Location: You Essay.
Posted: 30th Apr 2008 23:01
You could just add a texture to the ball and scroll the object texture to simulate rolling

3.11 We do not tolerate posts made for the purpose of putting down another forum member, group of members, religion, our company, our staff or any of our moderators, past or present.
ShaunRW
DBPro Developer
16
Years of Service
User Offline
Joined: 7th Jan 2008
Location: Brisbane, Australia
Posted: 5th May 2008 13:08
Quote: "ou could just add a texture to the ball and scroll the object texture to simulate rolling"


hmmmm...that would be much easier

ill check it out later on




shaun...

winxp-intel core 2 duo 2.00ghz-2.00gb ram
nvidia en7300gt silent 256mb gfx

Login to post a reply

Server time is: 2024-11-25 03:58:42
Your offset time is: 2024-11-25 03:58:42