miniassimp
diff include/miniassimp/light.h @ 0:879c81d94345
initial commit
author | John Tsiombikas <nuclear@member.fsf.org> |
---|---|
date | Mon, 28 Jan 2019 18:19:26 +0200 |
parents | |
children |
line diff
1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/include/miniassimp/light.h Mon Jan 28 18:19:26 2019 +0200 1.3 @@ -0,0 +1,259 @@ 1.4 +/* 1.5 +--------------------------------------------------------------------------- 1.6 +Open Asset Import Library (assimp) 1.7 +--------------------------------------------------------------------------- 1.8 + 1.9 +Copyright (c) 2006-2018, assimp team 1.10 + 1.11 + 1.12 + 1.13 +All rights reserved. 1.14 + 1.15 +Redistribution and use of this software in source and binary forms, 1.16 +with or without modification, are permitted provided that the following 1.17 +conditions are met: 1.18 + 1.19 +* Redistributions of source code must retain the above 1.20 + copyright notice, this list of conditions and the 1.21 + following disclaimer. 1.22 + 1.23 +* Redistributions in binary form must reproduce the above 1.24 + copyright notice, this list of conditions and the 1.25 + following disclaimer in the documentation and/or other 1.26 + materials provided with the distribution. 1.27 + 1.28 +* Neither the name of the assimp team, nor the names of its 1.29 + contributors may be used to endorse or promote products 1.30 + derived from this software without specific prior 1.31 + written permission of the assimp team. 1.32 + 1.33 +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 1.34 +"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 1.35 +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 1.36 +A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 1.37 +OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 1.38 +SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 1.39 +LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 1.40 +DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 1.41 +THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 1.42 +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 1.43 +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 1.44 +--------------------------------------------------------------------------- 1.45 +*/ 1.46 + 1.47 +/** @file light.h 1.48 + * @brief Defines the aiLight data structure 1.49 + */ 1.50 + 1.51 +#pragma once 1.52 +#ifndef AI_LIGHT_H_INC 1.53 +#define AI_LIGHT_H_INC 1.54 + 1.55 +#include "types.h" 1.56 + 1.57 +#ifdef __cplusplus 1.58 +extern "C" { 1.59 +#endif 1.60 + 1.61 +// --------------------------------------------------------------------------- 1.62 +/** Enumerates all supported types of light sources. 1.63 + */ 1.64 +enum aiLightSourceType 1.65 +{ 1.66 + aiLightSource_UNDEFINED = 0x0, 1.67 + 1.68 + //! A directional light source has a well-defined direction 1.69 + //! but is infinitely far away. That's quite a good 1.70 + //! approximation for sun light. 1.71 + aiLightSource_DIRECTIONAL = 0x1, 1.72 + 1.73 + //! A point light source has a well-defined position 1.74 + //! in space but no direction - it emits light in all 1.75 + //! directions. A normal bulb is a point light. 1.76 + aiLightSource_POINT = 0x2, 1.77 + 1.78 + //! A spot light source emits light in a specific 1.79 + //! angle. It has a position and a direction it is pointing to. 1.80 + //! A good example for a spot light is a light spot in 1.81 + //! sport arenas. 1.82 + aiLightSource_SPOT = 0x3, 1.83 + 1.84 + //! The generic light level of the world, including the bounces 1.85 + //! of all other light sources. 1.86 + //! Typically, there's at most one ambient light in a scene. 1.87 + //! This light type doesn't have a valid position, direction, or 1.88 + //! other properties, just a color. 1.89 + aiLightSource_AMBIENT = 0x4, 1.90 + 1.91 + //! An area light is a rectangle with predefined size that uniformly 1.92 + //! emits light from one of its sides. The position is center of the 1.93 + //! rectangle and direction is its normal vector. 1.94 + aiLightSource_AREA = 0x5, 1.95 + 1.96 + /** This value is not used. It is just there to force the 1.97 + * compiler to map this enum to a 32 Bit integer. 1.98 + */ 1.99 +#ifndef SWIG 1.100 + _aiLightSource_Force32Bit = INT_MAX 1.101 +#endif 1.102 +}; 1.103 + 1.104 +// --------------------------------------------------------------------------- 1.105 +/** Helper structure to describe a light source. 1.106 + * 1.107 + * Assimp supports multiple sorts of light sources, including 1.108 + * directional, point and spot lights. All of them are defined with just 1.109 + * a single structure and distinguished by their parameters. 1.110 + * Note - some file formats (such as 3DS, ASE) export a "target point" - 1.111 + * the point a spot light is looking at (it can even be animated). Assimp 1.112 + * writes the target point as a subnode of a spotlights's main node, 1.113 + * called "<spotName>.Target". However, this is just additional information 1.114 + * then, the transformation tracks of the main node make the 1.115 + * spot light already point in the right direction. 1.116 +*/ 1.117 +struct aiLight 1.118 +{ 1.119 + /** The name of the light source. 1.120 + * 1.121 + * There must be a node in the scenegraph with the same name. 1.122 + * This node specifies the position of the light in the scene 1.123 + * hierarchy and can be animated. 1.124 + */ 1.125 + C_STRUCT aiString mName; 1.126 + 1.127 + /** The type of the light source. 1.128 + * 1.129 + * aiLightSource_UNDEFINED is not a valid value for this member. 1.130 + */ 1.131 + C_ENUM aiLightSourceType mType; 1.132 + 1.133 + /** Position of the light source in space. Relative to the 1.134 + * transformation of the node corresponding to the light. 1.135 + * 1.136 + * The position is undefined for directional lights. 1.137 + */ 1.138 + C_STRUCT aiVector3D mPosition; 1.139 + 1.140 + /** Direction of the light source in space. Relative to the 1.141 + * transformation of the node corresponding to the light. 1.142 + * 1.143 + * The direction is undefined for point lights. The vector 1.144 + * may be normalized, but it needn't. 1.145 + */ 1.146 + C_STRUCT aiVector3D mDirection; 1.147 + 1.148 + /** Up direction of the light source in space. Relative to the 1.149 + * transformation of the node corresponding to the light. 1.150 + * 1.151 + * The direction is undefined for point lights. The vector 1.152 + * may be normalized, but it needn't. 1.153 + */ 1.154 + C_STRUCT aiVector3D mUp; 1.155 + 1.156 + /** Constant light attenuation factor. 1.157 + * 1.158 + * The intensity of the light source at a given distance 'd' from 1.159 + * the light's position is 1.160 + * @code 1.161 + * Atten = 1/( att0 + att1 * d + att2 * d*d) 1.162 + * @endcode 1.163 + * This member corresponds to the att0 variable in the equation. 1.164 + * Naturally undefined for directional lights. 1.165 + */ 1.166 + float mAttenuationConstant; 1.167 + 1.168 + /** Linear light attenuation factor. 1.169 + * 1.170 + * The intensity of the light source at a given distance 'd' from 1.171 + * the light's position is 1.172 + * @code 1.173 + * Atten = 1/( att0 + att1 * d + att2 * d*d) 1.174 + * @endcode 1.175 + * This member corresponds to the att1 variable in the equation. 1.176 + * Naturally undefined for directional lights. 1.177 + */ 1.178 + float mAttenuationLinear; 1.179 + 1.180 + /** Quadratic light attenuation factor. 1.181 + * 1.182 + * The intensity of the light source at a given distance 'd' from 1.183 + * the light's position is 1.184 + * @code 1.185 + * Atten = 1/( att0 + att1 * d + att2 * d*d) 1.186 + * @endcode 1.187 + * This member corresponds to the att2 variable in the equation. 1.188 + * Naturally undefined for directional lights. 1.189 + */ 1.190 + float mAttenuationQuadratic; 1.191 + 1.192 + /** Diffuse color of the light source 1.193 + * 1.194 + * The diffuse light color is multiplied with the diffuse 1.195 + * material color to obtain the final color that contributes 1.196 + * to the diffuse shading term. 1.197 + */ 1.198 + C_STRUCT aiColor3D mColorDiffuse; 1.199 + 1.200 + /** Specular color of the light source 1.201 + * 1.202 + * The specular light color is multiplied with the specular 1.203 + * material color to obtain the final color that contributes 1.204 + * to the specular shading term. 1.205 + */ 1.206 + C_STRUCT aiColor3D mColorSpecular; 1.207 + 1.208 + /** Ambient color of the light source 1.209 + * 1.210 + * The ambient light color is multiplied with the ambient 1.211 + * material color to obtain the final color that contributes 1.212 + * to the ambient shading term. Most renderers will ignore 1.213 + * this value it, is just a remaining of the fixed-function pipeline 1.214 + * that is still supported by quite many file formats. 1.215 + */ 1.216 + C_STRUCT aiColor3D mColorAmbient; 1.217 + 1.218 + /** Inner angle of a spot light's light cone. 1.219 + * 1.220 + * The spot light has maximum influence on objects inside this 1.221 + * angle. The angle is given in radians. It is 2PI for point 1.222 + * lights and undefined for directional lights. 1.223 + */ 1.224 + float mAngleInnerCone; 1.225 + 1.226 + /** Outer angle of a spot light's light cone. 1.227 + * 1.228 + * The spot light does not affect objects outside this angle. 1.229 + * The angle is given in radians. It is 2PI for point lights and 1.230 + * undefined for directional lights. The outer angle must be 1.231 + * greater than or equal to the inner angle. 1.232 + * It is assumed that the application uses a smooth 1.233 + * interpolation between the inner and the outer cone of the 1.234 + * spot light. 1.235 + */ 1.236 + float mAngleOuterCone; 1.237 + 1.238 + /** Size of area light source. */ 1.239 + C_STRUCT aiVector2D mSize; 1.240 + 1.241 +#ifdef __cplusplus 1.242 + 1.243 + aiLight() AI_NO_EXCEPT 1.244 + : mType (aiLightSource_UNDEFINED) 1.245 + , mAttenuationConstant (0.f) 1.246 + , mAttenuationLinear (1.f) 1.247 + , mAttenuationQuadratic (0.f) 1.248 + , mAngleInnerCone ((float)AI_MATH_TWO_PI) 1.249 + , mAngleOuterCone ((float)AI_MATH_TWO_PI) 1.250 + , mSize (0.f, 0.f) 1.251 + { 1.252 + } 1.253 + 1.254 +#endif 1.255 +}; 1.256 + 1.257 +#ifdef __cplusplus 1.258 +} 1.259 +#endif 1.260 + 1.261 + 1.262 +#endif // !! AI_LIGHT_H_INC