Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
7b2f1dd
commit 2832096
Showing
8 changed files
with
112 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
#include "RenderableArrow.h" | ||
|
||
#include "EntityNode.h" | ||
|
||
namespace entity | ||
{ | ||
|
||
RenderableArrow::RenderableArrow(EntityNode& node) : | ||
_node(node), | ||
_needsUpdate(true) | ||
{} | ||
|
||
void RenderableArrow::queueUpdate() | ||
{ | ||
_needsUpdate = true; | ||
} | ||
|
||
void RenderableArrow::updateGeometry() | ||
{ | ||
if (!_needsUpdate) return; | ||
|
||
_needsUpdate = false; | ||
|
||
static Vector3 Up(0, 0, 1); | ||
const auto& origin = _node.worldAABB().getOrigin(); | ||
const auto& direction = _node.getDirection(); | ||
Vector3 left(-direction.y(), direction.x(), 0); | ||
|
||
Vector3 endpoint(origin + direction * 32.0); | ||
|
||
Vector3 tip1(endpoint + direction * (-8.0) + Up * (-4.0)); | ||
Vector3 tip2(tip1 + Up * 8.0); | ||
Vector3 tip3(endpoint + direction * (-8.0) + left * (-4.0)); | ||
Vector3 tip4(tip3 + left * 8.0); | ||
|
||
std::vector<ArbitraryMeshVertex> vertices | ||
{ | ||
ArbitraryMeshVertex(origin, {1,0,0}, {0,0}), | ||
ArbitraryMeshVertex(endpoint, {1,0,0}, {0,0}), | ||
ArbitraryMeshVertex(tip1, {1,0,0}, {0,0}), | ||
ArbitraryMeshVertex(tip2, {1,0,0}, {0,0}), | ||
ArbitraryMeshVertex(tip3, {1,0,0}, {0,0}), | ||
ArbitraryMeshVertex(tip4, {1,0,0}, {0,0}), | ||
}; | ||
|
||
// Indices are always the same, therefore constant | ||
static const std::vector<unsigned int> Indices | ||
{ | ||
0, 1, // origin to endpoint | ||
1, 2, // endpoint to tip1 | ||
1, 3, // endpoint to tip2 | ||
1, 4, // endpoint to tip3 | ||
1, 5, // endpoint to tip4 | ||
2, 4, // tip1 to tip3 | ||
4, 3, // tip3 to tip2 | ||
3, 5, // tip2 to tip4 | ||
5, 2, // tip4 to tip1 | ||
}; | ||
|
||
RenderableGeometry::updateGeometry(render::GeometryType::Lines, vertices, Indices); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
#pragma once | ||
|
||
#include "render/RenderableGeometry.h" | ||
|
||
namespace entity | ||
{ | ||
|
||
class EntityNode; | ||
|
||
class RenderableArrow : | ||
public render::RenderableGeometry | ||
{ | ||
private: | ||
const EntityNode& _node; | ||
bool _needsUpdate; | ||
|
||
public: | ||
RenderableArrow(EntityNode& node); | ||
|
||
void queueUpdate(); | ||
|
||
virtual void updateGeometry() override; | ||
}; | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters