Maya 1.0
|
A core widget for displaying objects. More...
#include <maya.h>
Inherits QOpenGLWidget.
Public Slots | |
void | paintGL () |
Renders the scene. More... | |
virtual void | mousePressEvent (QMouseEvent *) |
Process mouse click events. More... | |
virtual void | mouseReleaseEvent (QMouseEvent *) |
Process the mouse release events. More... | |
virtual void | mouseDoubleClickEvent (QMouseEvent *) |
Process the mouse double click events. More... | |
virtual void | mouseMoveEvent (QMouseEvent *) |
Overloaded function to capture the mouse events. More... | |
virtual void | wheelEvent (QWheelEvent *) |
Overloaded function to capture the wheel events. More... | |
virtual void | keyPressEvent (QKeyEvent *) |
Key events. More... | |
virtual void | keyReleaseEvent (QKeyEvent *) |
This function has been overloaded mainly to enable and disable the display of the tool on the screen. More... | |
Public Member Functions | |
MayaWidget (QWidget *=nullptr) | |
Create a widget for real time rendering. More... | |
~MayaWidget () | |
Release allocated resources. | |
void | SetCamera (const Camera &) |
Set the viewing camera. More... | |
QVector< Camera > | GetCameras () const |
Return the set of cameras. | |
Camera | GetCamera () const |
Get the camera. More... | |
void | AddCamera () |
Add the current camera to the set of reference cameras. | |
void | DeleteCamera () |
Remove the current camera from the set. | |
void | ChangeCamera () |
Charge une nouvelle position de la camera. | |
void | SetPlanes (const double &, const double &) |
Set the near and far planes. More... | |
void | SetPlane (const Box2 &, const double &, const double &) |
Change the parameter of the plane. More... | |
void | SetLight (const Vector &) |
Change the light position. More... | |
void | SetAnchor (const Vector &) |
Modify the anchor position. More... | |
Ray | ConvertPixelToRay (const QPoint &) const |
Convert a pixel on the screen of the viewport into a ray. More... | |
Ray | ConvertPixelToRay (const QPoint &, int, int, int) const |
Convert a pixel on the screen of the viewport into a ray, with anti-aliasing. More... | |
void | SetWorld (const MayaGeometryAll &) |
Set the geometry instances to be rendered. More... | |
void | AppendWorld (const MayaGeometryAll &) |
Append objects or instances to be rendered. More... | |
void | ReplaceInWorld (const MayaGeometryAll &) |
Replace instances to be rendered. More... | |
void | ReplaceMaterialInWorld (MayaGeometryAll &) |
Replace material of all instances. More... | |
void | ClearWorld () |
Clear all objects in the scene. | |
void | SaveScreen (int=1280, int=720) |
Capture the rendering viewport and save it to disk. | |
void | SaveScreen (int, int, const QString &) |
Capture the rendering viewport and save it to disk. More... | |
Static Public Member Functions | |
static void GLAPIENTRY | OpenGLDebugMessageCallback (GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei length, const GLchar *message, const void *userParam) |
Custom callback for OpenGL message. More... | |
Static Public Attributes | |
static bool | Verbose = false |
Static flag for verbose output in the console (useful for OpenGL debugging) More... | |
static GLenum | GLVerboseLevel = GL_DEBUG_SEVERITY_MEDIUM |
OpenGL verbosity level. Everything below is ignored. | |
Protected Member Functions | |
void | initializeGL () |
Set up the rendering state. | |
void | resizeGL (int, int) |
Set up the OpenGL view port and matrix mode according to the size of the window. More... | |
virtual void | UpdateAnchor (QMouseEvent *) |
Update the position of the Anchor on the intersection between the ray (mouse direction and the plane). More... | |
virtual void | RenderAnchor () |
Render the focus point. | |
virtual void | RenderLight () |
Render the Light position. | |
void | RenderBackGround () |
Render the Background. | |
void | RenderForeGround (QElapsedTimer) |
Render the foreground. More... | |
virtual void | InitGPU () |
Initialize GPU information (camera, textures, shaders). | |
void | InitProgram () |
Initialize the program shader. | |
void | InitCamera () |
Initialize camera transforms. | |
virtual void | InitAnchorShape () |
Initialize anchor shape. | |
virtual void | InitLightShape () |
Initialize light shape. | |
virtual void | InitSphereShape () |
Initialize transparent sphere. | |
void | InitTerrainTextures () |
Initialize the terrain texture. More... | |
void | InitEnvTextures () |
Initialize skybox (envmap) textures. | |
void | InitLight () |
Set up the OpenGL Light rendering state. | |
void | updateGPU () |
Update the GPU parameters information (light, camera). | |
Protected Attributes | |
MayaGpuAll | gpuall |
Instances for storing the objects on the GPU. | |
MayaGpuSet | anchor |
Internal instance for drawing the anchor point. | |
MayaGpuSet | lightshape |
Light shape. | |
MayaGpuSet | sphereshape |
Transparent sphere. | |
Camera | camera |
Current camera. | |
int | y0 |
Reference mouse coordinates. | |
bool | useCamera |
Boolean flags. | |
MayaPlane | plane |
Horizontal plane. | |
Vector | ancre |
Focus point. | |
Vector | light |
Light point. | |
GpuParameter | gpuparam |
Set of parameters defining the way objects are rendered. | |
MayaShader * | gpubackground |
Program used to draw background;. | |
GLuint | backgroundVAO |
VAO used when drawing the background. | |
MayaCameraSet | cameras |
Set of cameras. | |
A core widget for displaying objects.
This class implements a widget for displaying geometric objects.
MayaWidget::MayaWidget | ( | QWidget * | parent = nullptr | ) |
Create a widget for real time rendering.
parent | Parent widget. |
References camera, gpuall, gpubackground, light, Vector::Null, and useCamera.
void MayaWidget::AppendWorld | ( | const MayaGeometryAll & | mga | ) |
Append objects or instances to be rendered.
mga | Set of objects. |
References MayaGpuAll::Append(), and gpuall.
Ray MayaWidget::ConvertPixelToRay | ( | const QPoint & | pixel | ) | const |
Convert a pixel on the screen of the viewport into a ray.
This function relies on the camera model to compute the ray.
pixel | The pixel coordinates. |
References camera, and Camera::PixelToRay().
Referenced by UpdateAnchor().
Ray MayaWidget::ConvertPixelToRay | ( | const QPoint & | pixel, |
int | a, | ||
int | x, | ||
int | y | ||
) | const |
Convert a pixel on the screen of the viewport into a ray, with anti-aliasing.
pixel | The pixel coordinates |
a | Anti-aliasing. |
x,y | Integer coordinates of the sub-pixel. |
References camera, and Camera::PixelToRay().
|
protected |
|
virtualslot |
Key events.
Left and right keys: move sideway.
Up and down keys: move back and forth.
L : show light A : show anchor P : show plane
e | Key events. |
References AddCamera(), Camera::BackForth(), camera, ChangeCamera(), DeleteCamera(), SaveScreen(), Camera::SideWay(), and useCamera.
|
virtualslot |
This function has been overloaded mainly to enable and disable the display of the tool on the screen.
e | Key events. |
|
virtualslot |
Process the mouse double click events.
e | Events. |
References ancre, camera, and Camera::SetAt().
|
virtualslot |
Overloaded function to capture the mouse events.
This function implements controls.
e | Mouse move events. |
References Camera::BackForth(), camera, Camera::LeftRightHorizontal(), Camera::LeftRightRound(), UpdateAnchor(), Camera::UpDownRound(), Camera::UpDownVertical(), Camera::View(), and y0.
|
virtualslot |
|
virtualslot |
Process the mouse release events.
e | Events. |
References Vector::Angle(), Camera::At(), camera, Camera::Eye(), and Math::Pi.
|
static |
Custom callback for OpenGL message.
source | |
type | |
id | |
severity | |
length | |
message | |
userParam |
References GLVerboseLevel.
Referenced by initializeGL().
|
slot |
Renders the scene.
The s for drawing the scene are performed here.
References Camera::At(), camera, Camera::Eye(), gpuall, gpuparam, plane, MayaPlane::Render(), MayaGpuAll::Render(), RenderAnchor(), RenderBackGround(), MayaGpuAll::RenderBBox(), RenderForeGround(), RenderLight(), Camera::Up(), and updateGPU().
|
protected |
Render the foreground.
t | Time. |
References camera, MayaStatistics::GetInstances(), MayaStatistics::GetInstancesTriangles(), MayaStatistics::GetInstancesVertices(), MayaStatistics::GetObjects(), MayaStatistics::GetObjectsTriangles(), MayaStatistics::GetObjectsVertices(), MayaGpuAll::GetStatistics(), gpuall, Camera::ToString(), and useCamera.
Referenced by paintGL().
void MayaWidget::ReplaceInWorld | ( | const MayaGeometryAll & | mga | ) |
Replace instances to be rendered.
mga | Set of geometry instances. |
References gpuall, and MayaGpuAll::Replace().
void MayaWidget::ReplaceMaterialInWorld | ( | MayaGeometryAll & | mga | ) |
Replace material of all instances.
mga | Set of geometry instances. |
References gpuall, and MayaGpuAll::UpdateMaterial().
|
protected |
Set up the OpenGL view port and matrix mode according to the size of the window.
w,h | Width and height of the window. |
References camera, Camera::GetAngleOfViewV(), Camera::GetFar(), Camera::GetNear(), and Math::RadianToDegree().
void MayaWidget::SaveScreen | ( | int | w, |
int | h, | ||
const QString & | url | ||
) |
Capture the rendering viewport and save it to disk.
w | width of the image |
h | height of the image |
url | url and name of the exported file |
void MayaWidget::SetAnchor | ( | const Vector & | v | ) |
Modify the anchor position.
Tha anchor is not rendered if is out of the plane.
v | Position of the anchor |
References ancre.
Referenced by UpdateAnchor().
void MayaWidget::SetCamera | ( | const Camera & | c | ) |
Set the viewing camera.
c | Camera. |
References camera, Camera::GetAngleOfViewV(), Camera::GetFar(), Camera::GetNear(), and Math::RadianToDegree().
void MayaWidget::SetLight | ( | const Vector & | p | ) |
void MayaWidget::SetPlane | ( | const Box2 & | box, |
const double & | h, | ||
const double & | l | ||
) |
Change the parameter of the plane.
It updates the MayaWidget view.
box | Rectangle. |
h | Height of the plane. |
l | Space between lines. |
References plane.
void MayaWidget::SetPlanes | ( | const double & | n, |
const double & | f | ||
) |
Set the near and far planes.
This function modifies the current camera. It updates the MayaWidget view.
n,f | Near and far planes distance. |
References camera, and Camera::SetPlanes().
void MayaWidget::SetWorld | ( | const MayaGeometryAll & | mga | ) |
Set the geometry instances to be rendered.
mga | Set of geometry instances. |
References MayaGpuAll::Append(), MayaGpuAll::ClearFrames(), and gpuall.
|
protectedvirtual |
Update the position of the Anchor on the intersection between the ray (mouse direction and the plane).
e | Mouse event. |
References ConvertPixelToRay(), MayaPlane::Intersect(), plane, and SetAnchor().
Referenced by mouseMoveEvent().
|
virtualslot |
Overloaded function to capture the wheel events.
e | Wheel events. |
References ancre, Camera::BackForth(), camera, and Camera::View().
|
static |
Static flag for verbose output in the console (useful for OpenGL debugging)
< Static flag for verbose output in the console (useful for OpenGL debugging)
OpenGL verbosity level. Everything below is ignored.
Referenced by initializeGL().