Parts with "ShowName" enabled now do what they are supposed to. Huzzah!

This commit is contained in:
andreja6
2018-10-25 18:56:00 -07:00
parent f7d6781698
commit 7e2eb2c694
7 changed files with 55 additions and 18 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*>();
std::vector<Instance*> postRenderStack = std::vector<Instance*>();
const std::string Globals::PlaceholderName = "Dynamica";
std::vector<Instance*> g_selectedInstances = std::vector<Instance*>();
bool running = false;

View File

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

View File

@@ -3,6 +3,7 @@
PVInstance::PVInstance(void)
{
Instance::Instance();
nameShown = false;
className = "PVInstance";
}
@@ -15,12 +16,26 @@ PVInstance::~PVInstance(void)
{
}
void PVInstance::postRender(RenderDevice* rd)
{
}
std::vector<PROPGRIDITEM> PVInstance::getProperties()
{
std::vector<PROPGRIDITEM> properties = Instance::getProperties();
properties.push_back(createPGI(
"Item",
"NameShown",
"This chooses whether the item name is shown",
false,
PIT_CHECK));
return properties;
}
void PVInstance::PropUpdate(LPPROPGRIDITEM &pItem)
{
Instance::PropUpdate(pItem);
if(strcmp(pItem->lpszPropName, "NameShown") == 0)
{
nameShown = (bool)pItem->lpCurValue;
}
else Instance::PropUpdate(pItem);
}

View File

@@ -8,6 +8,8 @@ public:
PVInstance(void);
~PVInstance(void);
PVInstance(const PVInstance &oinst);
virtual void postRender(RenderDevice* rd);
virtual std::vector<PROPGRIDITEM> getProperties();
virtual void PropUpdate(LPPROPGRIDITEM &pItem);
bool nameShown;
};

View File

@@ -27,18 +27,31 @@ PartInstance::PartInstance(void) : _bevelSize(0.03f), _parseVert(0), _debugTimer
void PartInstance::postRender(RenderDevice *rd)
{
G3D::GFontRef fntdominant = NULL;
if(fntdominant.notNull())
if(!nameShown)
return;
G3D::GFontRef fnt = NULL;
Instance* dm = parent;
while(dm != NULL)
{
Vector3 gamepoint = cFrame.translation;
if(DataModelInstance* mod = dynamic_cast<DataModelInstance*>(dm))
{
fnt = mod->font;
break;
}
dm = dm->getParent();
}
if(!fnt.isNull())
{
Vector3 gamepoint = position + Vector3(0,1.5,0);
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 < 100 && distance > -100)
{
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);
glDisable(GL_DEPTH_TEST);
fnt->draw3D(rd, name, CoordinateFrame(rd->getCameraToWorldMatrix().rotation, gamepoint), 0.03*distance, Color3::yellow(), Color3::black(), G3D::GFont::XALIGN_CENTER, G3D::GFont::YALIGN_CENTER);
glEnable(GL_DEPTH_TEST);
}
}
}
@@ -131,7 +144,7 @@ void PartInstance::setCFrame(CoordinateFrame coordinateFrame)
// Can probably be deleted
CoordinateFrame PartInstance::getCFrameRenderBased()
{
return CoordinateFrame(getCFrame().rotation,Vector3(getCFrame().translation.x, getCFrame().translation.y, getCFrame().translation.z));
return cFrame;//CoordinateFrame(getCFrame().rotation,Vector3(getCFrame().translation.x, getCFrame().translation.y, getCFrame().translation.z));
}
#ifdef NEW_BOX_RENDER
Box PartInstance::getBox()
@@ -242,6 +255,8 @@ bool PartInstance::isUniqueVertex(Vector3 pos)
#ifdef NEW_BOX_RENDER
void PartInstance::render(RenderDevice* rd) {
if(nameShown)
postRenderStack.push_back(this);
if (changed)
{
getBox();
@@ -519,12 +534,12 @@ void PartInstance::PropUpdate(LPPROPGRIDITEM &item)
}
}
else Instance::PropUpdate(item);
else PVInstance::PropUpdate(item);
}
std::vector<PROPGRIDITEM> PartInstance::getProperties()
{
std::vector<PROPGRIDITEM> properties = Instance::getProperties();
std::vector<PROPGRIDITEM> properties = PVInstance::getProperties();
properties.push_back(createPGI(

View File

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

View File

@@ -1211,7 +1211,7 @@ void Demo::onGraphics(RenderDevice* rd) {
renderDevice->setLight(0, GLight::directional(lighting.lightDirection, lighting.lightColor));
renderDevice->setAmbientLightColor(lighting.ambient);
/*
Vector3 gamepoint = Vector3(0, 5, 0);
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);
@@ -1222,7 +1222,7 @@ void Demo::onGraphics(RenderDevice* rd) {
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);
}
*/
rd->beforePrimitive();
@@ -1248,11 +1248,17 @@ void Demo::onGraphics(RenderDevice* rd) {
while(!postRenderStack.empty())
{
Instance* inst = postRenderStack.top();
postRenderStack.pop();
Instance* inst = postRenderStack.at(0);
postRenderStack.erase(postRenderStack.begin());
if(PVInstance* pinst = dynamic_cast<PVInstance*>(inst))
{
pinst->postRender(rd);
}
}
renderDevice->disableLighting();
if (sky.notNull()) {