// // VROPolyline.h // ViroRenderer // // Created by Raj Advani on 10/12/16. // Copyright © 2016 Viro Media. All rights reserved. // #include #include #include "VROGeometry.h" #include "VROAnimatable.h" class VROVector3f; class VROByteBuffer; class VROLineSegment; class VROShaderModifier; class VROPolyline : public VROGeometry { public: static std::shared_ptr createPolyline(std::vector> &path, float thickness); static std::shared_ptr createPolyline(std::vector &path, float thickness); VROPolyline(); virtual ~VROPolyline() {} /* Set the thickness. Animatable. */ void setThickness(float thickness); float getThickness() const { return _thickness; } /* Set the paths of this polyline. Each path is a contiguous line. This will reconstruct all paths. */ void setPaths(std::vector> &paths); /* Append the given point the last path in this polyline. This is more efficient than invoking setPaths. */ void appendPoint(VROVector3f point); virtual void setMaterials(std::vector> materials); private: float _thickness; VROPolyline(std::vector> sources, std::vector> elements, float thickness) : VROGeometry(sources, elements), _thickness(thickness) {} bool isEmpty() const; VROVector3f getLastPoint() const; static void buildGeometry(std::vector> &paths, std::vector> &sources, std::vector> &elements); static std::shared_ptr buildElement(size_t numCorners); static size_t encodeLine(const std::vector &path, VROByteBuffer &outBuffer); static size_t encodeQuad(VROLineSegment segment, bool beginDegenerate, bool endDegenerate, VROByteBuffer &buffer); static size_t encodeCircularEndcap(VROVector3f center, bool beginDegenerate, bool endDegenerate, VROByteBuffer &buffer); static void writeCorner(VROVector3f position, VROVector3f normal, VROByteBuffer &buffer); static std::shared_ptr createPolylineShaderModifier(); };