mirror of
https://github.com/OpenSpace/OpenSpace.git
synced 2026-05-04 01:39:47 -05:00
Merge branch 'feature/video-module' of https://github.com/OpenSpace/OpenSpace into feature/video-module
This commit is contained in:
@@ -41,6 +41,7 @@
|
||||
#include <ghoul/glm.h>
|
||||
#include <glm/gtx/string_cast.hpp>
|
||||
#include <optional>
|
||||
#include <variant>
|
||||
|
||||
namespace {
|
||||
enum BlendMode {
|
||||
@@ -91,7 +92,7 @@ namespace {
|
||||
std::optional<bool> mirrorBackside;
|
||||
|
||||
// [[codegen::verbatim(SizeInfo.description)]]
|
||||
float size;
|
||||
std::variant<float, glm::vec2> size;
|
||||
|
||||
enum class [[codegen::map(BlendMode)]] BlendMode {
|
||||
Normal,
|
||||
@@ -117,7 +118,7 @@ RenderablePlane::RenderablePlane(const ghoul::Dictionary& dictionary)
|
||||
, _blendMode(BlendModeInfo, properties::OptionProperty::DisplayType::Dropdown)
|
||||
, _billboard(BillboardInfo, false)
|
||||
, _mirrorBackside(MirrorBacksideInfo, false)
|
||||
, _size(SizeInfo, 10.f, 0.f, 1e25f)
|
||||
, _size(SizeInfo, glm::vec2(10.f), glm::vec2(0.f), glm::vec2(1e25f))
|
||||
, _multiplyColor(MultiplyColorInfo, glm::vec3(1.f), glm::vec3(0.f), glm::vec3(1.f))
|
||||
{
|
||||
Parameters p = codegen::bake<Parameters>(dictionary);
|
||||
@@ -125,7 +126,13 @@ RenderablePlane::RenderablePlane(const ghoul::Dictionary& dictionary)
|
||||
addProperty(_opacity);
|
||||
registerUpdateRenderBinFromOpacity();
|
||||
|
||||
_size = p.size;
|
||||
if (std::holds_alternative<float>(p.size)) {
|
||||
_size = glm::vec2(std::get<float>(p.size));
|
||||
}
|
||||
else {
|
||||
_size = std::get<glm::vec2>(p.size);
|
||||
}
|
||||
|
||||
_billboard = p.billboard.value_or(_billboard);
|
||||
_mirrorBackside = p.mirrorBackside.value_or(_mirrorBackside);
|
||||
|
||||
@@ -167,7 +174,7 @@ RenderablePlane::RenderablePlane(const ghoul::Dictionary& dictionary)
|
||||
|
||||
addProperty(_multiplyColor);
|
||||
|
||||
setBoundingSphere(_size);
|
||||
setBoundingSphere(glm::compMax(_size.value()));
|
||||
}
|
||||
|
||||
bool RenderablePlane::isReady() const {
|
||||
@@ -299,15 +306,16 @@ void RenderablePlane::update(const UpdateData&) {
|
||||
}
|
||||
|
||||
void RenderablePlane::createPlane() {
|
||||
const GLfloat size = _size;
|
||||
const GLfloat sizeX = _size.value().x;
|
||||
const GLfloat sizeY = _size.value().y;
|
||||
const GLfloat vertexData[] = {
|
||||
// x y z w s t
|
||||
-size, -size, 0.f, 0.f, 0.f, 0.f,
|
||||
size, size, 0.f, 0.f, 1.f, 1.f,
|
||||
-size, size, 0.f, 0.f, 0.f, 1.f,
|
||||
-size, -size, 0.f, 0.f, 0.f, 0.f,
|
||||
size, -size, 0.f, 0.f, 1.f, 0.f,
|
||||
size, size, 0.f, 0.f, 1.f, 1.f,
|
||||
// x y z w s t
|
||||
-sizeX, -sizeY, 0.f, 0.f, 0.f, 0.f,
|
||||
sizeX, sizeY, 0.f, 0.f, 1.f, 1.f,
|
||||
-sizeX, sizeY, 0.f, 0.f, 0.f, 1.f,
|
||||
-sizeX, -sizeY, 0.f, 0.f, 0.f, 0.f,
|
||||
sizeX, -sizeY, 0.f, 0.f, 1.f, 0.f,
|
||||
sizeX, sizeY, 0.f, 0.f, 1.f, 1.f,
|
||||
};
|
||||
|
||||
glBindVertexArray(_quad);
|
||||
|
||||
@@ -30,7 +30,7 @@
|
||||
#include <openspace/properties/optionproperty.h>
|
||||
#include <openspace/properties/stringproperty.h>
|
||||
#include <openspace/properties/scalar/boolproperty.h>
|
||||
#include <openspace/properties/scalar/floatproperty.h>
|
||||
#include <openspace/properties/vector/vec2property.h>
|
||||
#include <openspace/properties/vector/vec3property.h>
|
||||
#include <ghoul/opengl/ghoul_gl.h>
|
||||
|
||||
@@ -72,7 +72,7 @@ protected:
|
||||
properties::OptionProperty _blendMode;
|
||||
properties::BoolProperty _billboard;
|
||||
properties::BoolProperty _mirrorBackside;
|
||||
properties::FloatProperty _size;
|
||||
properties::Vec2Property _size;
|
||||
properties::Vec3Property _multiplyColor;
|
||||
|
||||
ghoul::opengl::ProgramObject* _shader = nullptr;
|
||||
|
||||
@@ -165,12 +165,12 @@ glm::ivec3 RenderableSkyTarget::borderColor() const {
|
||||
}
|
||||
|
||||
glm::dvec3 RenderableSkyTarget::rightVector() const {
|
||||
double scaling = (_verticalFov / 70)* static_cast<double>(_size.value());
|
||||
double scaling = (_verticalFov / 70)* static_cast<double>(_size.value().x);
|
||||
return scaling * _rightVector;
|
||||
}
|
||||
|
||||
glm::dvec3 RenderableSkyTarget::upVector() const {
|
||||
double scaling = (_verticalFov / 70) * static_cast<double>(_size.value());
|
||||
double scaling = (_verticalFov / 70) * static_cast<double>(_size.value().y);
|
||||
return scaling * _upVector;
|
||||
}
|
||||
|
||||
|
||||
@@ -52,6 +52,7 @@ protected:
|
||||
|
||||
private:
|
||||
VideoPlayer _videoPlayer;
|
||||
glm::vec2 _textureDimensions = glm::vec2(0.f);
|
||||
};
|
||||
|
||||
} // namespace openspace
|
||||
|
||||
@@ -78,6 +78,25 @@ void RenderableVideoPlane::update(const UpdateData& data) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Shape the vidoe based on the aspect ration of the film
|
||||
glm::vec2 textureDim = glm::vec2(_videoPlayer.frameTexture()->dimensions());
|
||||
if (_textureDimensions != textureDim) {
|
||||
float videoAspectRatio = textureDim.x / textureDim.y;
|
||||
float planeAspectRatio = _size.value().x / _size.value().y;
|
||||
|
||||
if (std::abs(planeAspectRatio - videoAspectRatio) >
|
||||
std::numeric_limits<float>::epsilon())
|
||||
{
|
||||
glm::vec2 newSize =
|
||||
videoAspectRatio > 0.f ?
|
||||
glm::vec2(_size.value().x * videoAspectRatio, _size.value().y) :
|
||||
glm::vec2(_size.value().x, _size.value().y * videoAspectRatio);
|
||||
_size = newSize;
|
||||
}
|
||||
|
||||
_textureDimensions = textureDim;
|
||||
}
|
||||
|
||||
RenderablePlane::update(data);
|
||||
}
|
||||
|
||||
|
||||
@@ -77,7 +77,7 @@ void ScreenSpaceVideo::update() {
|
||||
}
|
||||
glm::uvec3 texDimensions = _videoPlayer.frameTexture()->dimensions();
|
||||
if (_objectSize != glm::ivec2(texDimensions.x, texDimensions.y)) {
|
||||
_objectSize = _videoPlayer.frameTexture()->dimensions();
|
||||
_objectSize = texDimensions;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user