#ifndef __MODELS_H__ #define __MODELS_H__ #include #include #include #include typedef enum{ HARMONIC_MODEL, RADIALBASIS_MODEL, HARMONICSG_MODEL , COMPACT_MODEL} lighting_type_t; /*Generic Lighting model functions*/ ls_model_t* create_ls_lighting_model(lighting_type_t type); nl_model_t* create_nl_lighting_model(lighting_type_t type); struct lighting_data_model_t{ lighting_type_t lightingModelType; /*harmonic*/ int harmonicDegree; /*Glossy*/ double glossylikeG0; double glossylikeG1; /*radial*/ int radialResolution; double radialSpan; /*Point like*/ int pointlikeModel; double pointlikeK; double pointlikeRho; /*Compact*/ r3_t compactU; r3_t compactXi; double compactRho; double compactK; }; typedef struct lighting_data_model_t lighting_data_model_t; lighting_data_model_t parse_lighting_model(argparser_t* pp, bool_t determineParams); /* Given an arparser {pp} read the type of the model and returns a lighting_data_model_t structure woth its initializers except view_dir. The initializer parameters are readen only if {determineParams} as TRUE. Otherwise it will initialize only the field lightingModelType the input format is the following: POINTLIKE_MODEL pointlike [backplane|plain] [highlightK {K}] [terminatorRho {RHO}] HARMONIC_MODEL harmonic degree {DEGREE} HARMONICSG_MODEL harmonicSG degree {DEGREE} RADIALBASIS_MODEL radial resolution {RESOLUTION} span {SPAN} GLOSSYLIKE_MODEL glossy glossiness {G0} {G1} COMPACT_MODEL compact dirlight {Ux Uy Uz} dirbackplane {Xix Xiy Xiz } rho {RHO} K {K} */ /*Harmonic Model Functions*/ struct Harmonic_Lighting_t{ int num_comp; /*Number of triplests in the harmonic function*/ double** triplets; /*Set of triplets of the harmonic function*/ double* coeficients /*Value of each coeficient of the harmonic function*/; r3_t view_dir; }; typedef struct Harmonic_Lighting_t harmonic_lighting_t; harmonic_lighting_t* harmonic_init_components(int g,r3_t view_dir); /*Determines the degree of the triplets of the harmonic model*/ double harmonic_phi(int r, double* x, void* l_data); int harmonic_get_number_components(void* l_data); void harmonic_retrieve_components(double* C, int n,void* l_data); void harmonic_update_weights(void* l_data,double** X, double* F,double* weights, int n,double * sigma); double harmonic_shading(double* x,void* l_data); void harmonic_write_params(FILE* arq,void* l_data); void* harmonic_read_params(FILE* arq); void* harmonic_copy_lighting_data(void* l_data); double harmonic_compare_lightings(void* l_data1,void* l_data2); void harmonic_release_lighting_data(void* l_data); double harmonic_compute_pos_weights(double* x,void* l_data); double harmonic_retrieve_alpha(int r, void* l_data); double harmonic_alpha(int r, void* l_data); /*Radial Basis model*/ struct RadialBasis_Lighting_t{ int num_comp; /*Number of radial bases*/ r3_t* bcenter; /*centers of each radial basis coeficient*/ double* bradius;/*radius of each radial basis coeficient*/ double* coeficients; /*ditto*/ r3_t view_dir; }; typedef struct RadialBasis_Lighting_t radialbasis_lighting_t; radialbasis_lighting_t* radialbasis_init_components(int resolution,double span,r2_t center,double raio, r2_t estica,r3_t pole); /*Given Resolution, Span, center, radius,stretch and "north pole" direction, generate the terms of the radial basis */ double radialbasis_phi(int r, double* x, void* l_data); int radialbasis_get_number_components(void* l_data); void radialbasis_retrieve_components(double* C, int n,void* l_data); void radialbasis_update_weights(void* l_data,double** X, double* F,double* weights, int n,double * sigma); double radialbasis_shading(double* x,void* l_data); void radialbasis_write_params(FILE* arq,void* l_data); void* radialbasis_read_params(FILE* arq); void* radialbasis_copy_lighting_data(void* l_data); double radialbasis_compare_lightings(void* l_data1,void* l_data2); void radialbasis_release_lighting_data(void* l_data); double radialbasis_compute_pos_weights(double* x,void* l_data); double radialbasis_retrieve_alpha(int r, void* l_data); double radialbasis_alpha(int r, void* l_data); /*Harmonic Stereographic Model Functions*/ struct HarmonicSG_Lighting_t{ int num_comp; /*Number of tuples in the harmonic function*/ double** tuples; /*Set of tuples of the harmonic function*/ double* coeficients /*Value of each coeficient of the harmonic function*/; r3_t view_dir; }; typedef struct HarmonicSG_Lighting_t harmonicSG_lighting_t; harmonicSG_lighting_t* harmonicSG_init_components(int g,r3_t view_dir); /*Determines the degree of the triplets of the harmonic model*/ double harmonicSG_phi(int r, double* x, void* l_data); int harmonicSG_get_number_components(void* l_data); void harmonicSG_retrieve_components(double* C, int n,void* l_data); void harmonicSG_update_weights(void* l_data,double** X, double* F,double* weights, int n,double * sigma); double harmonicSG_shading(double* x,void* l_data); void harmonicSG_write_params(FILE* arq,void* l_data); void* harmonicSG_read_params(FILE* arq); void* harmonicSG_copy_lighting_data(void* l_data); double harmonicSG_compare_lightings(void* l_data1,void* l_data2); void harmonicSG_release_lighting_data(void* l_data); double harmonicSG_compute_pos_weights(double* x,void* l_data); double harmonicSG_retrieve_alpha(int r, void* l_data); double harmonicSG_alpha(int r, void* l_data); /*Compact light with Phong reflection model*/ struct Compact_Lighting_t{ r3_t view_dir; /*Direction of the point of view (FIXED)*/ /*Non linear coefficients*/ r3_t dirlight; /*Light source direction*/ double radlight; /*Angular radius of the light source*/ double shine; /*Intensity of the phong factor */ r3_t backnormal; /*Background*/ /*Uncertainties of the non linear coefficients*/ double err_dirligh; double err_radlight; double err_shine; double err_backnormal; /*Linear coefficients*/ double Ec; /*Intensity of light source*/ double El; /*Intensity of the phong shading factor*/ double Ea; /*Isotropic light source intensity*/ double Ef; /*Backplane light source intensity*/ /*Which basis elements to include*/ bool_t Hc; /*Compact light (dirlight,radlight)*/ bool_t Hl; /*Highlight (dirlight,shine)*/ bool_t Ha; /*isotropic light*/ bool_t Hf; /*backplane lighting (backnormal)*/ }; typedef struct Compact_Lighting_t compact_lighting_t; compact_lighting_t* compact_init_components( r3_t dirlight, double err_dirligh, double radlight, double err_radlight, double shine, double err_shine, r3_t backnormal, double err_backnormal, r3_t view_dir ) /* Initialize compact light model attributes. It accepts default values when there is no estimate to determine the the input values for the parameters thats is {dir_light} = {0,0,0} {rho} = nan {K} = nan {xi} = {0,0,0} {view_dir} attribute is mandatory ! To reproduce a pure lambertian gauge, use {rho} = 0 and K = inf. */ double compact_phi(int r, double* x,void* l_data); int compact_get_number_components(void* l_data); void compact_retrieve_components(double* C, int n,void* l_data); void compact_update_weights(void* l_data,double** X, double* F,double* weights, int n,double* sigma); double compact_shading(double* x,void* l_data); void compact_write_params(FILE* arq,void* l_data); void* compact_read_params(FILE* arq); void* compact_copy_lighting_data(void* l_data); double compact_compare_lightings(void* l_data1,void* l_data2); void compact_release_lighting_data(void* l_data); double compact_compute_pos_weights(double* x,void* l_data); double compact_alpha(int r, void* l_data); double compact_data_weights(double* x,void* l_data); /*Those are non linear*/ int compact_num_packed_params(void* l_data); double* compact_pack_parameter(void* l_data); void* compact_unpack_parameter(double* parameters,void* l_data); /*Empty retrieve alpha function*/ double retrieve_no_alpha(int r, void* l_data); /*Empty data weight function*/ double retrieve_no_weight(double* x, void* l_data); /*Validation functions*/ int NoValidation(double* c, int basis_size, bool_t* validity_array); /*Dummy function that aways returns as valid a given array */ #endif