Commit 48b45ae9 authored by Christopher Tenter's avatar Christopher Tenter

fix drawing and picking in CameraNode

parent 32013e5c
Pipeline #3691 failed with stage
in 38 minutes and 17 seconds
This diff is collapsed.
......@@ -115,25 +115,25 @@ public:
void pick(GLState& _state, PickTarget _target);
/// set model view matrix
void setModelView(ACG::GLMatrixd _modelView) { modelView_ = _modelView; };
void setModelView(ACG::GLMatrixd _modelView) { modelView_ = _modelView; modelViewInv_ = _modelView; modelViewInv_.invert(); update_vbo_ = true; }
/// Set projection Matrix ( used to calculate frustum ... )
void setProjection(ACG::GLMatrixd _projection) { projection_ = _projection; };
void setProjection(ACG::GLMatrixd _projection) { projection_ = _projection; update_vbo_ = true; }
/// Set viewport size ( This will be used to compute the aspect ratio )
void setSize(int _w, int _h) { width_ = _w; height_ = _h; aspectRatio_ = (double)width_ / (double)height_; }
void setSize(int _w, int _h) { /*obsolete*/ }
/// Return encoded view string
void setEncodedView(QString _encodedView) { encodedView_ = _encodedView; };
void setEncodedView(QString _encodedView) { encodedView_ = _encodedView; }
/// Set distance to far plane ( e.g. scene radius )
void setFarPlane(double _far) { far_ = _far; };
void setFarPlane(double _far) { /*obsolete*/ }
/// Set distance to near plane
void setNearPlane(double _near) { near_ = _near; };
void setNearPlane(double _near) { /*obsolete*/ }
/// Return encoded view string
QString getEncodedView() { return encodedView_; };
QString getEncodedView() { return encodedView_; }
/// Set if viewing frustum should be shown or not
void showFrustum(bool _showFrustum) { showFrustum_ = _showFrustum; }
......@@ -143,34 +143,31 @@ public:
private:
void updateBoundingBoxes(GLMatrixd& _modelview);
void updateVBO();
void updateBoundingBoxes();
// recalculate frustum positions in world space
void updateFrustumWS();
OpenMesh::Vec3d bbmin_;
OpenMesh::Vec3d bbmax_;
ACG::GLMatrixd modelView_;
ACG::GLMatrixd modelViewInv_;
ACG::GLMatrixd projection_;
int width_, height_;
double fovy_;
double half_height_;
double half_width_;
double far_half_height_;
double far_half_width_;
double aspectRatio_;
double near_;
double far_;
GLCylinder* cylinder_;
GLCone* cone_;
GeometryBuffer vbo_;
IndexBuffer ibo_;
VertexDeclaration vdecl_;
GeometryBuffer vbo_;
IndexBuffer ibo_;
VertexDeclaration vdecl_;
bool update_vbo_;
std::vector<Vec4f> vboData_; // 8 frustum vertices + camera position
int offsetTris_; // offsets into index buffer
int offsetLines_;
int offsetFront_;
QString encodedView_;
......
include (plugin)
if (EXISTS ${CMAKE_SOURCE_DIR}/ObjectTypes/Camera/Camera.hh)
openflipper_plugin (INSTALLDATA Icons Shaders)
openflipper_plugin (INSTALLDATA Icons)
else()
message( WARNING "Plugin TypeCamera disabled due to missing Camera ObjectType" )
endif ()
\ No newline at end of file
#version 130
in vec2 inCamOriginCoeff;
uniform mat4 clipSpaceToWorld;
uniform vec4 camOriginWS; // cam origin in world space
void main()
{
SG_VERTEX_BEGIN;
// transform clip to world space
vec4 posWS = clipSpaceToWorld * SG_INPUT_POSOS;
posWS.xyz /= posWS.w;
posWS.w = 1;
posWS = inCamOriginCoeff.x * posWS + inCamOriginCoeff.y * camOriginWS;
sg_vPosVS = g_mWV * posWS;
sg_vPosPS = g_mP * sg_vPosVS;
SG_VERTEX_END;
#ifdef SG_OUTPUT_POSOS
SG_OUTPUT_POSOS = posWS;
#endif
}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment