Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Q
qtquick3d
Manage
Activity
Members
Labels
Plan
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Andy Nichols
qtquick3d
Commits
c7a120aa
Commit
c7a120aa
authored
5 years ago
by
Richard Gustavsen
Browse files
Options
Downloads
Patches
Plain Diff
QDemonView3D: add worldToView
parent
7cd1debc
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Pipeline
#3593
passed
5 years ago
Changes
3
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
src/quick3d/qdemoncamera.cpp
+2
-0
2 additions, 0 deletions
src/quick3d/qdemoncamera.cpp
src/quick3d/qdemonview3d.cpp
+21
-0
21 additions, 0 deletions
src/quick3d/qdemonview3d.cpp
src/quick3d/qdemonview3d.h
+2
-0
2 additions, 0 deletions
src/quick3d/qdemonview3d.h
with
25 additions
and
0 deletions
src/quick3d/qdemoncamera.cpp
+
2
−
0
View file @
c7a120aa
...
@@ -157,6 +157,8 @@ void QDemonCamera::setProjectionMode(QDemonCamera::QDemonCameraProjectionMode pr
...
@@ -157,6 +157,8 @@ void QDemonCamera::setProjectionMode(QDemonCamera::QDemonCameraProjectionMode pr
* is normalized between 0 and 1. The top-left of the viewport is (0,0) and
* is normalized between 0 and 1. The top-left of the viewport is (0,0) and
* the botton-right is (1,1). If the position is not visible in the viewport, a
* the botton-right is (1,1). If the position is not visible in the viewport, a
* position of [-1, -1] is returned.
* position of [-1, -1] is returned.
*
* \sa QDemonView3D::worldToView
*/
*/
QVector2D
QDemonCamera
::
worldToViewport
(
const
QVector3D
&
worldPos
)
const
QVector2D
QDemonCamera
::
worldToViewport
(
const
QVector3D
&
worldPos
)
const
{
{
...
...
This diff is collapsed.
Click to expand it.
src/quick3d/qdemonview3d.cpp
+
21
−
0
View file @
c7a120aa
...
@@ -4,6 +4,7 @@
...
@@ -4,6 +4,7 @@
#include
"qdemonscenemanager_p.h"
#include
"qdemonscenemanager_p.h"
#include
"qdemonimage.h"
#include
"qdemonimage.h"
#include
"qdemonscenerenderer.h"
#include
"qdemonscenerenderer.h"
#include
"qdemoncamera.h"
#include
<QtDemonRuntimeRender/QDemonRenderLayer>
#include
<QtDemonRuntimeRender/QDemonRenderLayer>
#include
<QOpenGLFunctions>
#include
<QOpenGLFunctions>
...
@@ -421,6 +422,26 @@ QSurfaceFormat QDemonView3D::idealSurfaceFormat()
...
@@ -421,6 +422,26 @@ QSurfaceFormat QDemonView3D::idealSurfaceFormat()
return
f
;
return
f
;
}
}
/*!
* Transforms \a worldPoint from world space into view space. If the position
* is not visible in the viewport, a position of [-1, -1] is returned. This
* function requires that a camera is assigned to the view.
*
* \sa QDemonCamera::worldToViewport
*/
QVector2D
QDemonView3D
::
worldToView
(
const
QVector3D
&
worldPos
)
const
{
if
(
!
m_camera
)
{
qmlWarning
(
this
)
<<
"Cannot resolve position in view without a camera assigned!"
;
return
QVector2D
(
-
1
,
-
1
);
}
const
QVector2D
normalizedPos
=
m_camera
->
worldToViewport
(
worldPos
);
if
(
normalizedPos
.
x
()
<
0
)
return
normalizedPos
;
return
normalizedPos
*
QVector2D
(
float
(
width
()),
float
(
height
()));
}
void
QDemonView3D
::
invalidateSceneGraph
()
void
QDemonView3D
::
invalidateSceneGraph
()
{
{
m_node
=
nullptr
;
m_node
=
nullptr
;
...
...
This diff is collapsed.
Click to expand it.
src/quick3d/qdemonview3d.h
+
2
−
0
View file @
c7a120aa
...
@@ -57,6 +57,8 @@ public:
...
@@ -57,6 +57,8 @@ public:
static
QSurfaceFormat
idealSurfaceFormat
();
static
QSurfaceFormat
idealSurfaceFormat
();
Q_INVOKABLE
QVector2D
worldToView
(
const
QVector3D
&
worldPos
)
const
;
protected
:
protected
:
void
geometryChanged
(
const
QRectF
&
newGeometry
,
const
QRectF
&
oldGeometry
)
override
;
void
geometryChanged
(
const
QRectF
&
newGeometry
,
const
QRectF
&
oldGeometry
)
override
;
QSGNode
*
updatePaintNode
(
QSGNode
*
,
UpdatePaintNodeData
*
)
override
;
QSGNode
*
updatePaintNode
(
QSGNode
*
,
UpdatePaintNodeData
*
)
override
;
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment