Add outline rendering.
This commit is contained in:
parent
f04d86e0ad
commit
a20c0183df
20 changed files with 291 additions and 64 deletions
|
@ -7,7 +7,6 @@ list(APPEND visual_elements_LIB_INCLUDES
|
|||
SceneModel.cpp
|
||||
SceneItem.cpp
|
||||
SceneText.cpp
|
||||
Transform.cpp
|
||||
Texture.cpp
|
||||
GridNode.cpp
|
||||
AbstractVisualNode.cpp
|
||||
|
|
|
@ -67,56 +67,73 @@ SceneItem* GridNode::getSceneItem(std::size_t idx) const
|
|||
|
||||
unsigned GridNode::getNumSceneItems() const
|
||||
{
|
||||
return 1;
|
||||
return 2;
|
||||
}
|
||||
|
||||
void GridNode::update(FontsManager* fontsManager)
|
||||
{
|
||||
if (!mBackgroundModel || mDataDirty)
|
||||
{
|
||||
auto mesh = MeshPrimitives::buildExplodedGrid(mNumberX, mNumberY);
|
||||
|
||||
if (mHeight > mWidth)
|
||||
{
|
||||
mesh->scale(mWidth, mWidth);
|
||||
}
|
||||
else
|
||||
{
|
||||
mesh->scale(mHeight, mHeight);
|
||||
}
|
||||
|
||||
auto mesh = MeshPrimitives::buildExplodedGridAsTriMesh(mNumberX, mNumberY);
|
||||
|
||||
if (!mBackgroundModel)
|
||||
{
|
||||
std::cout << "Setting up background model for grid node " << std::endl;
|
||||
mBackgroundModel = std::make_unique<SceneModel>(std::move(mesh));
|
||||
mBackgroundModel->setName(mName + "_Model");
|
||||
mBackgroundModel->updateUniformColor({200, 200, 200, 1.0});
|
||||
mBackgroundModel->setName(mName + "_BackgroundModel");
|
||||
}
|
||||
else
|
||||
{
|
||||
mBackgroundModel.get()->updateMesh(std::move(mesh));
|
||||
mBackgroundModel->updateUniformColor({200, 200, 200, 1.0});
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
if (!mOutlineModel || mDataDirty)
|
||||
if (mOutlineModel || mDataDirty)
|
||||
{
|
||||
const auto rect = Rectangle(Point(), 1, 1);
|
||||
auto mesh = MeshPrimitives::build(rect);
|
||||
auto mesh = MeshPrimitives::buildExplodedGridAsLineMesh(mNumberX, mNumberY);
|
||||
|
||||
if (!mOutlineModel)
|
||||
{
|
||||
mOutlineModel = std::make_unique<SceneModel>(std::move(mesh));
|
||||
mOutlineModel->setName(mName + "_Model");
|
||||
mOutlineModel->setName(mName + "_OulineModel");
|
||||
}
|
||||
else
|
||||
{
|
||||
mOutlineModel.get()->updateMesh(std::move(mesh));
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
if (mDataDirty)
|
||||
{
|
||||
auto difference = mNumberX*mNumberY - mData.size();
|
||||
mData.resize(mNumberX*mNumberY, {});
|
||||
|
||||
auto node_data = std::vector<std::vector<double> >(4*mNumberX*mNumberY);
|
||||
for (unsigned idx=0; idx< node_data.size(); idx++)
|
||||
{
|
||||
if (idx < mData.size())
|
||||
{
|
||||
node_data[idx] = mData[idx].getAsVectorDouble();
|
||||
}
|
||||
|
||||
}
|
||||
//mBackgroundModel->getMesh()->addVectorAttribute("Color", mData);
|
||||
|
||||
}
|
||||
|
||||
if (mTransformIsDirty)
|
||||
{
|
||||
auto size = mHeight > mWidth ? mWidth : mHeight;
|
||||
|
||||
mBackgroundModel->updateTransform({mLocation, static_cast<double>(size), static_cast<double>(size)});
|
||||
mOutlineModel->updateTransform({mLocation, static_cast<double>(size), static_cast<double>(size)});
|
||||
mTransformIsDirty = false;
|
||||
}
|
||||
|
||||
if (mMaterialIsDirty)
|
||||
{
|
||||
mOutlineModel->updateUniformColor(mStrokeColor);
|
||||
mMaterialIsDirty = false;
|
||||
}
|
||||
|
||||
mDataDirty = false;
|
||||
}
|
||||
|
|
|
@ -73,8 +73,7 @@ void RectangleNode::update(FontsManager* fontsManager)
|
|||
{
|
||||
if (!mBackgroundItem || mGeometryIsDirty)
|
||||
{
|
||||
const auto rect = Rectangle(Point(), 1, 1);
|
||||
auto mesh = MeshPrimitives::build(rect);
|
||||
auto mesh = MeshPrimitives::buildRectangleAsTriMesh();
|
||||
|
||||
if (!mBackgroundItem)
|
||||
{
|
||||
|
|
|
@ -1,10 +0,0 @@
|
|||
#include "Transform.h"
|
||||
|
||||
Transform::Transform(const Point& location, double scaleX, double scaleY, double scaleZ)
|
||||
: mLocation(location),
|
||||
mScaleX(scaleX),
|
||||
mScaleY(scaleY),
|
||||
mScaleZ(scaleZ)
|
||||
{
|
||||
|
||||
}
|
|
@ -1,47 +0,0 @@
|
|||
#pragma once
|
||||
|
||||
#include "Point.h"
|
||||
|
||||
class Transform
|
||||
{
|
||||
public:
|
||||
Transform(const Point& location = {}, double scaleX = 1.0, double scaleY = 1.0, double scaleZ = 1.0);
|
||||
|
||||
const Point& getLocation() const
|
||||
{
|
||||
return mLocation;
|
||||
}
|
||||
|
||||
double getScaleX() const
|
||||
{
|
||||
return mScaleX;
|
||||
}
|
||||
|
||||
double getScaleY() const
|
||||
{
|
||||
return mScaleY;
|
||||
}
|
||||
|
||||
double getScaleZ() const
|
||||
{
|
||||
return mScaleZ;
|
||||
}
|
||||
|
||||
bool operator==(const Transform& rhs) const
|
||||
{
|
||||
return (mLocation == rhs.mLocation)
|
||||
&& (mScaleX == rhs.mScaleX)
|
||||
&& (mScaleY == rhs.mScaleY)
|
||||
&& (mScaleZ == rhs.mScaleZ);
|
||||
}
|
||||
bool operator!=(const Transform& rhs) const
|
||||
{
|
||||
return !operator==(rhs);
|
||||
}
|
||||
|
||||
private:
|
||||
Point mLocation;
|
||||
double mScaleX{1};
|
||||
double mScaleY{1};
|
||||
double mScaleZ{1};
|
||||
};
|
Loading…
Add table
Add a link
Reference in a new issue