//-----------------------------------------------------------------------------
void RaycastVolume::generateTextureCoordinates(const ivec3& img_size, const ivec3& min_corner, const ivec3& max_corner)
{
    if (!img_size.x() || !img_size.y() || !img_size.z())
    {
        Log::error("RaycastVolume::setDisplayRegion(): failed! The size passed does not represent a 3D image.\n");
        return;
    }

    float dx = 0.5f/img_size.x();
    float dy = 0.5f/img_size.y();
    float dz = 0.5f/img_size.z();

    float x0 = min_corner.x()/(float)img_size.x() + dx;
    float x1 = max_corner.x()/(float)img_size.x() - dx;
    float y0 = min_corner.y()/(float)img_size.y() + dy;
    float y1 = max_corner.y()/(float)img_size.y() - dy;
    float z0 = min_corner.z()/(float)img_size.z() + dz;
    float z1 = max_corner.z()/(float)img_size.z() - dz;

    fvec3 texc[] = 
    {
      fvec3( x0,y0,z1 ), fvec3( x1,y0,z1 ), fvec3( x1,y1,z1 ), fvec3( x0,y1,z1 ), 
      fvec3( x0,y0,z0 ), fvec3( x1,y0,z0 ), fvec3( x1,y1,z0 ), fvec3( x0,y1,z0 ), 
    };
    memcpy( mTexCoord->ptr(), texc, sizeof(texc) );
}
//-----------------------------------------------------------------------------
void SlicedVolume::generateTextureCoordinates(const ivec3& img_size)
{
  if (!img_size.x() || !img_size.y() || !img_size.z())
  {
    Log::error("SlicedVolume::generateTextureCoordinates(): failed! The img_size passed does not represent a 3D image.\n");
    return;
  }

  float dx = 0.5f/img_size.x();
  float dy = 0.5f/img_size.y();
  float dz = 0.5f/img_size.z();

  float x0 = 0.0f + dx;
  float x1 = 1.0f - dx;
  float y0 = 0.0f + dy;
  float y1 = 1.0f - dy;
  float z0 = 0.0f + dz;
  float z1 = 1.0f - dz;

  fvec3 texc[] = 
  {
    fvec3(x0,y0,z0), fvec3(x1,y0,z0), fvec3(x1,y1,z0), fvec3(x0,y1,z0),
    fvec3(x0,y0,z1), fvec3(x1,y0,z1), fvec3(x1,y1,z1), fvec3(x0,y1,z1),
  };
  memcpy(mTexCoord, texc, sizeof(texc));
}
//-----------------------------------------------------------------------------
void RaycastVolume::generateTextureCoordinates( const ivec3& size )
{
  if ( !size.x() || !size.y() || !size.z() )
  {
    Log::error( "RaycastVolume::generateTextureCoordinates(): failed! The size passed does not represent a 3D image.\n" );
    return;
  }

  float dx = 0.5f/size.x();
  float dy = 0.5f/size.y();
  float dz = 0.5f/size.z();

  float x0 = 0.0f + dx;
  float x1 = 1.0f - dx;
  float y0 = 0.0f + dy;
  float y1 = 1.0f - dy;
  float z0 = 0.0f + dz;
  float z1 = 1.0f - dz;

  fvec3 texc[] = 
  {
    fvec3( x0,y0,z1 ), fvec3( x1,y0,z1 ), fvec3( x1,y1,z1 ), fvec3( x0,y1,z1 ), // mic fixme: i don't remember why we need z1 here and z0 below...
    fvec3( x0,y0,z0 ), fvec3( x1,y0,z0 ), fvec3( x1,y1,z0 ), fvec3( x0,y1,z0 ), 
  };
  memcpy( mTexCoord->ptr(), texc, sizeof( texc ) );
}
Example #4
0
    explicit ivec4(const ivec3& v, GLint w) 
    {
	    mVec[0] = v.x();
	    mVec[1] = v.y();
	    mVec[2] = v.z();
	    mVec[3] = w;
    }
 inline ivec3 max(const ivec3& a, int b)
 {
   return ivec3( a.x() > b ? a.x() : b,
     a.y() > b ? a.y() : b,
     a.z() > b ? a.z() : b );
 }
 inline ivec3 max(const ivec3& a, const ivec3& b)
 {
   return ivec3( a.x() > b.x() ? a.x() : b.x(),
     a.y() > b.y() ? a.y() : b.y(),
     a.z() > b.z() ? a.z() : b.z() );
 }
 inline ivec3 min(const ivec3& a, int b)
 {
   return ivec3( a.x() < b ? a.x() : b,
     a.y() < b ? a.y() : b,
     a.z() < b ? a.z() : b );
 }
 inline float dot(const ivec3& v1, const ivec3& v2) { return (float)(v1.x()*v2.x() + v1.y()*v2.y() + v1.z()*v2.z()); }