7#include <QtCore/qdir.h>
8#include <QtQml/qqmlfile.h>
9#include <QtQuick3D/private/qquick3dmodel_p.h>
10#include <QtQuick3DRuntimeRender/private/qssgrenderbuffermanager_p.h>
102 return randomPositionModel(particleIndex);
131 clearModelVertexPositions();
136void QQuick3DParticleModelShape::createModel()
143 m_model = qobject_cast<QQuick3DModel *>(
obj);
148QVector3D QQuick3DParticleModelShape::randomPositionModel(
int particleIndex)
151 calculateModelVertexPositions();
159 if (m_modelTriangleAreas.size() == 0) {
160 m_modelTriangleAreas.reserve(
positions.size() / 3);
166 m_modelTriangleAreasSum +=
area;
167 m_modelTriangleAreas.append(m_modelTriangleAreasSum);
168 m_modelTriangleCenter +=
v1 +
v2 +
v3;
170 m_modelTriangleCenter /=
positions.size();
173 const float rndWeight = rand->get(particleIndex,
QPRand::Shape1) * m_modelTriangleAreasSum;
176 int index = std::lower_bound(m_modelTriangleAreas.begin(), m_modelTriangleAreas.end(), rndWeight) - m_modelTriangleAreas.begin();
183 const float aSqrt =
qSqrt(
a);
193 const float lambda = 5.0f;
194 const float alpha = -
qLn(1 - (1 -
qExp(-lambda)) * uniform) / lambda;
209void QQuick3DParticleModelShape::clearModelVertexPositions()
211 m_vertexPositions.clear();
212 m_modelTriangleAreas.clear();
213 m_modelTriangleAreasSum = 0;
216void QQuick3DParticleModelShape::calculateModelVertexPositions()
218 if (m_vertexPositions.empty()) {
224 bool hasIndexBuffer =
false;
234 hasIndexBuffer =
true;
235 indexBufferFormat =
attribute.componentType;
243 memcpy(
v,
data + posOffset +
i,
sizeof(
v));
246 if (hasIndexBuffer) {
251 for (
int i = 0;
i <
data.size();
i += indexSize) {
267 if (mesh.
drawMode() != QSSGMesh::Mesh::DrawMode::Triangles)
275 for (
int i = 0;
i < entries.size(); ++
i) {
276 const char *nameStr = entries[
i].name.constData();
278 posOffset = entries[
i].offset;
279 posCount = entries[
i].componentCount;
280 posType = entries[
i].componentType;
284 if (posCount == 3 && posType == QSSGMesh::Mesh::ComponentType::Float32) {
289 memcpy(
v,
data + posOffset +
i,
sizeof(
v));
294 for (
int i = 0;
i < indexData.size();
i += indexSize) {
296 memcpy(&
index, indexData +
i, indexSize);
302 if (!indicedPositions.
empty())
303 m_vertexPositions = indicedPositions;
static QString cleanPath(const QString &path)
Returns path with directory separators normalized (that is, platform-native separators converted to "...
\inmodule QtCore \reentrant
QString absoluteFilePath() const
Returns an absolute path including the file name.
bool exists() const
Returns true if the file exists; otherwise returns false.
bool open(OpenMode flags) override
Opens the file using OpenMode mode, returning true if successful; otherwise false.
bool empty() const noexcept
void append(parameter_type t)
The QMatrix4x4 class represents a 4x4 transformation matrix in 3D space.
void rotate(float angle, const QVector3D &vector)
Multiples this matrix by another that rotates coordinates through angle degrees about vector.
QVector3D mapVector(const QVector3D &vector) const
Maps vector by multiplying the top 3x3 portion of this matrix by vector.
QObject * parent() const
Returns a pointer to the parent object.
The QQmlComponent class encapsulates a QML component definition.
QQmlContext * creationContext() const
Returns the QQmlContext the component was created in.
virtual QObject * create(QQmlContext *context=nullptr)
Create an object instance from this component, within the specified context.
The QQmlContext class defines a context within a QML engine.
static QString urlToLocalFileOrQrc(const QString &)
If url is a local file returns a path suitable for passing to QFile.
\qmltype Geometry \inherits Object3D \inqmlmodule QtQuick3D \instantiates QQuick3DGeometry
Attribute::Semantic int int stride
Returns the byte stride of the vertex buffer.
int attributeCount() const
Returns the number of attributes defined for this geometry.
Attribute attribute(int index) const
Returns attribute definition number index.
QByteArray vertexData() const
Returns the vertex buffer data set by setVertexData.
QQuick3DGeometry * geometry
QQuick3DNode * parentNode()
QQuick3DParticleSystem * m_system
~QQuick3DParticleModelShape() override
QQuick3DParticleModelShape(QObject *parent=nullptr)
\qmltype ParticleModelShape3D \inherits ParticleAbtractShape3D \inqmlmodule QtQuick3D....
void setDelegate(QQmlComponent *delegate)
QVector3D getPosition(int particleIndex) override
static QString primitivePath(const QString &primitive)
static Mesh loadMesh(QIODevice *device, quint32 id=0)
VertexBuffer vertexBuffer() const
IndexBuffer indexBuffer() const
DrawMode drawMode() const
\macro QT_RESTRICTED_CAST_FROM_ASCII
QString toString(FormattingOptions options=FormattingOptions(PrettyDecoded)) const
Returns a string representation of the URL.
The QVector3D class represents a vector or vertex in 3D space.
float length() const noexcept
Returns the length of the vector from the origin.
static constexpr QVector3D crossProduct(QVector3D v1, QVector3D v2) noexcept
Returns the cross-product of vectors v1 and v2, which is normal to the plane spanned by v1 and v2.
Combined button and popup list for selecting options.
static const QCssKnownValue positions[NumKnownPositionModes - 1]
EGLOutputLayerEXT EGLint attribute
qfloat16 qSqrt(qfloat16 f)
static int area(const QSize &s)
GLint GLfloat GLfloat GLfloat v2
GLboolean GLboolean GLboolean b
GLsizei const GLfloat * v
[13]
GLboolean GLboolean GLboolean GLboolean a
[7]
const void GLsizei GLsizei stride
GLint GLsizei GLsizei GLenum GLenum GLsizei void * data
GLint GLfloat GLfloat GLfloat GLfloat v3
GLsizei GLsizei GLchar * source
GLfloat GLfloat GLfloat alpha
QQmlContext * qmlContext(const QObject *obj)
static QSSGMesh::Mesh loadModelShapeMesh(const QString &source)
QLatin1StringView QLatin1String
\inmodule QtCore \reentrant
static quint32 byteSizeForComponentType(Mesh::ComponentType componentType)
static const char * getPositionAttrName()
ComponentType componentType
QVector< VertexBufferEntry > entries
IUIAutomationTreeWalker __RPC__deref_out_opt IUIAutomationElement ** parent