frodo_jedi
YaBB Newbies
Offline
Posts: 18
How to increase the light of an object
Oct 22nd , 2008, 8:35pm
Hello everybody, I ask a suggestion to understand how to enlight a sphere in the following way. I want that the light of the sphere increases as the radious increases (only the light of the sphere, in the image there will be other objects). I wrote the following code but I am not able to understand which function (or better the right combination of lights) to use to enlight the sphere. /*------------------------------------------------------------------------------ ----------*/ //Importing libraries import processing.opengl.*; /*------------------------------------------------------------------------------ ----------*/ //GLOBAL VARIABLES int size_window = 1000;//not an odd number //Variables for the central sphere boolean draw_sphere = true;//enable the drawig of the sphereINPUT PARAMETER float c_s_radius;//the radius of the central sphere varies with a function (in order //radius_sphereradius_sphereto make the impression of vibration/pulsation float c_s_angle = 0.; float c_s_angle_increment = 1.; float c_s_pulsation_step_size = 12.;//controls the velocity of the pulsation (INPUT PARAMETER) /*------------------------------------------------------------------------------ ----------*/ void setup() { size(size_window,size_window, OPENGL); hint(ENABLE_OPENGL_4X_SMOOTH);// Enable 4x oversampling (if supported) }//end setup() /*------------------------------------------------------------------------------ ----------*/ void draw() { background(0); translate(width/2,height/2);//put the reference system in the centre define_lights();//global lights if(draw_sphere){//Draw the central sphere draw_central_sphere(size_window/48., size_window/36.);//NOTE: INPUT PARAMETERS to control the sizer of the sphere } }//end draw() /*------------------------------------------------------------------------------ ----------*/ //Functions void draw_central_sphere(float radius, float radius_offset){ define_c_s_lights();//light of the sphere fill(255, 255, 255);//white sphere if (c_s_angle >= 360.){ c_s_angle = 0.; } c_s_radius = sin(radians(c_s_angle))*radius + radius_offset; noStroke(); sphereDetail(100); sphere(c_s_radius); c_s_angle+= c_s_angle_increment*c_s_pulsation_step_size; }//end draw_central_sphere() void define_lights(){ ambientLight(102, 102, 102); lightSpecular(204, 204, 204); directionalLight(102, 102, 102, 0, 0, -1); specular(255, 255, 255); }//end define_line() void define_c_s_lights(){ shininess(5.0); emissive(0, 51, 102);//blu emissive light }//end define_central_dphere_lights() As you can see in the define_c_s_lights() function I tried with emissive() but I did not reach my objective. So please help me! Thanks in advance