User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the C section within the Software Development category of DaniWeb, a massive community of 397,750 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,604 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our C advertiser:
Views: 2040 | Replies: 3
Reply
Join Date: Mar 2005
Posts: 27
Reputation: crestaldin is an unknown quantity at this point 
Rep Power: 4
Solved Threads: 0
crestaldin crestaldin is offline Offline
Light Poster

Help Windows programming task

  #1  
Mar 19th, 2005
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.
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Mar 2005
Location: Woodland Hills CA
Posts: 49
Reputation: aj.wh.ca is an unknown quantity at this point 
Rep Power: 4
Solved Threads: 1
aj.wh.ca aj.wh.ca is offline Offline
Light Poster

Re: Windows programming task

  #2  
Mar 19th, 2005
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
Reply With Quote  
Join Date: Dec 2004
Location: Devon - UK
Posts: 420
Reputation: 1o0oBhP is an unknown quantity at this point 
Rep Power: 4
Solved Threads: 6
1o0oBhP's Avatar
1o0oBhP 1o0oBhP is offline Offline
Posting Pro in Training

Re: Windows programming task

  #3  
Mar 20th, 2005
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?
http://sales.carina-e.com

no www
no nonsense

coming soon to a pc near you! :cool:
Reply With Quote  
Join Date: Dec 2004
Location: Devon - UK
Posts: 420
Reputation: 1o0oBhP is an unknown quantity at this point 
Rep Power: 4
Solved Threads: 6
1o0oBhP's Avatar
1o0oBhP 1o0oBhP is offline Offline
Posting Pro in Training

Re: Windows programming task

  #4  
Mar 20th, 2005
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!
http://sales.carina-e.com

no www
no nonsense

coming soon to a pc near you! :cool:
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

DaniWeb C Marketplace
Thread Tools Display Modes

Similar Threads
Other Threads in the C Forum

All times are GMT -4. The time now is 3:22 am.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC