Datamodel V1.1
This commit is contained in:
79
main.cpp
79
main.cpp
@@ -20,7 +20,7 @@
|
||||
#include <iomanip>
|
||||
#include "Instance.h"
|
||||
#include "resource.h"
|
||||
#include "PhysicalInstance.h"
|
||||
#include "PartInstance.h"
|
||||
#include "TextButtonInstance.h"
|
||||
#include "ImageButtonInstance.h"
|
||||
#include "DataModelInstance.h"
|
||||
@@ -192,9 +192,9 @@ std::string Convert (float number){
|
||||
}
|
||||
|
||||
|
||||
PhysicalInstance* makePart()
|
||||
PartInstance* makePart()
|
||||
{
|
||||
PhysicalInstance* part = new PhysicalInstance();
|
||||
PartInstance* part = new PartInstance();
|
||||
return part;
|
||||
}
|
||||
|
||||
@@ -246,7 +246,14 @@ public:
|
||||
|
||||
void GUDButtonListener::onButton1MouseClick(BaseButtonInstance* button)
|
||||
{
|
||||
if(g_selectedInstances.size() > 0)
|
||||
bool cont = false;
|
||||
for(size_t i = 0; i < g_selectedInstances.size(); i++)
|
||||
if(g_selectedInstances.at(i)->canDelete)
|
||||
{
|
||||
cont = true;
|
||||
break;
|
||||
}
|
||||
if(cont)
|
||||
{
|
||||
AudioPlayer::playSound(dingSound);
|
||||
if(button->name == "Duplicate")
|
||||
@@ -254,7 +261,7 @@ void GUDButtonListener::onButton1MouseClick(BaseButtonInstance* button)
|
||||
std::vector<Instance*> newinst;
|
||||
for(size_t i = 0; i < g_selectedInstances.size(); i++)
|
||||
{
|
||||
if(g_selectedInstances.at(i) != dataModel->getWorkspace())
|
||||
if(g_selectedInstances.at(i)->canDelete)
|
||||
{
|
||||
Instance* tempinst = g_selectedInstances.at(i);
|
||||
|
||||
@@ -283,7 +290,7 @@ void RotateButtonListener::onButton1MouseClick(BaseButtonInstance* button)
|
||||
{
|
||||
Instance* selectedInstance = g_selectedInstances.at(0);
|
||||
AudioPlayer::playSound(clickSound);
|
||||
if(PhysicalInstance* part = dynamic_cast<PhysicalInstance*>(selectedInstance))
|
||||
if(PartInstance* part = dynamic_cast<PartInstance*>(selectedInstance))
|
||||
{
|
||||
if(button->name == "Tilt")
|
||||
part->setCFrame(part->getCFrame()*Matrix3::fromEulerAnglesXYZ(0,0,toRadians(90)));
|
||||
@@ -302,7 +309,7 @@ void deleteInstance()
|
||||
size_t undeletable = 0;
|
||||
while(g_selectedInstances.size() > undeletable)
|
||||
{
|
||||
if(g_selectedInstances.at(0) != dataModel && g_selectedInstances.at(0) != dataModel->getWorkspace())
|
||||
if(g_selectedInstances.at(0)->canDelete)
|
||||
{
|
||||
AudioPlayer::playSound(GetFileInPath("/content/sounds/pageturn.wav"));
|
||||
Instance* selectedInstance = g_selectedInstances.at(0);
|
||||
@@ -503,7 +510,9 @@ void Demo::initGUI()
|
||||
button->boxColor = Color4::clear();
|
||||
button->textSize = 12;
|
||||
button->title = "Group";
|
||||
button->setAllColorsSame();
|
||||
button->name = "Group";
|
||||
button->setAllColorsSame();
|
||||
button->textColorDis = Color3(0.8F,0.8F,0.8F);
|
||||
button->font = fntlighttrek;
|
||||
button->fontLocationRelativeTo = Vector2(10, 0);
|
||||
button->setParent(dataModel->getGuiRoot());
|
||||
@@ -517,7 +526,9 @@ void Demo::initGUI()
|
||||
button->boxColor = Color4::clear();
|
||||
button->textSize = 12;
|
||||
button->title = "UnGroup";
|
||||
button->name = "UnGroup";
|
||||
button->setAllColorsSame();
|
||||
button->textColorDis = Color3(0.8F,0.8F,0.8F);
|
||||
button->font = fntlighttrek;
|
||||
button->fontLocationRelativeTo = Vector2(10, 0);
|
||||
button->setParent(dataModel->getGuiRoot());
|
||||
@@ -531,6 +542,7 @@ void Demo::initGUI()
|
||||
button->textSize = 12;
|
||||
button->title = "Duplicate";
|
||||
button->setAllColorsSame();
|
||||
button->textColorDis = Color3(0.8F,0.8F,0.8F);
|
||||
button->font = fntlighttrek;
|
||||
button->fontLocationRelativeTo = Vector2(10, 0);
|
||||
button->setParent(dataModel->getGuiRoot());
|
||||
@@ -710,7 +722,7 @@ void Demo::onInit() {
|
||||
initGUI();
|
||||
|
||||
|
||||
PhysicalInstance* test = makePart();
|
||||
PartInstance* test = makePart();
|
||||
test->setParent(dataModel->getWorkspace());
|
||||
test->color = Color3(0.2F,0.3F,1);
|
||||
test->setSize(Vector3(24,1,24));
|
||||
@@ -838,14 +850,39 @@ std::vector<Instance*> Demo::getSelection()
|
||||
}
|
||||
void Demo::onSimulation(RealTime rdt, SimTime sdt, SimTime idt) {
|
||||
|
||||
Instance* obj = dataModel->getGuiRoot()->findFirstChild("Delete");
|
||||
if(obj != NULL)
|
||||
|
||||
|
||||
Instance * obj6 = dataModel->getGuiRoot()->findFirstChild("Delete");
|
||||
Instance * obj = dataModel->getGuiRoot()->findFirstChild("Duplicate");
|
||||
Instance * obj2 = dataModel->getGuiRoot()->findFirstChild("Group");
|
||||
Instance * obj3 = dataModel->getGuiRoot()->findFirstChild("UnGroup");
|
||||
Instance * obj4 = dataModel->getGuiRoot()->findFirstChild("Rotate");
|
||||
Instance * obj5 = dataModel->getGuiRoot()->findFirstChild("Tilt");
|
||||
if(obj != NULL && obj2 != NULL && obj3 != NULL && obj4 !=NULL && obj5 != NULL && obj6 != NULL)
|
||||
{
|
||||
ImageButtonInstance* button = (ImageButtonInstance*)obj;
|
||||
if(g_selectedInstances.size() <= 0 || g_selectedInstances.at(0) == dataModel->getWorkspace())
|
||||
button->disabled = true;
|
||||
else
|
||||
button->disabled = false;
|
||||
BaseButtonInstance* button = (BaseButtonInstance*)obj;
|
||||
BaseButtonInstance* button2 = (BaseButtonInstance*)obj2;
|
||||
BaseButtonInstance* button3 = (BaseButtonInstance*)obj3;
|
||||
BaseButtonInstance* button4 = (BaseButtonInstance*)obj4;
|
||||
BaseButtonInstance* button5 = (BaseButtonInstance*)obj5;
|
||||
BaseButtonInstance* button6 = (BaseButtonInstance*)obj6;
|
||||
button->disabled = true;
|
||||
button2->disabled = true;
|
||||
button3->disabled = true;
|
||||
button4->disabled = true;
|
||||
button5->disabled = true;
|
||||
button6->disabled = true;
|
||||
for(size_t i = 0; i < g_selectedInstances.size(); i++)
|
||||
if(g_selectedInstances.at(i)->canDelete)
|
||||
{
|
||||
button->disabled = false;
|
||||
button2->disabled = false;
|
||||
button3->disabled = false;
|
||||
button4->disabled = false;
|
||||
button5->disabled = false;
|
||||
button6->disabled = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -913,14 +950,14 @@ void Demo::onUserInput(UserInput* ui) {
|
||||
|
||||
if (GetHoldKeyState(VK_LBUTTON)) {
|
||||
if (dragging) {
|
||||
PhysicalInstance* part = NULL;
|
||||
PartInstance* part = NULL;
|
||||
if(g_selectedInstances.size() > 0)
|
||||
part = (PhysicalInstance*) g_selectedInstances.at(0);
|
||||
part = (PartInstance*) g_selectedInstances.at(0);
|
||||
Ray dragRay = cameraController.getCamera()->worldRay(dataModel->mousex, dataModel->mousey, renderDevice->getViewport());
|
||||
std::vector<Instance*> instances = dataModel->getWorkspace()->getAllChildren();
|
||||
for(size_t i = 0; i < instances.size(); i++)
|
||||
{
|
||||
if(PhysicalInstance* moveTo = dynamic_cast<PhysicalInstance*>(instances.at(i)))
|
||||
if(PartInstance* moveTo = dynamic_cast<PartInstance*>(instances.at(i)))
|
||||
{
|
||||
float __time = testRay.intersectionTime(moveTo->getBox());
|
||||
float __nearest=std::numeric_limits<float>::infinity();
|
||||
@@ -1162,7 +1199,7 @@ void Demo::onGraphics(RenderDevice* rd) {
|
||||
{
|
||||
for(size_t i = 0; i < g_selectedInstances.size(); i++)
|
||||
{
|
||||
if(PhysicalInstance* part = dynamic_cast<PhysicalInstance*>(g_selectedInstances.at(i)))
|
||||
if(PartInstance* part = dynamic_cast<PartInstance*>(g_selectedInstances.at(i)))
|
||||
{
|
||||
Vector3 size = part->getSize();
|
||||
Vector3 pos = part->getPosition();
|
||||
@@ -1291,7 +1328,7 @@ void Demo::onMouseLeftPressed(HWND hwnd,int x,int y)
|
||||
bool objFound = false;
|
||||
for(size_t i = 0; i < instances.size(); i++)
|
||||
{
|
||||
if(PhysicalInstance* test = dynamic_cast<PhysicalInstance*>(instances.at(i)))
|
||||
if(PartInstance* test = dynamic_cast<PartInstance*>(instances.at(i)))
|
||||
{
|
||||
float time = testRay.intersectionTime(test->getBox());
|
||||
|
||||
|
||||
Reference in New Issue
Block a user