|
|
|
@@ -11,11 +11,13 @@
|
|
|
|
@author Morgan McGuire, matrix@graphics3d.com
|
|
|
|
@author Morgan McGuire, matrix@graphics3d.com
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
#include <G3DAll.h>
|
|
|
|
#include <G3DAll.h>
|
|
|
|
|
|
|
|
#include <iomanip>
|
|
|
|
#include "Instance.h"
|
|
|
|
#include "Instance.h"
|
|
|
|
#include "resource.h"
|
|
|
|
#include "resource.h"
|
|
|
|
#include "PhysicalInstance.h"
|
|
|
|
#include "PhysicalInstance.h"
|
|
|
|
#include "TextButtonInstance.h"
|
|
|
|
#include "TextButtonInstance.h"
|
|
|
|
#include "ImageButtonInstance.h"
|
|
|
|
#include "ImageButtonInstance.h"
|
|
|
|
|
|
|
|
#include "DataModelInstance.h"
|
|
|
|
#include "AudioPlayer.h"
|
|
|
|
#include "AudioPlayer.h"
|
|
|
|
#include <limits.h>
|
|
|
|
#include <limits.h>
|
|
|
|
|
|
|
|
|
|
|
|
@@ -23,12 +25,9 @@
|
|
|
|
#error Requires G3D 6.10
|
|
|
|
#error Requires G3D 6.10
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
HWND hwnd;
|
|
|
|
HWND hwnd;
|
|
|
|
static const float VNUM = 0.01F;
|
|
|
|
|
|
|
|
static std::string title = "";
|
|
|
|
static std::string title = "";
|
|
|
|
static const std::string VERSION = "PRE-ALPHA ";
|
|
|
|
static DataModelInstance* dataModel;
|
|
|
|
static std::vector<Instance*> instances;
|
|
|
|
|
|
|
|
static std::vector<Instance*> instances_2D;
|
|
|
|
|
|
|
|
static Instance* dataModel;
|
|
|
|
|
|
|
|
GFontRef fntdominant = NULL;
|
|
|
|
GFontRef fntdominant = NULL;
|
|
|
|
GFontRef fntlighttrek = NULL;
|
|
|
|
GFontRef fntlighttrek = NULL;
|
|
|
|
Ray testRay;
|
|
|
|
Ray testRay;
|
|
|
|
@@ -42,8 +41,6 @@ static int index = 2;
|
|
|
|
static std::string cameraSound = "";
|
|
|
|
static std::string cameraSound = "";
|
|
|
|
static std::string clickSound = "";
|
|
|
|
static std::string clickSound = "";
|
|
|
|
static std::string dingSound = "";
|
|
|
|
static std::string dingSound = "";
|
|
|
|
static float TIMERVAL = 60.0F;
|
|
|
|
|
|
|
|
static int SCOREVAL = 0;
|
|
|
|
|
|
|
|
static G3D::TextureRef go = NULL;
|
|
|
|
static G3D::TextureRef go = NULL;
|
|
|
|
static G3D::TextureRef go_ovr = NULL;
|
|
|
|
static G3D::TextureRef go_ovr = NULL;
|
|
|
|
static G3D::TextureRef go_dn = NULL;
|
|
|
|
static G3D::TextureRef go_dn = NULL;
|
|
|
|
@@ -63,13 +60,14 @@ static bool left = false;
|
|
|
|
static bool right = false;
|
|
|
|
static bool right = false;
|
|
|
|
static bool centerCam = false;
|
|
|
|
static bool centerCam = false;
|
|
|
|
static bool panRight = false;
|
|
|
|
static bool panRight = false;
|
|
|
|
|
|
|
|
static bool panLeft = false;
|
|
|
|
static bool tiltUp = false;
|
|
|
|
static bool tiltUp = false;
|
|
|
|
static const int CURSOR = 0;
|
|
|
|
static const int CURSOR = 0;
|
|
|
|
static const int ARROWS = 1;
|
|
|
|
static const int ARROWS = 1;
|
|
|
|
static const int RESIZE = 2;
|
|
|
|
static const int RESIZE = 2;
|
|
|
|
static int mode = CURSOR;
|
|
|
|
static int mode = CURSOR;
|
|
|
|
|
|
|
|
bool dragging = false;
|
|
|
|
Vector3 cameraPos = Vector3(0,2,10);
|
|
|
|
Vector3 cameraPos = Vector3(0,2,10);
|
|
|
|
Vector3 focalPointT = Vector3(0,0,0);
|
|
|
|
|
|
|
|
Vector2 oldMouse = Vector2(0,0);
|
|
|
|
Vector2 oldMouse = Vector2(0,0);
|
|
|
|
float moveRate = 0.5;
|
|
|
|
float moveRate = 0.5;
|
|
|
|
Instance* selectedInstance = NULL;
|
|
|
|
Instance* selectedInstance = NULL;
|
|
|
|
@@ -174,10 +172,10 @@ Demo::Demo(App* _app) : GApplet(_app), app(_app) {
|
|
|
|
|
|
|
|
|
|
|
|
void clearInstances()
|
|
|
|
void clearInstances()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
for(size_t i = 0; i < instances.size(); i++)
|
|
|
|
//for(size_t i = 0; i < instances.size(); i++)
|
|
|
|
{
|
|
|
|
//{
|
|
|
|
delete instances.at(i);
|
|
|
|
// delete instances.at(i);
|
|
|
|
}
|
|
|
|
//}
|
|
|
|
delete dataModel;
|
|
|
|
delete dataModel;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@@ -225,23 +223,23 @@ std::string Convert (float number){
|
|
|
|
PhysicalInstance* makePart()
|
|
|
|
PhysicalInstance* makePart()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
PhysicalInstance* part = new PhysicalInstance();
|
|
|
|
PhysicalInstance* part = new PhysicalInstance();
|
|
|
|
instances.push_back(part);
|
|
|
|
// instances.push_back(part);
|
|
|
|
return part;
|
|
|
|
return part;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
TextButtonInstance* makeTextButton()
|
|
|
|
TextButtonInstance* makeTextButton()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
TextButtonInstance* part = new TextButtonInstance();
|
|
|
|
TextButtonInstance* part = new TextButtonInstance();
|
|
|
|
instances.push_back(part);
|
|
|
|
// instances.push_back(part);
|
|
|
|
instances_2D.push_back(part);
|
|
|
|
// instances_2D.push_back(part);
|
|
|
|
return part;
|
|
|
|
return part;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
ImageButtonInstance* makeImageButton(G3D::TextureRef newImage = NULL, G3D::TextureRef overImage = NULL, G3D::TextureRef downImage = NULL, G3D::TextureRef disableImage = NULL)
|
|
|
|
ImageButtonInstance* makeImageButton(G3D::TextureRef newImage = NULL, G3D::TextureRef overImage = NULL, G3D::TextureRef downImage = NULL, G3D::TextureRef disableImage = NULL)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
ImageButtonInstance* part = new ImageButtonInstance(newImage,overImage, downImage, disableImage);
|
|
|
|
ImageButtonInstance* part = new ImageButtonInstance(newImage,overImage, downImage, disableImage);
|
|
|
|
instances.push_back(part);
|
|
|
|
// instances.push_back(part);
|
|
|
|
instances_2D.push_back(part);
|
|
|
|
// instances_2D.push_back(part);
|
|
|
|
return part;
|
|
|
|
return part;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@@ -254,7 +252,7 @@ public:
|
|
|
|
|
|
|
|
|
|
|
|
void CameraButtonListener::onButton1MouseClick(BaseButtonInstance* button)
|
|
|
|
void CameraButtonListener::onButton1MouseClick(BaseButtonInstance* button)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
AudioPlayer::PlaySound(cameraSound);
|
|
|
|
AudioPlayer::playSound(cameraSound);
|
|
|
|
CoordinateFrame frame = usableApp->debugCamera.getCoordinateFrame();
|
|
|
|
CoordinateFrame frame = usableApp->debugCamera.getCoordinateFrame();
|
|
|
|
if(button->name == "CenterCam")
|
|
|
|
if(button->name == "CenterCam")
|
|
|
|
centerCam = true;
|
|
|
|
centerCam = true;
|
|
|
|
@@ -264,6 +262,8 @@ void CameraButtonListener::onButton1MouseClick(BaseButtonInstance* button)
|
|
|
|
cameraPos = Vector3(cameraPos.x, cameraPos.y, cameraPos.z) - frame.lookVector()*2;
|
|
|
|
cameraPos = Vector3(cameraPos.x, cameraPos.y, cameraPos.z) - frame.lookVector()*2;
|
|
|
|
else if(button->name == "PanRight")
|
|
|
|
else if(button->name == "PanRight")
|
|
|
|
panRight = true;
|
|
|
|
panRight = true;
|
|
|
|
|
|
|
|
else if(button->name == "PanLeft")
|
|
|
|
|
|
|
|
panLeft = true;
|
|
|
|
else if(button->name == "TiltUp")
|
|
|
|
else if(button->name == "TiltUp")
|
|
|
|
tiltUp = true;
|
|
|
|
tiltUp = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
@@ -277,7 +277,7 @@ void GUDButtonListener::onButton1MouseClick(BaseButtonInstance* button)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if(selectedInstance != NULL)
|
|
|
|
if(selectedInstance != NULL)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
AudioPlayer::PlaySound(dingSound);
|
|
|
|
AudioPlayer::playSound(dingSound);
|
|
|
|
if(button->name == "Duplicate")
|
|
|
|
if(button->name == "Duplicate")
|
|
|
|
{
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
@@ -295,8 +295,8 @@ void RotateButtonListener::onButton1MouseClick(BaseButtonInstance* button)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if(selectedInstance != NULL)
|
|
|
|
if(selectedInstance != NULL)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
AudioPlayer::PlaySound(clickSound);
|
|
|
|
AudioPlayer::playSound(clickSound);
|
|
|
|
if(selectedInstance->className == "Part")
|
|
|
|
if(selectedInstance->getClassName() == "Part")
|
|
|
|
{
|
|
|
|
{
|
|
|
|
PhysicalInstance* part = (PhysicalInstance*) selectedInstance;
|
|
|
|
PhysicalInstance* part = (PhysicalInstance*) selectedInstance;
|
|
|
|
if(button->name == "Tilt")
|
|
|
|
if(button->name == "Tilt")
|
|
|
|
@@ -313,17 +313,11 @@ void deleteInstance()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if(selectedInstance != NULL)
|
|
|
|
if(selectedInstance != NULL)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
for(size_t i = 0; i < instances.size(); i++)
|
|
|
|
if(selectedInstance->getParent() != NULL)
|
|
|
|
{
|
|
|
|
selectedInstance->getParent()->removeChild(selectedInstance);
|
|
|
|
if(instances.at(i) == selectedInstance)
|
|
|
|
delete selectedInstance;
|
|
|
|
{
|
|
|
|
|
|
|
|
Instance* deleting = instances.at(i);
|
|
|
|
|
|
|
|
instances.erase(instances.begin() + i);
|
|
|
|
|
|
|
|
delete deleting;
|
|
|
|
|
|
|
|
selectedInstance = NULL;
|
|
|
|
selectedInstance = NULL;
|
|
|
|
AudioPlayer::PlaySound(GetFileInPath("/content/sounds/pageturn.wav"));
|
|
|
|
AudioPlayer::playSound(GetFileInPath("/content/sounds/pageturn.wav"));
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@@ -351,7 +345,7 @@ void ModeSelectionListener::onButton1MouseClick(BaseButtonInstance* button)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
CoordinateFrame frame = usableApp->debugCamera.getCoordinateFrame();
|
|
|
|
CoordinateFrame frame = usableApp->debugCamera.getCoordinateFrame();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
std::vector<Instance*> instances_2D = dataModel->getGuiRoot()->getAllChildren();
|
|
|
|
for(size_t i = 0; i < instances_2D.size(); i++)
|
|
|
|
for(size_t i = 0; i < instances_2D.size(); i++)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if(instances_2D.at(i)->name == "Cursor" || instances_2D.at(i)->name == "Resize" || instances_2D.at(i)->name == "Arrows")
|
|
|
|
if(instances_2D.at(i)->name == "Cursor" || instances_2D.at(i)->name == "Resize" || instances_2D.at(i)->name == "Arrows")
|
|
|
|
@@ -377,7 +371,7 @@ void initGUI()
|
|
|
|
button->boxBegin = Vector2(0, -24);
|
|
|
|
button->boxBegin = Vector2(0, -24);
|
|
|
|
button->boxEnd = Vector2(80, 0);
|
|
|
|
button->boxEnd = Vector2(80, 0);
|
|
|
|
button->floatBottom = true;
|
|
|
|
button->floatBottom = true;
|
|
|
|
button->parent = dataModel;
|
|
|
|
button->setParent(dataModel->getGuiRoot());
|
|
|
|
button->font = fntlighttrek;
|
|
|
|
button->font = fntlighttrek;
|
|
|
|
button->textColor = Color3(0,255,255);
|
|
|
|
button->textColor = Color3(0,255,255);
|
|
|
|
button->textOutlineColor = Color4::clear();
|
|
|
|
button->textOutlineColor = Color4::clear();
|
|
|
|
@@ -389,7 +383,7 @@ void initGUI()
|
|
|
|
button->boxBegin = Vector2(0, -48);
|
|
|
|
button->boxBegin = Vector2(0, -48);
|
|
|
|
button->boxEnd = Vector2(80, -24);
|
|
|
|
button->boxEnd = Vector2(80, -24);
|
|
|
|
button->floatBottom = true;
|
|
|
|
button->floatBottom = true;
|
|
|
|
button->parent = dataModel;
|
|
|
|
button->setParent(dataModel->getGuiRoot());
|
|
|
|
button->font = fntlighttrek;
|
|
|
|
button->font = fntlighttrek;
|
|
|
|
button->textColor = Color3(0,255,255);
|
|
|
|
button->textColor = Color3(0,255,255);
|
|
|
|
button->textOutlineColor = Color4::clear();
|
|
|
|
button->textOutlineColor = Color4::clear();
|
|
|
|
@@ -401,7 +395,7 @@ void initGUI()
|
|
|
|
button->boxBegin = Vector2(0, -72);
|
|
|
|
button->boxBegin = Vector2(0, -72);
|
|
|
|
button->boxEnd = Vector2(80, -48);
|
|
|
|
button->boxEnd = Vector2(80, -48);
|
|
|
|
button->floatBottom = true;
|
|
|
|
button->floatBottom = true;
|
|
|
|
button->parent = dataModel;
|
|
|
|
button->setParent(dataModel->getGuiRoot());
|
|
|
|
button->font = fntlighttrek;
|
|
|
|
button->font = fntlighttrek;
|
|
|
|
button->textColor = Color3(0,255,255);
|
|
|
|
button->textColor = Color3(0,255,255);
|
|
|
|
button->textOutlineColor = Color4::clear();
|
|
|
|
button->textOutlineColor = Color4::clear();
|
|
|
|
@@ -413,7 +407,7 @@ void initGUI()
|
|
|
|
button->boxBegin = Vector2(0, -96);
|
|
|
|
button->boxBegin = Vector2(0, -96);
|
|
|
|
button->boxEnd = Vector2(80, -72);
|
|
|
|
button->boxEnd = Vector2(80, -72);
|
|
|
|
button->floatBottom = true;
|
|
|
|
button->floatBottom = true;
|
|
|
|
button->parent = dataModel;
|
|
|
|
button->setParent(dataModel->getGuiRoot());
|
|
|
|
button->font = fntlighttrek;
|
|
|
|
button->font = fntlighttrek;
|
|
|
|
button->textColor = Color3(0,255,255);
|
|
|
|
button->textColor = Color3(0,255,255);
|
|
|
|
button->textOutlineColor = Color4::clear();
|
|
|
|
button->textOutlineColor = Color4::clear();
|
|
|
|
@@ -425,7 +419,7 @@ void initGUI()
|
|
|
|
button->boxBegin = Vector2(0, -120);
|
|
|
|
button->boxBegin = Vector2(0, -120);
|
|
|
|
button->boxEnd = Vector2(80, -96);
|
|
|
|
button->boxEnd = Vector2(80, -96);
|
|
|
|
button->floatBottom = true;
|
|
|
|
button->floatBottom = true;
|
|
|
|
button->parent = dataModel;
|
|
|
|
button->setParent(dataModel->getGuiRoot());
|
|
|
|
button->font = fntlighttrek;
|
|
|
|
button->font = fntlighttrek;
|
|
|
|
button->textColor = Color3(0,255,255);
|
|
|
|
button->textColor = Color3(0,255,255);
|
|
|
|
button->boxOutlineColor = Color3(0,255,255);
|
|
|
|
button->boxOutlineColor = Color3(0,255,255);
|
|
|
|
@@ -436,7 +430,7 @@ void initGUI()
|
|
|
|
button = makeTextButton();
|
|
|
|
button = makeTextButton();
|
|
|
|
button->boxBegin = Vector2(0, 0);
|
|
|
|
button->boxBegin = Vector2(0, 0);
|
|
|
|
button->boxEnd = Vector2(125, 25);
|
|
|
|
button->boxEnd = Vector2(125, 25);
|
|
|
|
button->parent = dataModel;
|
|
|
|
button->setParent(dataModel->getGuiRoot());
|
|
|
|
button->font = fntlighttrek;
|
|
|
|
button->font = fntlighttrek;
|
|
|
|
button->textColor = Color3::white();
|
|
|
|
button->textColor = Color3::white();
|
|
|
|
button->boxColor = Color4::clear();
|
|
|
|
button->boxColor = Color4::clear();
|
|
|
|
@@ -449,7 +443,7 @@ void initGUI()
|
|
|
|
button = makeTextButton();
|
|
|
|
button = makeTextButton();
|
|
|
|
button->boxBegin = Vector2(125, 0);
|
|
|
|
button->boxBegin = Vector2(125, 0);
|
|
|
|
button->boxEnd = Vector2(250, 25);
|
|
|
|
button->boxEnd = Vector2(250, 25);
|
|
|
|
button->parent = dataModel;
|
|
|
|
button->setParent(dataModel->getGuiRoot());
|
|
|
|
button->font = fntlighttrek;
|
|
|
|
button->font = fntlighttrek;
|
|
|
|
button->textColor = Color3::white();
|
|
|
|
button->textColor = Color3::white();
|
|
|
|
button->boxColor = Color4::clear();
|
|
|
|
button->boxColor = Color4::clear();
|
|
|
|
@@ -462,7 +456,7 @@ void initGUI()
|
|
|
|
button = makeTextButton();
|
|
|
|
button = makeTextButton();
|
|
|
|
button->boxBegin = Vector2(250, 0);
|
|
|
|
button->boxBegin = Vector2(250, 0);
|
|
|
|
button->boxEnd = Vector2(375, 25);
|
|
|
|
button->boxEnd = Vector2(375, 25);
|
|
|
|
button->parent = dataModel;
|
|
|
|
button->setParent(dataModel->getGuiRoot());
|
|
|
|
button->font = fntlighttrek;
|
|
|
|
button->font = fntlighttrek;
|
|
|
|
button->textColor = Color3::white();
|
|
|
|
button->textColor = Color3::white();
|
|
|
|
button->boxColor = Color4::clear();
|
|
|
|
button->boxColor = Color4::clear();
|
|
|
|
@@ -475,7 +469,7 @@ void initGUI()
|
|
|
|
button = makeTextButton();
|
|
|
|
button = makeTextButton();
|
|
|
|
button->boxBegin = Vector2(375, 0);
|
|
|
|
button->boxBegin = Vector2(375, 0);
|
|
|
|
button->boxEnd = Vector2(500, 25);
|
|
|
|
button->boxEnd = Vector2(500, 25);
|
|
|
|
button->parent = dataModel;
|
|
|
|
button->setParent(dataModel->getGuiRoot());
|
|
|
|
button->font = fntlighttrek;
|
|
|
|
button->font = fntlighttrek;
|
|
|
|
button->textColor = Color3::white();
|
|
|
|
button->textColor = Color3::white();
|
|
|
|
button->boxColor = Color4::clear();
|
|
|
|
button->boxColor = Color4::clear();
|
|
|
|
@@ -488,7 +482,7 @@ void initGUI()
|
|
|
|
button = makeTextButton();
|
|
|
|
button = makeTextButton();
|
|
|
|
button->boxBegin = Vector2(500, 0);
|
|
|
|
button->boxBegin = Vector2(500, 0);
|
|
|
|
button->boxEnd = Vector2(625, 25);
|
|
|
|
button->boxEnd = Vector2(625, 25);
|
|
|
|
button->parent = dataModel;
|
|
|
|
button->setParent(dataModel->getGuiRoot());
|
|
|
|
button->font = fntlighttrek;
|
|
|
|
button->font = fntlighttrek;
|
|
|
|
button->textColor = Color3::white();
|
|
|
|
button->textColor = Color3::white();
|
|
|
|
button->boxColor = Color4::clear();
|
|
|
|
button->boxColor = Color4::clear();
|
|
|
|
@@ -511,7 +505,7 @@ void initGUI()
|
|
|
|
button->setAllColorsSame();
|
|
|
|
button->setAllColorsSame();
|
|
|
|
button->font = fntlighttrek;
|
|
|
|
button->font = fntlighttrek;
|
|
|
|
button->fontLocationRelativeTo = Vector2(10, 0);
|
|
|
|
button->fontLocationRelativeTo = Vector2(10, 0);
|
|
|
|
button->parent = dataModel;
|
|
|
|
button->setParent(dataModel->getGuiRoot());
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
button = makeTextButton();
|
|
|
|
button = makeTextButton();
|
|
|
|
@@ -525,7 +519,7 @@ void initGUI()
|
|
|
|
button->setAllColorsSame();
|
|
|
|
button->setAllColorsSame();
|
|
|
|
button->font = fntlighttrek;
|
|
|
|
button->font = fntlighttrek;
|
|
|
|
button->fontLocationRelativeTo = Vector2(10, 0);
|
|
|
|
button->fontLocationRelativeTo = Vector2(10, 0);
|
|
|
|
button->parent = dataModel;
|
|
|
|
button->setParent(dataModel->getGuiRoot());
|
|
|
|
|
|
|
|
|
|
|
|
button = makeTextButton();
|
|
|
|
button = makeTextButton();
|
|
|
|
button->boxBegin = Vector2(0,265);
|
|
|
|
button->boxBegin = Vector2(0,265);
|
|
|
|
@@ -538,7 +532,7 @@ void initGUI()
|
|
|
|
button->setAllColorsSame();
|
|
|
|
button->setAllColorsSame();
|
|
|
|
button->font = fntlighttrek;
|
|
|
|
button->font = fntlighttrek;
|
|
|
|
button->fontLocationRelativeTo = Vector2(10, 0);
|
|
|
|
button->fontLocationRelativeTo = Vector2(10, 0);
|
|
|
|
button->parent = dataModel;
|
|
|
|
button->setParent(dataModel->getGuiRoot());
|
|
|
|
button->name = "Duplicate";
|
|
|
|
button->name = "Duplicate";
|
|
|
|
button->setButtonListener(new GUDButtonListener());
|
|
|
|
button->setButtonListener(new GUDButtonListener());
|
|
|
|
|
|
|
|
|
|
|
|
@@ -547,7 +541,7 @@ void initGUI()
|
|
|
|
instance->name = "go";
|
|
|
|
instance->name = "go";
|
|
|
|
instance->size = Vector2(65,65);
|
|
|
|
instance->size = Vector2(65,65);
|
|
|
|
instance->position = Vector2(6.5, 25);
|
|
|
|
instance->position = Vector2(6.5, 25);
|
|
|
|
instance->parent = dataModel;
|
|
|
|
instance->setParent(dataModel->getGuiRoot());
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@@ -558,14 +552,14 @@ void initGUI()
|
|
|
|
Texture::fromFile(GetFileInPath("/content/images/ArrowTool_ds.png")));
|
|
|
|
Texture::fromFile(GetFileInPath("/content/images/ArrowTool_ds.png")));
|
|
|
|
instance->size = Vector2(50,50);
|
|
|
|
instance->size = Vector2(50,50);
|
|
|
|
instance->position = Vector2(15, 90);
|
|
|
|
instance->position = Vector2(15, 90);
|
|
|
|
instance->parent = dataModel;
|
|
|
|
instance->setParent(dataModel->getGuiRoot());
|
|
|
|
instance->name = "Cursor";
|
|
|
|
instance->name = "Cursor";
|
|
|
|
instance->setButtonListener(new ModeSelectionListener());
|
|
|
|
instance->setButtonListener(new ModeSelectionListener());
|
|
|
|
|
|
|
|
|
|
|
|
instance = makeImageButton(Texture::fromFile(GetFileInPath("/content/images/ScaleTool.png")),Texture::fromFile(GetFileInPath("/content/images/ScaleTool_ovr.png")),Texture::fromFile(GetFileInPath("/content/images/ScaleTool_dn.png")),Texture::fromFile(GetFileInPath("/content/images/ScaleTool_ds.png")));
|
|
|
|
instance = makeImageButton(Texture::fromFile(GetFileInPath("/content/images/ScaleTool.png")),Texture::fromFile(GetFileInPath("/content/images/ScaleTool_ovr.png")),Texture::fromFile(GetFileInPath("/content/images/ScaleTool_dn.png")),Texture::fromFile(GetFileInPath("/content/images/ScaleTool_ds.png")));
|
|
|
|
instance->size = Vector2(40,40);
|
|
|
|
instance->size = Vector2(40,40);
|
|
|
|
instance->position = Vector2(0, 140);
|
|
|
|
instance->position = Vector2(0, 140);
|
|
|
|
instance->parent = dataModel;
|
|
|
|
instance->setParent(dataModel->getGuiRoot());
|
|
|
|
instance->name = "Resize";
|
|
|
|
instance->name = "Resize";
|
|
|
|
instance->setButtonListener(new ModeSelectionListener());
|
|
|
|
instance->setButtonListener(new ModeSelectionListener());
|
|
|
|
|
|
|
|
|
|
|
|
@@ -577,7 +571,7 @@ void initGUI()
|
|
|
|
Texture::fromFile(GetFileInPath("/content/images/MoveTool_ds.png")));
|
|
|
|
Texture::fromFile(GetFileInPath("/content/images/MoveTool_ds.png")));
|
|
|
|
instance->size = Vector2(40,40);
|
|
|
|
instance->size = Vector2(40,40);
|
|
|
|
instance->position = Vector2(40, 140);
|
|
|
|
instance->position = Vector2(40, 140);
|
|
|
|
instance->parent = dataModel;
|
|
|
|
instance->setParent(dataModel->getGuiRoot());
|
|
|
|
instance->name = "Arrows";
|
|
|
|
instance->name = "Arrows";
|
|
|
|
instance->setButtonListener(new ModeSelectionListener());
|
|
|
|
instance->setButtonListener(new ModeSelectionListener());
|
|
|
|
|
|
|
|
|
|
|
|
@@ -588,7 +582,7 @@ void initGUI()
|
|
|
|
Texture::fromFile(GetFileInPath("/content/images/SelectionRotate_ds.png")));
|
|
|
|
Texture::fromFile(GetFileInPath("/content/images/SelectionRotate_ds.png")));
|
|
|
|
instance->size = Vector2(30,30);
|
|
|
|
instance->size = Vector2(30,30);
|
|
|
|
instance->position = Vector2(10, 175);
|
|
|
|
instance->position = Vector2(10, 175);
|
|
|
|
instance->parent = dataModel;
|
|
|
|
instance->setParent(dataModel->getGuiRoot());
|
|
|
|
instance->name = "Rotate";
|
|
|
|
instance->name = "Rotate";
|
|
|
|
instance->setButtonListener(new RotateButtonListener());
|
|
|
|
instance->setButtonListener(new RotateButtonListener());
|
|
|
|
|
|
|
|
|
|
|
|
@@ -599,7 +593,7 @@ void initGUI()
|
|
|
|
Texture::fromFile(GetFileInPath("/content/images/SelectionTilt_ds.png")));
|
|
|
|
Texture::fromFile(GetFileInPath("/content/images/SelectionTilt_ds.png")));
|
|
|
|
instance->size = Vector2(30,30);
|
|
|
|
instance->size = Vector2(30,30);
|
|
|
|
instance->position = Vector2(40, 175);
|
|
|
|
instance->position = Vector2(40, 175);
|
|
|
|
instance->parent = dataModel;
|
|
|
|
instance->setParent(dataModel->getGuiRoot());
|
|
|
|
instance->name = "Tilt";
|
|
|
|
instance->name = "Tilt";
|
|
|
|
instance->setButtonListener(new RotateButtonListener());
|
|
|
|
instance->setButtonListener(new RotateButtonListener());
|
|
|
|
|
|
|
|
|
|
|
|
@@ -611,7 +605,7 @@ void initGUI()
|
|
|
|
Texture::fromFile(GetFileInPath("/content/images/Delete_ds.png")));
|
|
|
|
Texture::fromFile(GetFileInPath("/content/images/Delete_ds.png")));
|
|
|
|
instance->size = Vector2(40,46);
|
|
|
|
instance->size = Vector2(40,46);
|
|
|
|
instance->position = Vector2(20, 284);
|
|
|
|
instance->position = Vector2(20, 284);
|
|
|
|
instance->parent = dataModel;
|
|
|
|
instance->setParent(dataModel->getGuiRoot());
|
|
|
|
instance->name = "Delete";
|
|
|
|
instance->name = "Delete";
|
|
|
|
instance->setButtonListener(new DeleteListener());
|
|
|
|
instance->setButtonListener(new DeleteListener());
|
|
|
|
|
|
|
|
|
|
|
|
@@ -623,7 +617,7 @@ void initGUI()
|
|
|
|
instance->floatBottom = true;
|
|
|
|
instance->floatBottom = true;
|
|
|
|
instance->floatRight = true;
|
|
|
|
instance->floatRight = true;
|
|
|
|
instance->position = Vector2(-77, -90);
|
|
|
|
instance->position = Vector2(-77, -90);
|
|
|
|
instance->parent = dataModel;
|
|
|
|
instance->setParent(dataModel->getGuiRoot());
|
|
|
|
instance->name = "ZoomIn";
|
|
|
|
instance->name = "ZoomIn";
|
|
|
|
instance->setButtonListener(new CameraButtonListener());
|
|
|
|
instance->setButtonListener(new CameraButtonListener());
|
|
|
|
|
|
|
|
|
|
|
|
@@ -635,7 +629,7 @@ void initGUI()
|
|
|
|
instance->floatBottom = true;
|
|
|
|
instance->floatBottom = true;
|
|
|
|
instance->floatRight = true;
|
|
|
|
instance->floatRight = true;
|
|
|
|
instance->position = Vector2(-77, -31);
|
|
|
|
instance->position = Vector2(-77, -31);
|
|
|
|
instance->parent = dataModel;
|
|
|
|
instance->setParent(dataModel->getGuiRoot());
|
|
|
|
instance->name = "ZoomOut";
|
|
|
|
instance->name = "ZoomOut";
|
|
|
|
instance->setButtonListener(new CameraButtonListener());
|
|
|
|
instance->setButtonListener(new CameraButtonListener());
|
|
|
|
|
|
|
|
|
|
|
|
@@ -647,7 +641,7 @@ void initGUI()
|
|
|
|
instance->floatBottom = true;
|
|
|
|
instance->floatBottom = true;
|
|
|
|
instance->floatRight = true;
|
|
|
|
instance->floatRight = true;
|
|
|
|
instance->position = Vector2(-110, -50);
|
|
|
|
instance->position = Vector2(-110, -50);
|
|
|
|
instance->parent = dataModel;
|
|
|
|
instance->setParent(dataModel->getGuiRoot());
|
|
|
|
instance->name = "PanLeft";
|
|
|
|
instance->name = "PanLeft";
|
|
|
|
instance->setButtonListener(new CameraButtonListener());
|
|
|
|
instance->setButtonListener(new CameraButtonListener());
|
|
|
|
|
|
|
|
|
|
|
|
@@ -659,7 +653,7 @@ void initGUI()
|
|
|
|
instance->floatBottom = true;
|
|
|
|
instance->floatBottom = true;
|
|
|
|
instance->floatRight = true;
|
|
|
|
instance->floatRight = true;
|
|
|
|
instance->position = Vector2(-45, -50);
|
|
|
|
instance->position = Vector2(-45, -50);
|
|
|
|
instance->parent = dataModel;
|
|
|
|
instance->setParent(dataModel->getGuiRoot());
|
|
|
|
instance->name = "PanRight";
|
|
|
|
instance->name = "PanRight";
|
|
|
|
instance->setButtonListener(new CameraButtonListener());
|
|
|
|
instance->setButtonListener(new CameraButtonListener());
|
|
|
|
|
|
|
|
|
|
|
|
@@ -671,7 +665,7 @@ void initGUI()
|
|
|
|
instance->floatBottom = true;
|
|
|
|
instance->floatBottom = true;
|
|
|
|
instance->floatRight = true;
|
|
|
|
instance->floatRight = true;
|
|
|
|
instance->position = Vector2(-77, -60);
|
|
|
|
instance->position = Vector2(-77, -60);
|
|
|
|
instance->parent = dataModel;
|
|
|
|
instance->setParent(dataModel->getGuiRoot());
|
|
|
|
instance->name = "CenterCam";
|
|
|
|
instance->name = "CenterCam";
|
|
|
|
instance->setButtonListener(new CameraButtonListener());
|
|
|
|
instance->setButtonListener(new CameraButtonListener());
|
|
|
|
|
|
|
|
|
|
|
|
@@ -683,7 +677,7 @@ void initGUI()
|
|
|
|
instance->floatBottom = true;
|
|
|
|
instance->floatBottom = true;
|
|
|
|
instance->floatRight = true;
|
|
|
|
instance->floatRight = true;
|
|
|
|
instance->position = Vector2(-105, -75);
|
|
|
|
instance->position = Vector2(-105, -75);
|
|
|
|
instance->parent = dataModel;
|
|
|
|
instance->setParent(dataModel->getGuiRoot());
|
|
|
|
instance->name = "TiltUp";
|
|
|
|
instance->name = "TiltUp";
|
|
|
|
instance->setButtonListener(new CameraButtonListener());
|
|
|
|
instance->setButtonListener(new CameraButtonListener());
|
|
|
|
|
|
|
|
|
|
|
|
@@ -695,7 +689,7 @@ void initGUI()
|
|
|
|
instance->floatBottom = true;
|
|
|
|
instance->floatBottom = true;
|
|
|
|
instance->floatRight = true;
|
|
|
|
instance->floatRight = true;
|
|
|
|
instance->position = Vector2(-40, -75);
|
|
|
|
instance->position = Vector2(-40, -75);
|
|
|
|
instance->parent = dataModel;
|
|
|
|
instance->setParent(dataModel->getGuiRoot());
|
|
|
|
instance->name = "TiltDown";
|
|
|
|
instance->name = "TiltDown";
|
|
|
|
instance->setButtonListener(new CameraButtonListener());
|
|
|
|
instance->setButtonListener(new CameraButtonListener());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
@@ -706,89 +700,89 @@ void Demo::onInit() {
|
|
|
|
// Called before Demo::run() beings
|
|
|
|
// Called before Demo::run() beings
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
dataModel = new Instance();
|
|
|
|
dataModel = new DataModelInstance();
|
|
|
|
dataModel->parent = NULL;
|
|
|
|
dataModel->setParent(NULL);
|
|
|
|
dataModel->name = "undefined";
|
|
|
|
dataModel->name = "undefined";
|
|
|
|
|
|
|
|
|
|
|
|
initGUI();
|
|
|
|
initGUI();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
PhysicalInstance* test = makePart();
|
|
|
|
PhysicalInstance* test = makePart();
|
|
|
|
test->parent = dataModel;
|
|
|
|
test->setParent(dataModel->getWorkspace());
|
|
|
|
test->color = Color3(0.2F,0.3F,1);
|
|
|
|
test->color = Color3(0.2F,0.3F,1);
|
|
|
|
test->size = Vector3(24,1,24);
|
|
|
|
test->setSize(Vector3(24,1,24));
|
|
|
|
test->setPosition(Vector3(0,0,0));
|
|
|
|
test->setPosition(Vector3(0,0,0));
|
|
|
|
test->setCFrame(test->getCFrame() * Matrix3::fromEulerAnglesXYZ(0,toRadians(90),0));
|
|
|
|
test->setCFrame(test->getCFrame() * Matrix3::fromEulerAnglesXYZ(0,toRadians(40),toRadians(40)));
|
|
|
|
//selectedInstance = test;
|
|
|
|
//selectedInstance = test;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
test = makePart();
|
|
|
|
test = makePart();
|
|
|
|
test->parent = dataModel;
|
|
|
|
test->setParent(dataModel->getWorkspace());
|
|
|
|
test->color = Color3(.5F,1,.5F);
|
|
|
|
test->color = Color3(.5F,1,.5F);
|
|
|
|
test->size = Vector3(4,1,2);
|
|
|
|
test->setSize(Vector3(4,1,2));
|
|
|
|
test->setPosition(Vector3(-10,1,0));
|
|
|
|
test->setPosition(Vector3(-10,1,0));
|
|
|
|
test = makePart();
|
|
|
|
test = makePart();
|
|
|
|
test->parent = dataModel;
|
|
|
|
test->setParent(dataModel->getWorkspace());
|
|
|
|
test->color = Color3(.5F,1,.5F);
|
|
|
|
test->color = Color3(.5F,1,.5F);
|
|
|
|
test->size = Vector3(4,1,2);
|
|
|
|
test->setSize(Vector3(4,1,2));
|
|
|
|
test->setPosition(Vector3(10,1,0));
|
|
|
|
test->setPosition(Vector3(10,1,0));
|
|
|
|
|
|
|
|
|
|
|
|
test = makePart();
|
|
|
|
test = makePart();
|
|
|
|
test->parent = dataModel;
|
|
|
|
test->setParent(dataModel->getWorkspace());
|
|
|
|
test->color = Color3::gray();
|
|
|
|
test->color = Color3::gray();
|
|
|
|
test->size = Vector3(4,1,2);
|
|
|
|
test->setSize(Vector3(4,1,2));
|
|
|
|
test->setPosition(Vector3(7,2,0));
|
|
|
|
test->setPosition(Vector3(7,2,0));
|
|
|
|
|
|
|
|
|
|
|
|
test = makePart();
|
|
|
|
test = makePart();
|
|
|
|
test->parent = dataModel;
|
|
|
|
test->setParent(dataModel->getWorkspace());
|
|
|
|
test->color = Color3::gray();
|
|
|
|
test->color = Color3::gray();
|
|
|
|
test->size = Vector3(4,1,2);
|
|
|
|
test->setSize(Vector3(4,1,2));
|
|
|
|
test->setPosition(Vector3(-7,2,0));
|
|
|
|
test->setPosition(Vector3(-7,2,0));
|
|
|
|
|
|
|
|
|
|
|
|
test = makePart();
|
|
|
|
test = makePart();
|
|
|
|
test->parent = dataModel;
|
|
|
|
test->setParent(dataModel->getWorkspace());
|
|
|
|
test->color = Color3::gray();
|
|
|
|
test->color = Color3::gray();
|
|
|
|
test->size = Vector3(4,1,2);
|
|
|
|
test->setSize(Vector3(4,1,2));
|
|
|
|
test->setPosition(Vector3(4,3,0));
|
|
|
|
test->setPosition(Vector3(4,3,0));
|
|
|
|
|
|
|
|
|
|
|
|
test = makePart();
|
|
|
|
test = makePart();
|
|
|
|
test->parent = dataModel;
|
|
|
|
test->setParent(dataModel->getWorkspace());
|
|
|
|
test->color = Color3::gray();
|
|
|
|
test->color = Color3::gray();
|
|
|
|
test->size = Vector3(4,1,2);
|
|
|
|
test->setSize(Vector3(4,1,2));
|
|
|
|
test->setPosition(Vector3(-5,3,0));
|
|
|
|
test->setPosition(Vector3(-5,3,0));
|
|
|
|
|
|
|
|
|
|
|
|
test = makePart();
|
|
|
|
test = makePart();
|
|
|
|
test->parent = dataModel;
|
|
|
|
test->setParent(dataModel->getWorkspace());
|
|
|
|
test->color = Color3::gray();
|
|
|
|
test->color = Color3::gray();
|
|
|
|
test->size = Vector3(4,1,2);
|
|
|
|
test->setSize(Vector3(4,1,2));
|
|
|
|
test->setPosition(Vector3(1,4,0));
|
|
|
|
test->setPosition(Vector3(1,4,0));
|
|
|
|
|
|
|
|
|
|
|
|
test = makePart();
|
|
|
|
test = makePart();
|
|
|
|
test->parent = dataModel;
|
|
|
|
test->setParent(dataModel->getWorkspace());
|
|
|
|
test->color = Color3::gray();
|
|
|
|
test->color = Color3::gray();
|
|
|
|
test->size = Vector3(4,1,2);
|
|
|
|
test->setSize(Vector3(4,1,2));
|
|
|
|
test->setPosition(Vector3(-3,4,0));
|
|
|
|
test->setPosition(Vector3(-3,4,0));
|
|
|
|
|
|
|
|
|
|
|
|
test = makePart();
|
|
|
|
test = makePart();
|
|
|
|
test->parent = dataModel;
|
|
|
|
test->setParent(dataModel->getWorkspace());
|
|
|
|
test->color = Color3::gray();
|
|
|
|
test->color = Color3::gray();
|
|
|
|
test->size = Vector3(4,1,2);
|
|
|
|
test->setSize(Vector3(4,1,2));
|
|
|
|
test->setPosition(Vector3(-2,5,0));
|
|
|
|
test->setPosition(Vector3(-2,5,0));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
test = makePart();
|
|
|
|
test = makePart();
|
|
|
|
test->parent = dataModel;
|
|
|
|
test->setParent(dataModel->getWorkspace());
|
|
|
|
test->color = Color3::gray();
|
|
|
|
test->color = Color3::gray();
|
|
|
|
test->size = Vector3(4,1,2);
|
|
|
|
test->setSize(Vector3(4,1,2));
|
|
|
|
test->setPosition(Vector3(0,6,0));
|
|
|
|
test->setPosition(Vector3(0,6,0));
|
|
|
|
|
|
|
|
|
|
|
|
test = makePart();
|
|
|
|
test = makePart();
|
|
|
|
test->parent = dataModel;
|
|
|
|
test->setParent(dataModel->getWorkspace());
|
|
|
|
test->color = Color3::gray();
|
|
|
|
test->color = Color3::gray();
|
|
|
|
test->size = Vector3(-4,-1,-2);
|
|
|
|
test->setSize(Vector3(4,1,2));
|
|
|
|
test->setPosition(Vector3(2,7,0));
|
|
|
|
test->setPosition(Vector3(2,7,0));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@@ -829,18 +823,17 @@ void Demo::onCleanup() {
|
|
|
|
|
|
|
|
|
|
|
|
void Demo::onLogic() {
|
|
|
|
void Demo::onLogic() {
|
|
|
|
// Add non-simulation game logic and AI code here
|
|
|
|
// Add non-simulation game logic and AI code here
|
|
|
|
for(size_t i = 0; i < instances_2D.size(); i++)
|
|
|
|
|
|
|
|
|
|
|
|
Instance* obj = dataModel->getGuiRoot()->findFirstChild("Delete");
|
|
|
|
|
|
|
|
if(obj != NULL)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if(instances_2D.at(i)->name == "Delete")
|
|
|
|
ImageButtonInstance* button = (ImageButtonInstance*)obj;
|
|
|
|
{
|
|
|
|
|
|
|
|
ImageButtonInstance* button = (ImageButtonInstance*)instances_2D.at(i);
|
|
|
|
|
|
|
|
if(selectedInstance == NULL)
|
|
|
|
if(selectedInstance == NULL)
|
|
|
|
button->disabled = true;
|
|
|
|
button->disabled = true;
|
|
|
|
else
|
|
|
|
else
|
|
|
|
button->disabled = false;
|
|
|
|
button->disabled = false;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@@ -900,7 +893,17 @@ void Demo::onSimulation(RealTime rdt, SimTime sdt, SimTime idt) {
|
|
|
|
{
|
|
|
|
{
|
|
|
|
panRight = false;
|
|
|
|
panRight = false;
|
|
|
|
CoordinateFrame frame = app->debugCamera.getCoordinateFrame();
|
|
|
|
CoordinateFrame frame = app->debugCamera.getCoordinateFrame();
|
|
|
|
Vector3 camerapoint = frame.translation;
|
|
|
|
float y = frame.translation.y;
|
|
|
|
|
|
|
|
CoordinateFrame frame2 = CoordinateFrame(frame.rotation, frame.translation + frame.lookVector()*25);
|
|
|
|
|
|
|
|
Vector3 focus = frame.translation+frame.lookVector()*25;
|
|
|
|
|
|
|
|
frame2 = frame2 * Matrix3::fromEulerAnglesXYZ(0,toRadians(45),0);
|
|
|
|
|
|
|
|
frame2 = frame2 - frame2.lookVector()*25;
|
|
|
|
|
|
|
|
cameraPos = Vector3(frame2.translation.x, y, frame2.translation.z);
|
|
|
|
|
|
|
|
CoordinateFrame newFrame = CoordinateFrame(frame2.rotation, Vector3(frame2.translation.x, y, frame2.translation.z));
|
|
|
|
|
|
|
|
newFrame.lookAt(focus);
|
|
|
|
|
|
|
|
app->debugController.setCoordinateFrame(newFrame);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*Vector3 camerapoint = frame.translation;
|
|
|
|
Vector3 focalPoint = camerapoint + frame.lookVector() * 25;
|
|
|
|
Vector3 focalPoint = camerapoint + frame.lookVector() * 25;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@@ -909,7 +912,8 @@ void Demo::onSimulation(RealTime rdt, SimTime sdt, SimTime idt) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
float angle = toRadians(90);
|
|
|
|
|
|
|
|
|
|
|
|
float angle = atan2(camerapoint.z - focalPoint.z, focalPoint.x - camerapoint.x);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//message = Convert(angle);
|
|
|
|
//message = Convert(angle);
|
|
|
|
@@ -928,20 +932,35 @@ void Demo::onSimulation(RealTime rdt, SimTime sdt, SimTime idt) {
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
messageTime = System::time();
|
|
|
|
messageTime = System::time();
|
|
|
|
|
|
|
|
|
|
|
|
//abs(((float)(getVectorDistance(Vector3(focalPoint.x, camerapoint.y, focalPoint.z), camerapoint))));
|
|
|
|
//abs(((float)(getVectorDistance(Vector3(focalPoint.x, camerapoint.y, focalPoint.z), camerapoint))));
|
|
|
|
float x = distc * cos(angle-toRadians(2)) + focalPoint.x;
|
|
|
|
float x = distc * cos(angle + toRadians(2)) + focalPoint.x;
|
|
|
|
float z = distc * sin(angle-toRadians(2)) + focalPoint.z;
|
|
|
|
float z = distc * sin(angle + toRadians(2)) + focalPoint.z;
|
|
|
|
message = "NOT 0, " + Convert(x) + ", " + Convert(z);
|
|
|
|
message = "NOT 0, " + Convert(toDegrees(angle)) + ", " + Convert(toDegrees(angle + toRadians(2)));
|
|
|
|
//camerapoint = Vector3(sin(angle)*distc,camerapoint.y,cos(angle)*distc);
|
|
|
|
//camerapoint = Vector3(sin(angle)*distc,camerapoint.y,cos(angle)*distc);
|
|
|
|
camerapoint = Vector3(x,camerapoint.y,z);
|
|
|
|
camerapoint = Vector3(x,camerapoint.y,z);
|
|
|
|
CoordinateFrame newFrame = CoordinateFrame(camerapoint);
|
|
|
|
CoordinateFrame newFrame = CoordinateFrame(camerapoint);
|
|
|
|
newFrame.lookAt(focalPoint);
|
|
|
|
newFrame.lookAt(focalPoint);
|
|
|
|
cameraPos = camerapoint;
|
|
|
|
cameraPos = camerapoint;
|
|
|
|
app->debugController.setCoordinateFrame(newFrame);
|
|
|
|
app->debugController.setCoordinateFrame(newFrame);*/
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if(panLeft)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
panLeft = false;
|
|
|
|
|
|
|
|
CoordinateFrame frame = app->debugCamera.getCoordinateFrame();
|
|
|
|
|
|
|
|
float y = frame.translation.y;
|
|
|
|
|
|
|
|
CoordinateFrame frame2 = CoordinateFrame(frame.rotation, frame.translation + frame.lookVector()*25);
|
|
|
|
|
|
|
|
Vector3 focus = frame.translation+frame.lookVector()*25;
|
|
|
|
|
|
|
|
frame2 = frame2 * Matrix3::fromEulerAnglesXYZ(0,toRadians(-45),0);
|
|
|
|
|
|
|
|
frame2 = frame2 - frame2.lookVector()*25;
|
|
|
|
|
|
|
|
cameraPos = Vector3(frame2.translation.x, y, frame2.translation.z);
|
|
|
|
|
|
|
|
CoordinateFrame newFrame = CoordinateFrame(frame2.rotation, Vector3(frame2.translation.x, y, frame2.translation.z));
|
|
|
|
|
|
|
|
newFrame.lookAt(focus);
|
|
|
|
|
|
|
|
app->debugController.setCoordinateFrame(newFrame);
|
|
|
|
|
|
|
|
}
|
|
|
|
if(tiltUp)
|
|
|
|
if(tiltUp)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
tiltUp = false;
|
|
|
|
tiltUp = false;
|
|
|
|
@@ -1008,7 +1027,6 @@ void Demo::onUserInput(UserInput* ui) {
|
|
|
|
showMouse = true;
|
|
|
|
showMouse = true;
|
|
|
|
app->debugController.setActive(false);
|
|
|
|
app->debugController.setActive(false);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if(ui->keyPressed(SDLK_LSHIFT) || ui->keyPressed(SDLK_RSHIFT))
|
|
|
|
if(ui->keyPressed(SDLK_LSHIFT) || ui->keyPressed(SDLK_RSHIFT))
|
|
|
|
{
|
|
|
|
{
|
|
|
|
moveRate = 1;
|
|
|
|
moveRate = 1;
|
|
|
|
@@ -1020,13 +1038,13 @@ void Demo::onUserInput(UserInput* ui) {
|
|
|
|
|
|
|
|
|
|
|
|
if(ui->keyPressed(SDL_MOUSE_WHEEL_UP_KEY))
|
|
|
|
if(ui->keyPressed(SDL_MOUSE_WHEEL_UP_KEY))
|
|
|
|
{
|
|
|
|
{
|
|
|
|
AudioPlayer::PlaySound(cameraSound);
|
|
|
|
AudioPlayer::playSound(cameraSound);
|
|
|
|
CoordinateFrame frame = app->debugCamera.getCoordinateFrame();
|
|
|
|
CoordinateFrame frame = app->debugCamera.getCoordinateFrame();
|
|
|
|
cameraPos = cameraPos + frame.lookVector()*2;
|
|
|
|
cameraPos = cameraPos + frame.lookVector()*2;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if(ui->keyPressed(SDL_MOUSE_WHEEL_DOWN_KEY))
|
|
|
|
if(ui->keyPressed(SDL_MOUSE_WHEEL_DOWN_KEY))
|
|
|
|
{
|
|
|
|
{
|
|
|
|
AudioPlayer::PlaySound(cameraSound);
|
|
|
|
AudioPlayer::playSound(cameraSound);
|
|
|
|
CoordinateFrame frame = app->debugCamera.getCoordinateFrame();
|
|
|
|
CoordinateFrame frame = app->debugCamera.getCoordinateFrame();
|
|
|
|
cameraPos = cameraPos - frame.lookVector()*2;
|
|
|
|
cameraPos = cameraPos - frame.lookVector()*2;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
@@ -1091,9 +1109,10 @@ void Demo::onUserInput(UserInput* ui) {
|
|
|
|
if(ui->keyPressed(SDL_LEFT_MOUSE_KEY))
|
|
|
|
if(ui->keyPressed(SDL_LEFT_MOUSE_KEY))
|
|
|
|
{
|
|
|
|
{
|
|
|
|
bool onGUI = false;
|
|
|
|
bool onGUI = false;
|
|
|
|
|
|
|
|
std::vector<Instance*> instances_2D = dataModel->getGuiRoot()->getAllChildren();
|
|
|
|
for(size_t i = 0; i < instances_2D.size(); i++)
|
|
|
|
for(size_t i = 0; i < instances_2D.size(); i++)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if(instances_2D.at(i)->className == "TextButton" || instances_2D.at(i)->className == "ImageButton")
|
|
|
|
if(instances_2D.at(i)->getClassName() == "TextButton" || instances_2D.at(i)->getClassName() == "ImageButton")
|
|
|
|
{
|
|
|
|
{
|
|
|
|
BaseButtonInstance* button = (BaseButtonInstance*)instances_2D.at(i);
|
|
|
|
BaseButtonInstance* button = (BaseButtonInstance*)instances_2D.at(i);
|
|
|
|
if(button->mouseInButton(ui->mouseXY().x, ui->mouseXY().y, app->renderDevice))
|
|
|
|
if(button->mouseInButton(ui->mouseXY().x, ui->mouseXY().y, app->renderDevice))
|
|
|
|
@@ -1109,9 +1128,10 @@ void Demo::onUserInput(UserInput* ui) {
|
|
|
|
testRay = app->debugCamera.worldRay(mousex, mousey, app->renderDevice->getViewport());
|
|
|
|
testRay = app->debugCamera.worldRay(mousex, mousey, app->renderDevice->getViewport());
|
|
|
|
float nearest=std::numeric_limits<float>::infinity();
|
|
|
|
float nearest=std::numeric_limits<float>::infinity();
|
|
|
|
Vector3 camPos = app->debugCamera.getCoordinateFrame().translation;
|
|
|
|
Vector3 camPos = app->debugCamera.getCoordinateFrame().translation;
|
|
|
|
|
|
|
|
std::vector<Instance*> instances = dataModel->getWorkspace()->getAllChildren();
|
|
|
|
for(size_t i = 0; i < instances.size(); i++)
|
|
|
|
for(size_t i = 0; i < instances.size(); i++)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if(instances.at(i)->className == "Part" && instances.at(i)->parent == dataModel)
|
|
|
|
if(instances.at(i)->getClassName() == "Part")
|
|
|
|
{
|
|
|
|
{
|
|
|
|
PhysicalInstance* test = (PhysicalInstance*)instances.at(i);
|
|
|
|
PhysicalInstance* test = (PhysicalInstance*)instances.at(i);
|
|
|
|
float time = testRay.intersectionTime(test->getBox());
|
|
|
|
float time = testRay.intersectionTime(test->getBox());
|
|
|
|
@@ -1121,6 +1141,9 @@ void Demo::onUserInput(UserInput* ui) {
|
|
|
|
{
|
|
|
|
{
|
|
|
|
nearest=time;
|
|
|
|
nearest=time;
|
|
|
|
selectedInstance = test;
|
|
|
|
selectedInstance = test;
|
|
|
|
|
|
|
|
//message = "Dragging = true.";
|
|
|
|
|
|
|
|
//messageTime = System::time();
|
|
|
|
|
|
|
|
dragging = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
@@ -1135,10 +1158,14 @@ void Demo::onUserInput(UserInput* ui) {
|
|
|
|
|
|
|
|
|
|
|
|
if(ui->keyReleased(SDL_LEFT_MOUSE_KEY))
|
|
|
|
if(ui->keyReleased(SDL_LEFT_MOUSE_KEY))
|
|
|
|
{
|
|
|
|
{
|
|
|
|
|
|
|
|
dragging = false;
|
|
|
|
|
|
|
|
//message = "Dragging = false.";
|
|
|
|
|
|
|
|
//messageTime = System::time();
|
|
|
|
|
|
|
|
std::vector<Instance*> instances_2D = dataModel->getGuiRoot()->getAllChildren();
|
|
|
|
|
|
|
|
std::vector<Instance*> instances = dataModel->getWorkspace()->getAllChildren();
|
|
|
|
for(size_t i = 0; i < instances_2D.size(); i++)
|
|
|
|
for(size_t i = 0; i < instances_2D.size(); i++)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if(instances_2D.at(i)->className == "TextButton" || instances_2D.at(i)->className == "ImageButton")
|
|
|
|
if(instances_2D.at(i)->getClassName() == "TextButton" || instances_2D.at(i)->getClassName() == "ImageButton")
|
|
|
|
{
|
|
|
|
{
|
|
|
|
BaseButtonInstance* button = (BaseButtonInstance*)instances_2D.at(i);
|
|
|
|
BaseButtonInstance* button = (BaseButtonInstance*)instances_2D.at(i);
|
|
|
|
if(button->mouseInButton(ui->mouseXY().x, ui->mouseXY().y, app->renderDevice))
|
|
|
|
if(button->mouseInButton(ui->mouseXY().x, ui->mouseXY().y, app->renderDevice))
|
|
|
|
@@ -1149,6 +1176,33 @@ void Demo::onUserInput(UserInput* ui) {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (ui->keyDown(SDL_LEFT_MOUSE_KEY)) {
|
|
|
|
|
|
|
|
if (dragging) {
|
|
|
|
|
|
|
|
PhysicalInstance* part = (PhysicalInstance*) selectedInstance;
|
|
|
|
|
|
|
|
Ray dragRay = app->debugCamera.worldRay(mousex, mousey, app->renderDevice->getViewport());
|
|
|
|
|
|
|
|
std::vector<Instance*> instances = dataModel->getWorkspace()->getAllChildren();
|
|
|
|
|
|
|
|
for(size_t i = 0; i < instances.size(); i++)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
if(instances.at(i)->getClassName() == "Part")
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
PhysicalInstance* moveTo = (PhysicalInstance*)instances.at(i);
|
|
|
|
|
|
|
|
float __time = testRay.intersectionTime(moveTo->getBox());
|
|
|
|
|
|
|
|
float __nearest=std::numeric_limits<float>::infinity();
|
|
|
|
|
|
|
|
if (__time != inf())
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
if (__nearest>__time)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
Vector3 closest = (dragRay.closestPoint(moveTo->getPosition()) * 2);
|
|
|
|
|
|
|
|
part->setPosition(closest);
|
|
|
|
|
|
|
|
//part->setPosition(Vector3(floor(closest.x),part->getPosition().y,floor(closest.z)));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
Sleep(10);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//readMouseGUIInput();
|
|
|
|
//readMouseGUIInput();
|
|
|
|
// Add other key handling here
|
|
|
|
// Add other key handling here
|
|
|
|
@@ -1205,10 +1259,11 @@ bool mouseInArea(float point1x, float point1y, float point2x, float point2y)
|
|
|
|
|
|
|
|
|
|
|
|
void drawButtons(RenderDevice* rd)
|
|
|
|
void drawButtons(RenderDevice* rd)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
|
|
|
|
std::vector<Instance*> instances_2D = dataModel->getGuiRoot()->getChildren();
|
|
|
|
for(size_t i = 0; i < instances_2D.size(); i++)
|
|
|
|
for(size_t i = 0; i < instances_2D.size(); i++)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
Instance* instance = instances_2D.at(i);
|
|
|
|
Instance* instance = instances_2D.at(i);
|
|
|
|
if((instance->className == "TextButton" || instance->className == "ImageButton") && instance->parent == dataModel)
|
|
|
|
if(instance->getClassName() == "TextButton" || instance->getClassName() == "ImageButton")
|
|
|
|
{
|
|
|
|
{
|
|
|
|
BaseButtonInstance* tbi = (BaseButtonInstance*)instance;
|
|
|
|
BaseButtonInstance* tbi = (BaseButtonInstance*)instance;
|
|
|
|
tbi->drawObj(rd, Vector2(mousex, mousey), mouseButton1Down);
|
|
|
|
tbi->drawObj(rd, Vector2(mousex, mousey), mouseButton1Down);
|
|
|
|
@@ -1218,6 +1273,7 @@ void drawButtons(RenderDevice* rd)
|
|
|
|
|
|
|
|
|
|
|
|
void drawOutline(Vector3 from, Vector3 to, RenderDevice* rd, LightingParameters lighting, Vector3 size, Vector3 pos, CoordinateFrame c)
|
|
|
|
void drawOutline(Vector3 from, Vector3 to, RenderDevice* rd, LightingParameters lighting, Vector3 size, Vector3 pos, CoordinateFrame c)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
//rd->setLight(0, NULL);
|
|
|
|
//rd->setLight(0, NULL);
|
|
|
|
//rd->setAmbientLightColor(Color3(1,1,1));
|
|
|
|
//rd->setAmbientLightColor(Color3(1,1,1));
|
|
|
|
Color3 outline = Color3::cyan();//Color3(0.098F,0.6F,1.0F);
|
|
|
|
Color3 outline = Color3::cyan();//Color3(0.098F,0.6F,1.0F);
|
|
|
|
@@ -1243,24 +1299,33 @@ void drawOutline(Vector3 from, Vector3 to, RenderDevice* rd, LightingParameters
|
|
|
|
{
|
|
|
|
{
|
|
|
|
rd->setLight(0, NULL);
|
|
|
|
rd->setLight(0, NULL);
|
|
|
|
rd->setAmbientLightColor(Color3(1,1,1));
|
|
|
|
rd->setAmbientLightColor(Color3(1,1,1));
|
|
|
|
float max = size.x;
|
|
|
|
|
|
|
|
if(abs(size.y) > max)
|
|
|
|
AABox box;
|
|
|
|
max = size.y;
|
|
|
|
c.toWorldSpace(Box(from, to)).getBounds(box);
|
|
|
|
if(abs(size.z) > max)
|
|
|
|
float max = box.high().y - pos.y;
|
|
|
|
max = size.z;
|
|
|
|
|
|
|
|
max = max / 2;
|
|
|
|
Draw::arrow(pos, Vector3(0, 1.5+max, 0), rd);
|
|
|
|
Draw::arrow(pos, Vector3(0, 1+max, 0), rd);
|
|
|
|
Draw::arrow(pos, Vector3(0, (-1.5)-max, 0), rd);
|
|
|
|
Draw::arrow(pos, Vector3(1+max, 0, 0), rd);
|
|
|
|
|
|
|
|
Draw::arrow(pos, Vector3(0, 0, 1+max), rd);
|
|
|
|
max = box.high().x - pos.x;
|
|
|
|
Draw::arrow(pos, Vector3(0, (-1)-max, 0), rd);
|
|
|
|
|
|
|
|
Draw::arrow(pos, Vector3((-1)-max, 0, 0), rd);
|
|
|
|
Draw::arrow(pos, Vector3(1.5+max, 0, 0), rd);
|
|
|
|
Draw::arrow(pos, Vector3(0, 0, (-1)-max), rd);
|
|
|
|
Draw::arrow(pos, Vector3((-1.5)-max, 0, 0), rd);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
max = box.high().z - pos.z;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Draw::arrow(pos, Vector3(0, 0, 1.5+max), rd);
|
|
|
|
|
|
|
|
Draw::arrow(pos, Vector3(0, 0, (-1.5)-max), rd);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
rd->setAmbientLightColor(lighting.ambient);
|
|
|
|
rd->setAmbientLightColor(lighting.ambient);
|
|
|
|
rd->setLight(0, GLight::directional(lighting.lightDirection, lighting.lightColor));
|
|
|
|
rd->setLight(0, GLight::directional(lighting.lightDirection, lighting.lightColor));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if(mode == RESIZE)
|
|
|
|
else if(mode == RESIZE)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
|
|
|
|
//Box box = c.toWorldSpace(Box(from, to))
|
|
|
|
|
|
|
|
Color3 sphereColor = outline;
|
|
|
|
rd->setLight(0, NULL);
|
|
|
|
rd->setLight(0, NULL);
|
|
|
|
rd->setAmbientLightColor(Color3(1,1,1));
|
|
|
|
rd->setAmbientLightColor(Color3(1,1,1));
|
|
|
|
Vector3 gamepoint = pos;
|
|
|
|
Vector3 gamepoint = pos;
|
|
|
|
@@ -1268,17 +1333,31 @@ void drawOutline(Vector3 from, Vector3 to, RenderDevice* rd, LightingParameters
|
|
|
|
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 < 200)
|
|
|
|
if(distance < 200)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
Color3 sphereColor = outline;
|
|
|
|
|
|
|
|
float multiplier = distance * 0.025F/2;
|
|
|
|
float multiplier = distance * 0.025F/2;
|
|
|
|
if(multiplier < 0.25F)
|
|
|
|
if(multiplier < 0.25F)
|
|
|
|
multiplier = 0.25F;
|
|
|
|
multiplier = 0.25F;
|
|
|
|
|
|
|
|
Vector3 position = pos + (c.lookVector()*((size.z/2)+1));
|
|
|
|
|
|
|
|
Draw::sphere(Sphere(position, multiplier), rd, sphereColor, Color4::clear());
|
|
|
|
|
|
|
|
position = pos - (c.lookVector()*((size.z/2)+1));
|
|
|
|
|
|
|
|
Draw::sphere(Sphere(position, multiplier), rd, sphereColor, Color4::clear());
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
position = pos + (c.rightVector()*((size.x/2)+1));
|
|
|
|
|
|
|
|
Draw::sphere(Sphere(position, multiplier), rd, sphereColor, Color4::clear());
|
|
|
|
|
|
|
|
position = pos - (c.rightVector()*((size.x/2)+1));
|
|
|
|
|
|
|
|
Draw::sphere(Sphere(position, multiplier), rd, sphereColor, Color4::clear());
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
position = pos + (c.upVector()*((size.y/2)+1));
|
|
|
|
|
|
|
|
Draw::sphere(Sphere(position, multiplier), rd, sphereColor, Color4::clear());
|
|
|
|
|
|
|
|
position = pos - (c.upVector()*((size.y/2)+1));
|
|
|
|
|
|
|
|
Draw::sphere(Sphere(position, multiplier), rd, sphereColor, Color4::clear());
|
|
|
|
|
|
|
|
//Draw::sphere(Sphere(Vector3(pos.x, pos.y - (size.y/2 + 1), pos.z), multiplier), rd, sphereColor, Color4::clear());
|
|
|
|
|
|
|
|
//Draw::sphere(Sphere(Vector3(pos.x + (size.x/2 + 1), pos.y, pos.z), multiplier), rd, sphereColor, Color4::clear());
|
|
|
|
|
|
|
|
//Draw::sphere(Sphere(Vector3(pos.x - (size.x/2 + 1), pos.y, pos.z), multiplier), rd, sphereColor, Color4::clear());
|
|
|
|
|
|
|
|
//Draw::sphere(Sphere(Vector3(pos.x, pos.y, pos.z + (size.z/2 + 1)), multiplier), rd, sphereColor, Color4::clear());
|
|
|
|
|
|
|
|
//Draw::sphere(Sphere(Vector3(pos.x, pos.y, pos.z - (size.z/2 + 1)), multiplier), rd, sphereColor, Color4::clear());
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Draw::sphere(Sphere(Vector3(pos.x, pos.y + (size.y/2 + 1), pos.z), multiplier), rd, sphereColor, Color4::clear());
|
|
|
|
|
|
|
|
Draw::sphere(Sphere(Vector3(pos.x, pos.y - (size.y/2 + 1), pos.z), multiplier), rd, sphereColor, Color4::clear());
|
|
|
|
|
|
|
|
Draw::sphere(Sphere(Vector3(pos.x + (size.x/2 + 1), pos.y, pos.z), multiplier), rd, sphereColor, Color4::clear());
|
|
|
|
|
|
|
|
Draw::sphere(Sphere(Vector3(pos.x - (size.x/2 + 1), pos.y, pos.z), multiplier), rd, sphereColor, Color4::clear());
|
|
|
|
|
|
|
|
Draw::sphere(Sphere(Vector3(pos.x, pos.y, pos.z + (size.z/2 + 1)), multiplier), rd, sphereColor, Color4::clear());
|
|
|
|
|
|
|
|
Draw::sphere(Sphere(Vector3(pos.x, pos.y, pos.z - (size.z/2 + 1)), multiplier), rd, sphereColor, Color4::clear());
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
rd->setAmbientLightColor(lighting.ambient);
|
|
|
|
rd->setAmbientLightColor(lighting.ambient);
|
|
|
|
rd->setLight(0, GLight::directional(lighting.lightDirection, lighting.lightColor));
|
|
|
|
rd->setLight(0, GLight::directional(lighting.lightDirection, lighting.lightColor));
|
|
|
|
@@ -1369,18 +1448,27 @@ void Demo::onGraphics(RenderDevice* rd) {
|
|
|
|
|
|
|
|
|
|
|
|
//app->renderDevice->pushState();
|
|
|
|
//app->renderDevice->pushState();
|
|
|
|
//app->renderDevice->popState();
|
|
|
|
//app->renderDevice->popState();
|
|
|
|
|
|
|
|
dataModel->getWorkspace()->render(rd);
|
|
|
|
|
|
|
|
if(selectedInstance != NULL)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
PhysicalInstance* part = (PhysicalInstance*)selectedInstance;
|
|
|
|
|
|
|
|
Vector3 size = part->getSize();
|
|
|
|
|
|
|
|
Vector3 pos = part->getPosition();
|
|
|
|
|
|
|
|
drawOutline(Vector3(0+size.x/4, 0+size.y/4, 0+size.z/4) ,Vector3(0-size.x/4,0-size.y/4,0-size.z/4), rd, lighting, Vector3(size.x/2, size.y/2, size.z/2), Vector3(pos.x/2, pos.y/2, pos.z/2), part->getCFrameRenderBased());
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
/*std::vector<Instance*> instances = dataModel->getWorkspace()->getAllChildren();
|
|
|
|
for(size_t i = 0; i < instances.size(); i++)
|
|
|
|
for(size_t i = 0; i < instances.size(); i++)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
Instance* instance = instances.at(i);
|
|
|
|
Instance* instance = instances.at(i);
|
|
|
|
if(instance->className == "Part" && instance->parent != NULL)
|
|
|
|
if(instance->getClassName() == "Part")
|
|
|
|
{
|
|
|
|
{
|
|
|
|
|
|
|
|
instance->render(rd);
|
|
|
|
PhysicalInstance* part = (PhysicalInstance*)instance;
|
|
|
|
PhysicalInstance* part = (PhysicalInstance*)instance;
|
|
|
|
Draw::box(part->getBox(), app->renderDevice, part->color, Color4::clear());
|
|
|
|
//part->render(rd);
|
|
|
|
|
|
|
|
//Draw::box(part->getBox(), app->renderDevice, part->color, Color4::clear());
|
|
|
|
if(selectedInstance == part)
|
|
|
|
if(selectedInstance == part)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
Vector3 size = part->size;
|
|
|
|
Vector3 size = part->getSize();
|
|
|
|
Vector3 pos = part->getCFrame().translation;
|
|
|
|
Vector3 pos = part->getCFrame().translation;
|
|
|
|
drawOutline(Vector3(0+size.x/4, 0+size.y/4, 0+size.z/4) ,Vector3(0-size.x/4,0-size.y/4,0-size.z/4), rd, lighting, Vector3(size.x/2, size.y/2, size.z/2), Vector3(pos.x/2, pos.y/2, pos.z/2), part->getCFrameRenderBased());
|
|
|
|
drawOutline(Vector3(0+size.x/4, 0+size.y/4, 0+size.z/4) ,Vector3(0-size.x/4,0-size.y/4,0-size.z/4), rd, lighting, Vector3(size.x/2, size.y/2, size.z/2), Vector3(pos.x/2, pos.y/2, pos.z/2), part->getCFrameRenderBased());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
@@ -1388,11 +1476,11 @@ void Demo::onGraphics(RenderDevice* rd) {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
Box box;
|
|
|
|
Box box;*/
|
|
|
|
|
|
|
|
|
|
|
|
//Draw::ray(testRay, rd, Color3::orange(), 1);
|
|
|
|
//Draw::ray(testRay, rd, Color3::orange(), 1);
|
|
|
|
|
|
|
|
|
|
|
|
/*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);
|
|
|
|
if(distance < 50 && distance > -50)
|
|
|
|
if(distance < 50 && distance > -50)
|
|
|
|
@@ -1401,7 +1489,7 @@ void Demo::onGraphics(RenderDevice* rd) {
|
|
|
|
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);
|
|
|
|
fntdominant->draw3D(rd, "Testing", CoordinateFrame(rd->getCameraToWorldMatrix().rotation, gamepoint), 0.04*distance, Color3::yellow(), Color3::black(), G3D::GFont::XALIGN_CENTER, G3D::GFont::YALIGN_CENTER);
|
|
|
|
}*/
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
app->renderDevice->disableLighting();
|
|
|
|
app->renderDevice->disableLighting();
|
|
|
|
|
|
|
|
|
|
|
|
@@ -1423,8 +1511,10 @@ void Demo::onGraphics(RenderDevice* rd) {
|
|
|
|
fntdominant->draw2D(rd, message, Vector2((rd->getWidth()/2)-(fntdominant->get2DStringBounds(message, 20).x/2),(rd->getHeight()/2)-(fntdominant->get2DStringBounds(message, 20).y/2)), 20, Color3::yellow(), Color3::black());
|
|
|
|
fntdominant->draw2D(rd, message, Vector2((rd->getWidth()/2)-(fntdominant->get2DStringBounds(message, 20).x/2),(rd->getHeight()/2)-(fntdominant->get2DStringBounds(message, 20).y/2)), 20, Color3::yellow(), Color3::black());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
fntdominant->draw2D(rd, "Timer: " + Convert(TIMERVAL), Vector2(rd->getWidth() - 120, 0+offset), 20, Color3::fromARGB(0x81C518), Color3::black());
|
|
|
|
std::stringstream stream;
|
|
|
|
fntdominant->draw2D(rd, "Score: " + Convert(SCOREVAL), Vector2(rd->getWidth() - 120, 25+offset), 20, Color3::fromARGB(0x81C518), Color3::black());
|
|
|
|
stream << std::fixed << std::setprecision(1) << dataModel->getWorkspace()->timer;
|
|
|
|
|
|
|
|
fntdominant->draw2D(rd, "Timer: " + stream.str(), Vector2(rd->getWidth() - 120, 0+offset), 20, Color3::fromARGB(0x81C518), Color3::black());
|
|
|
|
|
|
|
|
fntdominant->draw2D(rd, "Score: " + Convert(dataModel->getWorkspace()->score), Vector2(rd->getWidth() - 120, 25+offset), 20, Color3::fromARGB(0x81C518), Color3::black());
|
|
|
|
|
|
|
|
|
|
|
|
//GUI Boxes
|
|
|
|
//GUI Boxes
|
|
|
|
|
|
|
|
|
|
|
|
@@ -1700,19 +1790,21 @@ int main(int argc, char** argv) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
SetWindowPos(hwndMain, NULL, 0, 0, 800, 600, NULL);
|
|
|
|
SetWindowPos(hwndMain, NULL, 0, 0, 800, 600, NULL);
|
|
|
|
HMONITOR monitor = MonitorFromWindow(hwndMain, MONITOR_DEFAULTTONEAREST);
|
|
|
|
|
|
|
|
MONITORINFO lpmi;
|
|
|
|
|
|
|
|
GetMonitorInfo( monitor, &lpmi);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int widthMON = lpmi.rcMonitor.bottom;
|
|
|
|
|
|
|
|
int heightMON = lpmi.rcMonitor.right;
|
|
|
|
if(GetClientRect(hwndMain, &rect))
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
width = rect.right - rect.left;
|
|
|
|
|
|
|
|
height = rect.bottom - rect.top;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
SetWindowPos(hwnd, NULL, 0, 0, width, height, NULL);
|
|
|
|
|
|
|
|
|
|
|
|
//message = Convert(widthMON) + ", " + Convert(heightMON);
|
|
|
|
//message = Convert(widthMON) + ", " + Convert(heightMON);
|
|
|
|
//messageTime = G3D::System::time();
|
|
|
|
//messageTime = G3D::System::time();
|
|
|
|
|
|
|
|
|
|
|
|
app.run();
|
|
|
|
app.run();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
catch(std::exception)
|
|
|
|
catch(...)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
OnError(-1);
|
|
|
|
OnError(-1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|