943,771 Members | Top Members by Rank

Ad:
  • C Discussion Thread
  • Unsolved
  • Views: 2814
  • C RSS
Mar 19th, 2005
0

Windows programming task

Expand Post »
Ps I need some help with my Windows programming assignment.
My instructor wants us to draw an ellipse(2D) and make it appear like a ball(3D) by applying different shades of the same color to different parts of the ellipse.
By assuming any point is the light source, parts near to that source will be lighter and parts farther will be darker but there should be a gradual change in the shades as one moves from one region to another.
He said we'd need a loop and (of course) a SetPixel function to do this.
Anyone who has an idea should please help out.
Similar Threads
Reputation Points: 10
Solved Threads: 0
Light Poster
crestaldin is offline Offline
30 posts
since Mar 2005
Mar 19th, 2005
0

Re: Windows programming task

Quote originally posted by crestaldin ...
Ps I need some help with my Windows programming assignment.
My instructor wants us to draw an ellipse(2D) and make it appear like a ball(3D) by applying different shades of the same color to different parts of the ellipse.
By assuming any point is the light source, parts near to that source will be lighter and parts farther will be darker but there should be a gradual change in the shades as one moves from one region to another.
He said we'd need a loop and (of course) a SetPixel function to do this.
Anyone who has an idea should please help out.
I dont know myself exactly, but you can talk to this guy on yahoo. ankit_jain_gzb or you can mail him on ankit_jain_gzb@yahoo.co.in
Reputation Points: 12
Solved Threads: 1
Junior Poster in Training
aj.wh.ca is offline Offline
53 posts
since Mar 2005
Mar 20th, 2005
0

Re: Windows programming task

Well for a start to make an ellipse appear like a ball you need to make a CIRCLE not an ellipse, then depending on the angle of the light you need to do some VERY basic lighting algorithms ASSUMING the object IS 3 dimensional. If you set the light source to be pointing through the centre of the circle and its angle varying as it travels around the shape then the lighting shouldnt be too hard to figure out. What output do you have at the moment?
Reputation Points: 16
Solved Threads: 6
Posting Pro in Training
1o0oBhP is offline Offline
445 posts
since Dec 2004
Mar 20th, 2005
0

Re: Windows programming task

Sorry I re-read the question. Your instructor is asking you to do a 'fake 3d' lighting effect (I was going to show you a 'real' techniqe!). He / She has said that colour must fade depending on distance from a point. So here's my solution

Process WM_LBUTTONDOWN messages so that wherever you click this is where the light source is

Loop through the 'ellipse'. Using pythagorus' theorum you can work out the distance from the current shape pixel to the light source pixel (where the user clicked) then by scaling colour components by this value you will get RGB values required at each pixel and therefore have done the fake lighting tech!
Reputation Points: 16
Solved Threads: 6
Posting Pro in Training
1o0oBhP is offline Offline
445 posts
since Dec 2004

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in C Forum Timeline: Program security (When Launched)
Next Thread in C Forum Timeline: Calendar Creator





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC