Add path rendering.

This commit is contained in:
jmsgrogan 2023-01-19 14:25:58 +00:00
parent f2ab532005
commit 97afa782a0
39 changed files with 1148 additions and 131 deletions

View file

@ -0,0 +1,59 @@
#include "PathNode.h"
#include "Path.h"
#include "SceneInfo.h"
PathNode::PathNode(const Point& loc, const std::string& psPath)
: GeometryNode(loc),
mPathString(psPath)
{
}
std::unique_ptr<PathNode> PathNode::Create(const Point& loc, const std::string& psPath)
{
return std::make_unique<PathNode>(loc, psPath);
}
GeometryNode::Type PathNode::getType()
{
return GeometryNode::Type::Path;
}
const std::string& PathNode::getPathString() const
{
return mPathString;
}
void PathNode::setPathString(const std::string& psPath)
{
mPathString = psPath;
}
void PathNode::createOrUpdateGeometry(SceneInfo* sceneInfo)
{
if (!mBackgroundItem)
{
if (sceneInfo->mSupportsGeometryPrimitives)
{
auto path = std::make_unique<GeometryPath>();
path->buildFromPostscript(mPathString);
mBackgroundItem = std::make_unique<SceneModel>(std::move(path));
mBackgroundItem->setName(mName + "_Model");
}
}
else
{
if (sceneInfo->mSupportsGeometryPrimitives)
{
auto path = std::make_unique<GeometryPath>();
path->buildFromPostscript(mPathString);
mBackgroundItem->updateGeometry(std::move(path));
}
}
}
void PathNode::updateTransform()
{
mBackgroundItem->updateTransform({ mLocation });
}

View file

@ -0,0 +1,24 @@
#pragma once
#include "GeometryNode.h"
#include <memory>
class PathNode : public GeometryNode
{
public:
PathNode(const Point& loc, const std::string& psPath);
static std::unique_ptr<PathNode> Create(const Point& loc, const std::string& psPath);
GeometryNode::Type getType() override;
const std::string& getPathString() const;
void setPathString(const std::string& psPath);
private:
void createOrUpdateGeometry(SceneInfo* sceneInfo) override;
void updateTransform() override;
std::string mPathString;
};