1 /* 2 *------------------------------------------------------------ 3 * Copyright(c) 2009-2010 by Digital Media Professionals Inc. 4 * All rights reserved. 5 *------------------------------------------------------------ 6 * This source code is the confidential and proprietary 7 * of Digital Media Professionals Inc. 8 *------------------------------------------------------------ 9 */ 10 #ifndef __GAS_H__ 11 #define __GAS_H__ 12 13 /* 14 * Definitions 15 */ 16 17 #include <nn/gx.h> 18 #include <nn/math.h> 19 20 #define APP_NAME "PartsysGas" 21 22 /* accumulation buffer should have same size as display buffer */ 23 #define GAS_ACC_WIDTH (nn::gx::DISPLAY0_WIDTH) 24 #define GAS_ACC_HEIGHT (nn::gx::DISPLAY0_HEIGHT) 25 /* texture should have powered by 2 size which is bigger than DISPLAY size */ 26 #define GAS_TEX_WIDTH (512) 27 #define GAS_TEX_HEIGHT (512) 28 29 /* Default buffer ID */ 30 #define DISPLAY_BUFFER (0) /* default frame buffer */ 31 32 /* Particle pattern */ 33 #define PARTICLE_PATTERNS (1) 34 #define PARTICLE_FILES "rom:/resources/ptcl0.tga" 35 36 struct _particleSys 37 { 38 GLuint m_pSysPositionID; 39 40 nn::math::Matrix44 m_partsys_center; 41 nn::math::Matrix44 m_partsys_color; 42 nn::math::Matrix44 m_partsys_radius; 43 nn::math::Matrix44 m_partsys_aspect; 44 45 float m_speed; 46 float m_particleCountMax; 47 float m_size_min_max[2]; 48 float m_prng[4]; /* constant for the Pseudo Random Number Generator (modulo based) */ 49 float m_random_seed[4]; /* seeds for the PRNG */ 50 51 float simulationTime; /* application side. Holds the current time for particle system */ 52 float dTime; /* application side. Holds the time interval between each frame */ 53 int NFrame; /* application side. Number of frames for this particle system */ 54 }; 55 56 57 struct gas_data 58 { 59 /* Gas geometry definition (accumulation pass) */ 60 struct _particleSys pSys; 61 GLuint pattern[PARTICLE_PATTERNS]; /* Texture ID applied to each particle */ 62 GLfloat _dela_z; /* used in accumulation pass, to control final alpha blending*/ 63 64 GLint _autoAcc; /* used in post synthesis pass */ 65 float _densMax; /* used in post synthesis pass. Shading control*/ 66 GLfloat _lightDirX; /* used in post synthesis pass. Shading control */ 67 GLfloat _lightDirY; /* used in post synthesis pass. Shading control */ 68 GLfloat _LightXY[4]; /* used in post synthesis pass. Shading control */ 69 GLfloat _LightZ[4]; /* used in post synthesis pass. Shading control */ 70 GLuint FogLut_ID; /* used in post synthesis pass. Look up table ID */ 71 GLuint CollectionLUT_ID; /* used in post synthesis pass. Texture collection ID */ 72 GLuint gasTransfert_ID[3]; /* used in post synthesis pass. Lookup table ID for gas color look up table */ 73 float RR[16],GG[16],BB[16]; /* used in post synthesis pass. Lookup table for gas color content */ 74 float fogTable[256]; /* used in post synthesis pass. Fog look up table for density to alpha conversion*/ 75 GLenum shadingDensitySrc; /* used in post synthesis pass. Density selection for shading input*/ 76 GLenum colorLutInput; /* used in post synthesis pass. Input selection for the gas color look up*/ 77 /* Gas geometry definition / simple quad (post synthesis pass) */ 78 GLuint quad_index_ID; /* used in post synthesis pass. Vertex Index buffer ID */ 79 GLuint quad_vertBuf_ID; /* used in post synthesis pass. Vertex position buffer ID */ 80 GLuint quad_texBuf_ID; /* used in post synthesis pass. Vertex Texture coordinates buffer ID */ 81 GLuint quad_colBuf_ID; /* used in post synthesis pass. Vertex color buffer ID */ 82 83 }; 84 85 /* 86 * Function declarations 87 */ 88 89 /* buffer initialization */ 90 void GasInitialize(void); 91 92 /* gaseous object data structure default initialization */ 93 void DefaultGasObject(struct gas_data *gas,float *gasColorTable); 94 95 /* utility function to update the gas color lookup table */ 96 void SetGasColorTable(struct gas_data *gas,float *gasColorTable); 97 98 /* accumulation pass */ 99 void GasAccumulation(); 100 101 /* shading pass */ 102 void GasShading(void); 103 104 105 #endif /* __GAS_H__ */ 106