Morph-SynRJ

view efx_harmonics.h @ 0:22de913c2d84

morph-synrj intro
author "Cedric Pinson <cedric.pinson@alcove.fr> <mornifle@plopbyte.net>"
date Tue Nov 27 15:23:52 2007 +0100 (2007-11-27)
parents
children
line source
1 /** @file stv_harmonics.h
2 *
3 * @brief Sphericals Harmonics Effect
4 *
5 ******************************************************************************************************************
6 *
7 * @author Stv based on Paul Bourke's web site (http://astronomy.swin.edu.au/~pbourke/surfaces/sphericalh/)
8 *
9 * @date Created 2003/10
10 *
11 * @version $Id: efx_harmonics.h,v 1.6 2004/01/17 08:37:27 psc80 Exp $
12 *
13 ******************************************************************************************************************/
15 #ifndef EFX_SPHERICAL_H
16 #define EFX_SPHERICAL_H
18 #include "mth_vector3.h"
19 #include "mth_vector2.h"
20 #include "cmn_shape.h"
22 class efxSpherical_t;
24 class efxSphericalShape_t : public cmnSquareShape_t
25 {
26 int params[8];
28 mth::Vector3_t ComputeVertex(double _theta, double _phi,double _scale);
29 mth::Vector3_t ComputeNormal(const mth::Vector3_t& _a,const mth::Vector3_t& _b, const mth::Vector3_t& _c);
31 GLuint textureBase;
33 public:
35 efxSphericalShape_t():cmnSquareShape_t() {textureBase=0;}
37 // specify params or use random
38 void Params(int _a0,int _a1,int _a2,int _a3,int _a4,int _a5,int _a6,int _a7);
39 void RandomizeParams();
41 // generate shape with a scale factor
42 void Generate(float _scale,bool _reverse=false);
44 void Draw() ;
45 void SetTexture(GLuint _id) { textureBase=_id;}
47 };
51 class efxSpherical_t
52 {
54 int nbShapes;
55 int resolutions;
57 efxSphericalShape_t* shapes;
59 //shape used to morph
60 efxSphericalShape_t morph;
62 // shared uvs
63 mth::Vector2_t* uvs;
65 public:
67 efxSpherical_t(){ shapes=0;uvs=0;}
68 ~efxSpherical_t(){}
71 void Init(int _nbShapes,int _resolutions,float _scale=15);
74 int NbShapes() { return nbShapes;}
76 int ResolutionOfGrid() { return resolutions;}
78 void Kill();
81 /// morph a shape 1 with a shape 2 with a range t [0-1]. the result is into morph, given by MorphShape
82 void MakeMorph(int _shape1,int _shape2,float _t);
84 efxSphericalShape_t& MorphShape() { return morph;}
87 efxSphericalShape_t& Shape(int _i) { return shapes[_i];}
89 void SetTexture(GLuint _id);
91 };
94 #endif