Skip to content

Commit

Permalink
qmlui: more on multi beam bars
Browse files Browse the repository at this point in the history
  • Loading branch information
mcallegari committed Nov 12, 2018
1 parent db3dfb8 commit 0f4a513
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 43 deletions.
63 changes: 32 additions & 31 deletions qmlui/mainview3d.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1309,46 +1309,47 @@ void MainView3D::updateFixtureRotation(quint32 itemID, QVector3D degrees)

void MainView3D::updateLightMatrix(SceneItem *mesh)
{
// no head ? Nothing to do
if (mesh->m_headItem == nullptr)
return;

// below, we extract a rotation matrix and position, which we need for properly
// positioning and rotating the spotlight cone.
if (mesh->m_headItem)
{
QMatrix4x4 m = (mesh->m_rootTransform->matrix());
QMatrix4x4 m = (mesh->m_rootTransform->matrix());

if (mesh->m_armItem)
{
QMatrix4x4 armTransform = getTransform(mesh->m_armItem)->matrix();
m.translate(armTransform.data()[12], armTransform.data()[13], armTransform.data()[14]);
}
if (mesh->m_armItem)
{
QMatrix4x4 armTransform = getTransform(mesh->m_armItem)->matrix();
m.translate(armTransform.data()[12], armTransform.data()[13], armTransform.data()[14]);
}

if (mesh->m_headItem)
{
QMatrix4x4 headTransform = getTransform(mesh->m_headItem)->matrix();
m.translate(headTransform.data()[12], headTransform.data()[13], headTransform.data()[14]);
}
if (mesh->m_headItem)
{
QMatrix4x4 headTransform = getTransform(mesh->m_headItem)->matrix();
m.translate(headTransform.data()[12], headTransform.data()[13], headTransform.data()[14]);
}

QVector4D xb = m * QVector4D(1, 0, 0, 0);
QVector4D yb = m * QVector4D(0, 1, 0, 0);
QVector4D zb = m * QVector4D(0, 0, 1, 0);
QVector4D xb = m * QVector4D(1, 0, 0, 0);
QVector4D yb = m * QVector4D(0, 1, 0, 0);
QVector4D zb = m * QVector4D(0, 0, 1, 0);

QVector3D xa = QVector3D(xb.x(), xb.y(), xb.z()).normalized();
QVector3D ya = QVector3D(yb.x(), yb.y(), yb.z()).normalized();
QVector3D za = QVector3D(zb.x(), zb.y(), zb.z()).normalized();
QVector3D xa = QVector3D(xb.x(), xb.y(), xb.z()).normalized();
QVector3D ya = QVector3D(yb.x(), yb.y(), yb.z()).normalized();
QVector3D za = QVector3D(zb.x(), zb.y(), zb.z()).normalized();

QMatrix4x4 lightMatrix = QMatrix4x4(
xa.x(), xa.y(), xa.z(), 0,
ya.x(), ya.y(), ya.z(), 0,
za.x(), za.y(), za.z(), 0,
0, 0, 0, 1
).transposed();
QMatrix4x4 lightMatrix = QMatrix4x4(
xa.x(), xa.y(), xa.z(), 0,
ya.x(), ya.y(), ya.z(), 0,
za.x(), za.y(), za.z(), 0,
0, 0, 0, 1
).transposed();

QVector4D result = m * QVector4D(0, 0, 0, 1);
QVector4D result = m * QVector4D(0, 0, 0, 1);

QMetaObject::invokeMethod(mesh->m_rootItem, "setHeadLightProps",
Q_ARG(QVariant, 0),
Q_ARG(QVariant, QVariant::fromValue(QVector3D(result.x(), result.y(), result.z()))),
Q_ARG(QVariant, QVariant::fromValue(lightMatrix)));
}
QMetaObject::invokeMethod(mesh->m_rootItem, "setHeadLightProps",
Q_ARG(QVariant, 0),
Q_ARG(QVariant, QVariant::fromValue(QVector3D(result.x(), result.y(), result.z()))),
Q_ARG(QVariant, QVariant::fromValue(lightMatrix)));
}

void MainView3D::updateFixtureScale(quint32 itemID, QVector3D origSize)
Expand Down
2 changes: 1 addition & 1 deletion qmlui/mainview3d.h
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,7 @@ protected slots:
QRenderTarget *m_gBuffer;
QRenderTarget *m_frontDepthTarget;

/** Map of QLC+ fixture IDs and QML Entity items */
/** Map of QLC+ item IDs and SceneItem references */
QMap<quint32, SceneItem*> m_entitiesMap;

/** Cache of the loaded models against bounding volumes */
Expand Down
32 changes: 21 additions & 11 deletions qmlui/qml/fixturesfunctions/3DView/MultiBeams3DItem.qml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ Entity

property int itemID: fixtureManager.invalidFixture()
property bool isSelected: false
property int headsNumber: 1
property int headsNumber: 0
property vector3d phySize: Qt.vector3d(1, 0.1, 0.1)

onItemIDChanged:
Expand All @@ -52,8 +52,8 @@ Entity
property Transform tiltTransform

/* **************** Focus properties **************** */
property real focusMinDegrees: 15
property real focusMaxDegrees: 30
property real focusMinDegrees: 5
property real focusMaxDegrees: 5
property real distCutoff: 40.0
property real cutoffAngle: (focusMinDegrees / 2) * (Math.PI / 180)

Expand Down Expand Up @@ -99,9 +99,14 @@ Entity

function setHeadLightProps(headIndex, pos, matrix)
{
var head = getHead(headIndex)
head.lightPos = pos
head.lightMatrix = matrix
for (var h = 0; h < headsNumber; h++)
{
var head = getHead(h)
var hPos = Qt.vector3d(pos.x * h, pos.y, pos.z)
head.lightPos = hPos
head.lightMatrix = matrix
console.log("Setting light info: " + hPos + ", m: " + matrix)
}
}

function setHeadIntensity(headIndex, intensity)
Expand Down Expand Up @@ -223,7 +228,7 @@ Entity
NodeInstantiator
{
id: headsRepeater
//model: fixtureEntity.headsNumber
model: 0

onObjectAdded:
{
Expand Down Expand Up @@ -267,18 +272,18 @@ Entity
property matrix4x4 lightViewProjectionScaleAndOffsetMatrix:
Math3D.getLightViewProjectionScaleOffsetMatrix(lightViewProjectionMatrix)

//property Transform headTransform: Transform { translation: Qt.vector3d(0, 0.1 * index, 0) }
property Transform headTransform: Transform { translation: Qt.vector3d(0.1 * index, 0, 0) }

function setupScattering(shadingEffect, scatteringEffect, depthEffect, sceneEntity)
{
shadingCone.coneEffect = shadingEffect
shadingCone.parent = sceneEntity
shadingCone.spotlightConeMesh = sceneEntity.coneMesh
/*
scatteringCone.coneEffect = scatteringEffect

//scatteringCone.coneEffect = scatteringEffect
scatteringCone.parent = sceneEntity
scatteringCone.spotlightConeMesh = sceneEntity.coneMesh
*/

outDepthCone.coneEffect = depthEffect
outDepthCone.parent = sceneEntity
outDepthCone.spotlightConeMesh = sceneEntity.coneMesh
Expand Down Expand Up @@ -333,6 +338,11 @@ Entity
coneLayer: outputDepthLayer
fxEntity: headDelegate
}

components: [
headTransform,
sceneLayer
]
} // Entity
} // Repeater

Expand Down

0 comments on commit 0f4a513

Please sign in to comment.