Made properties "dynamically update", no longer simply says NO when object makes no sense
This commit is contained in:
@@ -31,17 +31,50 @@ DataModelInstance::~DataModelInstance(void)
|
||||
void DataModelInstance::setMessage(std::string msg)
|
||||
{
|
||||
message = msg;
|
||||
isBrickCount = false;
|
||||
showMessage = true;
|
||||
}
|
||||
|
||||
void DataModelInstance::clearMessage()
|
||||
{
|
||||
showMessage = false;
|
||||
isBrickCount = false;
|
||||
message = "";
|
||||
}
|
||||
|
||||
void DataModelInstance::setMessageBrickCount()
|
||||
{
|
||||
isBrickCount = true;
|
||||
showMessage = true;
|
||||
}
|
||||
|
||||
void DataModelInstance::drawMessage(RenderDevice* rd)
|
||||
{
|
||||
if(isBrickCount)
|
||||
{
|
||||
int brickCount = 0;
|
||||
int instCount = 0;
|
||||
std::vector<Instance*> inst = getAllChildren();
|
||||
for(size_t i = 0; i < inst.size(); i++)
|
||||
{
|
||||
if(PartInstance* moveTo = dynamic_cast<PartInstance*>(inst.at(i)))
|
||||
{
|
||||
brickCount++;
|
||||
}
|
||||
else
|
||||
{
|
||||
instCount++;
|
||||
}
|
||||
}
|
||||
char brkc[12];
|
||||
sprintf(brkc, "%d", brickCount);
|
||||
char instc[12];
|
||||
sprintf(instc, "%d", instCount);
|
||||
message = "Bricks: ";
|
||||
message += brkc;
|
||||
message += " Snaps: ";
|
||||
message += instc;
|
||||
}
|
||||
if(showMessage && !font.isNull())
|
||||
{
|
||||
int x = rd->getWidth()/2;
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
#pragma once
|
||||
#include "WorkspaceInstance.h"
|
||||
#include "LevelInstance.h"
|
||||
#include "PartInstance.h"
|
||||
|
||||
class DataModelInstance :
|
||||
public Instance
|
||||
@@ -9,6 +10,7 @@ public:
|
||||
DataModelInstance(void);
|
||||
~DataModelInstance(void);
|
||||
void setMessage(std::string);
|
||||
void setMessageBrickCount();
|
||||
void clearMessage();
|
||||
void drawMessage(RenderDevice*);
|
||||
WorkspaceInstance* getWorkspace();
|
||||
@@ -26,6 +28,7 @@ public:
|
||||
void setMousePos(int x,int y);
|
||||
void setMousePos(Vector2 pos);
|
||||
bool mouseButton1Down;
|
||||
|
||||
private:
|
||||
bool isBrickCount;
|
||||
|
||||
};
|
||||
|
||||
@@ -152,6 +152,7 @@ bool PartInstance::collides(Box box)
|
||||
|
||||
void PartInstance::render(RenderDevice* rd)
|
||||
{
|
||||
|
||||
if(changed)
|
||||
Box box = getBox();
|
||||
|
||||
@@ -257,7 +258,6 @@ void PartInstance::PropUpdate(LPPROPGRIDITEM &item)
|
||||
sprintf(pto, "%g, %g, %g", cFrame.translation.x, cFrame.translation.y, cFrame.translation.z, "what");
|
||||
LPCSTR str = LPCSTR(pto);
|
||||
item->lpCurValue = (LPARAM)str;
|
||||
MessageBox(NULL, "NO","NO", MB_OK);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -286,7 +286,6 @@ void PartInstance::PropUpdate(LPPROPGRIDITEM &item)
|
||||
sprintf(pto, "%g, %g, %g", cFrame.translation.x, cFrame.translation.y, cFrame.translation.z, "what");
|
||||
LPCSTR str = LPCSTR(pto);
|
||||
item->lpCurValue = (LPARAM)str;
|
||||
MessageBox(NULL, "NO","NO", MB_OK);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -164,6 +164,7 @@ LRESULT CALLBACK PropProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
|
||||
LPNMPROPGRID lpnmp = (LPNMPROPGRID)pnm;
|
||||
LPPROPGRIDITEM item = PropGrid_GetItemData(pnm->hwndFrom,lpnmp->iIndex);
|
||||
selectedInstance->PropUpdate(item);
|
||||
propWind->SetProperties(selectedInstance);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
30
main.cpp
30
main.cpp
@@ -786,7 +786,7 @@ void Demo::onInit() {
|
||||
test->setSize(Vector3(4,1,2));
|
||||
test->setPosition(Vector3(-2,5,0));
|
||||
|
||||
|
||||
//dataModel->setMessageBrickCount();
|
||||
|
||||
|
||||
test = makePart();
|
||||
@@ -851,7 +851,7 @@ std::vector<Instance*> Demo::getSelection()
|
||||
return g_selectedInstances;
|
||||
}
|
||||
void Demo::onSimulation(RealTime rdt, SimTime sdt, SimTime idt) {
|
||||
if(!running)
|
||||
if(running)
|
||||
{
|
||||
std::vector <Instance* > objects = dataModel->getWorkspace()->getAllChildren();
|
||||
for(size_t i = 0; i < objects.size(); i++)
|
||||
@@ -1182,6 +1182,8 @@ void Demo::onGraphics(RenderDevice* rd) {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
if(Globals::useMousePoint)
|
||||
{
|
||||
mousepos = Globals::mousepoint;
|
||||
@@ -1208,10 +1210,25 @@ 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);
|
||||
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);
|
||||
}
|
||||
|
||||
rd->beforePrimitive();
|
||||
|
||||
|
||||
dataModel->getWorkspace()->render(rd);
|
||||
rd->afterPrimitive();
|
||||
|
||||
|
||||
if(g_selectedInstances.size() > 0)
|
||||
{
|
||||
for(size_t i = 0; i < g_selectedInstances.size(); i++)
|
||||
@@ -1226,16 +1243,7 @@ void Demo::onGraphics(RenderDevice* rd) {
|
||||
}
|
||||
|
||||
|
||||
//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);
|
||||
//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);
|
||||
//}
|
||||
|
||||
renderDevice->disableLighting();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user