Added postrender

This commit is contained in:
andreja6
2018-10-25 18:16:39 -07:00
parent b1af53995a
commit 30a05af3b2
5 changed files with 28 additions and 2 deletions

View File

@@ -8,7 +8,7 @@ int const Globals::patch = 2;
int Globals::surfaceId = 2;
bool Globals::showMouse = true;
bool Globals::useMousePoint = false;
std::stack<Instance*> postRenderStack = std::stack<Instance*>();
const std::string Globals::PlaceholderName = "Dynamica";
std::vector<Instance*> g_selectedInstances = std::vector<Instance*>();
bool running = false;

View File

@@ -1,6 +1,7 @@
#pragma once
#include "DataModelInstance.h"
#include <G3DAll.h>
#include <stack>
class Globals
{
@@ -20,5 +21,6 @@ public:
static const std::string PlaceholderName;
};
extern std::stack<Instance*> postRenderStack;
extern std::vector<Instance*> g_selectedInstances;
extern bool running;

View File

@@ -25,6 +25,24 @@ PartInstance::PartInstance(void) : _bevelSize(0.03f), _parseVert(0), _debugTimer
shape = Enum::Shape::Block;
}
void PartInstance::postRender(RenderDevice *rd)
{
G3D::GFontRef fntdominant = NULL;
if(fntdominant != NULL)
{
Vector3 gamepoint = cFrame.translation;
Vector3 camerapoint = rd->getCameraToWorldMatrix().translation;
float distance = pow(pow((double)gamepoint.x - (double)camerapoint.x, 2) + pow((double)gamepoint.y - (double)camerapoint.y, 2) + pow((double)gamepoint.z - (double)camerapoint.z, 2), 0.5);
if(distance < 50 && distance > -50)
{
if(distance < 0)
distance = distance*-1;
fntdominant->draw3D(rd, "Testing", CoordinateFrame(rd->getCameraToWorldMatrix().rotation, gamepoint), 0.04*distance, Color3::yellow(), Color3::black(), G3D::GFont::XALIGN_CENTER, G3D::GFont::YALIGN_CENTER);
}
}
}
PartInstance::PartInstance(const PartInstance &oinst)
{
PVInstance::PVInstance(oinst);

View File

@@ -10,6 +10,7 @@ public:
PartInstance(void);
PartInstance(const PartInstance &oinst);
Instance* clone() const { return new PartInstance(*this); }
void PartInstance::postRender(RenderDevice* rd);
~PartInstance(void);
virtual void render(RenderDevice*);
Vector3 velocity;

View File

@@ -1246,7 +1246,12 @@ void Demo::onGraphics(RenderDevice* rd) {
}
while(!postRenderStack.empty())
{
Instance* inst = postRenderStack.top();
postRenderStack.pop();
}
renderDevice->disableLighting();