Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-02-21 09:30:08

0001 /*
0002 ---------------------------------------------------------------------------
0003 Open Asset Import Library (assimp)
0004 ---------------------------------------------------------------------------
0005 
0006 Copyright (c) 2006-2024, assimp team
0007 
0008 All rights reserved.
0009 
0010 Redistribution and use of this software in source and binary forms,
0011 with or without modification, are permitted provided that the following
0012 conditions are met:
0013 
0014 * Redistributions of source code must retain the above
0015   copyright notice, this list of conditions and the
0016   following disclaimer.
0017 
0018 * Redistributions in binary form must reproduce the above
0019   copyright notice, this list of conditions and the
0020   following disclaimer in the documentation and/or other
0021   materials provided with the distribution.
0022 
0023 * Neither the name of the assimp team, nor the names of its
0024   contributors may be used to endorse or promote products
0025   derived from this software without specific prior
0026   written permission of the assimp team.
0027 
0028 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
0029 "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
0030 LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
0031 A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
0032 OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
0033 SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
0034 LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
0035 DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
0036 THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
0037 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
0038 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
0039 ---------------------------------------------------------------------------
0040 */
0041 
0042 /** @file light.h
0043  *  @brief Defines the aiLight data structure
0044  */
0045 
0046 #pragma once
0047 #ifndef AI_LIGHT_H_INC
0048 #define AI_LIGHT_H_INC
0049 
0050 #ifdef __GNUC__
0051 #   pragma GCC system_header
0052 #endif
0053 
0054 #include <assimp/types.h>
0055 
0056 #ifdef __cplusplus
0057 extern "C" {
0058 #endif
0059 
0060 // ---------------------------------------------------------------------------
0061 /** Enumerates all supported types of light sources.
0062  */
0063 enum aiLightSourceType {
0064     aiLightSource_UNDEFINED     = 0x0,
0065 
0066     //! A directional light source has a well-defined direction
0067     //! but is infinitely far away. That's quite a good
0068     //! approximation for sun light.
0069     aiLightSource_DIRECTIONAL   = 0x1,
0070 
0071     //! A point light source has a well-defined position
0072     //! in space but no direction - it emits light in all
0073     //! directions. A normal bulb is a point light.
0074     aiLightSource_POINT         = 0x2,
0075 
0076     //! A spot light source emits light in a specific
0077     //! angle. It has a position and a direction it is pointing to.
0078     //! A good example for a spot light is a light spot in
0079     //! sport arenas.
0080     aiLightSource_SPOT          = 0x3,
0081 
0082     //! The generic light level of the world, including the bounces
0083     //! of all other light sources.
0084     //! Typically, there's at most one ambient light in a scene.
0085     //! This light type doesn't have a valid position, direction, or
0086     //! other properties, just a color.
0087     aiLightSource_AMBIENT       = 0x4,
0088 
0089     //! An area light is a rectangle with predefined size that uniformly
0090     //! emits light from one of its sides. The position is center of the
0091     //! rectangle and direction is its normal vector.
0092     aiLightSource_AREA          = 0x5,
0093 
0094     /** This value is not used. It is just there to force the
0095      *  compiler to map this enum to a 32 Bit integer.
0096      */
0097 #ifndef SWIG
0098     _aiLightSource_Force32Bit = INT_MAX
0099 #endif
0100 };
0101 
0102 // ---------------------------------------------------------------------------
0103 /** Helper structure to describe a light source.
0104  *
0105  *  Assimp supports multiple sorts of light sources, including
0106  *  directional, point and spot lights. All of them are defined with just
0107  *  a single structure and distinguished by their parameters.
0108  *  Note - some file formats (such as 3DS, ASE) export a "target point" -
0109  *  the point a spot light is looking at (it can even be animated). Assimp
0110  *  writes the target point as a sub-node of a spot-lights's main node,
0111  *  called "<spotName>.Target". However, this is just additional information
0112  *  then, the transformation tracks of the main node make the
0113  *  spot light already point in the right direction.
0114 */
0115 struct aiLight {
0116     /** The name of the light source.
0117      *
0118      *  There must be a node in the scene-graph with the same name.
0119      *  This node specifies the position of the light in the scene
0120      *  hierarchy and can be animated.
0121      */
0122     C_STRUCT aiString mName;
0123 
0124     /** The type of the light source.
0125      *
0126      * aiLightSource_UNDEFINED is not a valid value for this member.
0127      */
0128     C_ENUM aiLightSourceType mType;
0129 
0130     /** Position of the light source in space. Relative to the
0131      *  transformation of the node corresponding to the light.
0132      *
0133      *  The position is undefined for directional lights.
0134      */
0135     C_STRUCT aiVector3D mPosition;
0136 
0137     /** Direction of the light source in space. Relative to the
0138      *  transformation of the node corresponding to the light.
0139      *
0140      *  The direction is undefined for point lights. The vector
0141      *  may be normalized, but it needn't.
0142      */
0143     C_STRUCT aiVector3D mDirection;
0144 
0145     /** Up direction of the light source in space. Relative to the
0146      *  transformation of the node corresponding to the light.
0147      *
0148      *  The direction is undefined for point lights. The vector
0149      *  may be normalized, but it needn't.
0150      */
0151     C_STRUCT aiVector3D mUp;
0152 
0153     /** Constant light attenuation factor.
0154      *
0155      *  The intensity of the light source at a given distance 'd' from
0156      *  the light's position is
0157      *  @code
0158      *  Atten = 1/( att0 + att1 * d + att2 * d*d)
0159      *  @endcode
0160      *  This member corresponds to the att0 variable in the equation.
0161      *  Naturally undefined for directional lights.
0162      */
0163     float mAttenuationConstant;
0164 
0165     /** Linear light attenuation factor.
0166      *
0167      *  The intensity of the light source at a given distance 'd' from
0168      *  the light's position is
0169      *  @code
0170      *  Atten = 1/( att0 + att1 * d + att2 * d*d)
0171      *  @endcode
0172      *  This member corresponds to the att1 variable in the equation.
0173      *  Naturally undefined for directional lights.
0174      */
0175     float mAttenuationLinear;
0176 
0177     /** Quadratic light attenuation factor.
0178      *
0179      *  The intensity of the light source at a given distance 'd' from
0180      *  the light's position is
0181      *  @code
0182      *  Atten = 1/( att0 + att1 * d + att2 * d*d)
0183      *  @endcode
0184      *  This member corresponds to the att2 variable in the equation.
0185      *  Naturally undefined for directional lights.
0186      */
0187     float mAttenuationQuadratic;
0188 
0189     /** Diffuse color of the light source
0190      *
0191      *  The diffuse light color is multiplied with the diffuse
0192      *  material color to obtain the final color that contributes
0193      *  to the diffuse shading term.
0194      */
0195     C_STRUCT aiColor3D mColorDiffuse;
0196 
0197     /** Specular color of the light source
0198      *
0199      *  The specular light color is multiplied with the specular
0200      *  material color to obtain the final color that contributes
0201      *  to the specular shading term.
0202      */
0203     C_STRUCT aiColor3D mColorSpecular;
0204 
0205     /** Ambient color of the light source
0206      *
0207      *  The ambient light color is multiplied with the ambient
0208      *  material color to obtain the final color that contributes
0209      *  to the ambient shading term. Most renderers will ignore
0210      *  this value it, is just a remaining of the fixed-function pipeline
0211      *  that is still supported by quite many file formats.
0212      */
0213     C_STRUCT aiColor3D mColorAmbient;
0214 
0215     /** Inner angle of a spot light's light cone.
0216      *
0217      *  The spot light has maximum influence on objects inside this
0218      *  angle. The angle is given in radians. It is 2PI for point
0219      *  lights and undefined for directional lights.
0220      */
0221     float mAngleInnerCone;
0222 
0223     /** Outer angle of a spot light's light cone.
0224      *
0225      *  The spot light does not affect objects outside this angle.
0226      *  The angle is given in radians. It is 2PI for point lights and
0227      *  undefined for directional lights. The outer angle must be
0228      *  greater than or equal to the inner angle.
0229      *  It is assumed that the application uses a smooth
0230      *  interpolation between the inner and the outer cone of the
0231      *  spot light.
0232      */
0233     float mAngleOuterCone;
0234 
0235     /** Size of area light source. */
0236     C_STRUCT aiVector2D mSize;
0237 
0238 #ifdef __cplusplus
0239 
0240     aiLight() AI_NO_EXCEPT
0241         :   mType                 (aiLightSource_UNDEFINED)
0242         ,   mAttenuationConstant  (0.f)
0243         ,   mAttenuationLinear    (1.f)
0244         ,   mAttenuationQuadratic (0.f)
0245         ,   mAngleInnerCone       ((float)AI_MATH_TWO_PI)
0246         ,   mAngleOuterCone       ((float)AI_MATH_TWO_PI)
0247         ,   mSize                 (0.f, 0.f)
0248     {
0249     }
0250 
0251 #endif
0252 };
0253 
0254 #ifdef __cplusplus
0255 }
0256 #endif
0257 
0258 #endif // !! AI_LIGHT_H_INC