Parts with "ShowName" enabled now do what they are supposed to. Huzzah!
This commit is contained in:
@@ -8,7 +8,7 @@ int const Globals::patch = 2;
|
|||||||
int Globals::surfaceId = 2;
|
int Globals::surfaceId = 2;
|
||||||
bool Globals::showMouse = true;
|
bool Globals::showMouse = true;
|
||||||
bool Globals::useMousePoint = false;
|
bool Globals::useMousePoint = false;
|
||||||
std::stack<Instance*> postRenderStack = std::stack<Instance*>();
|
std::vector<Instance*> postRenderStack = std::vector<Instance*>();
|
||||||
const std::string Globals::PlaceholderName = "Dynamica";
|
const std::string Globals::PlaceholderName = "Dynamica";
|
||||||
std::vector<Instance*> g_selectedInstances = std::vector<Instance*>();
|
std::vector<Instance*> g_selectedInstances = std::vector<Instance*>();
|
||||||
bool running = false;
|
bool running = false;
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
#include "DataModelInstance.h"
|
#include "DataModelInstance.h"
|
||||||
#include <G3DAll.h>
|
#include <G3DAll.h>
|
||||||
#include <stack>
|
|
||||||
|
|
||||||
class Globals
|
class Globals
|
||||||
{
|
{
|
||||||
@@ -21,6 +20,6 @@ public:
|
|||||||
static const std::string PlaceholderName;
|
static const std::string PlaceholderName;
|
||||||
};
|
};
|
||||||
|
|
||||||
extern std::stack<Instance*> postRenderStack;
|
extern std::vector<Instance*> postRenderStack;
|
||||||
extern std::vector<Instance*> g_selectedInstances;
|
extern std::vector<Instance*> g_selectedInstances;
|
||||||
extern bool running;
|
extern bool running;
|
||||||
@@ -3,6 +3,7 @@
|
|||||||
PVInstance::PVInstance(void)
|
PVInstance::PVInstance(void)
|
||||||
{
|
{
|
||||||
Instance::Instance();
|
Instance::Instance();
|
||||||
|
nameShown = false;
|
||||||
className = "PVInstance";
|
className = "PVInstance";
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -15,12 +16,26 @@ PVInstance::~PVInstance(void)
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void PVInstance::postRender(RenderDevice* rd)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
std::vector<PROPGRIDITEM> PVInstance::getProperties()
|
std::vector<PROPGRIDITEM> PVInstance::getProperties()
|
||||||
{
|
{
|
||||||
std::vector<PROPGRIDITEM> properties = Instance::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;
|
return properties;
|
||||||
}
|
}
|
||||||
void PVInstance::PropUpdate(LPPROPGRIDITEM &pItem)
|
void PVInstance::PropUpdate(LPPROPGRIDITEM &pItem)
|
||||||
{
|
{
|
||||||
Instance::PropUpdate(pItem);
|
if(strcmp(pItem->lpszPropName, "NameShown") == 0)
|
||||||
|
{
|
||||||
|
nameShown = (bool)pItem->lpCurValue;
|
||||||
|
}
|
||||||
|
else Instance::PropUpdate(pItem);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,6 +8,8 @@ public:
|
|||||||
PVInstance(void);
|
PVInstance(void);
|
||||||
~PVInstance(void);
|
~PVInstance(void);
|
||||||
PVInstance(const PVInstance &oinst);
|
PVInstance(const PVInstance &oinst);
|
||||||
|
virtual void postRender(RenderDevice* rd);
|
||||||
virtual std::vector<PROPGRIDITEM> getProperties();
|
virtual std::vector<PROPGRIDITEM> getProperties();
|
||||||
virtual void PropUpdate(LPPROPGRIDITEM &pItem);
|
virtual void PropUpdate(LPPROPGRIDITEM &pItem);
|
||||||
|
bool nameShown;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -27,18 +27,31 @@ PartInstance::PartInstance(void) : _bevelSize(0.03f), _parseVert(0), _debugTimer
|
|||||||
|
|
||||||
void PartInstance::postRender(RenderDevice *rd)
|
void PartInstance::postRender(RenderDevice *rd)
|
||||||
{
|
{
|
||||||
G3D::GFontRef fntdominant = NULL;
|
if(!nameShown)
|
||||||
if(fntdominant.notNull())
|
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;
|
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);
|
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)
|
if(distance < 0)
|
||||||
distance = distance*-1;
|
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
|
// Can probably be deleted
|
||||||
CoordinateFrame PartInstance::getCFrameRenderBased()
|
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
|
#ifdef NEW_BOX_RENDER
|
||||||
Box PartInstance::getBox()
|
Box PartInstance::getBox()
|
||||||
@@ -242,6 +255,8 @@ bool PartInstance::isUniqueVertex(Vector3 pos)
|
|||||||
|
|
||||||
#ifdef NEW_BOX_RENDER
|
#ifdef NEW_BOX_RENDER
|
||||||
void PartInstance::render(RenderDevice* rd) {
|
void PartInstance::render(RenderDevice* rd) {
|
||||||
|
if(nameShown)
|
||||||
|
postRenderStack.push_back(this);
|
||||||
if (changed)
|
if (changed)
|
||||||
{
|
{
|
||||||
getBox();
|
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> PartInstance::getProperties()
|
||||||
{
|
{
|
||||||
std::vector<PROPGRIDITEM> properties = Instance::getProperties();
|
std::vector<PROPGRIDITEM> properties = PVInstance::getProperties();
|
||||||
|
|
||||||
|
|
||||||
properties.push_back(createPGI(
|
properties.push_back(createPGI(
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ public:
|
|||||||
PartInstance(void);
|
PartInstance(void);
|
||||||
PartInstance(const PartInstance &oinst);
|
PartInstance(const PartInstance &oinst);
|
||||||
Instance* clone() const { return new PartInstance(*this); }
|
Instance* clone() const { return new PartInstance(*this); }
|
||||||
void PartInstance::postRender(RenderDevice* rd);
|
virtual void PartInstance::postRender(RenderDevice* rd);
|
||||||
~PartInstance(void);
|
~PartInstance(void);
|
||||||
virtual void render(RenderDevice*);
|
virtual void render(RenderDevice*);
|
||||||
Vector3 velocity;
|
Vector3 velocity;
|
||||||
|
|||||||
14
main.cpp
14
main.cpp
@@ -1211,7 +1211,7 @@ void Demo::onGraphics(RenderDevice* rd) {
|
|||||||
renderDevice->setLight(0, GLight::directional(lighting.lightDirection, lighting.lightColor));
|
renderDevice->setLight(0, GLight::directional(lighting.lightDirection, lighting.lightColor));
|
||||||
renderDevice->setAmbientLightColor(lighting.ambient);
|
renderDevice->setAmbientLightColor(lighting.ambient);
|
||||||
|
|
||||||
|
/*
|
||||||
Vector3 gamepoint = Vector3(0, 5, 0);
|
Vector3 gamepoint = Vector3(0, 5, 0);
|
||||||
Vector3 camerapoint = rd->getCameraToWorldMatrix().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);
|
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;
|
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);
|
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();
|
rd->beforePrimitive();
|
||||||
|
|
||||||
|
|
||||||
@@ -1248,11 +1248,17 @@ void Demo::onGraphics(RenderDevice* rd) {
|
|||||||
|
|
||||||
while(!postRenderStack.empty())
|
while(!postRenderStack.empty())
|
||||||
{
|
{
|
||||||
Instance* inst = postRenderStack.top();
|
Instance* inst = postRenderStack.at(0);
|
||||||
postRenderStack.pop();
|
postRenderStack.erase(postRenderStack.begin());
|
||||||
|
if(PVInstance* pinst = dynamic_cast<PVInstance*>(inst))
|
||||||
|
{
|
||||||
|
pinst->postRender(rd);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
renderDevice->disableLighting();
|
renderDevice->disableLighting();
|
||||||
|
|
||||||
if (sky.notNull()) {
|
if (sky.notNull()) {
|
||||||
|
|||||||
Reference in New Issue
Block a user