2012-01-22 18:39:42 +00:00
|
|
|
#ifndef _PAYSAGES_LIGHTING_H_
|
|
|
|
#define _PAYSAGES_LIGHTING_H_
|
|
|
|
|
|
|
|
#include "shared/types.h"
|
2012-01-23 23:45:33 +00:00
|
|
|
#include "renderer.h"
|
2012-04-22 17:12:39 +00:00
|
|
|
#include "pack.h"
|
2012-01-22 18:39:42 +00:00
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
2012-01-23 23:45:33 +00:00
|
|
|
#define LIGHTING_MAX_LIGHTS 10
|
2012-01-22 18:39:42 +00:00
|
|
|
|
2012-06-05 20:22:12 +00:00
|
|
|
struct LightDefinition
|
2012-01-22 18:39:42 +00:00
|
|
|
{
|
2012-01-25 17:31:36 +00:00
|
|
|
Vector3 direction; /* Global direction of the light */
|
|
|
|
Color color; /* Main color of the light */
|
2012-06-17 09:40:40 +00:00
|
|
|
double reflection; /* Reflected factor of the light (for specular lighting) */
|
2012-01-25 17:31:36 +00:00
|
|
|
int filtered; /* Should the light be filtered (by atmosphere, water...) */
|
|
|
|
int masked; /* Should the light be masked (cast shadows..) */
|
2012-06-17 09:40:40 +00:00
|
|
|
double amplitude; /* Angle amplitude of the light source (for multi-sampling, pi / 2.0 for skydome) */
|
2012-06-05 20:22:12 +00:00
|
|
|
};
|
2012-01-22 18:39:42 +00:00
|
|
|
|
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
int autosetfromsky;
|
|
|
|
int nblights;
|
2012-01-23 23:45:33 +00:00
|
|
|
LightDefinition lights[LIGHTING_MAX_LIGHTS];
|
2012-01-22 18:39:42 +00:00
|
|
|
int _nbautolights;
|
2012-01-23 23:45:33 +00:00
|
|
|
LightDefinition _autolights[LIGHTING_MAX_LIGHTS];
|
2012-01-22 18:39:42 +00:00
|
|
|
} LightingDefinition;
|
|
|
|
|
2012-06-05 20:22:12 +00:00
|
|
|
struct LightStatus
|
2012-05-06 10:13:34 +00:00
|
|
|
{
|
|
|
|
int nblights;
|
|
|
|
LightDefinition lights[LIGHTING_MAX_LIGHTS * 2];
|
2012-06-05 20:22:12 +00:00
|
|
|
};
|
2012-05-06 10:13:34 +00:00
|
|
|
|
2012-01-22 18:39:42 +00:00
|
|
|
void lightingInit();
|
2012-02-12 16:57:29 +00:00
|
|
|
void lightingQuit();
|
2012-04-22 17:12:39 +00:00
|
|
|
void lightingSave(PackStream* stream, LightingDefinition* definition);
|
|
|
|
void lightingLoad(PackStream* stream, LightingDefinition* definition);
|
2012-01-22 18:39:42 +00:00
|
|
|
|
|
|
|
LightingDefinition lightingCreateDefinition();
|
2012-01-23 23:45:33 +00:00
|
|
|
void lightingDeleteDefinition(LightingDefinition* definition);
|
|
|
|
void lightingCopyDefinition(LightingDefinition* source, LightingDefinition* destination);
|
2012-01-22 18:39:42 +00:00
|
|
|
void lightingValidateDefinition(LightingDefinition* definition);
|
|
|
|
|
|
|
|
int lightingGetLightCount(LightingDefinition* definition);
|
|
|
|
LightDefinition lightingGetLight(LightingDefinition* definition, int light);
|
|
|
|
int lightingAddLight(LightingDefinition* definition, LightDefinition light);
|
|
|
|
void lightingDeleteLight(LightingDefinition* definition, int light);
|
|
|
|
|
2012-05-06 10:13:34 +00:00
|
|
|
void lightingGetStatus(LightingDefinition* definition, Renderer* renderer, Vector3 location, LightStatus* result);
|
|
|
|
Color lightingApplyStatusToSurface(Renderer* renderer, LightStatus* status, Vector3 location, Vector3 normal, SurfaceMaterial material);
|
2012-01-23 23:45:33 +00:00
|
|
|
Color lightingApplyToSurface(LightingDefinition* definition, Renderer* renderer, Vector3 location, Vector3 normal, SurfaceMaterial material);
|
2012-01-22 18:39:42 +00:00
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#endif
|