@@ -271,6 +271,22 @@ namespace SCIRun {
271271 updateCamera ();
272272 }
273273
274+ // ----------------------------------------------------------------------------------------------
275+ void SRInterface::updateCamera ()
276+ {
277+ // Update the static camera with the appropriate world to view transform.
278+ glm::mat4 viewToWorld = mCamera ->getViewToWorld ();
279+ glm::mat4 projection = mCamera ->getViewToProjection ();
280+
281+ gen::StaticCamera* camera = mCore .getStaticComponent <gen::StaticCamera>();
282+ if (camera)
283+ {
284+ camera->data .winWidth = static_cast <float >(mScreenWidth );
285+ camera->data .setView (viewToWorld);
286+ camera->data .setProjection (projection, mCamera ->getFOVY (), mCamera ->getAspect (), mCamera ->getZNear (), mCamera ->getZFar ());
287+ }
288+ }
289+
274290 // Getters/Setters-------------------------------------------------------------------------------
275291 void SRInterface::setZoomInverted (bool value) {mCamera ->setZoomInverted (value);}
276292 void SRInterface::setLockZoom (bool lock) {mCamera ->setLockZoom (lock);}
@@ -705,6 +721,52 @@ namespace SCIRun {
705721 std::abs (glm::dot (n, a4))));
706722 }
707723
724+ // ----------------------------------------------------------------------------------------------
725+ void SRInterface::updateClippingPlanes ()
726+ {
727+ StaticClippingPlanes* clippingPlanes = mCore .getStaticComponent <StaticClippingPlanes>();
728+ if (clippingPlanes)
729+ {
730+ clippingPlanes->clippingPlanes .clear ();
731+ clippingPlanes->clippingPlaneCtrls .clear ();
732+ // boundbox transformation
733+ glm::mat4 trans_bb = glm::mat4 ();
734+ glm::vec3 scale_bb (mSceneBBox .x_length () / 2.0 , mSceneBBox .y_length () / 2.0 , mSceneBBox .z_length () / 2.0 );
735+ glm::vec3 center_bb (mSceneBBox .center ().x (), mSceneBBox .center ().y (), mSceneBBox .center ().z ());
736+ glm::mat4 temp = glm::scale (glm::mat4 (), scale_bb);
737+ trans_bb = temp * trans_bb;
738+ temp = glm::translate (glm::mat4 (), center_bb);
739+ trans_bb = temp * trans_bb;
740+ int index = 0 ;
741+ for (auto i : clippingPlanes_)
742+ {
743+ glm::vec3 n3 (i.x , i.y , i.z );
744+ double d = i.d ;
745+ glm::vec4 n (0.0 );
746+ if (glm::length (n3) > 0.0 )
747+ {
748+ n3 = glm::normalize (n3);
749+ n = glm::vec4 (n3, 0.0 );
750+ d *= getMaxProjLength (n3);
751+ }
752+ glm::vec4 o = glm::vec4 (n.x , n.y , n.z , 1.0 ) * d;
753+ o.w = 1 ;
754+ o = trans_bb * o;
755+ n = glm::inverseTranspose (trans_bb) * n;
756+ o.w = 0 ;
757+ n.w = 0 ;
758+ n = glm::normalize (n);
759+ n.w = -glm::dot (o, n);
760+ clippingPlanes->clippingPlanes .push_back (n);
761+ glm::vec4 control (i.visible ? 1.0 : 0.0 ,
762+ i.showFrame ? 1.0 : 0.0 ,
763+ i.reverseNormal ? 1.0 : 0.0 , 0.0 );
764+ clippingPlanes->clippingPlaneCtrls .push_back (control);
765+ index++;
766+ }
767+ }
768+ }
769+
708770
709771
710772 // ----------------------------------------------------------------------------------------------
@@ -1569,22 +1631,6 @@ namespace SCIRun {
15691631 }
15701632 }
15711633
1572- // ----------------------------------------------------------------------------------------------
1573- void SRInterface::updateCamera ()
1574- {
1575- // Update the static camera with the appropriate world to view transform.
1576- glm::mat4 viewToWorld = mCamera ->getViewToWorld ();
1577- glm::mat4 projection = mCamera ->getViewToProjection ();
1578-
1579- gen::StaticCamera* camera = mCore .getStaticComponent <gen::StaticCamera>();
1580- if (camera)
1581- {
1582- camera->data .winWidth = static_cast <float >(mScreenWidth );
1583- camera->data .setView (viewToWorld);
1584- camera->data .setProjection (projection, mCamera ->getFOVY (), mCamera ->getAspect (), mCamera ->getZNear (), mCamera ->getZFar ());
1585- }
1586- }
1587-
15881634 // ----------------------------------------------------------------------------------------------
15891635 void SRInterface::updateWorldLight ()
15901636 {
@@ -1603,52 +1649,6 @@ namespace SCIRun {
16031649 }
16041650 }
16051651
1606- // ----------------------------------------------------------------------------------------------
1607- void SRInterface::updateClippingPlanes ()
1608- {
1609- StaticClippingPlanes* clippingPlanes = mCore .getStaticComponent <StaticClippingPlanes>();
1610- if (clippingPlanes)
1611- {
1612- clippingPlanes->clippingPlanes .clear ();
1613- clippingPlanes->clippingPlaneCtrls .clear ();
1614- // boundbox transformation
1615- glm::mat4 trans_bb = glm::mat4 ();
1616- glm::vec3 scale_bb (mSceneBBox .x_length () / 2.0 , mSceneBBox .y_length () / 2.0 , mSceneBBox .z_length () / 2.0 );
1617- glm::vec3 center_bb (mSceneBBox .center ().x (), mSceneBBox .center ().y (), mSceneBBox .center ().z ());
1618- glm::mat4 temp = glm::scale (glm::mat4 (), scale_bb);
1619- trans_bb = temp * trans_bb;
1620- temp = glm::translate (glm::mat4 (), center_bb);
1621- trans_bb = temp * trans_bb;
1622- int index = 0 ;
1623- for (auto i : clippingPlanes_)
1624- {
1625- glm::vec3 n3 (i.x , i.y , i.z );
1626- double d = i.d ;
1627- glm::vec4 n (0.0 );
1628- if (glm::length (n3) > 0.0 )
1629- {
1630- n3 = glm::normalize (n3);
1631- n = glm::vec4 (n3, 0.0 );
1632- d *= getMaxProjLength (n3);
1633- }
1634- glm::vec4 o = glm::vec4 (n.x , n.y , n.z , 1.0 ) * d;
1635- o.w = 1 ;
1636- o = trans_bb * o;
1637- n = glm::inverseTranspose (trans_bb) * n;
1638- o.w = 0 ;
1639- n.w = 0 ;
1640- n = glm::normalize (n);
1641- n.w = -glm::dot (o, n);
1642- clippingPlanes->clippingPlanes .push_back (n);
1643- glm::vec4 control (i.visible ? 1.0 : 0.0 ,
1644- i.showFrame ? 1.0 : 0.0 ,
1645- i.reverseNormal ? 1.0 : 0.0 , 0.0 );
1646- clippingPlanes->clippingPlaneCtrls .push_back (control);
1647- index++;
1648- }
1649- }
1650- }
1651-
16521652 // ----------------------------------------------------------------------------------------------
16531653 void SRInterface::applyUniform (uint64_t entityID, const SpireSubPass::Uniform& uniform)
16541654 {
0 commit comments