//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
-// Foundation, 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA
+// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
//
//
# include <simgear_config.h>
#endif
+#include <osg/ref_ptr>
+#include <osg/Texture2D>
+
#include <simgear/compiler.h>
#include <plib/sg.h>
-#include <plib/ssg.h>
#include <simgear/math/sg_random.h>
#include <simgear/misc/sg_path.hxx>
-#include STL_ALGORITHM
+#include <algorithm>
#include SG_GLU_H
#include "cloudfield.hxx"
/*
*/
-static ssgTexture *cloudTextures[SGNewCloud::CLTexture_max];
+static osg::ref_ptr<osg::Texture2D> cloudTextures[SGNewCloud::CLTexture_max];
bool SGNewCloud::useAnisotropic = true;
SGBbCache *SGNewCloud::cldCache = 0;
static bool texturesLoaded = false;
static float minx, maxx, miny, maxy, minz, maxz;
+static int cloudIdCounter = 1;
float SGNewCloud::nearRadius = 3500.0f;
bool SGNewCloud::lowQuality = false;
pauseLength = 0.0f;
last_step = -1.0f;
familly = CLFamilly_nn;
- cloudId = (int) this;
+ cloudId = ++cloudIdCounter;
sgSetVec3(center, 0.0f, 0.0f, 0.0f);
sgSetVec3(cloudpos, 0.0f, 0.0f, 0.0f);
radius = 0.0f;
cloud_path.set(tex_path);
cloud_path.append("cl_cumulus.rgb");
- cloudTextures[ CLTexture_cumulus ] = new ssgTexture( cloud_path.str().c_str(), false, false, false );
- cloudTextures[ CLTexture_cumulus ]->ref();
+ // OSGFIXME
+// cloudTextures[ CLTexture_cumulus ] = new osg::Texture2D( cloud_path.str().c_str(), false, false, false );
+ cloudTextures[ CLTexture_cumulus ] = new osg::Texture2D;
cloud_path.set(tex_path);
cloud_path.append("cl_stratus.rgb");
- cloudTextures[ CLTexture_stratus ] = new ssgTexture( cloud_path.str().c_str(), false, false, false );
- cloudTextures[ CLTexture_stratus ]->ref();
+ // OSGFIXME
+// cloudTextures[ CLTexture_stratus ] = new ssgTexture( cloud_path.str().c_str(), false, false, false );
+ cloudTextures[ CLTexture_stratus ] = new osg::Texture2D;
}
sgSubVec3( deltaPos, newSpriteDef.pos, thisBox->pos );
sgAddVec3( thisBox->center, deltaPos );
- r = r * 0.65f; // 0.5 * 1.xxx
+ r = r * 0.70f; // 0.5 * 1.xxx
if( x - r < minx )
minx = x - r;
if( y - r < miny )
// in practice there is no texture switch (atm)
if( previousTexture != thisTexture ) {
previousTexture = thisTexture;
- glBindTexture(GL_TEXTURE_2D, cloudTextures[thisTexture]->getHandle());
+ // OSGFIXME
+// glBindTexture(GL_TEXTURE_2D, cloudTextures[thisTexture]->getHandle());
}
sgVec3 translate;
sgVec3 pos;
sgSetVec3( pos, translate[SG_X], translate[SG_Z], translate[SG_Y] );
sgCopyVec3( translate, pos );
- sgNormaliseVec3( translate );
-#if 0
- // change view angle when near a sprite
- sgVec3 trans={translate[0], translate[2], translate[1]};
- float angle = sgScalarProductVec3( SGCloudField::view_vec, trans );
- if( fabs(angle) < 0.85f ) {
- // view not ok from under
- sgSetVec3( translate, -SGCloudField::view_vec[0],-SGCloudField::view_vec[2],-SGCloudField::view_vec[1] );
-// sgSetVec3( l0,1,0,0 );
-// sgSetVec3( l1,1,0,0 );
-// sgSetVec3( l2,1,0,0 );
-// sgSetVec3( l3,1,0,0 );
- }
-#endif
+ translate[2] -= FakeEyePos[1];
+// sgNormaliseVec3( translate );
+ float dist_sprite = sgLengthVec3 ( translate );
+ sgScaleVec3 ( translate, SG_ONE / dist_sprite ) ;
sgVec3 x, y, up = {0.0f, 0.0f, 1.0f};
- sgVectorProductVec3(x, translate, up);
- sgVectorProductVec3(y, x, translate);
+ if( dist_sprite > 2*r ) {
+ sgVectorProductVec3(x, translate, up);
+ sgVectorProductVec3(y, x, translate);
+ } else {
+ sgCopyVec3( x, SGCloudField::view_X );
+ sgCopyVec3( y, SGCloudField::view_Y );
+ }
sgScaleVec3(x, r);
sgScaleVec3(y, r);
sgVec3 pos;
sgSetVec3( pos, translate[SG_X], translate[SG_Z], translate[SG_Y] );
sgCopyVec3( translate, pos );
+ pos[2] += deltaPos[1];
+
sgNormaliseVec3( translate );
sgVec3 x, y, up = {0.0f, 0.0f, 1.0f};
sgVectorProductVec3(x, translate, up);
sgVec3 deltaPos;
sgCopyVec3( deltaPos, FakeEyePos);
+ deltaPos[1] = 0.0;
sgSubVec3( dist, center, FakeEyePos);
float dist_center = sgLengthVec3(dist);
}
// draw the newly built BB or an old one
glBindTexture(GL_TEXTURE_2D, texID);
- RenderBB(deltaPos, first_time, dist_center);
+ RenderBB(FakeEyePos, first_time, dist_center);
}
}