| | |
Windows programming task
Please support our C advertiser: Programming Forums - DaniWeb Sister Site
![]() |
•
•
Join Date: Mar 2005
Posts: 30
Reputation:
Solved Threads: 0
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.
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.
•
•
Join Date: Mar 2005
Posts: 53
Reputation:
Solved Threads: 1
•
•
•
•
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.
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:
no www
no nonsense
coming soon to a pc near you! :cool:
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!
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:
no www
no nonsense
coming soon to a pc near you! :cool:
![]() |
Similar Threads
- Learning Windows Programming: Good Books? (C++)
- Plz Help:In windows programming how to close dialog box? (C++)
- a major windows programming problem.. (C++)
- Windows Programming (Win 32 API) (C)
- Windows Programming (C++)
- A request for information on Windows programming in C (C++)
Other Threads in the C Forum
- Previous Thread: Program security (When Launched)
- Next Thread: Calendar Creator
| Thread Tools | Search this Thread |
#include * ansi append array arrays asterisks bash binarysearch centimeter changingto char character convert copyimagefile cprogramme creafecopyofanytypeoffileinc createprocess() database dynamic execv fgets file floatingpointvalidation fork framework function getlogicaldrivestrin givemetehcodez grade gtkwinlinux hacking histogram ide inches include infiniteloop initialization input interest intmain() iso kernel keyboard kilometer km license linked linkedlist linux list lists looping lowest matrix meter microsoft number oddnumber open opendocumentformat openwebfoundation overwrite owf pdf pointer pointers posix power probleminc process program programming radix recursion recv recvblocked research reversing segmentationfault sequential single socket socketprogramming standard strchr string suggestions systemcall test testing threads turboc unix urboc user variable wab whythiscodecausesegmentationfault windowsapi





