*** empty log message ***
This commit is contained in:
@@ -11,6 +11,7 @@
|
||||
* OpenSceneGraph Public License for more details.
|
||||
*/
|
||||
#include <osg/CullStack>
|
||||
#include <osg/Timer>
|
||||
|
||||
using namespace osg;
|
||||
|
||||
@@ -199,27 +200,79 @@ void CullStack::pushModelViewMatrix(RefMatrix* matrix)
|
||||
_modelviewStack.push_back(matrix);
|
||||
|
||||
pushCullingSet();
|
||||
|
||||
//osg::Timer timer;
|
||||
|
||||
//osg::Timer_t tick_1 = timer.tick();
|
||||
|
||||
// fast method for computing the eye point in local coords which doesn't require the inverse matrix.
|
||||
const float x_0 = (*matrix)(0,0);
|
||||
const float x_1 = (*matrix)(1,0);
|
||||
const float x_2 = (*matrix)(2,0);
|
||||
const float x_scale = (*matrix)(3,0) / -(x_0*x_0+x_1*x_1+x_2*x_2);
|
||||
const float x_len2 = (x_0*x_0+x_1*x_1+x_2*x_2);
|
||||
|
||||
const float y_0 = (*matrix)(0,1);
|
||||
const float y_1 = (*matrix)(1,1);
|
||||
const float y_2 = (*matrix)(2,1);
|
||||
const float y_scale = (*matrix)(3,1) / -(y_0*y_0+y_1*y_1+y_2*y_2);
|
||||
const float y_len2 = (y_0*y_0+y_1*y_1+y_2*y_2);
|
||||
|
||||
|
||||
const float z_0 = (*matrix)(0,2);
|
||||
const float z_1 = (*matrix)(1,2);
|
||||
const float z_2 = (*matrix)(2,2);
|
||||
const float z_scale = (*matrix)(3,2) / -(z_0*z_0+z_1*z_1+z_2*z_2);
|
||||
const float z_len2 = (z_0*z_0+z_1*z_1+z_2*z_2);
|
||||
|
||||
|
||||
bool useFastPath = (osg::equivalent(x_len2,y_len2) &&
|
||||
osg::equivalent(x_len2,z_len2) &&
|
||||
osg::equivalent(y_len2,z_len2));
|
||||
|
||||
// std::cout<<"x_len2 = "<<x_len2 << "\ty_len2 = "<<y_len2 << "\tz_len2 = "<<z_len2 << std::endl;
|
||||
|
||||
if (useFastPath)
|
||||
{
|
||||
const float xyz_len0 = x_0*x_0 + y_0*y_0 + z_0*z_0;
|
||||
const float xyz_len1 = x_1*x_1 + y_1*y_1 + z_1*z_1;
|
||||
const float xyz_len2 = x_2*x_2 + y_2*y_2 + z_2*z_2;
|
||||
|
||||
// std::cout<<"xyz_len0 = "<<xyz_len0 << "\txyz_len2 = "<<xyz_len1 << "\txyz_len2 = "<<xyz_len2 << std::endl;
|
||||
|
||||
if (!osg::equivalent(xyz_len0,xyz_len1) ||
|
||||
!osg::equivalent(xyz_len0,xyz_len2) ||
|
||||
!osg::equivalent(xyz_len1,xyz_len2)) useFastPath = false;
|
||||
|
||||
}
|
||||
|
||||
if (useFastPath)
|
||||
{
|
||||
// compute the eye point in local coords using a fast technique
|
||||
// which assumes that only proportional scaling, no shearing, this
|
||||
// is satisfied for most scene graph usage.
|
||||
|
||||
const float x_scale = (*matrix)(3,0) / -x_len2;
|
||||
const float y_scale = (*matrix)(3,1) / -y_len2;
|
||||
const float z_scale = (*matrix)(3,2) / -z_len2;
|
||||
|
||||
osg::Vec3 fast_eyepoint(x_0*x_scale + y_0*y_scale + z_0*z_scale,
|
||||
x_1*x_scale + y_1*y_scale + z_1*z_scale,
|
||||
x_2*x_scale + y_2*y_scale + z_2*z_scale);
|
||||
|
||||
_eyePointStack.push_back(fast_eyepoint);
|
||||
|
||||
// std::cout<<"fast path "<<*matrix<<std::endl;
|
||||
}
|
||||
else
|
||||
{
|
||||
// shearing or no proportional scaling has been detected so we
|
||||
// callback to compute the inverse of the model view matrix and
|
||||
// transforming the eye point into local coords. This is ten
|
||||
// to thirty times slower than the above fast path.
|
||||
osg::Vec3 slow_eyepoint(osg::Matrix::inverse(*matrix).getTrans());
|
||||
_eyePointStack.push_back(slow_eyepoint);
|
||||
|
||||
//std::cout<<"slow path "<<*matrix<<std::endl;
|
||||
}
|
||||
|
||||
_eyePointStack.push_back(osg::Vec3(x_0*x_scale + y_0*y_scale + z_0*z_scale,
|
||||
x_1*x_scale + y_1*y_scale + z_1*z_scale,
|
||||
x_2*x_scale + y_2*y_scale + z_2*z_scale));
|
||||
|
||||
|
||||
osg::Vec3 lookVector = getLookVectorLocal();
|
||||
|
||||
|
||||
@@ -257,8 +257,18 @@ struct ComputeBound : public Drawable::PrimitiveFunctor
|
||||
{
|
||||
ComputeBound():_vertices(0) {}
|
||||
|
||||
virtual void setVertexArray(unsigned int count,const Vec2* vertices)
|
||||
{
|
||||
notify(WARN)<<"ComputeBound does not support Vec2* vertex arrays"<<std::endl;
|
||||
}
|
||||
|
||||
virtual void setVertexArray(unsigned int,const Vec3* vertices) { _vertices = vertices; }
|
||||
|
||||
virtual void setVertexArray(unsigned int count,const Vec4* vertices)
|
||||
{
|
||||
notify(WARN)<<"ComputeBound does not support Vec4* vertex arrays"<<std::endl;
|
||||
}
|
||||
|
||||
virtual void drawArrays(GLenum,GLint first,GLsizei count)
|
||||
{
|
||||
if (_vertices)
|
||||
@@ -305,8 +315,12 @@ struct ComputeBound : public Drawable::PrimitiveFunctor
|
||||
}
|
||||
|
||||
virtual void begin(GLenum) {}
|
||||
virtual void vertex(const Vec2& vert) { _bb.expandBy(osg::Vec3(vert[0],vert[1],0.0f)); }
|
||||
virtual void vertex(const Vec3& vert) { _bb.expandBy(vert); }
|
||||
virtual void vertex(const Vec4& vert) { if (vert[3]!=0.0f) _bb.expandBy(osg::Vec3(vert[0],vert[1],vert[2])/vert[3]); }
|
||||
virtual void vertex(float x,float y) { _bb.expandBy(x,y,1.0f); }
|
||||
virtual void vertex(float x,float y,float z) { _bb.expandBy(x,y,z); }
|
||||
virtual void vertex(float x,float y,float z,float w) { if (w!=0.0f) _bb.expandBy(x/w,y/w,z/w); }
|
||||
virtual void end() {}
|
||||
|
||||
const Vec3* _vertices;
|
||||
|
||||
@@ -83,6 +83,7 @@ CXXFILES =\
|
||||
Texture3D.cpp\
|
||||
TextureCubeMap.cpp\
|
||||
TextureRectangle.cpp\
|
||||
TransformAttributeFunctor.cpp\
|
||||
Timer.cpp\
|
||||
Transform.cpp\
|
||||
UnitTestFramework.cpp\
|
||||
|
||||
@@ -16,22 +16,26 @@
|
||||
|
||||
using namespace osg;
|
||||
|
||||
class DrawVertex
|
||||
class DrawVertex : public osg::ConstValueVisitor
|
||||
{
|
||||
public:
|
||||
|
||||
DrawVertex(const Vec3Array* vertices,const IndexArray* indices):
|
||||
DrawVertex(const Array* vertices,const IndexArray* indices):
|
||||
_vertices(vertices),
|
||||
_indices(indices) {}
|
||||
|
||||
void operator () (unsigned int pos)
|
||||
{
|
||||
if (_indices) glVertex3fv((*_vertices)[_indices->index(pos)].ptr());
|
||||
else glVertex3fv((*_vertices)[pos].ptr());
|
||||
if (_indices) _vertices->accept(_indices->index(pos),*this);
|
||||
else _vertices->accept(pos,*this);
|
||||
}
|
||||
|
||||
const Vec3Array* _vertices;
|
||||
const IndexArray* _indices;
|
||||
virtual void apply(const Vec2& v) { glVertex2fv(v.ptr()); }
|
||||
virtual void apply(const Vec3& v) { glVertex3fv(v.ptr()); }
|
||||
virtual void apply(const Vec4& v) { glVertex4fv(v.ptr()); }
|
||||
|
||||
const Array* _vertices;
|
||||
const IndexArray* _indices;
|
||||
};
|
||||
|
||||
class DrawNormal
|
||||
@@ -813,7 +817,7 @@ void Geometry::drawImplementation(State& state) const
|
||||
//
|
||||
|
||||
if( _vertexArray.valid() )
|
||||
state.setVertexPointer(3,GL_FLOAT,0,_vertexArray->getDataPointer());
|
||||
state.setVertexPointer(_vertexArray->getDataSize(),_vertexArray->getDataType(),0,_vertexArray->getDataPointer());
|
||||
else
|
||||
state.disableVertexPointer();
|
||||
|
||||
@@ -1547,13 +1551,26 @@ void Geometry::accept(ConstAttributeFunctor& af) const
|
||||
|
||||
void Geometry::accept(PrimitiveFunctor& functor) const
|
||||
{
|
||||
if (!_vertexArray.valid() || _vertexArray->empty()) return;
|
||||
|
||||
|
||||
if (!_vertexArray.valid() || _vertexArray->getNumElements()==0) return;
|
||||
|
||||
if (!_vertexIndices.valid())
|
||||
{
|
||||
functor.setVertexArray(_vertexArray->size(),&(_vertexArray->front()));
|
||||
|
||||
switch(_vertexArray->getType())
|
||||
{
|
||||
case(Array::Vec2ArrayType):
|
||||
functor.setVertexArray(_vertexArray->getNumElements(),static_cast<const Vec2*>(_vertexArray->getDataPointer()));
|
||||
break;
|
||||
case(Array::Vec3ArrayType):
|
||||
functor.setVertexArray(_vertexArray->getNumElements(),static_cast<const Vec3*>(_vertexArray->getDataPointer()));
|
||||
break;
|
||||
case(Array::Vec4ArrayType):
|
||||
functor.setVertexArray(_vertexArray->getNumElements(),static_cast<const Vec4*>(_vertexArray->getDataPointer()));
|
||||
break;
|
||||
default:
|
||||
notify(WARN)<<"Warning: Geometry::accept(PrimtiveFunctor&) cannot handle Vertex Array type"<<_vertexArray->getType()<<std::endl;
|
||||
return;
|
||||
}
|
||||
|
||||
for(PrimitiveSetList::const_iterator itr=_primitives.begin();
|
||||
itr!=_primitives.end();
|
||||
++itr)
|
||||
@@ -1563,6 +1580,27 @@ void Geometry::accept(PrimitiveFunctor& functor) const
|
||||
}
|
||||
else
|
||||
{
|
||||
const Vec2Array* vec2Array = 0;
|
||||
const Vec3Array* vec3Array = 0;
|
||||
const Vec4Array* vec4Array = 0;
|
||||
Array::Type type = _vertexArray->getType();
|
||||
switch(type)
|
||||
{
|
||||
case(Array::Vec2ArrayType):
|
||||
vec2Array = static_cast<const Vec2Array*>(_vertexArray.get());
|
||||
break;
|
||||
case(Array::Vec3ArrayType):
|
||||
vec3Array = static_cast<const Vec3Array*>(_vertexArray.get());
|
||||
break;
|
||||
case(Array::Vec4ArrayType):
|
||||
vec4Array = static_cast<const Vec4Array*>(_vertexArray.get());
|
||||
break;
|
||||
default:
|
||||
notify(WARN)<<"Warning: Geometry::accept(PrimtiveFunctor&) cannot handle Vertex Array type"<<_vertexArray->getType()<<std::endl;
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
for(PrimitiveSetList::const_iterator itr=_primitives.begin();
|
||||
itr!=_primitives.end();
|
||||
++itr)
|
||||
@@ -1581,7 +1619,21 @@ void Geometry::accept(PrimitiveFunctor& functor) const
|
||||
vindex<indexEnd;
|
||||
++vindex)
|
||||
{
|
||||
functor.vertex((*_vertexArray)[_vertexIndices->index(vindex)]);
|
||||
switch(type)
|
||||
{
|
||||
case(Array::Vec2ArrayType):
|
||||
functor.vertex((*vec2Array)[_vertexIndices->index(vindex)]);
|
||||
break;
|
||||
case(Array::Vec3ArrayType):
|
||||
functor.vertex((*vec3Array)[_vertexIndices->index(vindex)]);
|
||||
break;
|
||||
case(Array::Vec4ArrayType):
|
||||
functor.vertex((*vec4Array)[_vertexIndices->index(vindex)]);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
functor.end();
|
||||
@@ -1601,7 +1653,20 @@ void Geometry::accept(PrimitiveFunctor& functor) const
|
||||
|
||||
for(GLsizei primCount=0;primCount<*primItr;++primCount)
|
||||
{
|
||||
functor.vertex((*_vertexArray)[_vertexIndices->index(vindex)]);
|
||||
switch(type)
|
||||
{
|
||||
case(Array::Vec2ArrayType):
|
||||
functor.vertex((*vec2Array)[_vertexIndices->index(vindex)]);
|
||||
break;
|
||||
case(Array::Vec3ArrayType):
|
||||
functor.vertex((*vec3Array)[_vertexIndices->index(vindex)]);
|
||||
break;
|
||||
case(Array::Vec4ArrayType):
|
||||
functor.vertex((*vec4Array)[_vertexIndices->index(vindex)]);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
++vindex;
|
||||
}
|
||||
|
||||
@@ -1621,7 +1686,20 @@ void Geometry::accept(PrimitiveFunctor& functor) const
|
||||
++primCount,++primItr)
|
||||
{
|
||||
unsigned int vindex=*primItr;
|
||||
functor.vertex((*_vertexArray)[_vertexIndices->index(vindex)]);
|
||||
switch(type)
|
||||
{
|
||||
case(Array::Vec2ArrayType):
|
||||
functor.vertex((*vec2Array)[_vertexIndices->index(vindex)]);
|
||||
break;
|
||||
case(Array::Vec3ArrayType):
|
||||
functor.vertex((*vec3Array)[_vertexIndices->index(vindex)]);
|
||||
break;
|
||||
case(Array::Vec4ArrayType):
|
||||
functor.vertex((*vec4Array)[_vertexIndices->index(vindex)]);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
functor.end();
|
||||
@@ -1637,7 +1715,20 @@ void Geometry::accept(PrimitiveFunctor& functor) const
|
||||
++primItr)
|
||||
{
|
||||
unsigned int vindex=*primItr;
|
||||
functor.vertex((*_vertexArray)[_vertexIndices->index(vindex)]);
|
||||
switch(type)
|
||||
{
|
||||
case(Array::Vec2ArrayType):
|
||||
functor.vertex((*vec2Array)[_vertexIndices->index(vindex)]);
|
||||
break;
|
||||
case(Array::Vec3ArrayType):
|
||||
functor.vertex((*vec3Array)[_vertexIndices->index(vindex)]);
|
||||
break;
|
||||
case(Array::Vec4ArrayType):
|
||||
functor.vertex((*vec4Array)[_vertexIndices->index(vindex)]);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
functor.end();
|
||||
@@ -1653,7 +1744,20 @@ void Geometry::accept(PrimitiveFunctor& functor) const
|
||||
++primItr)
|
||||
{
|
||||
unsigned int vindex=*primItr;
|
||||
functor.vertex((*_vertexArray)[_vertexIndices->index(vindex)]);
|
||||
switch(type)
|
||||
{
|
||||
case(Array::Vec2ArrayType):
|
||||
functor.vertex((*vec2Array)[_vertexIndices->index(vindex)]);
|
||||
break;
|
||||
case(Array::Vec3ArrayType):
|
||||
functor.vertex((*vec3Array)[_vertexIndices->index(vindex)]);
|
||||
break;
|
||||
case(Array::Vec4ArrayType):
|
||||
functor.vertex((*vec4Array)[_vertexIndices->index(vindex)]);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
functor.end();
|
||||
@@ -1742,7 +1846,7 @@ void Geometry::computeCorrectBindingsAndArraySizes()
|
||||
{
|
||||
if (verifyBindings()) return;
|
||||
|
||||
if (!_vertexArray.valid() || _vertexArray->empty())
|
||||
if (!_vertexArray.valid() || _vertexArray->getNumElements()==0)
|
||||
{
|
||||
// no vertex array so switch everything off.
|
||||
|
||||
|
||||
@@ -142,6 +142,7 @@ unsigned int Image::computeNumComponents(GLenum format)
|
||||
switch(format)
|
||||
{
|
||||
case(GL_COMPRESSED_RGB_S3TC_DXT1_EXT): return 3;
|
||||
case(GL_COMPRESSED_RGBA_S3TC_DXT1_EXT): return 4;
|
||||
case(GL_COMPRESSED_RGBA_S3TC_DXT3_EXT): return 4;
|
||||
case(GL_COMPRESSED_RGBA_S3TC_DXT5_EXT): return 4;
|
||||
case(GL_COLOR_INDEX): return 1;
|
||||
@@ -157,7 +158,11 @@ unsigned int Image::computeNumComponents(GLenum format)
|
||||
case(GL_BGRA): return 4;
|
||||
case(GL_LUMINANCE): return 1;
|
||||
case(GL_LUMINANCE_ALPHA): return 2;
|
||||
default: return 0;
|
||||
default:
|
||||
{
|
||||
std::cout<<"error format = "<<std::hex<<format<<std::endl;
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -167,6 +172,8 @@ unsigned int Image::computePixelSizeInBits(GLenum format,GLenum type)
|
||||
switch(type)
|
||||
{
|
||||
case(GL_COMPRESSED_RGB_S3TC_DXT1_EXT): return 4;
|
||||
|
||||
case(GL_COMPRESSED_RGBA_S3TC_DXT1_EXT): return 4;
|
||||
|
||||
case(GL_COMPRESSED_RGBA_S3TC_DXT3_EXT): return 8;
|
||||
|
||||
@@ -199,7 +206,11 @@ unsigned int Image::computePixelSizeInBits(GLenum format,GLenum type)
|
||||
case(GL_UNSIGNED_INT_8_8_8_8_REV):
|
||||
case(GL_UNSIGNED_INT_10_10_10_2):
|
||||
case(GL_UNSIGNED_INT_2_10_10_10_REV): return 32;
|
||||
default: return 0;
|
||||
default:
|
||||
{
|
||||
std::cout<<"error type = "<<type<<std::endl;
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -209,6 +220,7 @@ unsigned int Image::computeRowWidthInBytes(int width,GLenum format,GLenum type,i
|
||||
unsigned int pixelSize = computePixelSizeInBits(format,type);
|
||||
int widthInBits = width*pixelSize;
|
||||
int packingInBits = packing*8;
|
||||
std::cout << "width="<<width<<" pixelSize="<<pixelSize<<" width in bit="<<widthInBits<<" packingInBits="<<packingInBits<<" widthInBits%packingInBits="<<widthInBits%packingInBits<<std::endl;
|
||||
return (widthInBits/packingInBits + ((widthInBits%packingInBits)?1:0))*packing;
|
||||
}
|
||||
|
||||
@@ -227,6 +239,40 @@ int Image::computeNearestPowerOfTwo(int s,float bias)
|
||||
return s;
|
||||
}
|
||||
|
||||
unsigned int Image::getTotalSizeInBytesIncludingMipmaps() const
|
||||
{
|
||||
if (_mipmapData.empty())
|
||||
{
|
||||
// no mips so just return size of main image
|
||||
return getTotalSizeInBytes();
|
||||
}
|
||||
|
||||
int s = _s;
|
||||
int t = _t;
|
||||
int r = _r;
|
||||
|
||||
unsigned int maxValue = 0;
|
||||
for(unsigned int i=0;i<_mipmapData.size() && _mipmapData[i];++i)
|
||||
{
|
||||
s >>= 1;
|
||||
t >>= 1;
|
||||
r >>= 1;
|
||||
maxValue = maximum(maxValue,_mipmapData[i]);
|
||||
}
|
||||
|
||||
if (s==0) s=1;
|
||||
if (t==0) t=1;
|
||||
if (r==0) r=1;
|
||||
|
||||
unsigned int sizeOfLastMipMap = computeRowWidthInBytes(s,_pixelFormat,_dataType,_packing)*
|
||||
r*t;
|
||||
|
||||
// std::cout<<"sizeOfLastMipMap="<<sizeOfLastMipMap<<"\ts="<<s<<"\tt="<<t<<"\tr"<<r<<std::endl;
|
||||
|
||||
return maxValue+sizeOfLastMipMap;
|
||||
}
|
||||
|
||||
|
||||
void Image::setInternalTextureFormat(GLint internalFormat)
|
||||
{
|
||||
// won't do any sanity checking right now, leave it to
|
||||
|
||||
@@ -53,17 +53,17 @@ void Material::setAmbient(Face face, const Vec4& ambient )
|
||||
case(FRONT):
|
||||
_ambientFrontAndBack = false;
|
||||
_ambientFront = ambient;
|
||||
clampArray4BetweenRange(_ambientFront,0.0f,1.0f,"osg::Material::setAmbient(..)");
|
||||
//clampArray4BetweenRange(_ambientFront,0.0f,1.0f,"osg::Material::setAmbient(..)");
|
||||
break;
|
||||
case(BACK):
|
||||
_ambientFrontAndBack = false;
|
||||
_ambientBack = ambient;
|
||||
clampArray4BetweenRange(_ambientBack,0.0f,1.0f,"Material::setAmbient(..)");
|
||||
//clampArray4BetweenRange(_ambientBack,0.0f,1.0f,"Material::setAmbient(..)");
|
||||
break;
|
||||
case(FRONT_AND_BACK):
|
||||
_ambientFrontAndBack = true;
|
||||
_ambientFront = ambient;
|
||||
clampArray4BetweenRange(_ambientFront,0.0f,1.0f,"Material::setAmbient(..)");
|
||||
//clampArray4BetweenRange(_ambientFront,0.0f,1.0f,"Material::setAmbient(..)");
|
||||
_ambientBack = _ambientFront;
|
||||
break;
|
||||
default:
|
||||
@@ -100,17 +100,17 @@ void Material::setDiffuse(Face face, const Vec4& diffuse )
|
||||
case(FRONT):
|
||||
_diffuseFrontAndBack = false;
|
||||
_diffuseFront = diffuse;
|
||||
clampArray4BetweenRange(_diffuseFront,0.0f,1.0f,"Material::setDiffuse(..)");
|
||||
//clampArray4BetweenRange(_diffuseFront,0.0f,1.0f,"Material::setDiffuse(..)");
|
||||
break;
|
||||
case(BACK):
|
||||
_diffuseFrontAndBack = false;
|
||||
_diffuseBack = diffuse;
|
||||
clampArray4BetweenRange(_diffuseBack,0.0f,1.0f,"Material::setDiffuse(..)");
|
||||
//clampArray4BetweenRange(_diffuseBack,0.0f,1.0f,"Material::setDiffuse(..)");
|
||||
break;
|
||||
case(FRONT_AND_BACK):
|
||||
_diffuseFrontAndBack = true;
|
||||
_diffuseFront = diffuse;
|
||||
clampArray4BetweenRange(_diffuseFront,0.0f,1.0f,"Material::setDiffuse(..)");
|
||||
//clampArray4BetweenRange(_diffuseFront,0.0f,1.0f,"Material::setDiffuse(..)");
|
||||
_diffuseBack = _diffuseFront;
|
||||
break;
|
||||
default:
|
||||
@@ -148,17 +148,17 @@ void Material::setSpecular(Face face, const Vec4& specular )
|
||||
case(FRONT):
|
||||
_specularFrontAndBack = false;
|
||||
_specularFront = specular;
|
||||
clampArray4BetweenRange(_specularFront,0.0f,1.0f,"Material::setSpecular(..)");
|
||||
//clampArray4BetweenRange(_specularFront,0.0f,1.0f,"Material::setSpecular(..)");
|
||||
break;
|
||||
case(BACK):
|
||||
_specularFrontAndBack = false;
|
||||
_specularBack = specular;
|
||||
clampArray4BetweenRange(_specularBack,0.0f,1.0f,"Material::setSpecular(..)");
|
||||
//clampArray4BetweenRange(_specularBack,0.0f,1.0f,"Material::setSpecular(..)");
|
||||
break;
|
||||
case(FRONT_AND_BACK):
|
||||
_specularFrontAndBack = true;
|
||||
_specularFront = specular;
|
||||
clampArray4BetweenRange(_specularFront,0.0f,1.0f,"Material::setSpecular(..)");
|
||||
//clampArray4BetweenRange(_specularFront,0.0f,1.0f,"Material::setSpecular(..)");
|
||||
_specularBack = _specularFront;
|
||||
break;
|
||||
default:
|
||||
@@ -196,17 +196,17 @@ void Material::setEmission(Face face, const Vec4& emission )
|
||||
case(FRONT):
|
||||
_emissionFrontAndBack = false;
|
||||
_emissionFront = emission;
|
||||
clampArray4BetweenRange(_emissionFront,0.0f,1.0f,"Material::setEmission(..)");
|
||||
//clampArray4BetweenRange(_emissionFront,0.0f,1.0f,"Material::setEmission(..)");
|
||||
break;
|
||||
case(BACK):
|
||||
_emissionFrontAndBack = false;
|
||||
_emissionBack = emission;
|
||||
clampArray4BetweenRange(_emissionBack,0.0f,1.0f,"Material::setEmission(..)");
|
||||
//clampArray4BetweenRange(_emissionBack,0.0f,1.0f,"Material::setEmission(..)");
|
||||
break;
|
||||
case(FRONT_AND_BACK):
|
||||
_emissionFrontAndBack = true;
|
||||
_emissionFront = emission;
|
||||
clampArray4BetweenRange(_emissionFront,0.0f,1.0f,"Material::setEmission(..)");
|
||||
//clampArray4BetweenRange(_emissionFront,0.0f,1.0f,"Material::setEmission(..)");
|
||||
_emissionBack = _emissionFront;
|
||||
break;
|
||||
default:
|
||||
@@ -285,7 +285,7 @@ float Material::getShininess(Face face) const
|
||||
|
||||
void Material::setTransparency(Face face,float transparency)
|
||||
{
|
||||
clampBetweenRange(transparency,0.0f,1.0f,"Material::setTransparency()");
|
||||
//clampBetweenRange(transparency,0.0f,1.0f,"Material::setTransparency()");
|
||||
|
||||
if (face==FRONT || face==FRONT_AND_BACK)
|
||||
{
|
||||
|
||||
@@ -16,7 +16,8 @@
|
||||
|
||||
using namespace osg;
|
||||
|
||||
NodeVisitor::NodeVisitor(TraversalMode tm)
|
||||
NodeVisitor::NodeVisitor(TraversalMode tm):
|
||||
Referenced()
|
||||
{
|
||||
_visitorType = NODE_VISITOR;
|
||||
_traversalNumber = -1;
|
||||
@@ -26,7 +27,8 @@ NodeVisitor::NodeVisitor(TraversalMode tm)
|
||||
_nodeMaskOverride = 0x0;
|
||||
}
|
||||
|
||||
NodeVisitor::NodeVisitor(VisitorType type,TraversalMode tm)
|
||||
NodeVisitor::NodeVisitor(VisitorType type,TraversalMode tm):
|
||||
Referenced()
|
||||
{
|
||||
_visitorType = type;
|
||||
_traversalNumber = -1;
|
||||
|
||||
@@ -55,7 +55,10 @@ Point::Point()
|
||||
_size = 1.0f; // TODO find proper default
|
||||
_fadeThresholdSize = 1.0f; // TODO find proper default
|
||||
// TODO find proper default
|
||||
_distanceAttenuation = Vec3(0.0f, 1.0f/5.f, 0.0f);
|
||||
_distanceAttenuation = Vec3(1, 0.0, 0.0);
|
||||
|
||||
_minSize = 0.0;
|
||||
_maxSize = 100.0;//depends on mulitsampling ... some default necessary
|
||||
}
|
||||
|
||||
|
||||
@@ -99,6 +102,15 @@ void Point::setDistanceAttenuation(const Vec3& distanceAttenuation)
|
||||
_distanceAttenuation = distanceAttenuation;
|
||||
}
|
||||
|
||||
void Point::setMinSize(float minSize)
|
||||
{
|
||||
_minSize = minSize;
|
||||
}
|
||||
|
||||
void Point::setMaxSize(float maxSize)
|
||||
{
|
||||
_maxSize = maxSize;
|
||||
}
|
||||
|
||||
void Point::apply(State&) const
|
||||
{
|
||||
@@ -112,8 +124,14 @@ void Point::apply(State&) const
|
||||
init_GL_EXT();
|
||||
}
|
||||
|
||||
if (s_PointParameterfvEXT) s_PointParameterfvEXT(GL_DISTANCE_ATTENUATION_EXT, (const GLfloat*)&_distanceAttenuation);
|
||||
if (s_PointParameterfEXT) s_PointParameterfEXT(GL_POINT_FADE_THRESHOLD_SIZE_EXT, _fadeThresholdSize);
|
||||
|
||||
if (s_PointParameterfvEXT) s_PointParameterfvEXT(GL_DISTANCE_ATTENUATION_EXT, (const GLfloat*)&_distanceAttenuation);
|
||||
|
||||
if (s_PointParameterfEXT)
|
||||
{
|
||||
s_PointParameterfEXT(GL_POINT_FADE_THRESHOLD_SIZE_EXT, _fadeThresholdSize);
|
||||
s_PointParameterfEXT(GL_POINT_SIZE_MIN_EXT, _minSize);
|
||||
s_PointParameterfEXT(GL_POINT_SIZE_MAX_EXT, _maxSize);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
#include <osg/GLExtensions>
|
||||
|
||||
|
||||
using namespace std;
|
||||
using namespace osg;
|
||||
|
||||
State::State()
|
||||
@@ -726,7 +727,7 @@ bool State::checkGLErrors(StateAttribute::GLMode mode) const
|
||||
GLenum errorNo = glGetError();
|
||||
if (errorNo!=GL_NO_ERROR)
|
||||
{
|
||||
osg::notify(WARN)<<"Warning: detected OpenGL error '"<<gluErrorString(errorNo)<<"' after applying GLMode "<<mode<< std::endl;
|
||||
osg::notify(WARN)<<"Warning: detected OpenGL error '"<<gluErrorString(errorNo)<<"' after applying GLMode 0x"<<hex<<mode<<dec<< std::endl;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
||||
@@ -49,14 +49,18 @@ void TexEnvCombine::apply(State&) const
|
||||
static bool s_isTexEnvCrossbarSupported =
|
||||
isGLExtensionSupported("GL_ARB_texture_env_crossbar");
|
||||
|
||||
static bool s_isNVTexEnvCrossbarSupported =
|
||||
isGLExtensionSupported("GL_NV_texture_env_combine4");
|
||||
|
||||
static bool s_isTexEnvDot3Supported =
|
||||
isGLExtensionSupported("GL_ARB_texture_env_dot3");
|
||||
|
||||
|
||||
bool needsTexEnvDot3 = (_combine_RGB==DOT3_RGB) ||
|
||||
(_combine_RGB==DOT3_RGBA);
|
||||
|
||||
bool supported = s_isTexEnvCombineSupported;
|
||||
if (_needsTexEnvCrossbar && !s_isTexEnvCrossbarSupported) supported = false;
|
||||
if (_needsTexEnvCrossbar && !(s_isTexEnvCrossbarSupported || s_isNVTexEnvCrossbarSupported)) supported = false;
|
||||
if (needsTexEnvDot3 && !s_isTexEnvDot3Supported) supported = false;
|
||||
|
||||
if (supported)
|
||||
|
||||
@@ -23,6 +23,11 @@ TextureRectangle::TextureRectangle():
|
||||
_textureWidth(0),
|
||||
_textureHeight(0)
|
||||
{
|
||||
setWrap(WRAP_S, CLAMP);
|
||||
setWrap(WRAP_T, CLAMP);
|
||||
|
||||
setFilter(MIN_FILTER, LINEAR);
|
||||
setFilter(MAG_FILTER, LINEAR);
|
||||
}
|
||||
|
||||
TextureRectangle::TextureRectangle(const TextureRectangle& text,const CopyOp& copyop):
|
||||
@@ -132,7 +137,7 @@ void TextureRectangle::apply(State& state) const
|
||||
|
||||
applyTexParameters(GL_TEXTURE_RECTANGLE_NV, state);
|
||||
|
||||
applyTexImageRectangle(GL_TEXTURE_RECTANGLE_NV, _image.get(), state, _textureWidth, _textureHeight);
|
||||
applyTexImage(GL_TEXTURE_RECTANGLE_NV, _image.get(), state, _textureWidth, _textureHeight);
|
||||
|
||||
// in theory the following line is redundant, but in practice
|
||||
// have found that the first frame drawn doesn't apply the textures
|
||||
@@ -146,7 +151,22 @@ void TextureRectangle::apply(State& state) const
|
||||
}
|
||||
}
|
||||
|
||||
void TextureRectangle::applyTexImageRectangle(GLenum target, Image* image, State& state, GLsizei& inwidth, GLsizei& inheight) const
|
||||
void TextureRectangle::applyTexParameters(GLenum target, State& state) const
|
||||
{
|
||||
// get the contextID (user defined ID of 0 upwards) for the
|
||||
// current OpenGL context.
|
||||
const unsigned int contextID = state.getContextID();
|
||||
|
||||
glTexParameteri( target, GL_TEXTURE_WRAP_S, _wrap_s );
|
||||
glTexParameteri( target, GL_TEXTURE_WRAP_T, _wrap_t );
|
||||
|
||||
glTexParameteri( target, GL_TEXTURE_MIN_FILTER, _min_filter);
|
||||
glTexParameteri( target, GL_TEXTURE_MAG_FILTER, _mag_filter);
|
||||
|
||||
getTextureParameterDirty(contextID) = false;
|
||||
}
|
||||
|
||||
void TextureRectangle::applyTexImage(GLenum target, Image* image, State& state, GLsizei& inwidth, GLsizei& inheight) const
|
||||
{
|
||||
// if we don't have a valid image we can't create a texture!
|
||||
if (!image || !image->data())
|
||||
|
||||
Reference in New Issue
Block a user