void ofxBehavior::addFloatParam(string key, float value, float min, float max) { floatParams[key] = new float(); floatParamsRanges[key] = ofVec2f(min, max); floatParamsAllocation[key] = true; setFloatParam(key, value); }
void RenderPipelineLayer::setCamera(CameraPtr camera) noexcept { auto semantic = Material::getMaterialSemantic(); if (camera->getCameraOrder() != CameraOrder::CO_SHADOW) { if (camera->getCameraType() == CameraType::CT_PERSPECTIVE) { float ratio; float aperture; float znear; float zfar; camera->getPerspective(aperture, ratio, znear, zfar); std::size_t width, height; this->getWindowResolution(width, height); float windowRatio = (float)width / (float)height; if (ratio != windowRatio) { ratio = windowRatio; camera->makePerspective(aperture, znear, zfar, ratio); } semantic->setFloatParam(GlobalFloatSemantic::CameraAperture, aperture); semantic->setFloatParam(GlobalFloatSemantic::CameraNear, znear); semantic->setFloatParam(GlobalFloatSemantic::CameraFar, zfar); } else { float left; float right; float top; float bottom; float ratio; float znear; float zfar; camera->getOrtho(left, right, top, bottom, ratio, znear, zfar); std::size_t width, height; this->getWindowResolution(width, height); float windowRatio = (float)width / (float)height; if (ratio != windowRatio) { ratio = windowRatio; camera->makeOrtho(left, right, top, bottom, znear, zfar, ratio); } semantic->setFloatParam(GlobalFloatSemantic::CameraNear, znear); semantic->setFloatParam(GlobalFloatSemantic::CameraFar, zfar); } } semantic->setFloat3Param(GlobalFloat3Semantic::CameraView, camera->getLookAt()); semantic->setFloat3Param(GlobalFloat3Semantic::CameraPosition, camera->getTranslate()); semantic->setFloat3Param(GlobalFloat3Semantic::CameraDirection, camera->getLookAt() - camera->getTranslate()); semantic->setMatrixParam(GlobalMatrixSemantic::matView, camera->getView()); semantic->setMatrixParam(GlobalMatrixSemantic::matViewInverse, camera->getViewInverse()); semantic->setMatrixParam(GlobalMatrixSemantic::matViewInverseTranspose, camera->getViewInverseTranspose()); semantic->setMatrixParam(GlobalMatrixSemantic::matProject, camera->getProject()); semantic->setMatrixParam(GlobalMatrixSemantic::matProjectInverse, camera->getProjectInverse()); semantic->setMatrixParam(GlobalMatrixSemantic::matViewProject, camera->getViewProject()); semantic->setMatrixParam(GlobalMatrixSemantic::matViewProjectInverse, camera->getViewProjectInverse()); _camera = camera; }