/****************************************************************************** Project this line's start and end onto projectOnto ******************************************************************************/ void Line::GetProjection(Vector3& dir, Line& projectedVec) { //project start--------------------------------------// Vector3 proj_start = vectorProjection(this->start, dir); //project end---------------------------------------// Vector3 proj_end = vectorProjection(this->end, dir); projectedVec.Set(proj_start.x, proj_start.y, proj_end.x, proj_end.y); }
void GeneralViewer::setCutPlane( const soglu::Planef &aCutPlane ) { getViewerState().mVolumeRenderConfig.cutPlane = aCutPlane; glm::fvec3 point = glm::fvec3(aCutPlane.point()[0], aCutPlane.point()[1], aCutPlane.point()[2]); glm::fvec3 normal = glm::fvec3(aCutPlane.normal()[0], aCutPlane.normal()[1], aCutPlane.normal()[2]); glm::fvec3 dir = vectorProjection(normal, point - getCameraTargetPosition()); float offset = glm::length(dir); if( glm::dot(dir, normal) < 0.0f ) { offset *= -1.0f; } getViewerState().mVolumeRenderConfig.cutPlaneCameraTargetOffset = offset; notifyAboutSettingsChange(); update(); }