Exemple #1
0
void GLRaycaster::Render3DPreLoop(const RenderRegion3D &) {

  // render nearplane into buffer
  if (m_iBricksRenderedInThisSubFrame == 0) {
    GPUState localState = m_BaseState;
    localState.enableBlend = false;
    localState.depthMask = false;
    localState.enableDepthTest  = false;
    m_pContext->GetStateManager()->Apply(localState);

    m_TargetBinder.Bind(m_pFBORayEntry);
  
    FLOATMATRIX4 mInvProj = m_mProjection[0].inverse();
    mInvProj.setProjection();
    m_pProgramRenderFrontFacesNT->Enable();
    
    m_pNearPlaneQuad->Bind();
    m_pNearPlaneQuad->Draw(GL_QUADS);
    m_pNearPlaneQuad->UnBind();

    m_TargetBinder.Unbind();
  }

  switch (m_eRenderMode) {
    case RM_1DTRANS    :  m_p1DTransTex->Bind(1);
                          break;
    case RM_2DTRANS    :  m_p2DTransTex->Bind(1);
                          break;
    case RM_ISOSURFACE :  break;
    default    :          T_ERROR("Invalid rendermode set");
                          break;
  }

}
void ScaleAndBiasDlg::CopyScaleAndBias() {
  FLOATMATRIX4 bias;
  FLOATMATRIX4 scale;

  bias.Translation(biasVec);
  scale.Scaling(scaleVec);

  SetExpertTransform(scale*bias);
}
Exemple #3
0
void Mesh::ScaleAndBias(const FLOATVECTOR3& scale,
                        const FLOATVECTOR3& translation) {

  for (VertVec::iterator i = m_Data.m_vertices.begin();i<m_Data.m_vertices.end();i++)
	  *i = (*i*scale) + translation;

  m_Bounds[0] = (m_Bounds[0] * scale) + translation;
  m_Bounds[1] = (m_Bounds[1] * scale) + translation;

  FLOATMATRIX4 s;  s.Scaling(scale);
  FLOATMATRIX4 b;  b.Translation(translation);
  m_TransformFromOriginal = m_TransformFromOriginal * s * b;

  GeometryHasChanged(false, true);
}
Exemple #4
0
void GLRaycaster::RenderBox(const RenderRegion& renderRegion,
                            const FLOATVECTOR3& vCenter,
                            const FLOATVECTOR3& vExtend,
                            const FLOATVECTOR3& vMinCoords,
                            const FLOATVECTOR3& vMaxCoords, bool bCullBack,
                            EStereoID eStereoID) const {
  
  m_pContext->GetStateManager()->SetCullState(bCullBack ? CULL_FRONT : CULL_BACK);

  FLOATVECTOR3 vMinPoint, vMaxPoint;
  vMinPoint = (vCenter - vExtend/2.0);
  vMaxPoint = (vCenter + vExtend/2.0);

  // \todo compute this only once per brick
  FLOATMATRIX4 m = ComputeEyeToTextureMatrix(renderRegion,
                                             FLOATVECTOR3(vMaxPoint.x, vMaxPoint.y, vMaxPoint.z),
                                             FLOATVECTOR3(vMaxCoords.x, vMaxCoords.y, vMaxCoords.z),
                                             FLOATVECTOR3(vMinPoint.x, vMinPoint.y, vMinPoint.z),
                                             FLOATVECTOR3(vMinCoords.x, vMinCoords.y, vMinCoords.z),
                                             eStereoID);

  m.setTextureMatrix();

  std::vector<FLOATVECTOR3> posData;
  MaxMinBoxToVector(vMinPoint, vMaxPoint, posData);

  if ( m_bClipPlaneOn ) {
    // clip plane is normaly defined in world space, transform back to model space
    FLOATMATRIX4 inv = (renderRegion.rotation * renderRegion.translation).inverse();
    PLANE<float> transformed = m_ClipPlane.Plane() * inv;

    const FLOATVECTOR3 normal(transformed.xyz().normalized());
    const float d = transformed.d();

    Clipper::BoxPlane(posData, normal, d);
  }

  m_pBBoxVBO->ClearVertexData();
  m_pBBoxVBO->AddVertexData(posData);

  m_pBBoxVBO->Bind();
  m_pBBoxVBO->Draw(GL_TRIANGLES);
  m_pBBoxVBO->UnBind();
}
void MainWindow::CropData() {
  if (m_pActiveRenderWin) {

    // todo fix this by copying the meshes from the old dataset to the new one
    if (!m_pActiveRenderWin->GetRendererMeshes().empty()) {
      QMessageBox::warning(this, "File Error", "Cropping datasets that contain meshes is not supported at the moment.", QMessageBox::Ok);
      return;
    }

    bool bKeepOldData = (QMessageBox::Yes == 
      QMessageBox::question(NULL, "Create Backup?", "Do you want to create a backup of the current dataset before cropping?", QMessageBox::Yes, QMessageBox::No));


    m_pActiveRenderWin->SetDatasetIsInvalid(true);

    PleaseWaitDialog pleaseWait(this);
    pleaseWait.SetText("Cropping dataset");
    pleaseWait.AttachLabel(&m_MasterController);

    LuaClassInstance first3DRegion = m_pActiveRenderWin->GetFirst3DRegion();
    ExtendedPlane p = m_pActiveRenderWin->GetRendererClipPlane();
    FLOATMATRIX4 trans = m_pActiveRenderWin->GetRotation(first3DRegion) *
                         m_pActiveRenderWin->GetTranslation(first3DRegion);

    // get rid of the viewing transformation in the plane
    p.Transform(trans.inverse(),false);

    if (!m_pActiveRenderWin->RendererCropDataset(m_strTempDir,bKeepOldData)) {
      if (!m_bScriptMode) {
        QMessageBox::warning(this, "File Error", "Unable to crop dataset, is the file write protected?", QMessageBox::Ok);
      }
    } else {
      ToggleClipPlane(false);

    }
    m_pActiveRenderWin->SetDatasetIsInvalid(false);

    RenderWindow* current = m_pActiveRenderWin;
    m_pActiveRenderWin = NULL; // set m_pActiveRenderWin to NULL so RenderWindowActive thinks it has changed
    RenderWindowActive(current);

    pleaseWait.close();
  }
}
Exemple #6
0
FLOATMATRIX4 GLRaycaster::ComputeEyeToTextureMatrix(const RenderRegion &renderRegion,
                                                    FLOATVECTOR3 p1, FLOATVECTOR3 t1,
                                                    FLOATVECTOR3 p2, FLOATVECTOR3 t2,
                                                    EStereoID eStereoID) const {
  FLOATMATRIX4 m;

  FLOATMATRIX4 mInvModelView = renderRegion.modelView[size_t(eStereoID)].inverse();

  FLOATVECTOR3 vTrans1 = -p1;
  FLOATVECTOR3 vScale  = (t2-t1) / (p2-p1);
  FLOATVECTOR3 vTrans2 =  t1;

  FLOATMATRIX4 mTrans1;
  FLOATMATRIX4 mScale;
  FLOATMATRIX4 mTrans2;

  mTrans1.Translation(vTrans1.x,vTrans1.y,vTrans1.z);
  mScale.Scaling(vScale.x,vScale.y,vScale.z);
  mTrans2.Translation(vTrans2.x,vTrans2.y,vTrans2.z);

  m = mInvModelView * mTrans1 * mScale * mTrans2;

  return m;
}
void ScaleAndBiasDlg::InvertMatrix() {
  FLOATMATRIX4 m = GetExpertTransform();
  SetExpertTransform(m.inverse());
}
Exemple #8
0
void GLSBVR::Render3DInLoop(const RenderRegion3D& renderRegion,
                            size_t iCurrentBrick, EStereoID eStereoID) {

  m_pContext->GetStateManager()->Apply(m_BaseState);

  const Brick& b = (eStereoID == SI_LEFT_OR_MONO) ? m_vCurrentBrickList[iCurrentBrick] : m_vLeftEyeBrickList[iCurrentBrick];
  
  if (m_iBricksRenderedInThisSubFrame == 0 && m_eRenderMode == RM_ISOSURFACE){
    m_TargetBinder.Bind(m_pFBOIsoHit[size_t(eStereoID)], 0, m_pFBOIsoHit[size_t(eStereoID)], 1);
    GL(glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT));
    if (m_bDoClearView) {
      m_TargetBinder.Bind(m_pFBOCVHit[size_t(eStereoID)], 0, m_pFBOCVHit[size_t(eStereoID)], 1);
      GL(glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT));
    }
  }

  if (!m_bSupportsMeshes && b.bIsEmpty) return;

  // setup the slice generator
  m_SBVRGeogen.SetBrickData(b.vExtension, b.vVoxelCount,
                            b.vTexcoordsMin, b.vTexcoordsMax);
  FLOATMATRIX4 maBricktTrans;
  maBricktTrans.Translation(b.vCenter.x, b.vCenter.y, b.vCenter.z);
  m_mProjection[size_t(eStereoID)].setProjection();
  renderRegion.modelView[size_t(eStereoID)].setModelview();

  m_SBVRGeogen.SetBrickTrans(b.vCenter);
  m_SBVRGeogen.SetWorld(renderRegion.rotation*renderRegion.translation);
  m_SBVRGeogen.SetView(m_mView[size_t(eStereoID)]);

  if (m_bSupportsMeshes) {
    m_SBVRGeogen.ResetMesh();
    if (m_eRenderMode != RM_ISOSURFACE) {
      for (vector<shared_ptr<RenderMesh>>::iterator mesh = m_Meshes.begin();
           mesh != m_Meshes.end(); mesh++) {
        if ((*mesh)->GetActive()) {
          m_SBVRGeogen.AddMesh((*mesh)->GetInPointList(false));
        }
      }
    }
  }

  m_SBVRGeogen.ComputeGeometry(b.bIsEmpty);

  if (m_eRenderMode == RM_ISOSURFACE) {
    m_pContext->GetStateManager()->SetEnableBlend(false);

    m_TargetBinder.Bind(m_pFBOIsoHit[size_t(eStereoID)], 0, m_pFBOIsoHit[size_t(eStereoID)], 1);
    SetBrickDepShaderVars(b);
    
    GLSLProgram* shader = this->ColorData() ? m_pProgramColor : m_pProgramIso;
    shader->Set("fIsoval", static_cast<float>
                                        (this->GetNormalizedIsovalue()));    
    RenderProxyGeometry();

    if (m_bDoClearView) {
      m_TargetBinder.Bind(m_pFBOCVHit[size_t(eStereoID)], 0, m_pFBOCVHit[size_t(eStereoID)], 1);

      m_pProgramIso->Enable();
      m_pProgramIso->Set("fIsoval", static_cast<float>
                                                 (GetNormalizedCVIsovalue()));
      RenderProxyGeometry();
    }
  } else {
    m_pContext->GetStateManager()->SetDepthMask(false);

    m_TargetBinder.Bind(m_pFBO3DImageNext[size_t(eStereoID)]);
    SetBrickDepShaderVars(b);
    RenderProxyGeometry();
  }
  m_TargetBinder.Unbind();
}