Do not test!

Add color qvector to polyline entity to allow for multiple colors
through the line.
Add some new icons to the tabs of the app.
This commit is contained in:
Artur Gomes 2017-08-02 19:32:04 +01:00
parent e79a78e839
commit 2c80e2e86e
9 changed files with 61 additions and 12 deletions

View file

@ -58,6 +58,7 @@ void RenderablePolyLineEntityItem::createPipeline() {
_format->setAttribute(gpu::Stream::POSITION, 0, gpu::Element(gpu::VEC3, gpu::FLOAT, gpu::XYZ), 0);
_format->setAttribute(gpu::Stream::NORMAL, 0, gpu::Element(gpu::VEC3, gpu::FLOAT, gpu::XYZ), NORMAL_OFFSET);
_format->setAttribute(gpu::Stream::TEXCOORD, 0, gpu::Element(gpu::VEC2, gpu::FLOAT, gpu::UV), TEXTURE_OFFSET);
_format->setAttribute(gpu::Stream::COLOR, 0, gpu::Element(gpu::VEC3, gpu::UINT8, gpu::RGB), 0);
auto VS = gpu::Shader::createVertex(std::string(paintStroke_vert));
auto PS = gpu::Shader::createPixel(std::string(paintStroke_frag));
@ -99,7 +100,6 @@ void RenderablePolyLineEntityItem::updateGeometry() {
for (int i = 0; i < _vertices.size() / 2; i++) {
vCoord = 0.0f;
if (!_isUVModeStretch && vertexIndex > 2) {
distanceToLastPoint = glm::distance(_vertices.at(vertexIndex), _vertices.at(vertexIndex - 2));
if (doesStrokeWidthVary) {
@ -107,7 +107,8 @@ void RenderablePolyLineEntityItem::updateGeometry() {
//because it looks better than using the same method as below
accumulatedStrokeWidth += 2 * _strokeWidths[i];
float strokeWidth = 2 * _strokeWidths[i];
float newUcoord = glm::ceil((_textureAspectRatio * (accumulatedDistance + distanceToLastPoint)) / (accumulatedStrokeWidth / i));
float newUcoord = glm::ceil(
(_textureAspectRatio * (accumulatedDistance + distanceToLastPoint)) / (accumulatedStrokeWidth / i));
float increaseValue = newUcoord - uCoord;
increaseValue = increaseValue > 0 ? increaseValue : 1;
uCoord += increaseValue;
@ -124,12 +125,18 @@ void RenderablePolyLineEntityItem::updateGeometry() {
_verticesBuffer->append(sizeof(glm::vec3), (const gpu::Byte*)&_vertices.at(vertexIndex));
_verticesBuffer->append(sizeof(glm::vec3), (const gpu::Byte*)&_normals.at(i));
_verticesBuffer->append(sizeof(glm::vec2), (gpu::Byte*)&uv);
_strokeColors.size() > i
? _verticesBuffer->append(sizeof(glm::vec3), (const gpu::Byte*)&_strokeColors.at(i))
: _verticesBuffer->append(sizeof(glm::vec3), (const gpu::Byte*)&toGlm(getXColor()));
vertexIndex++;
uv.y = 1.0f;
_verticesBuffer->append(sizeof(glm::vec3), (const gpu::Byte*)&_vertices.at(vertexIndex));
_verticesBuffer->append(sizeof(glm::vec3), (const gpu::Byte*)&_normals.at(i));
_verticesBuffer->append(sizeof(glm::vec2), (const gpu::Byte*)&uv);
_strokeColors.size() > i
? _verticesBuffer->append(sizeof(glm::vec3), (const gpu::Byte*)&_strokeColors.at(i))
: _verticesBuffer->append(sizeof(glm::vec3), (const gpu::Byte*)&toGlm(getXColor()));
vertexIndex++;
_numVertices += 2;
@ -149,6 +156,7 @@ void RenderablePolyLineEntityItem::updateGeometry() {
_pointsChanged = false;
_normalsChanged = false;
_strokeWidthsChanged = false;
_strokeColorsChanged = false;
}
void RenderablePolyLineEntityItem::updateVertices() {
@ -203,9 +211,9 @@ void RenderablePolyLineEntityItem::update(const quint64& now) {
PolyLineUniforms uniforms;
uniforms.color = toGlm(getXColor());
memcpy(&_uniformBuffer.edit<PolyLineUniforms>(), &uniforms, sizeof(PolyLineUniforms));
if (_pointsChanged || _strokeWidthsChanged || _normalsChanged) {
if (_pointsChanged || _strokeWidthsChanged || _normalsChanged || _strokeColorsChanged) {
QWriteLocker lock(&_quadReadWriteLock);
_empty = (_points.size() < 2 || _normals.size() < 2 || _strokeWidths.size() < 2);
_empty = (_points.size() < 2 || _normals.size() < 2 || _strokeWidths.size() < 2 || _strokeColors.size() < 2);
if (!_empty) {
updateVertices();
updateGeometry();

View file

@ -302,8 +302,9 @@ EntityPropertyFlags EntityItemProperties::getChangedProperties() const {
CHECK_PROPERTY_CHANGE(PROP_FACE_CAMERA, faceCamera);
CHECK_PROPERTY_CHANGE(PROP_ACTION_DATA, actionData);
CHECK_PROPERTY_CHANGE(PROP_NORMALS, normals);
CHECK_PROPERTY_CHANGE(PROP_STROKE_COLORS, strokeColors);
CHECK_PROPERTY_CHANGE(PROP_STROKE_WIDTHS, strokeWidths);
CHECK_PROPERTY_CHANGE(PROP_IS_UV_MODE_STRETCH, isUVModeStretch);
CHECK_PROPERTY_CHANGE(PROP_IS_UV_MODE_STRETCH, isUVModeStretch);
CHECK_PROPERTY_CHANGE(PROP_X_TEXTURE_URL, xTextureURL);
CHECK_PROPERTY_CHANGE(PROP_Y_TEXTURE_URL, yTextureURL);
CHECK_PROPERTY_CHANGE(PROP_Z_TEXTURE_URL, zTextureURL);
@ -537,6 +538,7 @@ QScriptValue EntityItemProperties::copyToScriptValue(QScriptEngine* engine, bool
COPY_PROPERTY_TO_QSCRIPTVALUE(PROP_LINE_WIDTH, lineWidth);
COPY_PROPERTY_TO_QSCRIPTVALUE(PROP_LINE_POINTS, linePoints);
COPY_PROPERTY_TO_QSCRIPTVALUE(PROP_NORMALS, normals);
COPY_PROPERTY_TO_QSCRIPTVALUE(PROP_STROKE_COLORS, strokeColors);
COPY_PROPERTY_TO_QSCRIPTVALUE(PROP_STROKE_WIDTHS, strokeWidths);
COPY_PROPERTY_TO_QSCRIPTVALUE(PROP_TEXTURES, textures);
COPY_PROPERTY_TO_QSCRIPTVALUE(PROP_IS_UV_MODE_STRETCH, isUVModeStretch);
@ -689,8 +691,10 @@ void EntityItemProperties::copyFromScriptValue(const QScriptValue& object, bool
COPY_PROPERTY_FROM_QSCRIPTVALUE(faceCamera, bool, setFaceCamera);
COPY_PROPERTY_FROM_QSCRIPTVALUE(actionData, QByteArray, setActionData);
COPY_PROPERTY_FROM_QSCRIPTVALUE(normals, qVectorVec3, setNormals);
COPY_PROPERTY_FROM_QSCRIPTVALUE(strokeColors, qVectorVec3, setStrokeColors);
COPY_PROPERTY_FROM_QSCRIPTVALUE(strokeWidths,qVectorFloat, setStrokeWidths);
COPY_PROPERTY_FROM_QSCRIPTVALUE(isUVModeStretch, bool, setIsUVModeStretch);
if (!honorReadOnly) {
// this is used by the json reader to set things that we don't want javascript to able to affect.
@ -828,6 +832,7 @@ void EntityItemProperties::merge(const EntityItemProperties& other) {
COPY_PROPERTY_IF_CHANGED(faceCamera);
COPY_PROPERTY_IF_CHANGED(actionData);
COPY_PROPERTY_IF_CHANGED(normals);
COPY_PROPERTY_IF_CHANGED(strokeColors);
COPY_PROPERTY_IF_CHANGED(strokeWidths);
COPY_PROPERTY_IF_CHANGED(isUVModeStretch);
COPY_PROPERTY_IF_CHANGED(created);
@ -1003,6 +1008,7 @@ void EntityItemProperties::entityPropertyFlagsFromScriptValue(const QScriptValue
ADD_PROPERTY_TO_MAP(PROP_FACE_CAMERA, FaceCamera, faceCamera, bool);
ADD_PROPERTY_TO_MAP(PROP_ACTION_DATA, ActionData, actionData, QByteArray);
ADD_PROPERTY_TO_MAP(PROP_NORMALS, Normals, normals, QVector<glm::vec3>);
ADD_PROPERTY_TO_MAP(PROP_STROKE_COLORS, StrokeColors, strokeColors, QVector<glm::vec3>);
ADD_PROPERTY_TO_MAP(PROP_STROKE_WIDTHS, StrokeWidths, strokeWidths, QVector<float>);
ADD_PROPERTY_TO_MAP(PROP_IS_UV_MODE_STRETCH, IsUVModeStretch, isUVModeStretch, QVector<float>);
ADD_PROPERTY_TO_MAP(PROP_X_TEXTURE_URL, XTextureURL, xTextureURL, QString);
@ -1328,6 +1334,7 @@ bool EntityItemProperties::encodeEntityEditPacket(PacketType command, EntityItem
APPEND_ENTITY_PROPERTY(PROP_LINE_WIDTH, properties.getLineWidth());
APPEND_ENTITY_PROPERTY(PROP_LINE_POINTS, properties.getLinePoints());
APPEND_ENTITY_PROPERTY(PROP_NORMALS, properties.getNormals());
APPEND_ENTITY_PROPERTY(PROP_STROKE_COLORS, properties.getStrokeColors());
APPEND_ENTITY_PROPERTY(PROP_STROKE_WIDTHS, properties.getStrokeWidths());
APPEND_ENTITY_PROPERTY(PROP_TEXTURES, properties.getTextures());
APPEND_ENTITY_PROPERTY(PROP_IS_UV_MODE_STRETCH, properties.getIsUVModeStretch());
@ -1625,6 +1632,7 @@ bool EntityItemProperties::decodeEntityEditPacket(const unsigned char* data, int
READ_ENTITY_PROPERTY_TO_PROPERTIES(PROP_LINE_WIDTH, float, setLineWidth);
READ_ENTITY_PROPERTY_TO_PROPERTIES(PROP_LINE_POINTS, QVector<glm::vec3>, setLinePoints);
READ_ENTITY_PROPERTY_TO_PROPERTIES(PROP_NORMALS, QVector<glm::vec3>, setNormals);
READ_ENTITY_PROPERTY_TO_PROPERTIES(PROP_STROKE_COLORS, QVector<glm::vec3>, setStrokeColors);
READ_ENTITY_PROPERTY_TO_PROPERTIES(PROP_STROKE_WIDTHS, QVector<float>, setStrokeWidths);
READ_ENTITY_PROPERTY_TO_PROPERTIES(PROP_TEXTURES, QString, setTextures);
READ_ENTITY_PROPERTY_TO_PROPERTIES(PROP_IS_UV_MODE_STRETCH, bool, setIsUVModeStretch);
@ -1776,6 +1784,7 @@ void EntityItemProperties::markAllChanged() {
_actionDataChanged = true;
_normalsChanged = true;
_strokeColorsChanged = true;
_strokeWidthsChanged = true;
_isUVModeStretchChanged = true;

View file

@ -188,6 +188,7 @@ public:
DEFINE_PROPERTY(PROP_FACE_CAMERA, FaceCamera, faceCamera, bool, TextEntityItem::DEFAULT_FACE_CAMERA);
DEFINE_PROPERTY_REF(PROP_ACTION_DATA, ActionData, actionData, QByteArray, QByteArray());
DEFINE_PROPERTY(PROP_NORMALS, Normals, normals, QVector<glm::vec3>, QVector<glm::vec3>());
DEFINE_PROPERTY(PROP_STROKE_COLORS, StrokeColors, strokeColors, QVector<glm::vec3>, QVector<glm::vec3>());
DEFINE_PROPERTY(PROP_STROKE_WIDTHS, StrokeWidths, strokeWidths, QVector<float>, QVector<float>());
DEFINE_PROPERTY(PROP_IS_UV_MODE_STRETCH, IsUVModeStretch, isUVModeStretch, bool, true);
DEFINE_PROPERTY_REF(PROP_X_TEXTURE_URL, XTextureURL, xTextureURL, QString, "");

View file

@ -108,6 +108,7 @@ enum EntityPropertyList {
// Used by PolyLine entity
PROP_NORMALS,
PROP_STROKE_COLORS,
PROP_STROKE_WIDTHS,
PROP_IS_UV_MODE_STRETCH,

View file

@ -36,9 +36,11 @@ EntityItem(entityItemID),
_lineWidth(DEFAULT_LINE_WIDTH),
_pointsChanged(true),
_normalsChanged(true),
_strokeColorsChanged(true),
_strokeWidthsChanged(true),
_points(QVector<glm::vec3>(0.0f)),
_normals(QVector<glm::vec3>(0.0f)),
_strokeColors(QVector<glm::vec3>(0.0f)),
_strokeWidths(QVector<float>(0.0f)),
_textures(""),
_isUVModeStretch(true)
@ -58,6 +60,7 @@ EntityItemProperties PolyLineEntityItem::getProperties(EntityPropertyFlags desir
COPY_ENTITY_PROPERTY_TO_PROPERTIES(lineWidth, getLineWidth);
COPY_ENTITY_PROPERTY_TO_PROPERTIES(linePoints, getLinePoints);
COPY_ENTITY_PROPERTY_TO_PROPERTIES(normals, getNormals);
COPY_ENTITY_PROPERTY_TO_PROPERTIES(strokeColors, getStrokeColors);
COPY_ENTITY_PROPERTY_TO_PROPERTIES(strokeWidths, getStrokeWidths);
COPY_ENTITY_PROPERTY_TO_PROPERTIES(textures, getTextures);
COPY_ENTITY_PROPERTY_TO_PROPERTIES(isUVModeStretch, getIsUVModeStretch);
@ -73,6 +76,7 @@ bool PolyLineEntityItem::setProperties(const EntityItemProperties& properties) {
SET_ENTITY_PROPERTY_FROM_PROPERTIES(lineWidth, setLineWidth);
SET_ENTITY_PROPERTY_FROM_PROPERTIES(linePoints, setLinePoints);
SET_ENTITY_PROPERTY_FROM_PROPERTIES(normals, setNormals);
SET_ENTITY_PROPERTY_FROM_PROPERTIES(strokeColors, setStrokeColors);
SET_ENTITY_PROPERTY_FROM_PROPERTIES(strokeWidths, setStrokeWidths);
SET_ENTITY_PROPERTY_FROM_PROPERTIES(textures, setTextures);
SET_ENTITY_PROPERTY_FROM_PROPERTIES(isUVModeStretch, setIsUVModeStretch);
@ -123,6 +127,15 @@ bool PolyLineEntityItem::setNormals(const QVector<glm::vec3>& normals) {
return true;
}
bool PolyLineEntityItem::setStrokeColors(const QVector<glm::vec3>& strokeColors) {
withWriteLock([&] {
_strokeColors = strokeColors;
_strokeColorsChanged = true;
});
return true;
}
bool PolyLineEntityItem::setLinePoints(const QVector<glm::vec3>& points) {
if (points.size() > MAX_POINTS_PER_LINE) {
return false;
@ -175,6 +188,7 @@ int PolyLineEntityItem::readEntitySubclassDataFromBuffer(const unsigned char* da
READ_ENTITY_PROPERTY(PROP_LINE_WIDTH, float, setLineWidth);
READ_ENTITY_PROPERTY(PROP_LINE_POINTS, QVector<glm::vec3>, setLinePoints);
READ_ENTITY_PROPERTY(PROP_NORMALS, QVector<glm::vec3>, setNormals);
READ_ENTITY_PROPERTY(PROP_STROKE_COLORS, QVector<glm::vec3>, setStrokeColors);
READ_ENTITY_PROPERTY(PROP_STROKE_WIDTHS, QVector<float>, setStrokeWidths);
READ_ENTITY_PROPERTY(PROP_TEXTURES, QString, setTextures);
READ_ENTITY_PROPERTY(PROP_IS_UV_MODE_STRETCH, bool, setIsUVModeStretch);
@ -190,6 +204,7 @@ EntityPropertyFlags PolyLineEntityItem::getEntityProperties(EncodeBitstreamParam
requestedProperties += PROP_LINE_WIDTH;
requestedProperties += PROP_LINE_POINTS;
requestedProperties += PROP_NORMALS;
requestedProperties += PROP_STROKE_COLORS;
requestedProperties += PROP_STROKE_WIDTHS;
requestedProperties += PROP_TEXTURES;
requestedProperties += PROP_IS_UV_MODE_STRETCH;
@ -211,6 +226,7 @@ void PolyLineEntityItem::appendSubclassData(OctreePacketData* packetData, Encode
APPEND_ENTITY_PROPERTY(PROP_LINE_WIDTH, getLineWidth());
APPEND_ENTITY_PROPERTY(PROP_LINE_POINTS, getLinePoints());
APPEND_ENTITY_PROPERTY(PROP_NORMALS, getNormals());
APPEND_ENTITY_PROPERTY(PROP_STROKE_COLORS, getStrokeColors());
APPEND_ENTITY_PROPERTY(PROP_STROKE_WIDTHS, getStrokeWidths());
APPEND_ENTITY_PROPERTY(PROP_TEXTURES, getTextures());
APPEND_ENTITY_PROPERTY(PROP_IS_UV_MODE_STRETCH, getIsUVModeStretch());
@ -243,6 +259,14 @@ QVector<glm::vec3> PolyLineEntityItem::getNormals() const {
return result;
}
QVector<glm::vec3> PolyLineEntityItem::getStrokeColors() const {
QVector<glm::vec3> result;
withReadLock([&] {
result = _strokeColors;
});
return result;
}
QVector<float> PolyLineEntityItem::getStrokeWidths() const {
QVector<float> result;
withReadLock([&] {

View file

@ -64,6 +64,9 @@ class PolyLineEntityItem : public EntityItem {
bool setNormals(const QVector<glm::vec3>& normals);
QVector<glm::vec3> getNormals() const;
bool setStrokeColors(const QVector<glm::vec3>& strokeColors);
QVector<glm::vec3> getStrokeColors() const;
bool setStrokeWidths(const QVector<float>& strokeWidths);
QVector<float> getStrokeWidths() const;
@ -93,9 +96,11 @@ class PolyLineEntityItem : public EntityItem {
float _lineWidth;
bool _pointsChanged;
bool _normalsChanged;
bool _strokeColorsChanged;
bool _strokeWidthsChanged;
QVector<glm::vec3> _points;
QVector<glm::vec3> _normals;
QVector<glm::vec3> _strokeColors;
QVector<float> _strokeWidths;
QString _textures;
bool _isUVModeStretch;

View file

@ -0,0 +1 @@
<svg fill="#fff" id="Brush-icon-High-Fidelity" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512"><title>Artboard 1</title><path d="M186.14,357.79c7.59,9.58,8.08,17.35,8.5,23,1.45,19.27-6.3,35.94-22.69,47-16.48,11.34-42.76,18.39-66.78,20.23a155,155,0,0,1-59.6-7.11,8.54,8.54,0,0,1-5.89-8.38c.09-3.79,2.75-6.72,6.34-8,13.84-5.08,22.76-14.57,34.07-29.61s22.25-32.28,34.73-45C123.09,341.41,129,339,140.91,338c14.3-1,34.25,5.49,45.23,19.78"/><path d="M457.94,72.56A13,13,0,0,0,449.48,69c-2.41,0-4.82,1.24-7.22,2.46C367.84,122.63,226.49,258.69,163,320.63a53.88,53.88,0,0,1,35.08,15.43C211.45,349.24,214,370.93,214,370.93c61.05-64.34,196.33-207.59,246.45-282.71C462.84,83.38,462.79,76.14,457.94,72.56Z"/></svg>

After

Width:  |  Height:  |  Size: 710 B

View file

@ -0,0 +1 @@
<svg fill="#fff" id="Palette-icon-High-Fidelity" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512"><title>palette-icon</title><path d="M186.73,239.68a31.17,31.17,0,0,0,10.36-7.46,20.84,20.84,0,0,0,4.27-18.36c-3.11-12.11-15.54-17.4-26.67-19.67-10.51-2.14-21.55-2.44-31.34-6.82-14.91-6.66-24.85-23.11-23.8-39.41,1.28-20,17-36,33.5-47.35,60.53-41.4,146.23-41.86,207.34-1.31s94,119.52,79.92,191.5S366.23,423.51,294.48,438.65c-51.48,10.86-106-.5-152.82-24.6C120.85,403.33,101,389.8,86.82,371.13S64.92,328,70.05,305.2s23.86-41.3,46-48c13.5-4.08,27.93-3.92,41.68-7a142.49,142.49,0,0,0,24.14-8.3C183.52,241.16,185.14,240.45,186.73,239.68ZM373,148.22a29.25,29.25,0,1,0-3.88,41.32h0a29.26,29.26,0,0,0,4-41.17l-.14-.17Zm27.95,141.42.15-.12a29.45,29.45,0,1,0-41.45-4l.11.14a29.26,29.26,0,0,0,41.17,4l.15-.12Zm-40.52,89.43a29.25,29.25,0,1,0-41.17-4,29.26,29.26,0,0,0,41.17,4l.06,0ZM263.61,407.5a33.22,33.22,0,1,0-.15.1l.29-.24Zm-83.69-82.23A29.25,29.25,0,1,0,176,366.59h0a29.26,29.26,0,0,0,4-41.17l-.14-.17Z"/></svg>

After

Width:  |  Height:  |  Size: 1,010 B

View file

@ -22,18 +22,17 @@
.tabButton {
background-color: #000;
color: white;
font-size: 100%;
font-size: 20px;
padding: 12px;
margin: 0px;
text-align: center;
vertical-align: middle;
display: inline-block;
display: inline-flex;
user-select: none;
}
.tabIcon {
width: 24px;
height: 24px;
padding-right: 12px;
padding-right: 8px;
}
.selected {
background-color: #404040
@ -52,9 +51,9 @@
</head>
<body style="margin:0px;padding:0px;overflow:hidden">
<div id="tabs">
<span class="tabButton" onclick="selectTab(0)"><img class="tabIcon" src="../content/tabicons/colorpaletteBtn.png"/>Palette</span>
<span class="tabButton" onclick="selectTab(1)"><img class="tabIcon" src="../content/tabicons/brushesBtn.png"/>Brushes</span>
<span class="tabButton" onclick="selectTab(2)"><img class="tabIcon" src="../content/tabicons/pointingfinger128px.png"/>Hand</span>
<div class="tabButton" onclick="selectTab(0)"><img class="tabIcon" src="../content/tabicons/palette-icon.svg"/>Palette</div>
<div class="tabButton" onclick="selectTab(1)"><img class="tabIcon" src="../content/tabicons/brush-icon.svg"/>Brushes</div>
<div class="tabButton" onclick="selectTab(2)"><img class="tabIcon" src="../content/tabicons/pointingfinger128px.png"/>Hand</div>
<input type="button" onclick="undo()" id="undoButton" style="font-family: Font-Awesome;" disabled class="grayButton glyph" value="&#xf064;"/>
</div>
<div id="content">