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 analog clock

Author
Message
Kieran
18
Years of Service
User Offline
Joined: 6th Aug 2006
Location: Hamilton, New Zealand
Posted: 8th Aug 2008 13:21 Edited at: 8th Aug 2008 13:22
I have made this clock tower for my game



And I am wondering if someone can show me how to make some clock hands on it and rotate them according to the system time (programatically).

Attachments

Login to view attachments
LBFN
17
Years of Service
User Offline
Joined: 7th Apr 2007
Location: USA
Posted: 9th Aug 2008 04:39 Edited at: 9th Aug 2008 06:00
From a programming standpoint, the following will give you the raw data you will need for positioning the hands:


If you needed to convert the strings for hour, minutes and seconds into separate integers, you would use the 'val' function.

I would think you would have to make separate planes (plains) for the different hands. You would then ghost them and rotate them to the proper angle to show the correct time. I'm sorry, but I don't have time to help with that part.

Good luck,

LBFN
Nano brain
16
Years of Service
User Offline
Joined: 7th May 2008
Location:
Posted: 9th Aug 2008 23:17
I'll continue from here...

Firstly, we must know that for every 30 degrees there is a new hour on an analog clock(360/12). Secondly, for every 6 degrees there is a minute(360/60). Lastly, we want smooth transitions from hour to hour and minute to minute. So we must take into account the percentage values of the lower hands relative to the higher hands.

The hour hand:
What we must do to accomplish this task is first get the angle of for the hour hand at angle n. So, multiply the hour by 30. This will place our hand on the hour. But we must rotate the hour hand so that it lies somewhere between the current hour and the next hour, based on a percentage of the current minutes divided by total minutes in an hour(curminute/60), and rotate the hand angle more based on the percentage given times 30. This will position our hour hand between the current hour and the next correctly, which is based on the minute hand position, thus giving us a smooth transition from hour angle to hour angle.



The minute hand:
We do the same thing here as we did the hour, but relative to the angle of the seconds.



The second hand:
Finally, the easiest part. The second hand simply has to be rotated by seconds*6.



Now, these is the way to get the general angles for your clock hands. Depending on the angle of your clock tower, you will probably have to tweak and convert the angles a bit. Good luck fro m here.
spooky
22
Years of Service
User Offline
Joined: 30th Aug 2002
Location: United Kingdom
Posted: 9th Aug 2008 23:51
An old snippet of mine (4 year old!) that shows the basics of a 3d clock. Basically you make a 3d box for each hand, although a plain is probably good enough, then offset the rotational centre to the end of the hand, then rotate them relative to current time.



Boo!
LBFN
17
Years of Service
User Offline
Joined: 7th Apr 2007
Location: USA
Posted: 10th Aug 2008 19:28
spooky

That is very clever! I'm going to tuck that snippet away for future use.

Coming up on our 6th anniversary are we?

LB

Nano brain
16
Years of Service
User Offline
Joined: 7th May 2008
Location:
Posted: 12th Aug 2008 01:15
Good job spooky. That's exactly what I tried to explain.

Login to post a reply

Server time is: 2024-11-24 22:34:24
Your offset time is: 2024-11-24 22:34:24