Merge branch 'master' into MusicalProgrammer
This commit is contained in:
@@ -1,7 +1,7 @@
|
|||||||
#include "CameraController.h"
|
#include "CameraController.h"
|
||||||
#include "win32Defines.h"
|
#include "win32Defines.h"
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include "PhysicalInstance.h"
|
#include "PartInstance.h"
|
||||||
#include "Demo.h"
|
#include "Demo.h"
|
||||||
#include "AudioPlayer.h"
|
#include "AudioPlayer.h"
|
||||||
|
|
||||||
@@ -138,13 +138,18 @@ void CameraController::centerCamera(Instance* selection)
|
|||||||
lookAt(Vector3(0,0,0));
|
lookAt(Vector3(0,0,0));
|
||||||
focusPosition=Vector3(0,0,0);
|
focusPosition=Vector3(0,0,0);
|
||||||
}
|
}
|
||||||
else
|
else if(PartInstance* part = dynamic_cast<PartInstance*>(selection))
|
||||||
{
|
{
|
||||||
Vector3 partPos = ((PhysicalInstance*)selection)->getPosition()/2;
|
Vector3 partPos = (part)->getPosition()/2;
|
||||||
lookAt(partPos);
|
lookAt(partPos);
|
||||||
focusPosition=partPos;
|
focusPosition=partPos;
|
||||||
zoom=((partPos-frame.translation).magnitude());
|
zoom=((partPos-frame.translation).magnitude());
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
lookAt(Vector3(0,0,0));
|
||||||
|
focusPosition=Vector3(0,0,0);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CameraController::update(Demo* demo)
|
void CameraController::update(Demo* demo)
|
||||||
@@ -208,10 +213,10 @@ void CameraController::update(Demo* demo)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if(GetHoldKeyState(VK_RSHIFT) || GetHoldKeyState(VK_LSHIFT)) {
|
if(GetHoldKeyState(VK_RSHIFT) || GetHoldKeyState(VK_LSHIFT)) {
|
||||||
moveRate = 2.f;
|
moveRate = 2;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
moveRate = 1.f;
|
moveRate = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(GetHoldKeyState(VK_RBUTTON))
|
if(GetHoldKeyState(VK_RBUTTON))
|
||||||
|
|||||||
@@ -7,9 +7,34 @@
|
|||||||
using namespace std;
|
using namespace std;
|
||||||
using namespace rapidxml;
|
using namespace rapidxml;
|
||||||
|
|
||||||
PhysicalInstance* DataModelInstance::makePart()
|
|
||||||
|
DataModelInstance::DataModelInstance(void)
|
||||||
{
|
{
|
||||||
PhysicalInstance* part = new PhysicalInstance();
|
Instance::Instance();
|
||||||
|
workspace = new WorkspaceInstance();
|
||||||
|
guiRoot = new Instance();
|
||||||
|
level = new LevelInstance();
|
||||||
|
//children.push_back(workspace);
|
||||||
|
//children.push_back(level);
|
||||||
|
className = "dataModel";
|
||||||
|
mousex = 0;
|
||||||
|
mousey = 0;
|
||||||
|
mouseButton1Down = false;
|
||||||
|
showMessage = false;
|
||||||
|
canDelete = false;
|
||||||
|
|
||||||
|
workspace->setParent(this);
|
||||||
|
level->setParent(this);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
DataModelInstance::~DataModelInstance(void)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
PartInstance* DataModelInstance::makePart()
|
||||||
|
{
|
||||||
|
PartInstance* part = new PartInstance();
|
||||||
return part;
|
return part;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -50,6 +75,7 @@ bool DataModelInstance::scanXMLObject(xml_node<> * scanNode)
|
|||||||
|
|
||||||
for (xml_node<> *node = scanNode->first_node();node; node = node->next_sibling())
|
for (xml_node<> *node = scanNode->first_node();node; node = node->next_sibling())
|
||||||
{
|
{
|
||||||
|
|
||||||
if (strncmp(node->name(),"Item",4)==0)
|
if (strncmp(node->name(),"Item",4)==0)
|
||||||
{
|
{
|
||||||
xml_attribute<> *classAttr = node->first_attribute("class");
|
xml_attribute<> *classAttr = node->first_attribute("class");
|
||||||
@@ -135,11 +161,15 @@ bool DataModelInstance::scanXMLObject(xml_node<> * scanNode)
|
|||||||
float sizeZ = getFloatValue(sizeNode,"Z");
|
float sizeZ = getFloatValue(sizeNode,"Z");
|
||||||
|
|
||||||
if (_successfulLoad) {
|
if (_successfulLoad) {
|
||||||
PhysicalInstance* test = makePart();
|
PartInstance* test = makePart();
|
||||||
test->setParent(getWorkspace());
|
test->setParent(getWorkspace());
|
||||||
test->color = Color3(R,G,B);
|
test->color = Color3(R,G,B);
|
||||||
test->setSize(Vector3(sizeX,sizeY,sizeZ));
|
test->setSize(Vector3(sizeX,sizeY,sizeZ));
|
||||||
test->setCFrame(Matrix3(R00,R01,R02,R10,R11,R12,R20,R21,R22)*Vector3(X,Y,Z));
|
|
||||||
|
CoordinateFrame what;
|
||||||
|
what.translation = Vector3(X,Y,Z);
|
||||||
|
what.rotation = Matrix3(R00,R01,R02,R10,R11,R12,R20,R21,R22);
|
||||||
|
test->setCFrame(what);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -163,7 +193,7 @@ bool DataModelInstance::scanXMLObject(xml_node<> * scanNode)
|
|||||||
|
|
||||||
bool DataModelInstance::load()
|
bool DataModelInstance::load()
|
||||||
{
|
{
|
||||||
ifstream levelFile("skooter.rbxm");
|
ifstream levelFile("..//skooterFix.rbxm",ios::binary);
|
||||||
if (levelFile) {
|
if (levelFile) {
|
||||||
levelFile.seekg(0,levelFile.end);
|
levelFile.seekg(0,levelFile.end);
|
||||||
int length = levelFile.tellg();
|
int length = levelFile.tellg();
|
||||||
@@ -184,37 +214,53 @@ bool DataModelInstance::load()
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
DataModelInstance::DataModelInstance(void)
|
|
||||||
{
|
|
||||||
Instance::Instance();
|
|
||||||
workspace = new WorkspaceInstance();
|
|
||||||
guiRoot = new Instance();
|
|
||||||
children.push_back(workspace);
|
|
||||||
className = "dataModel";
|
|
||||||
mousex = 0;
|
|
||||||
mousey = 0;
|
|
||||||
mouseButton1Down = false;
|
|
||||||
showMessage = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
DataModelInstance::~DataModelInstance(void)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
void DataModelInstance::setMessage(std::string msg)
|
void DataModelInstance::setMessage(std::string msg)
|
||||||
{
|
{
|
||||||
message = msg;
|
message = msg;
|
||||||
|
isBrickCount = false;
|
||||||
showMessage = true;
|
showMessage = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void DataModelInstance::clearMessage()
|
void DataModelInstance::clearMessage()
|
||||||
{
|
{
|
||||||
showMessage = false;
|
showMessage = false;
|
||||||
|
isBrickCount = false;
|
||||||
message = "";
|
message = "";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void DataModelInstance::setMessageBrickCount()
|
||||||
|
{
|
||||||
|
isBrickCount = true;
|
||||||
|
showMessage = true;
|
||||||
|
}
|
||||||
|
|
||||||
void DataModelInstance::drawMessage(RenderDevice* rd)
|
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())
|
if(showMessage && !font.isNull())
|
||||||
{
|
{
|
||||||
int x = rd->getWidth()/2;
|
int x = rd->getWidth()/2;
|
||||||
@@ -248,3 +294,9 @@ Instance* DataModelInstance::getGuiRoot()
|
|||||||
{
|
{
|
||||||
return guiRoot;
|
return guiRoot;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
LevelInstance* DataModelInstance::getLevel()
|
||||||
|
{
|
||||||
|
return level;
|
||||||
|
}
|
||||||
@@ -1,8 +1,8 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
#include "rapidxml/rapidxml.hpp"
|
|
||||||
#include "instance.h"
|
|
||||||
#include "WorkspaceInstance.h"
|
#include "WorkspaceInstance.h"
|
||||||
#include "PhysicalInstance.h"
|
#include "LevelInstance.h"
|
||||||
|
#include "PartInstance.h"
|
||||||
|
#include "rapidxml/rapidxml.hpp"
|
||||||
|
|
||||||
class DataModelInstance :
|
class DataModelInstance :
|
||||||
public Instance
|
public Instance
|
||||||
@@ -11,12 +11,14 @@ public:
|
|||||||
DataModelInstance(void);
|
DataModelInstance(void);
|
||||||
~DataModelInstance(void);
|
~DataModelInstance(void);
|
||||||
void setMessage(std::string);
|
void setMessage(std::string);
|
||||||
|
void setMessageBrickCount();
|
||||||
void clearMessage();
|
void clearMessage();
|
||||||
bool load();
|
bool load();
|
||||||
bool printIfLoadError(const char* errorMsg);
|
|
||||||
void drawMessage(RenderDevice*);
|
void drawMessage(RenderDevice*);
|
||||||
WorkspaceInstance* getWorkspace();
|
WorkspaceInstance* getWorkspace();
|
||||||
WorkspaceInstance* workspace;
|
WorkspaceInstance* workspace;
|
||||||
|
LevelInstance * level;
|
||||||
|
LevelInstance * getLevel();
|
||||||
Instance* guiRoot;
|
Instance* guiRoot;
|
||||||
std::string message;
|
std::string message;
|
||||||
bool showMessage;
|
bool showMessage;
|
||||||
@@ -28,11 +30,13 @@ public:
|
|||||||
void setMousePos(int x,int y);
|
void setMousePos(int x,int y);
|
||||||
void setMousePos(Vector2 pos);
|
void setMousePos(Vector2 pos);
|
||||||
bool mouseButton1Down;
|
bool mouseButton1Down;
|
||||||
PhysicalInstance* makePart();
|
PartInstance* makePart();
|
||||||
private:
|
private:
|
||||||
|
bool isBrickCount;
|
||||||
bool scanXMLObject(rapidxml::xml_node<>* node);
|
bool scanXMLObject(rapidxml::xml_node<>* node);
|
||||||
rapidxml::xml_node<>* getNode(rapidxml::xml_node<> * node,const char* name );
|
rapidxml::xml_node<>* getNode(rapidxml::xml_node<> * node,const char* name );
|
||||||
float getFloatValue(rapidxml::xml_node<> * node,const char* name);
|
float getFloatValue(rapidxml::xml_node<> * node,const char* name);
|
||||||
bool _successfulLoad;
|
bool _successfulLoad;
|
||||||
std::string _errMsg;
|
std::string _errMsg;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|||||||
4
Demo.h
4
Demo.h
@@ -35,6 +35,7 @@ class Demo { // : public GApp {
|
|||||||
RenderDevice* renderDevice;
|
RenderDevice* renderDevice;
|
||||||
UserInput* userInput;
|
UserInput* userInput;
|
||||||
PropertyWindow* _propWindow;
|
PropertyWindow* _propWindow;
|
||||||
|
void generateShadowMap(const CoordinateFrame& lightViewMatrix) const;
|
||||||
private:
|
private:
|
||||||
void initGUI();
|
void initGUI();
|
||||||
HWND _hWndMain;
|
HWND _hWndMain;
|
||||||
@@ -47,7 +48,8 @@ class Demo { // : public GApp {
|
|||||||
HWND _hwndToolbox;
|
HWND _hwndToolbox;
|
||||||
HWND _buttonTest;
|
HWND _buttonTest;
|
||||||
HWND _hwndRenderer;
|
HWND _hwndRenderer;
|
||||||
|
G3D::TextureRef shadowMap;
|
||||||
|
double lightProjX, lightProjY, lightProjNear, lightProjFar;
|
||||||
protected:
|
protected:
|
||||||
Stopwatch m_graphicsWatch;
|
Stopwatch m_graphicsWatch;
|
||||||
Stopwatch m_logicWatch;
|
Stopwatch m_logicWatch;
|
||||||
|
|||||||
8
Enum.h
8
Enum.h
@@ -1,3 +1,5 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
namespace Enum
|
namespace Enum
|
||||||
{
|
{
|
||||||
namespace SurfaceType
|
namespace SurfaceType
|
||||||
@@ -6,4 +8,10 @@ namespace Enum
|
|||||||
Smooth, Bumps, Welds, Glue
|
Smooth, Bumps, Welds, Glue
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
namespace Shape
|
||||||
|
{
|
||||||
|
enum Value {
|
||||||
|
Block, Sphere, Cylinder
|
||||||
|
};
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -8,9 +8,10 @@ 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::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;
|
||||||
G3D::TextureRef Globals::surface;
|
G3D::TextureRef Globals::surface;
|
||||||
POINT Globals::mousepoint;
|
POINT Globals::mousepoint;
|
||||||
Globals::Globals(void){}
|
Globals::Globals(void){}
|
||||||
|
|||||||
@@ -20,4 +20,6 @@ public:
|
|||||||
static const std::string PlaceholderName;
|
static const std::string PlaceholderName;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
extern std::vector<Instance*> postRenderStack;
|
||||||
extern std::vector<Instance*> g_selectedInstances;
|
extern std::vector<Instance*> g_selectedInstances;
|
||||||
|
extern bool running;
|
||||||
26
GroupInstance.cpp
Normal file
26
GroupInstance.cpp
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
#include "GroupInstance.h"
|
||||||
|
|
||||||
|
GroupInstance::GroupInstance(void)
|
||||||
|
{
|
||||||
|
PVInstance::PVInstance();
|
||||||
|
className = "GroupInstance";
|
||||||
|
}
|
||||||
|
|
||||||
|
GroupInstance::GroupInstance(const GroupInstance &oinst)
|
||||||
|
{
|
||||||
|
PVInstance::PVInstance(oinst);
|
||||||
|
}
|
||||||
|
|
||||||
|
GroupInstance::~GroupInstance(void)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
std::vector<PROPGRIDITEM> GroupInstance::getProperties()
|
||||||
|
{
|
||||||
|
std::vector<PROPGRIDITEM> properties = PVInstance::getProperties();
|
||||||
|
return properties;
|
||||||
|
}
|
||||||
|
void GroupInstance::PropUpdate(LPPROPGRIDITEM &pItem)
|
||||||
|
{
|
||||||
|
PVInstance::PropUpdate(pItem);
|
||||||
|
}
|
||||||
13
GroupInstance.h
Normal file
13
GroupInstance.h
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
#pragma once
|
||||||
|
#include "PVInstance.h"
|
||||||
|
|
||||||
|
class GroupInstance :
|
||||||
|
public PVInstance
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
GroupInstance(void);
|
||||||
|
~GroupInstance(void);
|
||||||
|
GroupInstance(const GroupInstance &oinst);
|
||||||
|
virtual std::vector<PROPGRIDITEM> getProperties();
|
||||||
|
virtual void PropUpdate(LPPROPGRIDITEM &pItem);
|
||||||
|
};
|
||||||
@@ -9,6 +9,7 @@ Instance::Instance(void)
|
|||||||
name = "Default Game Instance";
|
name = "Default Game Instance";
|
||||||
className = "BaseInstance";
|
className = "BaseInstance";
|
||||||
listicon = 0;
|
listicon = 0;
|
||||||
|
canDelete = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
Instance::Instance(const Instance &oinst)
|
Instance::Instance(const Instance &oinst)
|
||||||
@@ -16,6 +17,7 @@ Instance::Instance(const Instance &oinst)
|
|||||||
|
|
||||||
name = oinst.name;
|
name = oinst.name;
|
||||||
className = oinst.className;
|
className = oinst.className;
|
||||||
|
canDelete = oinst.canDelete;
|
||||||
//setParent(oinst.parent);
|
//setParent(oinst.parent);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -31,7 +33,6 @@ void Instance::render(RenderDevice* rd)
|
|||||||
{
|
{
|
||||||
children.at(i)->render(rd);
|
children.at(i)->render(rd);
|
||||||
}
|
}
|
||||||
|
|
||||||
glDisableClientState(GL_VERTEX_ARRAY);
|
glDisableClientState(GL_VERTEX_ARRAY);
|
||||||
glDisableClientState(GL_COLOR_ARRAY);
|
glDisableClientState(GL_COLOR_ARRAY);
|
||||||
glDisableClientState(GL_NORMAL_ARRAY);
|
glDisableClientState(GL_NORMAL_ARRAY);
|
||||||
|
|||||||
@@ -5,6 +5,7 @@
|
|||||||
class Instance
|
class Instance
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
bool canDelete;
|
||||||
Instance(void);
|
Instance(void);
|
||||||
Instance(const Instance&);
|
Instance(const Instance&);
|
||||||
virtual ~Instance(void);
|
virtual ~Instance(void);
|
||||||
@@ -12,7 +13,7 @@ public:
|
|||||||
virtual void render(RenderDevice*);
|
virtual void render(RenderDevice*);
|
||||||
std::vector<Instance*> children; // All children.
|
std::vector<Instance*> children; // All children.
|
||||||
std::string getClassName();
|
std::string getClassName();
|
||||||
virtual Instance* findFirstChild(std::string);
|
Instance* findFirstChild(std::string);
|
||||||
std::vector<Instance* > getChildren();
|
std::vector<Instance* > getChildren();
|
||||||
std::vector<Instance* > getAllChildren();
|
std::vector<Instance* > getAllChildren();
|
||||||
void setParent(Instance*);
|
void setParent(Instance*);
|
||||||
|
|||||||
73
LevelInstance.cpp
Normal file
73
LevelInstance.cpp
Normal file
@@ -0,0 +1,73 @@
|
|||||||
|
#include "LevelInstance.h"
|
||||||
|
|
||||||
|
LevelInstance::LevelInstance(void)
|
||||||
|
{
|
||||||
|
Instance::Instance();
|
||||||
|
name = "Level";
|
||||||
|
winMessage = "You Won!";
|
||||||
|
loseMessage = "You Lost. Try Again";
|
||||||
|
timer = 60.0F;
|
||||||
|
score = 0;
|
||||||
|
canDelete = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
LevelInstance::~LevelInstance(void)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
char timerTxt[12];
|
||||||
|
char scoreTxt[12];
|
||||||
|
std::vector<PROPGRIDITEM> LevelInstance::getProperties()
|
||||||
|
{
|
||||||
|
std::vector<PROPGRIDITEM> properties = Instance::getProperties();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
properties.push_back(createPGI("Messages",
|
||||||
|
"WinMessage",
|
||||||
|
"The message that shows when the player wins.",
|
||||||
|
(LPARAM)winMessage.c_str(),
|
||||||
|
PIT_EDIT));
|
||||||
|
properties.push_back(createPGI("Messages",
|
||||||
|
"LoseMessage",
|
||||||
|
"The message that shows when the player loses.",
|
||||||
|
(LPARAM)loseMessage.c_str(),
|
||||||
|
PIT_EDIT));
|
||||||
|
|
||||||
|
|
||||||
|
sprintf(timerTxt, "%g", timer);
|
||||||
|
sprintf(scoreTxt, "%d", score);
|
||||||
|
properties.push_back(createPGI("Gameplay",
|
||||||
|
"InitialTimerValue",
|
||||||
|
"The ammount of time in seconds the player has to complete this level.\r\n\r\nPut 0 if time is limitless.",
|
||||||
|
(LPARAM)timerTxt,
|
||||||
|
PIT_EDIT));
|
||||||
|
properties.push_back(createPGI("Gameplay",
|
||||||
|
"InitialScoreValue",
|
||||||
|
"The ammount of points the player starts with.",
|
||||||
|
(LPARAM)scoreTxt,
|
||||||
|
PIT_EDIT));
|
||||||
|
return properties;
|
||||||
|
}
|
||||||
|
void LevelInstance::PropUpdate(LPPROPGRIDITEM &pItem)
|
||||||
|
{
|
||||||
|
if(strcmp(pItem->lpszPropName, "InitialTimerValue") == 0)
|
||||||
|
{
|
||||||
|
timer = atoi((LPSTR)pItem->lpCurValue);
|
||||||
|
}
|
||||||
|
if(strcmp(pItem->lpszPropName, "InitialScoreValue") == 0)
|
||||||
|
{
|
||||||
|
score = atof((LPSTR)pItem->lpCurValue);
|
||||||
|
}
|
||||||
|
if(strcmp(pItem->lpszPropName, "LoseMessage") == 0)
|
||||||
|
{
|
||||||
|
loseMessage = (LPSTR)pItem->lpCurValue;
|
||||||
|
}
|
||||||
|
if(strcmp(pItem->lpszPropName, "WinMessage") == 0)
|
||||||
|
{
|
||||||
|
winMessage = (LPSTR)pItem->lpCurValue;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
Instance::PropUpdate(pItem);
|
||||||
|
}
|
||||||
16
LevelInstance.h
Normal file
16
LevelInstance.h
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
#pragma once
|
||||||
|
#include "instance.h"
|
||||||
|
|
||||||
|
class LevelInstance :
|
||||||
|
public Instance
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
LevelInstance(void);
|
||||||
|
~LevelInstance(void);
|
||||||
|
float timer;
|
||||||
|
int score;
|
||||||
|
virtual std::vector<PROPGRIDITEM> getProperties();
|
||||||
|
std::string winMessage;
|
||||||
|
std::string loseMessage;
|
||||||
|
virtual void PropUpdate(LPPROPGRIDITEM &pItem);
|
||||||
|
};
|
||||||
41
PVInstance.cpp
Normal file
41
PVInstance.cpp
Normal file
@@ -0,0 +1,41 @@
|
|||||||
|
#include "PVInstance.h"
|
||||||
|
|
||||||
|
PVInstance::PVInstance(void)
|
||||||
|
{
|
||||||
|
Instance::Instance();
|
||||||
|
nameShown = false;
|
||||||
|
className = "PVInstance";
|
||||||
|
}
|
||||||
|
|
||||||
|
PVInstance::PVInstance(const PVInstance &oinst)
|
||||||
|
{
|
||||||
|
Instance::Instance(oinst);
|
||||||
|
}
|
||||||
|
|
||||||
|
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",
|
||||||
|
nameShown,
|
||||||
|
PIT_CHECK));
|
||||||
|
return properties;
|
||||||
|
}
|
||||||
|
void PVInstance::PropUpdate(LPPROPGRIDITEM &pItem)
|
||||||
|
{
|
||||||
|
if(strcmp(pItem->lpszPropName, "NameShown") == 0)
|
||||||
|
{
|
||||||
|
nameShown = (bool)pItem->lpCurValue;
|
||||||
|
}
|
||||||
|
else Instance::PropUpdate(pItem);
|
||||||
|
}
|
||||||
15
PVInstance.h
Normal file
15
PVInstance.h
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
#pragma once
|
||||||
|
#include "instance.h"
|
||||||
|
|
||||||
|
class PVInstance :
|
||||||
|
public Instance
|
||||||
|
{
|
||||||
|
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;
|
||||||
|
};
|
||||||
576
PartInstance.cpp
Normal file
576
PartInstance.cpp
Normal file
@@ -0,0 +1,576 @@
|
|||||||
|
#include "PartInstance.h"
|
||||||
|
#include "Globals.h"
|
||||||
|
#include <sstream>
|
||||||
|
#include <iomanip>
|
||||||
|
|
||||||
|
|
||||||
|
PartInstance::PartInstance(void) : _bevelSize(0.07f), _parseVert(0), _debugTimer(0)
|
||||||
|
{
|
||||||
|
PVInstance::PVInstance();
|
||||||
|
name = "Unnamed PVItem";
|
||||||
|
className = "Part";
|
||||||
|
canCollide = true;
|
||||||
|
anchored = true;
|
||||||
|
size = Vector3(2,1,4);
|
||||||
|
setCFrame(CoordinateFrame(Vector3(0,0,0)));
|
||||||
|
color = Color3::gray();
|
||||||
|
velocity = Vector3(0,0,0);
|
||||||
|
rotVelocity = Vector3(0,0,0);
|
||||||
|
top = Enum::SurfaceType::Smooth;
|
||||||
|
front = Enum::SurfaceType::Smooth;
|
||||||
|
right = Enum::SurfaceType::Smooth;
|
||||||
|
back = Enum::SurfaceType::Smooth;
|
||||||
|
left = Enum::SurfaceType::Smooth;
|
||||||
|
bottom = Enum::SurfaceType::Smooth;
|
||||||
|
shape = Enum::Shape::Block;
|
||||||
|
}
|
||||||
|
|
||||||
|
void PartInstance::postRender(RenderDevice *rd)
|
||||||
|
{
|
||||||
|
if(!nameShown)
|
||||||
|
return;
|
||||||
|
G3D::GFontRef fnt = NULL;
|
||||||
|
Instance* dm = parent;
|
||||||
|
while(dm != NULL)
|
||||||
|
{
|
||||||
|
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 < 100 && distance > -100)
|
||||||
|
{
|
||||||
|
if(distance < 0)
|
||||||
|
distance = distance*-1;
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
PartInstance::PartInstance(const PartInstance &oinst) : _bevelSize(0.07f), _parseVert(0), _debugTimer(0)
|
||||||
|
{
|
||||||
|
PVInstance::PVInstance(oinst);
|
||||||
|
//name = oinst.name;
|
||||||
|
//className = "Part";
|
||||||
|
name = oinst.name;
|
||||||
|
canCollide = oinst.canCollide;
|
||||||
|
setParent(oinst.parent);
|
||||||
|
anchored = oinst.anchored;
|
||||||
|
size = oinst.size;
|
||||||
|
setCFrame(oinst.cFrame);
|
||||||
|
color = oinst.color;
|
||||||
|
velocity = oinst.velocity;
|
||||||
|
rotVelocity = oinst.rotVelocity;
|
||||||
|
top = oinst.top;
|
||||||
|
front = oinst.front;
|
||||||
|
right = oinst.right;
|
||||||
|
back = oinst.back;
|
||||||
|
left = oinst.left;
|
||||||
|
bottom = oinst.bottom;
|
||||||
|
shape = oinst.shape;
|
||||||
|
changed = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
void PartInstance::setSize(Vector3 newSize)
|
||||||
|
{
|
||||||
|
int minsize = 1;
|
||||||
|
int maxsize = 512;
|
||||||
|
changed = true;
|
||||||
|
int sizex = (int)newSize.x;
|
||||||
|
if(sizex <= 0)
|
||||||
|
sizex = 1;
|
||||||
|
if(sizex > 512)
|
||||||
|
sizex = 512;
|
||||||
|
|
||||||
|
int sizey = (int)newSize.y;
|
||||||
|
if(sizey <= 0)
|
||||||
|
sizey = 1;
|
||||||
|
if(sizey > 512)
|
||||||
|
sizey = 512;
|
||||||
|
|
||||||
|
int sizez = (int)newSize.z;
|
||||||
|
if(sizez <= 0)
|
||||||
|
sizez = 1;
|
||||||
|
if(sizez > 512)
|
||||||
|
sizez = 512;
|
||||||
|
|
||||||
|
if(shape != Enum::Shape::Block)
|
||||||
|
{
|
||||||
|
int max = sizex;
|
||||||
|
if(sizey > max)
|
||||||
|
max = sizey;
|
||||||
|
if(sizez > max)
|
||||||
|
max = sizez;
|
||||||
|
sizex = sizey = sizez = max;
|
||||||
|
}
|
||||||
|
|
||||||
|
size = Vector3(sizex, sizey, sizez);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
Vector3 PartInstance::getSize()
|
||||||
|
{
|
||||||
|
return size;
|
||||||
|
}
|
||||||
|
Vector3 PartInstance::getPosition()
|
||||||
|
{
|
||||||
|
return position;
|
||||||
|
}
|
||||||
|
void PartInstance::setPosition(Vector3 pos)
|
||||||
|
{
|
||||||
|
position = pos;
|
||||||
|
cFrame = CoordinateFrame(pos);
|
||||||
|
changed = true;
|
||||||
|
}
|
||||||
|
CoordinateFrame PartInstance::getCFrame()
|
||||||
|
{
|
||||||
|
return cFrame;
|
||||||
|
}
|
||||||
|
void PartInstance::setCFrame(CoordinateFrame coordinateFrame)
|
||||||
|
{
|
||||||
|
cFrame = coordinateFrame;
|
||||||
|
position = coordinateFrame.translation;
|
||||||
|
changed = true;
|
||||||
|
}
|
||||||
|
// Can probably be deleted
|
||||||
|
CoordinateFrame PartInstance::getCFrameRenderBased()
|
||||||
|
{
|
||||||
|
return cFrame;//CoordinateFrame(getCFrame().rotation,Vector3(getCFrame().translation.x, getCFrame().translation.y, getCFrame().translation.z));
|
||||||
|
}
|
||||||
|
#ifdef NEW_BOX_RENDER
|
||||||
|
Box PartInstance::getBox()
|
||||||
|
{
|
||||||
|
Box box = Box(Vector3(size.x/2, size.y/2, size.z/2) ,Vector3(-size.x/2,-size.y/2,-size.z/2));
|
||||||
|
CoordinateFrame c = getCFrameRenderBased();
|
||||||
|
itemBox = c.toWorldSpace(box);
|
||||||
|
return itemBox;
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
Box PartInstance::getBox()
|
||||||
|
{
|
||||||
|
if(changed)
|
||||||
|
{
|
||||||
|
Box box = Box(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));
|
||||||
|
CoordinateFrame c = getCFrameRenderBased();
|
||||||
|
itemBox = c.toWorldSpace(box);
|
||||||
|
Vector3 v0,v1,v2,v3;
|
||||||
|
for (int f = 0; f < 6; f++) {
|
||||||
|
itemBox.getFaceCorners(f, v0,v1,v2,v3);
|
||||||
|
_vertices[f*16] = v0.x;
|
||||||
|
_vertices[(f*16)+1] = v0.y;
|
||||||
|
_vertices[(f*16)+2] = v0.z;
|
||||||
|
_vertices[(f*16)+3] = v1.x;
|
||||||
|
_vertices[(f*16)+4] = v1.y;
|
||||||
|
_vertices[(f*16)+5] = v1.z;
|
||||||
|
_vertices[(f*16)+6] = v2.x;
|
||||||
|
_vertices[(f*16)+7] = v2.y;
|
||||||
|
_vertices[(f*16)+8] = v2.z;
|
||||||
|
_vertices[(f*16)+9] = v3.x;
|
||||||
|
_vertices[(f*16)+10] = v3.y;
|
||||||
|
_vertices[(f*16)+11] = v3.z;
|
||||||
|
_vertices[(f*16)+12] = color.r;
|
||||||
|
_vertices[(f*16)+13] = color.g;
|
||||||
|
_vertices[(f*16)+14] = color.b;
|
||||||
|
_vertices[(f*16)+15] = 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return itemBox;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
bool PartInstance::collides(Box box)
|
||||||
|
{
|
||||||
|
return CollisionDetection::fixedSolidBoxIntersectsFixedSolidBox(getBox(), box);
|
||||||
|
}
|
||||||
|
|
||||||
|
void PartInstance::addVertex(Vector3 vertexPos,Color3 color)
|
||||||
|
{
|
||||||
|
_vertices.push_back(vertexPos.x);
|
||||||
|
_vertices.push_back(vertexPos.y);
|
||||||
|
_vertices.push_back(vertexPos.z);
|
||||||
|
_vertices.push_back(color.r);
|
||||||
|
_vertices.push_back(color.g);
|
||||||
|
_vertices.push_back(color.b);
|
||||||
|
}
|
||||||
|
void PartInstance::addNormals(Vector3 normal)
|
||||||
|
{
|
||||||
|
for (unsigned int i=0;i<3;i+=1) {
|
||||||
|
_normals.push_back(normal.x);
|
||||||
|
_normals.push_back(normal.y);
|
||||||
|
_normals.push_back(normal.z);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
void PartInstance::addTriangle(Vector3 v1,Vector3 v2,Vector3 v3)
|
||||||
|
{
|
||||||
|
addVertex(v1,color);
|
||||||
|
addVertex(v2,color);
|
||||||
|
addVertex(v3,color);
|
||||||
|
addNormals(cross(v2-v1,v3-v1).direction());
|
||||||
|
}
|
||||||
|
void PartInstance::debugPrintVertexIDs(RenderDevice* rd,GFontRef font,Matrix3 rot)
|
||||||
|
{
|
||||||
|
_debugUniqueVertices.clear();
|
||||||
|
glDisable(GL_DEPTH_TEST);
|
||||||
|
|
||||||
|
for (unsigned int i=0;i<_vertices.size();i+=6)
|
||||||
|
{
|
||||||
|
std::stringstream stream;
|
||||||
|
stream << std::fixed << std::setprecision(1) << i;
|
||||||
|
Vector3 testVector = Vector3(_vertices[i],_vertices[i+1],_vertices[i+2]);
|
||||||
|
if (isUniqueVertex(testVector))
|
||||||
|
{
|
||||||
|
|
||||||
|
font->draw3D(rd, stream.str(), CoordinateFrame(testVector) * -rot, 0.05, Color3::fromARGB(0xFF4F0000), Color4::clear());
|
||||||
|
_debugUniqueVertices.push_back(testVector);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
glEnable(GL_DEPTH_TEST);
|
||||||
|
}
|
||||||
|
void PartInstance::makeFace(int vertex1,int vertex2, int vertex3)
|
||||||
|
{
|
||||||
|
addTriangle(Vector3(_vertices[vertex1],_vertices[vertex1+1],_vertices[vertex1+2]),
|
||||||
|
Vector3(_vertices[vertex2],_vertices[vertex2+1],_vertices[vertex2+2]),
|
||||||
|
Vector3(_vertices[vertex3],_vertices[vertex3+1],_vertices[vertex3+2]));
|
||||||
|
}
|
||||||
|
bool PartInstance::isUniqueVertex(Vector3 pos)
|
||||||
|
{
|
||||||
|
for (unsigned int i=0;i<_debugUniqueVertices.size();i+=1)
|
||||||
|
{
|
||||||
|
if (pos==_debugUniqueVertices[i])
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifdef NEW_BOX_RENDER
|
||||||
|
void PartInstance::render(RenderDevice* rd) {
|
||||||
|
if(nameShown)
|
||||||
|
postRenderStack.push_back(this);
|
||||||
|
if (changed)
|
||||||
|
{
|
||||||
|
getBox();
|
||||||
|
_vertices.clear();
|
||||||
|
Vector3 renderSize = size/2;
|
||||||
|
// Front
|
||||||
|
addTriangle(Vector3(renderSize.x-_bevelSize,renderSize.y-_bevelSize,renderSize.z),
|
||||||
|
Vector3(-renderSize.x+_bevelSize,-renderSize.y+_bevelSize,renderSize.z),
|
||||||
|
Vector3(renderSize.x-_bevelSize,-renderSize.y+_bevelSize,renderSize.z)
|
||||||
|
);
|
||||||
|
|
||||||
|
addTriangle(Vector3(-renderSize.x+_bevelSize,renderSize.y-_bevelSize,renderSize.z),
|
||||||
|
Vector3(-renderSize.x+_bevelSize,-renderSize.y+_bevelSize,renderSize.z),
|
||||||
|
Vector3(renderSize.x-_bevelSize,renderSize.y-_bevelSize,renderSize.z)
|
||||||
|
);
|
||||||
|
|
||||||
|
// Top
|
||||||
|
addTriangle(Vector3(renderSize.x-_bevelSize,renderSize.y,renderSize.z-_bevelSize),
|
||||||
|
Vector3(renderSize.x-_bevelSize,renderSize.y,-renderSize.z+_bevelSize),
|
||||||
|
Vector3(-renderSize.x+_bevelSize,renderSize.y,renderSize.z-_bevelSize)
|
||||||
|
);
|
||||||
|
addTriangle(Vector3(-renderSize.x+_bevelSize,renderSize.y,renderSize.z-_bevelSize),
|
||||||
|
Vector3(renderSize.x-_bevelSize,renderSize.y,-renderSize.z+_bevelSize),
|
||||||
|
Vector3(-renderSize.x+_bevelSize,renderSize.y,-renderSize.z+_bevelSize)
|
||||||
|
);
|
||||||
|
|
||||||
|
// Back
|
||||||
|
addTriangle(Vector3(renderSize.x-_bevelSize,renderSize.y-_bevelSize,-renderSize.z),
|
||||||
|
Vector3(renderSize.x-_bevelSize,-renderSize.y+_bevelSize,-renderSize.z),
|
||||||
|
Vector3(-renderSize.x+_bevelSize,-renderSize.y+_bevelSize,-renderSize.z)
|
||||||
|
);
|
||||||
|
addTriangle(Vector3(renderSize.x-_bevelSize,renderSize.y-_bevelSize,-renderSize.z),
|
||||||
|
Vector3(-renderSize.x+_bevelSize,-renderSize.y+_bevelSize,-renderSize.z),
|
||||||
|
Vector3(-renderSize.x+_bevelSize,renderSize.y-_bevelSize,-renderSize.z)
|
||||||
|
);
|
||||||
|
|
||||||
|
// Bottom
|
||||||
|
addTriangle(Vector3(renderSize.x-_bevelSize,-renderSize.y,-renderSize.z+_bevelSize),
|
||||||
|
Vector3(renderSize.x-_bevelSize,-renderSize.y,renderSize.z-_bevelSize),
|
||||||
|
Vector3(-renderSize.x+_bevelSize,-renderSize.y,renderSize.z-_bevelSize)
|
||||||
|
);
|
||||||
|
addTriangle(Vector3(-renderSize.x+_bevelSize,-renderSize.y,renderSize.z-_bevelSize),
|
||||||
|
Vector3(-renderSize.x+_bevelSize,-renderSize.y,-renderSize.z+_bevelSize),
|
||||||
|
Vector3(renderSize.x-_bevelSize,-renderSize.y,-renderSize.z+_bevelSize)
|
||||||
|
);
|
||||||
|
// Left
|
||||||
|
addTriangle(Vector3(-renderSize.x,renderSize.y-_bevelSize,-renderSize.z+_bevelSize),
|
||||||
|
Vector3(-renderSize.x,-renderSize.y+_bevelSize,renderSize.z-_bevelSize),
|
||||||
|
Vector3(-renderSize.x,renderSize.y-_bevelSize,renderSize.z-_bevelSize)
|
||||||
|
);
|
||||||
|
addTriangle(Vector3(-renderSize.x,-renderSize.y+_bevelSize,renderSize.z-_bevelSize),
|
||||||
|
Vector3(-renderSize.x,renderSize.y-_bevelSize,-renderSize.z+_bevelSize),
|
||||||
|
Vector3(-renderSize.x,-renderSize.y+_bevelSize,-renderSize.z+_bevelSize)
|
||||||
|
);
|
||||||
|
// Right
|
||||||
|
addTriangle(Vector3(renderSize.x,renderSize.y-_bevelSize,renderSize.z-_bevelSize),
|
||||||
|
Vector3(renderSize.x,-renderSize.y+_bevelSize,renderSize.z-_bevelSize),
|
||||||
|
Vector3(renderSize.x,renderSize.y-_bevelSize,-renderSize.z+_bevelSize)
|
||||||
|
);
|
||||||
|
addTriangle(Vector3(renderSize.x,-renderSize.y+_bevelSize,-renderSize.z+_bevelSize),
|
||||||
|
Vector3(renderSize.x,renderSize.y-_bevelSize,-renderSize.z+_bevelSize),
|
||||||
|
Vector3(renderSize.x,-renderSize.y+_bevelSize,renderSize.z-_bevelSize)
|
||||||
|
);
|
||||||
|
|
||||||
|
// Bevel Top Front
|
||||||
|
makeFace(0,36,48);
|
||||||
|
makeFace(48,18,0);
|
||||||
|
// Bevel Left Front Corner
|
||||||
|
makeFace(18,156,162);
|
||||||
|
makeFace(24,18,162);
|
||||||
|
// Bevel Left Front Top Corner
|
||||||
|
makeFace(48,156,18);
|
||||||
|
// Bevel Left Front Bottom Corner
|
||||||
|
makeFace(120,6,150);
|
||||||
|
// Bevel Left Top
|
||||||
|
makeFace(48,66,156);
|
||||||
|
makeFace(144,156,66);
|
||||||
|
// Bevel Bottom
|
||||||
|
makeFace(6,120,114);
|
||||||
|
makeFace(114,12,6);
|
||||||
|
// Left Bottom
|
||||||
|
makeFace(120,150,174);
|
||||||
|
makeFace(174,132,120);
|
||||||
|
// Right Front Top Corner
|
||||||
|
makeFace(36,0,180);
|
||||||
|
// Right Front Corner
|
||||||
|
makeFace(180,0,12);
|
||||||
|
makeFace(186,180,12);
|
||||||
|
// Right Front Bottom Corner
|
||||||
|
makeFace(186,12,114);
|
||||||
|
// Right Bottom
|
||||||
|
makeFace(186,114,108);
|
||||||
|
makeFace(108,198,186);
|
||||||
|
// Right Top Corner
|
||||||
|
makeFace(180,192,36);
|
||||||
|
makeFace(192,42,36);
|
||||||
|
// Right Back Top Corner
|
||||||
|
makeFace(72,42,192);
|
||||||
|
// Right Back Bottom Corner
|
||||||
|
makeFace(78,198,108);
|
||||||
|
// Right Back Corner
|
||||||
|
makeFace(72,192,198);
|
||||||
|
makeFace(198,78,72);
|
||||||
|
// Back Bottom Corner
|
||||||
|
makeFace(78,108,132);
|
||||||
|
makeFace(132,84,78);
|
||||||
|
// Back Top
|
||||||
|
makeFace(42,72,102);
|
||||||
|
makeFace(102,66,42);
|
||||||
|
// Back Left Top Corner
|
||||||
|
makeFace(144,66,102);
|
||||||
|
// Back Left Corner
|
||||||
|
makeFace(144,102,84);
|
||||||
|
makeFace(84,174,144);
|
||||||
|
// Back Left Bottom Corner
|
||||||
|
makeFace(174,84,132);
|
||||||
|
|
||||||
|
for (unsigned short i=0;i<_vertices.size()/6;i++) {
|
||||||
|
_indices.push_back(i);
|
||||||
|
}
|
||||||
|
changed=false;
|
||||||
|
}
|
||||||
|
//rd->setObjectToWorldMatrix(cFrame);
|
||||||
|
CoordinateFrame forDraw = rd->getObjectToWorldMatrix();
|
||||||
|
rd->setObjectToWorldMatrix(cFrame);
|
||||||
|
glVertexPointer(3, GL_FLOAT,6 * sizeof(GLfloat), &_vertices[0]);
|
||||||
|
glColorPointer(3, GL_FLOAT,6 * sizeof(GLfloat), &_vertices[3]);
|
||||||
|
glNormalPointer(GL_FLOAT,3 * sizeof(GLfloat), &_normals[0]);
|
||||||
|
glPushMatrix();
|
||||||
|
//glTranslatef(2,7,0);
|
||||||
|
glDrawElements(GL_TRIANGLES, _indices.size(), GL_UNSIGNED_SHORT, &_indices[0]);
|
||||||
|
glPopMatrix();
|
||||||
|
rd->setObjectToWorldMatrix(forDraw);
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
void PartInstance::render(RenderDevice* rd)
|
||||||
|
{
|
||||||
|
|
||||||
|
if(changed)
|
||||||
|
Box box = getBox();
|
||||||
|
|
||||||
|
glColor(color);
|
||||||
|
/*glEnable( GL_TEXTURE_2D );
|
||||||
|
glEnable(GL_BLEND);// you enable blending function
|
||||||
|
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||||
|
glBindTexture( GL_TEXTURE_2D, Globals::surfaceId);
|
||||||
|
glBegin(GL_QUADS);*/
|
||||||
|
for(int i = 0; i < 96; i+=16)
|
||||||
|
{
|
||||||
|
double add = 0.8;
|
||||||
|
Enum::SurfaceType::Value face;
|
||||||
|
if(i == 0)//Back
|
||||||
|
face = back;
|
||||||
|
else if(i == 16)//Right
|
||||||
|
face = right;
|
||||||
|
else if(i == 32)//Front
|
||||||
|
face = front;
|
||||||
|
else if(i == 48)//Top
|
||||||
|
face = top;
|
||||||
|
else if(i == 64)//Left
|
||||||
|
face = left;
|
||||||
|
else if(i == 80)//Bottom
|
||||||
|
face = bottom;
|
||||||
|
|
||||||
|
/*if(face == Snaps)
|
||||||
|
add = 0.0;
|
||||||
|
else if(face == Inlets)
|
||||||
|
add = 0.2;*/
|
||||||
|
|
||||||
|
Vector3 v0 = Vector3(_vertices[i], _vertices[i+1], _vertices[i+2]), v1 = Vector3(_vertices[i+3], _vertices[i+4], _vertices[i+5]), v3 = Vector3(_vertices[i+9], _vertices[i+10], _vertices[i+11]);
|
||||||
|
/*glNormal3fv((v1 - v0).cross(v3 - v0).direction());
|
||||||
|
glTexCoord2f(0.0F,0.0F);
|
||||||
|
glVertex3fv(v0);
|
||||||
|
glTexCoord2f(1.0F,0.0F);
|
||||||
|
glVertex3fv(v1);
|
||||||
|
glTexCoord2f(1.0F,0.25F);
|
||||||
|
glVertex3f(_vertices[i+6], _vertices[i+7], _vertices[i+8]);
|
||||||
|
glTexCoord2f(0.0F,0.25F);
|
||||||
|
glVertex3fv(v3);*/
|
||||||
|
|
||||||
|
glEnable( GL_TEXTURE_2D );
|
||||||
|
glEnable(GL_BLEND);// you enable blending function
|
||||||
|
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||||
|
glBindTexture( GL_TEXTURE_2D, Globals::surfaceId);
|
||||||
|
glBegin( GL_QUADS );
|
||||||
|
glNormal3fv((v1 - v0).cross(v3 - v0).direction());
|
||||||
|
glTexCoord2d(0.0,0.0+add);
|
||||||
|
glVertex3fv(v0);
|
||||||
|
glTexCoord2d( 1.0,0.0+add);
|
||||||
|
glVertex3fv(v1);
|
||||||
|
glTexCoord2d(1.0,0.2+add);
|
||||||
|
glVertex3f(_vertices[i+6], _vertices[i+7], _vertices[i+8]);
|
||||||
|
glTexCoord2d( 0.0,0.2+add);
|
||||||
|
glVertex3fv(v3);
|
||||||
|
glEnd();
|
||||||
|
glDisable( GL_TEXTURE_2D );
|
||||||
|
}
|
||||||
|
/*glEnd();
|
||||||
|
glDisable(GL_TEXTURE_2D);*/
|
||||||
|
glColor(Color3::white());
|
||||||
|
if(!children.empty())
|
||||||
|
{
|
||||||
|
for(size_t i = 0; i < children.size(); i++)
|
||||||
|
{
|
||||||
|
children.at(i)->render(rd);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
PartInstance::~PartInstance(void)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
char pto[512];
|
||||||
|
char pto2[512];
|
||||||
|
#include <sstream>
|
||||||
|
|
||||||
|
void PartInstance::PropUpdate(LPPROPGRIDITEM &item)
|
||||||
|
{
|
||||||
|
if(strcmp(item->lpszPropName, "Color3") == 0)
|
||||||
|
{
|
||||||
|
color = Color3(GetRValue(item->lpCurValue)/255.0F,GetGValue(item->lpCurValue)/255.0F,GetBValue(item->lpCurValue)/255.0F);
|
||||||
|
changed=true;
|
||||||
|
}
|
||||||
|
else if(strcmp(item->lpszPropName, "Offset") == 0)
|
||||||
|
{
|
||||||
|
std::string str = (LPTSTR)item->lpCurValue;
|
||||||
|
std::vector<float> vect;
|
||||||
|
std::stringstream ss(str);
|
||||||
|
float i;
|
||||||
|
|
||||||
|
while (ss >> i)
|
||||||
|
{
|
||||||
|
vect.push_back(i);
|
||||||
|
|
||||||
|
if (ss.peek() == ',')
|
||||||
|
ss.ignore();
|
||||||
|
}
|
||||||
|
|
||||||
|
if(vect.size() != 3)
|
||||||
|
{
|
||||||
|
sprintf(pto, "%g, %g, %g", cFrame.translation.x, cFrame.translation.y, cFrame.translation.z, "what");
|
||||||
|
LPCSTR str = LPCSTR(pto);
|
||||||
|
item->lpCurValue = (LPARAM)str;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Vector3 pos(vect.at(0),vect.at(1),vect.at(2));
|
||||||
|
setPosition(pos);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
else if(strcmp(item->lpszPropName, "Size") == 0)
|
||||||
|
{
|
||||||
|
std::string str = (LPTSTR)item->lpCurValue;
|
||||||
|
std::vector<float> vect;
|
||||||
|
std::stringstream ss(str);
|
||||||
|
float i;
|
||||||
|
|
||||||
|
while (ss >> i)
|
||||||
|
{
|
||||||
|
vect.push_back(i);
|
||||||
|
|
||||||
|
if (ss.peek() == ',')
|
||||||
|
ss.ignore();
|
||||||
|
}
|
||||||
|
|
||||||
|
if(vect.size() != 3)
|
||||||
|
{
|
||||||
|
sprintf(pto, "%g, %g, %g", cFrame.translation.x, cFrame.translation.y, cFrame.translation.z, "what");
|
||||||
|
LPCSTR str = LPCSTR(pto);
|
||||||
|
item->lpCurValue = (LPARAM)str;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Vector3 size(vect.at(0),vect.at(1),vect.at(2));
|
||||||
|
setSize(size);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
else PVInstance::PropUpdate(item);
|
||||||
|
}
|
||||||
|
|
||||||
|
std::vector<PROPGRIDITEM> PartInstance::getProperties()
|
||||||
|
{
|
||||||
|
std::vector<PROPGRIDITEM> properties = PVInstance::getProperties();
|
||||||
|
|
||||||
|
|
||||||
|
properties.push_back(createPGI(
|
||||||
|
"Properties",
|
||||||
|
"Color3",
|
||||||
|
"The color of the selected part",
|
||||||
|
RGB((color.r*255),(color.g*255),(color.b*255)),
|
||||||
|
PIT_COLOR
|
||||||
|
));
|
||||||
|
|
||||||
|
sprintf(pto, "%g, %g, %g", cFrame.translation.x, cFrame.translation.y, cFrame.translation.z);
|
||||||
|
properties.push_back(createPGI(
|
||||||
|
"Item",
|
||||||
|
"Offset",
|
||||||
|
"The position of the object in the workspace",
|
||||||
|
(LPARAM)pto,
|
||||||
|
PIT_EDIT
|
||||||
|
));
|
||||||
|
sprintf(pto2, "%g, %g, %g", size.x, size.y, size.z);
|
||||||
|
properties.push_back(createPGI(
|
||||||
|
"Item",
|
||||||
|
"Size",
|
||||||
|
"The position of the object in the workspace",
|
||||||
|
(LPARAM)pto2,
|
||||||
|
PIT_EDIT
|
||||||
|
));
|
||||||
|
return properties;
|
||||||
|
}
|
||||||
|
|
||||||
63
PartInstance.h
Normal file
63
PartInstance.h
Normal file
@@ -0,0 +1,63 @@
|
|||||||
|
#pragma once
|
||||||
|
#include "PVInstance.h"
|
||||||
|
#include "Enum.h"
|
||||||
|
|
||||||
|
#define NEW_BOX_RENDER
|
||||||
|
|
||||||
|
class PartInstance : public PVInstance
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
PartInstance(void);
|
||||||
|
PartInstance(const PartInstance &oinst);
|
||||||
|
Instance* clone() const { return new PartInstance(*this); }
|
||||||
|
virtual void PartInstance::postRender(RenderDevice* rd);
|
||||||
|
~PartInstance(void);
|
||||||
|
virtual void render(RenderDevice*);
|
||||||
|
Vector3 velocity;
|
||||||
|
Enum::SurfaceType::Value top;
|
||||||
|
Enum::SurfaceType::Value front;
|
||||||
|
Enum::SurfaceType::Value right;
|
||||||
|
Enum::SurfaceType::Value back;
|
||||||
|
Enum::SurfaceType::Value left;
|
||||||
|
Enum::SurfaceType::Value bottom;
|
||||||
|
Enum::Shape::Value shape;
|
||||||
|
CoordinateFrame cFrame;
|
||||||
|
Color3 color;
|
||||||
|
Vector3 getPosition();
|
||||||
|
void setPosition(Vector3);
|
||||||
|
CoordinateFrame getCFrame();
|
||||||
|
void setCFrame(CoordinateFrame);
|
||||||
|
Box getBox();
|
||||||
|
Box getScaledBox();
|
||||||
|
CoordinateFrame getCFrameRenderBased();
|
||||||
|
Vector3 getSize();
|
||||||
|
void setSize(Vector3);
|
||||||
|
bool canCollide;
|
||||||
|
bool anchored;
|
||||||
|
Vector3 rotVelocity;
|
||||||
|
bool collides(Box);
|
||||||
|
virtual std::vector<PROPGRIDITEM> getProperties();
|
||||||
|
virtual void PropUpdate(LPPROPGRIDITEM &pItem);
|
||||||
|
void addVertex(Vector3 vertexPos,Color3 color);
|
||||||
|
void addNormals(Vector3 normal);
|
||||||
|
void addTriangle(Vector3 vertexPos,Vector3 vertexPos2, Vector3 vertexPos3);
|
||||||
|
void debugPrintVertexIDs(RenderDevice* rd, GFontRef font, Matrix3 camRot);
|
||||||
|
void makeFace(int vertex1, int vertex2, int vertex3);
|
||||||
|
bool isUniqueVertex(Vector3 pos);
|
||||||
|
private:
|
||||||
|
Vector3 position;
|
||||||
|
Vector3 size;
|
||||||
|
float _bevelSize;
|
||||||
|
int _parseVert;
|
||||||
|
int _debugTimer;
|
||||||
|
std::vector<Vector3> _debugUniqueVertices;
|
||||||
|
#ifdef NEW_BOX_RENDER
|
||||||
|
std::vector<GLfloat> _vertices;
|
||||||
|
std::vector<GLfloat> _normals;
|
||||||
|
#else
|
||||||
|
GLfloat _vertices[96];
|
||||||
|
#endif
|
||||||
|
std::vector<GLushort> _indices;
|
||||||
|
bool changed;
|
||||||
|
Box itemBox;
|
||||||
|
};
|
||||||
@@ -4,6 +4,7 @@
|
|||||||
#include "resource.h"
|
#include "resource.h"
|
||||||
#include "PropertyWindow.h"
|
#include "PropertyWindow.h"
|
||||||
#include "Globals.h"
|
#include "Globals.h"
|
||||||
|
#include "strsafe.h"
|
||||||
/*typedef struct typPRGP {
|
/*typedef struct typPRGP {
|
||||||
Instance* instance; // Declare member types
|
Instance* instance; // Declare member types
|
||||||
Property ∝
|
Property ∝
|
||||||
@@ -11,11 +12,14 @@
|
|||||||
|
|
||||||
std::vector<PROPGRIDITEM> prop;
|
std::vector<PROPGRIDITEM> prop;
|
||||||
std::vector<Instance*> children;
|
std::vector<Instance*> children;
|
||||||
Instance* selectedInstance;
|
Instance * selectedInstance;
|
||||||
|
Instance * parent = NULL;
|
||||||
|
const int CX_BITMAP = 16;
|
||||||
|
const int CY_BITMAP = 16;
|
||||||
|
|
||||||
LRESULT CALLBACK PropProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
|
LRESULT CALLBACK PropProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
|
||||||
{
|
{
|
||||||
|
TCHAR achTemp[256];
|
||||||
PropertyWindow *propWind = (PropertyWindow *)GetWindowLongPtr(hwnd, GWL_USERDATA);
|
PropertyWindow *propWind = (PropertyWindow *)GetWindowLongPtr(hwnd, GWL_USERDATA);
|
||||||
if (propWind==NULL)
|
if (propWind==NULL)
|
||||||
{
|
{
|
||||||
@@ -28,6 +32,78 @@ LRESULT CALLBACK PropProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
|
|||||||
ShowWindow(hwnd, SW_HIDE);
|
ShowWindow(hwnd, SW_HIDE);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
case WM_DRAWITEM:
|
||||||
|
{
|
||||||
|
std::cout << "Drawing?" << "\r\n";
|
||||||
|
COLORREF clrBackground;
|
||||||
|
COLORREF clrForeground;
|
||||||
|
TEXTMETRIC tm;
|
||||||
|
int x;
|
||||||
|
int y;
|
||||||
|
HRESULT hr;
|
||||||
|
size_t cch;
|
||||||
|
|
||||||
|
LPDRAWITEMSTRUCT lpdis = (LPDRAWITEMSTRUCT) lParam;
|
||||||
|
|
||||||
|
if (lpdis->itemID == -1) // Empty item)
|
||||||
|
break;
|
||||||
|
|
||||||
|
// Get the food icon from the item data.
|
||||||
|
HBITMAP hbmIcon = LoadBitmap(GetModuleHandle(NULL), MAKEINTRESOURCE(IDB_BITMAP1));
|
||||||
|
HBITMAP hbmMask = LoadBitmap(GetModuleHandle(NULL), MAKEINTRESOURCE(IDB_BITMAP1));
|
||||||
|
// The colors depend on whether the item is selected.
|
||||||
|
clrForeground = SetTextColor(lpdis->hDC,
|
||||||
|
GetSysColor(lpdis->itemState & ODS_SELECTED ?
|
||||||
|
COLOR_HIGHLIGHTTEXT : COLOR_WINDOWTEXT));
|
||||||
|
|
||||||
|
clrBackground = SetBkColor(lpdis->hDC,
|
||||||
|
GetSysColor(lpdis->itemState & ODS_SELECTED ?
|
||||||
|
COLOR_HIGHLIGHT : COLOR_WINDOW));
|
||||||
|
|
||||||
|
// Calculate the vertical and horizontal position.
|
||||||
|
GetTextMetrics(lpdis->hDC, &tm);
|
||||||
|
y = (lpdis->rcItem.bottom + lpdis->rcItem.top - tm.tmHeight) / 2;
|
||||||
|
x = LOWORD(GetDialogBaseUnits()) / 4;
|
||||||
|
|
||||||
|
// Get and display the text for the list item.
|
||||||
|
SendMessage(lpdis->hwndItem, CB_GETLBTEXT, lpdis->itemID, (LPARAM) achTemp);
|
||||||
|
|
||||||
|
hr = StringCchLength(achTemp, 256, &cch);
|
||||||
|
if (FAILED(hr))
|
||||||
|
{
|
||||||
|
// TODO: Write error handler.
|
||||||
|
}
|
||||||
|
|
||||||
|
ExtTextOut(lpdis->hDC, CX_BITMAP + 2 * x, y,
|
||||||
|
ETO_CLIPPED | ETO_OPAQUE, &lpdis->rcItem,
|
||||||
|
achTemp, (UINT)cch, NULL);
|
||||||
|
|
||||||
|
// Restore the previous colors.
|
||||||
|
SetTextColor(lpdis->hDC, clrForeground);
|
||||||
|
SetBkColor(lpdis->hDC, clrBackground);
|
||||||
|
|
||||||
|
// Draw the food icon for the item.
|
||||||
|
HDC hdc = CreateCompatibleDC(lpdis->hDC);
|
||||||
|
if (hdc == NULL)
|
||||||
|
break;
|
||||||
|
|
||||||
|
SelectObject(hdc, hbmMask);
|
||||||
|
BitBlt(lpdis->hDC, x, lpdis->rcItem.top + 1,
|
||||||
|
CX_BITMAP, CY_BITMAP, hdc, 0, 0, SRCAND);
|
||||||
|
|
||||||
|
SelectObject(hdc, hbmIcon);
|
||||||
|
BitBlt(lpdis->hDC, x, lpdis->rcItem.top + 1,
|
||||||
|
CX_BITMAP, CY_BITMAP, hdc, 0, 0, SRCPAINT);
|
||||||
|
|
||||||
|
DeleteDC(hdc);
|
||||||
|
|
||||||
|
// If the item has the focus, draw the focus rectangle.
|
||||||
|
if (lpdis->itemState & ODS_FOCUS)
|
||||||
|
DrawFocusRect(lpdis->hDC, &lpdis->rcItem);
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
break;
|
||||||
case WM_MEASUREITEM:
|
case WM_MEASUREITEM:
|
||||||
{
|
{
|
||||||
LPMEASUREITEMSTRUCT lpmis = (LPMEASUREITEMSTRUCT) lParam;
|
LPMEASUREITEMSTRUCT lpmis = (LPMEASUREITEMSTRUCT) lParam;
|
||||||
@@ -52,12 +128,31 @@ LRESULT CALLBACK PropProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
|
|||||||
propWind->ClearProperties();
|
propWind->ClearProperties();
|
||||||
while(g_selectedInstances.size() != 0)
|
while(g_selectedInstances.size() != 0)
|
||||||
g_selectedInstances.erase(g_selectedInstances.begin());
|
g_selectedInstances.erase(g_selectedInstances.begin());
|
||||||
|
if(parent != NULL)
|
||||||
|
{
|
||||||
|
std::cout << ItemIndex << std::endl;
|
||||||
|
if(ItemIndex == 1)
|
||||||
|
{
|
||||||
|
g_selectedInstances.push_back(parent);
|
||||||
|
propWind->SetProperties(parent);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
g_selectedInstances.push_back(children.at(ItemIndex+2));
|
||||||
|
propWind->SetProperties(children.at(ItemIndex+2));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
g_selectedInstances.push_back(children.at(ItemIndex-1));
|
g_selectedInstances.push_back(children.at(ItemIndex-1));
|
||||||
propWind->SetProperties(children.at(ItemIndex-1));
|
propWind->SetProperties(children.at(ItemIndex-1));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case WM_NOTIFY:
|
case WM_NOTIFY:
|
||||||
{
|
{
|
||||||
switch(((LPNMHDR)lParam)->code)
|
switch(((LPNMHDR)lParam)->code)
|
||||||
@@ -69,6 +164,7 @@ LRESULT CALLBACK PropProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
|
|||||||
LPNMPROPGRID lpnmp = (LPNMPROPGRID)pnm;
|
LPNMPROPGRID lpnmp = (LPNMPROPGRID)pnm;
|
||||||
LPPROPGRIDITEM item = PropGrid_GetItemData(pnm->hwndFrom,lpnmp->iIndex);
|
LPPROPGRIDITEM item = PropGrid_GetItemData(pnm->hwndFrom,lpnmp->iIndex);
|
||||||
selectedInstance->PropUpdate(item);
|
selectedInstance->PropUpdate(item);
|
||||||
|
//propWind->SetProperties(selectedInstance);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@@ -85,8 +181,18 @@ LRESULT CALLBACK PropProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
|
|||||||
void PropertyWindow::refreshExplorer()
|
void PropertyWindow::refreshExplorer()
|
||||||
{
|
{
|
||||||
SendMessage(_explorerComboBox,CB_RESETCONTENT,0,0);
|
SendMessage(_explorerComboBox,CB_RESETCONTENT,0,0);
|
||||||
|
parent = NULL;
|
||||||
for (unsigned int i=0;i<g_selectedInstances.size();i++) {
|
for (unsigned int i=0;i<g_selectedInstances.size();i++) {
|
||||||
|
|
||||||
SendMessage(_explorerComboBox,CB_ADDSTRING, 0,(LPARAM)g_selectedInstances[i]->name.c_str());
|
SendMessage(_explorerComboBox,CB_ADDSTRING, 0,(LPARAM)g_selectedInstances[i]->name.c_str());
|
||||||
|
if(g_selectedInstances[i]->getParent() != NULL)
|
||||||
|
{
|
||||||
|
std::string title = ".. (";
|
||||||
|
title += g_selectedInstances[i]->getParent()->name;
|
||||||
|
title += ")";
|
||||||
|
SendMessage(_explorerComboBox,CB_ADDSTRING, 0,(LPARAM)title.c_str());
|
||||||
|
parent = g_selectedInstances[i]->getParent();
|
||||||
|
}
|
||||||
children = g_selectedInstances[i]->getChildren();
|
children = g_selectedInstances[i]->getChildren();
|
||||||
for(size_t z = 0; z < children.size(); z++)
|
for(size_t z = 0; z < children.size(); z++)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -21,6 +21,7 @@ TextButtonInstance::TextButtonInstance(void)
|
|||||||
visible = true;
|
visible = true;
|
||||||
className = "TextButton";
|
className = "TextButton";
|
||||||
disabled = false;
|
disabled = false;
|
||||||
|
selected = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool TextButtonInstance::mouseInButton(float mousex, float mousey, RenderDevice* rd)
|
bool TextButtonInstance::mouseInButton(float mousex, float mousey, RenderDevice* rd)
|
||||||
@@ -58,6 +59,10 @@ void TextButtonInstance::setAllColorsSame()
|
|||||||
textOutlineColorDn = textOutlineColor;
|
textOutlineColorDn = textOutlineColor;
|
||||||
boxColorDn = boxColor;
|
boxColorDn = boxColor;
|
||||||
boxOutlineColorDn = boxOutlineColor;
|
boxOutlineColorDn = boxOutlineColor;
|
||||||
|
textColorDis = textColor;
|
||||||
|
textOutlineColorDis = textOutlineColor;
|
||||||
|
boxColorDis = boxColor;
|
||||||
|
boxOutlineColorDis = boxOutlineColor;
|
||||||
}
|
}
|
||||||
|
|
||||||
TextButtonInstance::~TextButtonInstance(void)
|
TextButtonInstance::~TextButtonInstance(void)
|
||||||
@@ -68,9 +73,9 @@ void TextButtonInstance::drawObj(RenderDevice* rd, Vector2 mousePos, bool mouseD
|
|||||||
{
|
{
|
||||||
Vector3 point1;
|
Vector3 point1;
|
||||||
Vector3 point2;
|
Vector3 point2;
|
||||||
|
|
||||||
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
|
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
|
||||||
glDisableClientState(GL_COLOR_ARRAY);
|
glDisableClientState(GL_COLOR_ARRAY);
|
||||||
|
|
||||||
if(floatBottom)
|
if(floatBottom)
|
||||||
{
|
{
|
||||||
point1 = Vector3(boxBegin.x, rd->getHeight() + boxBegin.y,0);
|
point1 = Vector3(boxBegin.x, rd->getHeight() + boxBegin.y,0);
|
||||||
@@ -83,7 +88,12 @@ void TextButtonInstance::drawObj(RenderDevice* rd, Vector2 mousePos, bool mouseD
|
|||||||
point2 = Vector3(boxEnd.x, boxEnd.y,0);
|
point2 = Vector3(boxEnd.x, boxEnd.y,0);
|
||||||
}
|
}
|
||||||
Vector2 RelativeTo = Vector2(point1.x + fontLocationRelativeTo.x, point1.y + fontLocationRelativeTo.y);
|
Vector2 RelativeTo = Vector2(point1.x + fontLocationRelativeTo.x, point1.y + fontLocationRelativeTo.y);
|
||||||
if(mouseInArea(point1.x, point1.y, point2.x, point2.y, mousePos.x, mousePos.y) && mouseDown)
|
if(disabled)
|
||||||
|
{
|
||||||
|
Draw::box(Box(point1, point2), rd, boxColorDis, boxOutlineColorDis);
|
||||||
|
font->draw2D(rd, title, RelativeTo, textSize, textColorDis, textOutlineColorDis);
|
||||||
|
}
|
||||||
|
else if(mouseInArea(point1.x, point1.y, point2.x, point2.y, mousePos.x, mousePos.y) && mouseDown)
|
||||||
{
|
{
|
||||||
Draw::box(Box(point1, point2), rd, boxColorDn, boxOutlineColorDn);
|
Draw::box(Box(point1, point2), rd, boxColorDn, boxOutlineColorDn);
|
||||||
font->draw2D(rd, title, RelativeTo, textSize, textColorDn, textOutlineColorDn);
|
font->draw2D(rd, title, RelativeTo, textSize, textColorDn, textOutlineColorDn);
|
||||||
@@ -93,6 +103,11 @@ void TextButtonInstance::drawObj(RenderDevice* rd, Vector2 mousePos, bool mouseD
|
|||||||
Draw::box(Box(point1, point2), rd, boxColorOvr, boxOutlineColorOvr);
|
Draw::box(Box(point1, point2), rd, boxColorOvr, boxOutlineColorOvr);
|
||||||
font->draw2D(rd, title, RelativeTo, textSize, textColorOvr, textOutlineColorOvr);
|
font->draw2D(rd, title, RelativeTo, textSize, textColorOvr, textOutlineColorOvr);
|
||||||
}
|
}
|
||||||
|
else if(selected)
|
||||||
|
{
|
||||||
|
Draw::box(Box(point1, point2), rd, boxColorOvr, boxOutlineColorOvr);
|
||||||
|
font->draw2D(rd, title, RelativeTo, textSize, textColorOvr, textOutlineColorOvr);
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Draw::box(Box(point1, point2), rd, boxColor, boxOutlineColor);
|
Draw::box(Box(point1, point2), rd, boxColor, boxOutlineColor);
|
||||||
|
|||||||
@@ -21,6 +21,10 @@ public:
|
|||||||
Color4 textOutlineColorDn;
|
Color4 textOutlineColorDn;
|
||||||
Color4 boxColorDn;
|
Color4 boxColorDn;
|
||||||
Color4 boxOutlineColorDn;
|
Color4 boxOutlineColorDn;
|
||||||
|
Color4 textColorDis;
|
||||||
|
Color4 textOutlineColorDis;
|
||||||
|
Color4 boxColorDis;
|
||||||
|
Color4 boxOutlineColorDis;
|
||||||
bool centeredWithinBox;
|
bool centeredWithinBox;
|
||||||
std::string title;
|
std::string title;
|
||||||
G3D::GFontRef font;
|
G3D::GFontRef font;
|
||||||
|
|||||||
@@ -3,11 +3,10 @@
|
|||||||
|
|
||||||
WorkspaceInstance::WorkspaceInstance(void)
|
WorkspaceInstance::WorkspaceInstance(void)
|
||||||
{
|
{
|
||||||
Instance::Instance();
|
GroupInstance::GroupInstance();
|
||||||
name = "Instance";
|
name = "Workspace";
|
||||||
className = "Level";
|
className = "Workspace";
|
||||||
timer = 60.0F;
|
canDelete = false;
|
||||||
score = 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
WorkspaceInstance::~WorkspaceInstance(void)
|
WorkspaceInstance::~WorkspaceInstance(void)
|
||||||
|
|||||||
@@ -1,13 +1,10 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
#include "instance.h"
|
#include "GroupInstance.h"
|
||||||
|
|
||||||
class WorkspaceInstance :
|
class WorkspaceInstance :
|
||||||
public Instance
|
public GroupInstance
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
float timer;
|
|
||||||
int score;
|
|
||||||
WorkspaceInstance(void);
|
WorkspaceInstance(void);
|
||||||
~WorkspaceInstance(void);
|
~WorkspaceInstance(void);
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|||||||
BIN
content/images/ArrowCursor.png
Normal file
BIN
content/images/ArrowCursor.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 2.0 KiB |
BIN
content/images/GrabRotateCursor.png
Normal file
BIN
content/images/GrabRotateCursor.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 2.8 KiB |
402
main.cpp
402
main.cpp
@@ -14,13 +14,14 @@
|
|||||||
// TODO: Move toolbar buttons with resized window.
|
// TODO: Move toolbar buttons with resized window.
|
||||||
|
|
||||||
#define _WIN32_WINNT 0x0400
|
#define _WIN32_WINNT 0x0400
|
||||||
|
//#define LEGACY_LOAD_G3DFUN_LEVEL
|
||||||
|
|
||||||
#include <G3DAll.h>
|
#include <G3DAll.h>
|
||||||
#include <initguid.h>
|
#include <initguid.h>
|
||||||
#include <iomanip>
|
#include <iomanip>
|
||||||
#include "Instance.h"
|
#include "Instance.h"
|
||||||
#include "resource.h"
|
#include "resource.h"
|
||||||
#include "PhysicalInstance.h"
|
#include "PartInstance.h"
|
||||||
#include "TextButtonInstance.h"
|
#include "TextButtonInstance.h"
|
||||||
#include "ImageButtonInstance.h"
|
#include "ImageButtonInstance.h"
|
||||||
#include "DataModelInstance.h"
|
#include "DataModelInstance.h"
|
||||||
@@ -41,11 +42,13 @@
|
|||||||
#include "PropertyWindow.h"
|
#include "PropertyWindow.h"
|
||||||
#include <commctrl.h>
|
#include <commctrl.h>
|
||||||
|
|
||||||
|
|
||||||
#if G3D_VER < 61000
|
#if G3D_VER < 61000
|
||||||
#error Requires G3D 6.10
|
#error Requires G3D 6.10
|
||||||
#endif
|
#endif
|
||||||
HWND hwnd;
|
HWND hwnd;
|
||||||
|
|
||||||
|
|
||||||
DEFINE_GUID(CLSID_G3d, 0xB323F8E0L, 0x2E68, 0x11D0, 0x90, 0xEA, 0x00, 0xAA, 0x00, 0x60, 0xF8, 0x6F);
|
DEFINE_GUID(CLSID_G3d, 0xB323F8E0L, 0x2E68, 0x11D0, 0x90, 0xEA, 0x00, 0xAA, 0x00, 0x60, 0xF8, 0x6F);
|
||||||
HRESULT hresult;
|
HRESULT hresult;
|
||||||
OLECHAR dat = ((OLECHAR)"SayHello");
|
OLECHAR dat = ((OLECHAR)"SayHello");
|
||||||
@@ -67,8 +70,10 @@ static std::string cameraSound = "";
|
|||||||
static std::string clickSound = "";
|
static std::string clickSound = "";
|
||||||
static std::string dingSound = "";
|
static std::string dingSound = "";
|
||||||
static int cursorid = 0;
|
static int cursorid = 0;
|
||||||
|
static int cursorOvrid = 0;
|
||||||
|
static int currentcursorid = 0;
|
||||||
static G3D::TextureRef cursor = NULL;
|
static G3D::TextureRef cursor = NULL;
|
||||||
static bool running = true;
|
static G3D::TextureRef cursorOvr = NULL;
|
||||||
static bool mouseMovedBeginMotion = false;
|
static bool mouseMovedBeginMotion = false;
|
||||||
static const int CURSOR = 0;
|
static const int CURSOR = 0;
|
||||||
static const int ARROWS = 1;
|
static const int ARROWS = 1;
|
||||||
@@ -76,13 +81,15 @@ static const int RESIZE = 2;
|
|||||||
static POINT oldGlobalMouse;
|
static POINT oldGlobalMouse;
|
||||||
static int mode = CURSOR;
|
static int mode = CURSOR;
|
||||||
bool dragging = false;
|
bool dragging = false;
|
||||||
Vector2 oldMouse = Vector2(0,0);
|
#include <math.h>
|
||||||
|
Vector2 mouseDownOn = Vector2(nan(), 0);
|
||||||
float moveRate = 0.5;
|
float moveRate = 0.5;
|
||||||
static const std::string PlaceholderName = "HyperCube";
|
static const std::string PlaceholderName = "HyperCube";
|
||||||
|
|
||||||
Demo *usableApp = NULL;
|
Demo *usableApp = NULL;
|
||||||
|
|
||||||
Demo::Demo(const GAppSettings& settings,HWND parentWindow) { //: GApp(settings,window) {
|
Demo::Demo(const GAppSettings& settings,HWND parentWindow) { //: GApp(settings,window) {
|
||||||
|
lightProjX = 17; lightProjY = 17; lightProjNear = 1; lightProjFar = 40;
|
||||||
_hWndMain = parentWindow;
|
_hWndMain = parentWindow;
|
||||||
|
|
||||||
HMODULE hThisInstance = GetModuleHandle(NULL);
|
HMODULE hThisInstance = GetModuleHandle(NULL);
|
||||||
@@ -191,9 +198,9 @@ std::string Convert (float number){
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
PhysicalInstance* makePart()
|
PartInstance* makePart()
|
||||||
{
|
{
|
||||||
PhysicalInstance* part = new PhysicalInstance();
|
PartInstance* part = new PartInstance();
|
||||||
return part;
|
return part;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -245,7 +252,14 @@ public:
|
|||||||
|
|
||||||
void GUDButtonListener::onButton1MouseClick(BaseButtonInstance* button)
|
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);
|
AudioPlayer::playSound(dingSound);
|
||||||
if(button->name == "Duplicate")
|
if(button->name == "Duplicate")
|
||||||
@@ -253,7 +267,7 @@ void GUDButtonListener::onButton1MouseClick(BaseButtonInstance* button)
|
|||||||
std::vector<Instance*> newinst;
|
std::vector<Instance*> newinst;
|
||||||
for(size_t i = 0; i < g_selectedInstances.size(); i++)
|
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);
|
Instance* tempinst = g_selectedInstances.at(i);
|
||||||
|
|
||||||
@@ -282,7 +296,7 @@ void RotateButtonListener::onButton1MouseClick(BaseButtonInstance* button)
|
|||||||
{
|
{
|
||||||
Instance* selectedInstance = g_selectedInstances.at(0);
|
Instance* selectedInstance = g_selectedInstances.at(0);
|
||||||
AudioPlayer::playSound(clickSound);
|
AudioPlayer::playSound(clickSound);
|
||||||
if(PhysicalInstance* part = dynamic_cast<PhysicalInstance*>(selectedInstance))
|
if(PartInstance* part = dynamic_cast<PartInstance*>(selectedInstance))
|
||||||
{
|
{
|
||||||
if(button->name == "Tilt")
|
if(button->name == "Tilt")
|
||||||
part->setCFrame(part->getCFrame()*Matrix3::fromEulerAnglesXYZ(0,0,toRadians(90)));
|
part->setCFrame(part->getCFrame()*Matrix3::fromEulerAnglesXYZ(0,0,toRadians(90)));
|
||||||
@@ -301,7 +315,7 @@ void deleteInstance()
|
|||||||
size_t undeletable = 0;
|
size_t undeletable = 0;
|
||||||
while(g_selectedInstances.size() > undeletable)
|
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"));
|
AudioPlayer::playSound(GetFileInPath("/content/sounds/pageturn.wav"));
|
||||||
Instance* selectedInstance = g_selectedInstances.at(0);
|
Instance* selectedInstance = g_selectedInstances.at(0);
|
||||||
@@ -378,6 +392,7 @@ void Demo::initGUI()
|
|||||||
button->title = "Hopper";
|
button->title = "Hopper";
|
||||||
button->fontLocationRelativeTo = Vector2(10, 3);
|
button->fontLocationRelativeTo = Vector2(10, 3);
|
||||||
button->setAllColorsSame();
|
button->setAllColorsSame();
|
||||||
|
button->boxOutlineColorOvr = Color3(0,255,255);
|
||||||
|
|
||||||
button = makeTextButton();
|
button = makeTextButton();
|
||||||
button->boxBegin = Vector2(0, -48);
|
button->boxBegin = Vector2(0, -48);
|
||||||
@@ -390,6 +405,7 @@ void Demo::initGUI()
|
|||||||
button->title = "Controller";
|
button->title = "Controller";
|
||||||
button->fontLocationRelativeTo = Vector2(10, 3);
|
button->fontLocationRelativeTo = Vector2(10, 3);
|
||||||
button->setAllColorsSame();
|
button->setAllColorsSame();
|
||||||
|
button->boxOutlineColorOvr = Color3(0,255,255);
|
||||||
|
|
||||||
button = makeTextButton();
|
button = makeTextButton();
|
||||||
button->boxBegin = Vector2(0, -72);
|
button->boxBegin = Vector2(0, -72);
|
||||||
@@ -402,6 +418,7 @@ void Demo::initGUI()
|
|||||||
button->title = "Color";
|
button->title = "Color";
|
||||||
button->fontLocationRelativeTo = Vector2(10, 3);
|
button->fontLocationRelativeTo = Vector2(10, 3);
|
||||||
button->setAllColorsSame();
|
button->setAllColorsSame();
|
||||||
|
button->boxOutlineColorOvr = Color3(0,255,255);
|
||||||
|
|
||||||
button = makeTextButton();
|
button = makeTextButton();
|
||||||
button->boxBegin = Vector2(0, -96);
|
button->boxBegin = Vector2(0, -96);
|
||||||
@@ -414,6 +431,7 @@ void Demo::initGUI()
|
|||||||
button->title = "Surface";
|
button->title = "Surface";
|
||||||
button->fontLocationRelativeTo = Vector2(10, 3);
|
button->fontLocationRelativeTo = Vector2(10, 3);
|
||||||
button->setAllColorsSame();
|
button->setAllColorsSame();
|
||||||
|
button->boxOutlineColorOvr = Color3(0,255,255);
|
||||||
|
|
||||||
button = makeTextButton();
|
button = makeTextButton();
|
||||||
button->boxBegin = Vector2(0, -120);
|
button->boxBegin = Vector2(0, -120);
|
||||||
@@ -422,10 +440,10 @@ void Demo::initGUI()
|
|||||||
button->setParent(dataModel->getGuiRoot());
|
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->title = "Model";
|
button->title = "Model";
|
||||||
button->fontLocationRelativeTo = Vector2(10, 3);
|
button->fontLocationRelativeTo = Vector2(10, 3);
|
||||||
button->setAllColorsSame();
|
button->setAllColorsSame();
|
||||||
|
button->boxOutlineColorOvr = Color3(0,255,255);
|
||||||
|
|
||||||
button = makeTextButton();
|
button = makeTextButton();
|
||||||
button->boxBegin = Vector2(0, 0);
|
button->boxBegin = Vector2(0, 0);
|
||||||
@@ -439,6 +457,7 @@ void Demo::initGUI()
|
|||||||
button->textSize = 16;
|
button->textSize = 16;
|
||||||
button->fontLocationRelativeTo = Vector2(10, 0);
|
button->fontLocationRelativeTo = Vector2(10, 0);
|
||||||
button->setAllColorsSame();
|
button->setAllColorsSame();
|
||||||
|
button->boxColorOvr = Color4(0.6F,0.6F,0.6F,0.4F);
|
||||||
|
|
||||||
button = makeTextButton();
|
button = makeTextButton();
|
||||||
button->boxBegin = Vector2(125, 0);
|
button->boxBegin = Vector2(125, 0);
|
||||||
@@ -452,6 +471,7 @@ void Demo::initGUI()
|
|||||||
button->textSize = 16;
|
button->textSize = 16;
|
||||||
button->fontLocationRelativeTo = Vector2(10, 0);
|
button->fontLocationRelativeTo = Vector2(10, 0);
|
||||||
button->setAllColorsSame();
|
button->setAllColorsSame();
|
||||||
|
button->boxColorOvr = Color4(0.6F,0.6F,0.6F,0.4F);
|
||||||
|
|
||||||
button = makeTextButton();
|
button = makeTextButton();
|
||||||
button->boxBegin = Vector2(250, 0);
|
button->boxBegin = Vector2(250, 0);
|
||||||
@@ -465,6 +485,7 @@ void Demo::initGUI()
|
|||||||
button->textSize = 16;
|
button->textSize = 16;
|
||||||
button->fontLocationRelativeTo = Vector2(10, 0);
|
button->fontLocationRelativeTo = Vector2(10, 0);
|
||||||
button->setAllColorsSame();
|
button->setAllColorsSame();
|
||||||
|
button->boxColorOvr = Color4(0.6F,0.6F,0.6F,0.4F);
|
||||||
|
|
||||||
button = makeTextButton();
|
button = makeTextButton();
|
||||||
button->boxBegin = Vector2(375, 0);
|
button->boxBegin = Vector2(375, 0);
|
||||||
@@ -478,6 +499,7 @@ void Demo::initGUI()
|
|||||||
button->textSize = 16;
|
button->textSize = 16;
|
||||||
button->fontLocationRelativeTo = Vector2(10, 0);
|
button->fontLocationRelativeTo = Vector2(10, 0);
|
||||||
button->setAllColorsSame();
|
button->setAllColorsSame();
|
||||||
|
button->boxColorOvr = Color4(0.6F,0.6F,0.6F,0.4F);
|
||||||
|
|
||||||
button = makeTextButton();
|
button = makeTextButton();
|
||||||
button->boxBegin = Vector2(500, 0);
|
button->boxBegin = Vector2(500, 0);
|
||||||
@@ -491,6 +513,7 @@ void Demo::initGUI()
|
|||||||
button->textSize = 16;
|
button->textSize = 16;
|
||||||
button->fontLocationRelativeTo = Vector2(10, 0);
|
button->fontLocationRelativeTo = Vector2(10, 0);
|
||||||
button->setAllColorsSame();
|
button->setAllColorsSame();
|
||||||
|
button->boxColorOvr = Color4(0.6F,0.6F,0.6F,0.4F);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -502,7 +525,9 @@ void Demo::initGUI()
|
|||||||
button->boxColor = Color4::clear();
|
button->boxColor = Color4::clear();
|
||||||
button->textSize = 12;
|
button->textSize = 12;
|
||||||
button->title = "Group";
|
button->title = "Group";
|
||||||
|
button->name = "Group";
|
||||||
button->setAllColorsSame();
|
button->setAllColorsSame();
|
||||||
|
button->textColorDis = Color3(0.8F,0.8F,0.8F);
|
||||||
button->font = fntlighttrek;
|
button->font = fntlighttrek;
|
||||||
button->fontLocationRelativeTo = Vector2(10, 0);
|
button->fontLocationRelativeTo = Vector2(10, 0);
|
||||||
button->setParent(dataModel->getGuiRoot());
|
button->setParent(dataModel->getGuiRoot());
|
||||||
@@ -516,7 +541,9 @@ void Demo::initGUI()
|
|||||||
button->boxColor = Color4::clear();
|
button->boxColor = Color4::clear();
|
||||||
button->textSize = 12;
|
button->textSize = 12;
|
||||||
button->title = "UnGroup";
|
button->title = "UnGroup";
|
||||||
|
button->name = "UnGroup";
|
||||||
button->setAllColorsSame();
|
button->setAllColorsSame();
|
||||||
|
button->textColorDis = Color3(0.8F,0.8F,0.8F);
|
||||||
button->font = fntlighttrek;
|
button->font = fntlighttrek;
|
||||||
button->fontLocationRelativeTo = Vector2(10, 0);
|
button->fontLocationRelativeTo = Vector2(10, 0);
|
||||||
button->setParent(dataModel->getGuiRoot());
|
button->setParent(dataModel->getGuiRoot());
|
||||||
@@ -530,6 +557,7 @@ void Demo::initGUI()
|
|||||||
button->textSize = 12;
|
button->textSize = 12;
|
||||||
button->title = "Duplicate";
|
button->title = "Duplicate";
|
||||||
button->setAllColorsSame();
|
button->setAllColorsSame();
|
||||||
|
button->textColorDis = Color3(0.8F,0.8F,0.8F);
|
||||||
button->font = fntlighttrek;
|
button->font = fntlighttrek;
|
||||||
button->fontLocationRelativeTo = Vector2(10, 0);
|
button->fontLocationRelativeTo = Vector2(10, 0);
|
||||||
button->setParent(dataModel->getGuiRoot());
|
button->setParent(dataModel->getGuiRoot());
|
||||||
@@ -708,16 +736,15 @@ void Demo::onInit() {
|
|||||||
|
|
||||||
initGUI();
|
initGUI();
|
||||||
|
|
||||||
dataModel->load();
|
#ifdef LEGACY_LOAD_G3DFUN_LEVEL
|
||||||
|
PartInstance* test = makePart();
|
||||||
// Say bye bye to this soon...
|
|
||||||
/*
|
|
||||||
PhysicalInstance* test = makePart();
|
|
||||||
test->setParent(dataModel->getWorkspace());
|
test->setParent(dataModel->getWorkspace());
|
||||||
test->color = Color3(0.2F,0.3F,1);
|
test->color = Color3(0.2F,0.3F,1);
|
||||||
test->setSize(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(0),toRadians(0)));
|
test->setCFrame(test->getCFrame() * Matrix3::fromEulerAnglesXYZ(0,toRadians(54),toRadians(0)));
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
test = makePart();
|
test = makePart();
|
||||||
test->setParent(dataModel->getWorkspace());
|
test->setParent(dataModel->getWorkspace());
|
||||||
@@ -730,7 +757,6 @@ void Demo::onInit() {
|
|||||||
test->setSize(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->setParent(dataModel->getWorkspace());
|
test->setParent(dataModel->getWorkspace());
|
||||||
test->color = Color3::gray();
|
test->color = Color3::gray();
|
||||||
@@ -773,7 +799,7 @@ void Demo::onInit() {
|
|||||||
test->setSize(Vector3(4,1,2));
|
test->setSize(Vector3(4,1,2));
|
||||||
test->setPosition(Vector3(-2,5,0));
|
test->setPosition(Vector3(-2,5,0));
|
||||||
|
|
||||||
|
//dataModel->setMessageBrickCount();
|
||||||
|
|
||||||
|
|
||||||
test = makePart();
|
test = makePart();
|
||||||
@@ -787,7 +813,9 @@ void Demo::onInit() {
|
|||||||
test->color = Color3::gray();
|
test->color = Color3::gray();
|
||||||
test->setSize(Vector3(4,1,2));
|
test->setSize(Vector3(4,1,2));
|
||||||
test->setPosition(Vector3(2,7,0));
|
test->setPosition(Vector3(2,7,0));
|
||||||
*/
|
#else
|
||||||
|
dataModel->load();
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -838,15 +866,55 @@ std::vector<Instance*> Demo::getSelection()
|
|||||||
return g_selectedInstances;
|
return g_selectedInstances;
|
||||||
}
|
}
|
||||||
void Demo::onSimulation(RealTime rdt, SimTime sdt, SimTime idt) {
|
void Demo::onSimulation(RealTime rdt, SimTime sdt, SimTime idt) {
|
||||||
|
if(running)
|
||||||
Instance* obj = dataModel->getGuiRoot()->findFirstChild("Delete");
|
|
||||||
if(obj != NULL)
|
|
||||||
{
|
{
|
||||||
ImageButtonInstance* button = (ImageButtonInstance*)obj;
|
std::vector <Instance* > objects = dataModel->getWorkspace()->getAllChildren();
|
||||||
if(g_selectedInstances.size() <= 0 || g_selectedInstances.at(0) == dataModel->getWorkspace())
|
for(size_t i = 0; i < objects.size(); i++)
|
||||||
|
{
|
||||||
|
if(PartInstance* moveTo = dynamic_cast<PartInstance*>(objects.at(i)))
|
||||||
|
{
|
||||||
|
moveTo->velocity.y -= (196.2F/30);
|
||||||
|
moveTo->setPosition(Vector3(moveTo->getPosition().x, moveTo->getPosition().y+(moveTo->velocity.y)/30, moveTo->getPosition().z));
|
||||||
|
if(moveTo->getPosition().y < -128)
|
||||||
|
{
|
||||||
|
moveTo->setParent(NULL);
|
||||||
|
delete moveTo;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
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)
|
||||||
|
{
|
||||||
|
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;
|
button->disabled = true;
|
||||||
else
|
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;
|
button->disabled = false;
|
||||||
|
button2->disabled = false;
|
||||||
|
button3->disabled = false;
|
||||||
|
button4->disabled = false;
|
||||||
|
button5->disabled = false;
|
||||||
|
button6->disabled = false;
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -878,6 +946,8 @@ bool IsHolding(int button)
|
|||||||
return (GetKeyState(button) >> 1)>0;
|
return (GetKeyState(button) >> 1)>0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
BOOL GetKPBool(int VK) {
|
BOOL GetKPBool(int VK) {
|
||||||
return (GetKeyState(VK) & 0x8000);
|
return (GetKeyState(VK) & 0x8000);
|
||||||
}
|
}
|
||||||
@@ -911,32 +981,61 @@ void Demo::onUserInput(UserInput* ui) {
|
|||||||
dataModel->mouseButton1Down = (GetKeyState(VK_LBUTTON) & 0x100) != 0;
|
dataModel->mouseButton1Down = (GetKeyState(VK_LBUTTON) & 0x100) != 0;
|
||||||
|
|
||||||
if (GetHoldKeyState(VK_LBUTTON)) {
|
if (GetHoldKeyState(VK_LBUTTON)) {
|
||||||
|
if(!G3D::isNaN(mouseDownOn.x))
|
||||||
|
{
|
||||||
|
if(abs(mouseDownOn.x - dataModel->mousex) > 4 || abs(mouseDownOn.y - dataModel->mousey) > 4)
|
||||||
|
{
|
||||||
|
dragging = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
mouseDownOn = Vector2(dataModel->mousex, dataModel->mousey);
|
||||||
|
}
|
||||||
if (dragging) {
|
if (dragging) {
|
||||||
PhysicalInstance* part = NULL;
|
PartInstance* part = NULL;
|
||||||
if(g_selectedInstances.size() > 0)
|
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());
|
Ray dragRay = cameraController.getCamera()->worldRay(dataModel->mousex, dataModel->mousey, renderDevice->getViewport());
|
||||||
std::vector<Instance*> instances = dataModel->getWorkspace()->getAllChildren();
|
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(PhysicalInstance* moveTo = dynamic_cast<PhysicalInstance*>(instances.at(i)))
|
if(PartInstance* moveTo = dynamic_cast<PartInstance*>(instances.at(i)))
|
||||||
{
|
{
|
||||||
|
Vector3 outLocation=Vector3(0,0,0);
|
||||||
|
Vector3 outNormal=Vector3(0,0,0);
|
||||||
|
|
||||||
|
if (moveTo!=part) {
|
||||||
|
if (CollisionDetection::collisionTimeForMovingPointFixedBox(dragRay.origin,dragRay.direction*100,moveTo->getBox(),outLocation,outNormal)!=inf())
|
||||||
|
{
|
||||||
|
part->setPosition(Vector3(floor(outLocation.x),floor(outLocation.y+1),floor(outLocation.z)));
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/*
|
||||||
float __time = testRay.intersectionTime(moveTo->getBox());
|
float __time = testRay.intersectionTime(moveTo->getBox());
|
||||||
float __nearest=std::numeric_limits<float>::infinity();
|
float __nearest=std::numeric_limits<float>::infinity();
|
||||||
if (__time != inf())
|
if (__time != inf() && moveTo != part)
|
||||||
{
|
{
|
||||||
if (__nearest>__time)
|
if (__nearest>__time)
|
||||||
{
|
{
|
||||||
Vector3 closest = (dragRay.closestPoint(moveTo->getPosition()) * 2);
|
Vector3 closest = (dragRay.closestPoint(moveTo->getPosition()));
|
||||||
part->setPosition(closest);
|
//part->setPosition(closest);
|
||||||
//part->setPosition(Vector3(floor(closest.x),part->getPosition().y,floor(closest.z)));
|
part->setPosition(Vector3(floor(closest.x),floor(closest.y),floor(closest.z)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Sleep(10);
|
Sleep(10);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
dragging = false;
|
||||||
|
mouseDownOn = Vector2(nan(), 0);
|
||||||
|
}
|
||||||
// Camera KB Handling {
|
// Camera KB Handling {
|
||||||
if (GetKPBool(VK_OEM_COMMA)) //Left
|
if (GetKPBool(VK_OEM_COMMA)) //Left
|
||||||
usableApp->cameraController.panLeft();
|
usableApp->cameraController.panLeft();
|
||||||
@@ -981,7 +1080,7 @@ void makeFlag(Vector3 &vec, RenderDevice* &rd)
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
bool mouseInArea(float point1x, float point1y, float point2x, float point2y)
|
/*bool mouseInArea(float point1x, float point1y, float point2x, float point2y)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
@@ -993,7 +1092,7 @@ bool mouseInArea(float point1x, float point1y, float point2x, float point2y)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}*/
|
||||||
|
|
||||||
|
|
||||||
void drawButtons(RenderDevice* rd)
|
void drawButtons(RenderDevice* rd)
|
||||||
@@ -1029,6 +1128,7 @@ void drawOutline(Vector3 from, Vector3 to, RenderDevice* rd, LightingParameters
|
|||||||
|
|
||||||
if(mode == ARROWS)
|
if(mode == ARROWS)
|
||||||
{
|
{
|
||||||
|
glScalef(2,2,2);
|
||||||
rd->setLight(0, NULL);
|
rd->setLight(0, NULL);
|
||||||
rd->setAmbientLightColor(Color3(1,1,1));
|
rd->setAmbientLightColor(Color3(1,1,1));
|
||||||
|
|
||||||
@@ -1036,23 +1136,24 @@ void drawOutline(Vector3 from, Vector3 to, RenderDevice* rd, LightingParameters
|
|||||||
c.toWorldSpace(Box(from, to)).getBounds(box);
|
c.toWorldSpace(Box(from, to)).getBounds(box);
|
||||||
float max = box.high().y - pos.y;
|
float max = box.high().y - pos.y;
|
||||||
|
|
||||||
Draw::arrow(pos, Vector3(0, 1.5+max, 0), rd);
|
Draw::arrow(pos/2, Vector3(0, 1.5+max, 0), rd);
|
||||||
Draw::arrow(pos, Vector3(0, (-1.5)-max, 0), rd);
|
Draw::arrow(pos/2, Vector3(0, (-1.5)-max, 0), rd);
|
||||||
|
|
||||||
max = box.high().x - pos.x;
|
max = box.high().x - pos.x;
|
||||||
|
|
||||||
Draw::arrow(pos, Vector3(1.5+max, 0, 0), rd);
|
Draw::arrow(pos/2, Vector3(1.5+max, 0, 0), rd);
|
||||||
Draw::arrow(pos, Vector3((-1.5)-max, 0, 0), rd);
|
Draw::arrow(pos/2, Vector3((-1.5)-max, 0, 0), rd);
|
||||||
|
|
||||||
max = box.high().z - pos.z;
|
max = box.high().z - pos.z;
|
||||||
|
|
||||||
Draw::arrow(pos, Vector3(0, 0, 1.5+max), rd);
|
Draw::arrow(pos/2, Vector3(0, 0, 1.5+max), rd);
|
||||||
Draw::arrow(pos, Vector3(0, 0, (-1.5)-max), rd);
|
Draw::arrow(pos/2, 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));
|
||||||
|
glScalef(1,1,1);
|
||||||
}
|
}
|
||||||
else if(mode == RESIZE)
|
else if(mode == RESIZE)
|
||||||
{
|
{
|
||||||
@@ -1064,24 +1165,23 @@ 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)
|
||||||
{
|
{
|
||||||
|
|
||||||
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));
|
Vector3 position = pos + (c.lookVector()*((size.z)+2));
|
||||||
Draw::sphere(Sphere(position, multiplier), rd, sphereColor, Color4::clear());
|
Draw::sphere(Sphere(position, multiplier*2), rd, sphereColor, Color4::clear());
|
||||||
position = pos - (c.lookVector()*((size.z/2)+1));
|
position = pos - (c.lookVector()*((size.z)+2));
|
||||||
Draw::sphere(Sphere(position, multiplier), rd, sphereColor, Color4::clear());
|
Draw::sphere(Sphere(position, multiplier*2), rd, sphereColor, Color4::clear());
|
||||||
|
|
||||||
position = pos + (c.rightVector()*((size.x/2)+1));
|
position = pos + (c.rightVector()*((size.x)+2));
|
||||||
Draw::sphere(Sphere(position, multiplier), rd, sphereColor, Color4::clear());
|
Draw::sphere(Sphere(position, multiplier*2), rd, sphereColor, Color4::clear());
|
||||||
position = pos - (c.rightVector()*((size.x/2)+1));
|
position = pos - (c.rightVector()*((size.x)+2));
|
||||||
Draw::sphere(Sphere(position, multiplier), rd, sphereColor, Color4::clear());
|
Draw::sphere(Sphere(position, multiplier*2), rd, sphereColor, Color4::clear());
|
||||||
|
|
||||||
position = pos + (c.upVector()*((size.y/2)+1));
|
position = pos + (c.upVector()*((size.y)+2));
|
||||||
Draw::sphere(Sphere(position, multiplier), rd, sphereColor, Color4::clear());
|
Draw::sphere(Sphere(position, multiplier*2), rd, sphereColor, Color4::clear());
|
||||||
position = pos - (c.upVector()*((size.y/2)+1));
|
position = pos - (c.upVector()*((size.y)+2));
|
||||||
Draw::sphere(Sphere(position, multiplier), rd, sphereColor, Color4::clear());
|
Draw::sphere(Sphere(position, multiplier*2), 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));
|
||||||
@@ -1098,16 +1198,20 @@ void Demo::exitApplication()
|
|||||||
|
|
||||||
void Demo::onGraphics(RenderDevice* rd) {
|
void Demo::onGraphics(RenderDevice* rd) {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
G3D::uint8 num = 0;
|
G3D::uint8 num = 0;
|
||||||
POINT mousepos;
|
POINT mousepos;
|
||||||
mouseOnScreen = true;
|
mouseOnScreen = true;
|
||||||
if (GetCursorPos(&mousepos))
|
if (GetCursorPos(&mousepos))
|
||||||
{
|
{
|
||||||
|
POINT pointm = mousepos;
|
||||||
if (ScreenToClient(_hWndMain, &mousepos))
|
if (ScreenToClient(_hWndMain, &mousepos))
|
||||||
{
|
{
|
||||||
//mouseOnScreen = true;
|
//mouseOnScreen = true;
|
||||||
|
//POINT pointm;
|
||||||
if(mousepos.x < 1 || mousepos.y < 1 || mousepos.x >= rd->getViewport().width()-1 || mousepos.y >= rd->getViewport().height()-1)
|
///GetCursorPos(&pointm);
|
||||||
|
if(_hwndRenderer != WindowFromPoint(pointm)) //OLD: mousepos.x < 1 || mousepos.y < 1 || mousepos.x >= rd->getViewport().width()-1 || mousepos.y >= rd->getViewport().height()-1
|
||||||
{
|
{
|
||||||
mouseOnScreen = false;
|
mouseOnScreen = false;
|
||||||
//ShowCursor(true);
|
//ShowCursor(true);
|
||||||
@@ -1125,6 +1229,8 @@ void Demo::onGraphics(RenderDevice* rd) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if(Globals::useMousePoint)
|
if(Globals::useMousePoint)
|
||||||
{
|
{
|
||||||
mousepos = Globals::mousepoint;
|
mousepos = Globals::mousepoint;
|
||||||
@@ -1132,6 +1238,20 @@ void Demo::onGraphics(RenderDevice* rd) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
LightingParameters lighting(G3D::toSeconds(11, 00, 00, AM));
|
LightingParameters lighting(G3D::toSeconds(11, 00, 00, AM));
|
||||||
|
|
||||||
|
Matrix4 lightProjectionMatrix(Matrix4::orthogonalProjection(-lightProjX, lightProjX, -lightProjY, lightProjY, lightProjNear, lightProjFar));
|
||||||
|
|
||||||
|
CoordinateFrame lightCFrame;
|
||||||
|
lightCFrame.lookAt(-lighting.lightDirection, Vector3::unitY());
|
||||||
|
lightCFrame.translation = lighting.lightDirection * 20;
|
||||||
|
|
||||||
|
Matrix4 lightMVP = lightProjectionMatrix * lightCFrame.inverse();
|
||||||
|
|
||||||
|
if (GLCaps::supports_GL_ARB_shadow()) {
|
||||||
|
generateShadowMap(lightCFrame);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
renderDevice->setProjectionAndCameraMatrix(*cameraController.getCamera());
|
renderDevice->setProjectionAndCameraMatrix(*cameraController.getCamera());
|
||||||
|
|
||||||
// Cyan background
|
// Cyan background
|
||||||
@@ -1151,19 +1271,37 @@ 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 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->pushState();
|
||||||
|
if (GLCaps::supports_GL_ARB_shadow()) {
|
||||||
|
rd->configureShadowMap(1, lightMVP, shadowMap);
|
||||||
|
}
|
||||||
rd->beforePrimitive();
|
rd->beforePrimitive();
|
||||||
|
|
||||||
|
|
||||||
dataModel->getWorkspace()->render(rd);
|
dataModel->getWorkspace()->render(rd);
|
||||||
|
|
||||||
|
|
||||||
//if (dataModel->children[0]->children.size()>0)
|
//if (dataModel->children[0]->children.size()>0)
|
||||||
//((PhysicalInstance*)dataModel->children[0]->children[0])->debugPrintVertexIDs(rd,fntdominant,-cameraController.getCoordinateFrame().rotation);
|
//((PartInstance*)dataModel->children[0]->children[0])->debugPrintVertexIDs(rd,fntdominant,-cameraController.getCoordinateFrame().rotation);
|
||||||
rd->afterPrimitive();
|
rd->afterPrimitive();
|
||||||
|
|
||||||
|
rd->popState();
|
||||||
if(g_selectedInstances.size() > 0)
|
if(g_selectedInstances.size() > 0)
|
||||||
{
|
{
|
||||||
for(size_t i = 0; i < g_selectedInstances.size(); i++)
|
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 size = part->getSize();
|
||||||
Vector3 pos = part->getPosition();
|
Vector3 pos = part->getPosition();
|
||||||
@@ -1173,16 +1311,18 @@ void Demo::onGraphics(RenderDevice* rd) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//Vector3 gamepoint = Vector3(0, 5, 0);
|
while(!postRenderStack.empty())
|
||||||
//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);
|
Instance* inst = postRenderStack.at(0);
|
||||||
//if(distance < 50 && distance > -50)
|
postRenderStack.erase(postRenderStack.begin());
|
||||||
|
if(PVInstance* pinst = dynamic_cast<PVInstance*>(inst))
|
||||||
|
{
|
||||||
|
pinst->postRender(rd);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
//{
|
|
||||||
// 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();
|
renderDevice->disableLighting();
|
||||||
|
|
||||||
@@ -1202,9 +1342,9 @@ void Demo::onGraphics(RenderDevice* rd) {
|
|||||||
fntdominant->draw2D(rd, "FPS: " + stream.str(), Vector2(120, 25), 10, Color3::fromARGB(0xFFFF00), Color3::black());
|
fntdominant->draw2D(rd, "FPS: " + stream.str(), Vector2(120, 25), 10, Color3::fromARGB(0xFFFF00), Color3::black());
|
||||||
stream.str("");
|
stream.str("");
|
||||||
stream.clear();
|
stream.clear();
|
||||||
stream << std::fixed << std::setprecision(1) << dataModel->getWorkspace()->timer;
|
stream << std::fixed << std::setprecision(1) << dataModel->getLevel()->timer;
|
||||||
fntdominant->draw2D(rd, "Timer: " + stream.str(), Vector2(rd->getWidth() - 120, 25), 20, Color3::fromARGB(0x81C518), Color3::black());
|
fntdominant->draw2D(rd, "Timer: " + stream.str(), Vector2(rd->getWidth() - 120, 25), 20, Color3::fromARGB(0x81C518), Color3::black());
|
||||||
fntdominant->draw2D(rd, "Score: " + Convert(dataModel->getWorkspace()->score), Vector2(rd->getWidth() - 120, 50), 20, Color3::fromARGB(0x81C518), Color3::black());
|
fntdominant->draw2D(rd, "Score: " + Convert(dataModel->getLevel()->score), Vector2(rd->getWidth() - 120, 50), 20, Color3::fromARGB(0x81C518), Color3::black());
|
||||||
|
|
||||||
//GUI Boxes
|
//GUI Boxes
|
||||||
Draw::box(G3D::Box(Vector3(0,25,0),Vector3(80,355,0)),rd,Color4(0.6F,0.6F,0.6F,0.4F), Color4(0,0,0,0));
|
Draw::box(G3D::Box(Vector3(0,25,0),Vector3(80,355,0)),rd,Color4(0.6F,0.6F,0.6F,0.4F), Color4(0,0,0,0));
|
||||||
@@ -1230,19 +1370,49 @@ void Demo::onGraphics(RenderDevice* rd) {
|
|||||||
glEnable(GL_BLEND);// you enable blending function
|
glEnable(GL_BLEND);// you enable blending function
|
||||||
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||||
|
|
||||||
|
std::vector<Instance*> instances = dataModel->getWorkspace()->getAllChildren();
|
||||||
|
currentcursorid = cursorid;
|
||||||
|
bool onGUI = false;
|
||||||
|
std::vector<Instance*> guis = dataModel->getGuiRoot()->getAllChildren();
|
||||||
|
for(size_t i = 0; i < guis.size(); i++)
|
||||||
|
{
|
||||||
|
if(BaseButtonInstance* button = dynamic_cast<BaseButtonInstance*>(guis.at(i)))
|
||||||
|
{
|
||||||
|
if(button->mouseInButton(dataModel->mousex,dataModel->mousey, renderDevice))
|
||||||
|
{
|
||||||
|
onGUI = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(!onGUI)
|
||||||
|
for(size_t i = 0; i < instances.size(); i++)
|
||||||
|
{
|
||||||
|
if(PartInstance* test = dynamic_cast<PartInstance*>(instances.at(i)))
|
||||||
|
{
|
||||||
|
float time = cameraController.getCamera()->worldRay(dataModel->mousex, dataModel->mousey, renderDevice->getViewport()).intersectionTime(test->getBox());
|
||||||
|
//float time = testRay.intersectionTime(test->getBox());
|
||||||
|
if (time != inf())
|
||||||
|
{
|
||||||
|
currentcursorid = cursorOvrid;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
glBindTexture( GL_TEXTURE_2D, cursorid);
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
glBindTexture( GL_TEXTURE_2D, currentcursorid);
|
||||||
|
|
||||||
|
|
||||||
glBegin( GL_QUADS );
|
glBegin( GL_QUADS );
|
||||||
glTexCoord2d(0.0,0.0);
|
glTexCoord2d(0.0,0.0);
|
||||||
glVertex2f(mousepos.x-40, mousepos.y-40);
|
glVertex2f(mousepos.x-64, mousepos.y-64);
|
||||||
glTexCoord2d( 1.0,0.0 );
|
glTexCoord2d( 1.0,0.0 );
|
||||||
glVertex2f(mousepos.x+40, mousepos.y-40);
|
glVertex2f(mousepos.x+64, mousepos.y-64);
|
||||||
glTexCoord2d(1.0,1.0 );
|
glTexCoord2d(1.0,1.0 );
|
||||||
glVertex2f(mousepos.x+40, mousepos.y+40 );
|
glVertex2f(mousepos.x+64, mousepos.y+64 );
|
||||||
glTexCoord2d( 0.0,1.0 );
|
glTexCoord2d( 0.0,1.0 );
|
||||||
glVertex2f( mousepos.x-40, mousepos.y+40 );
|
glVertex2f( mousepos.x-64, mousepos.y+64 );
|
||||||
glEnd();
|
glEnd();
|
||||||
|
|
||||||
glDisable( GL_TEXTURE_2D );
|
glDisable( GL_TEXTURE_2D );
|
||||||
@@ -1251,6 +1421,7 @@ void Demo::onGraphics(RenderDevice* rd) {
|
|||||||
rd->afterPrimitive();
|
rd->afterPrimitive();
|
||||||
rd->popState();
|
rd->popState();
|
||||||
renderDevice->pop2D();
|
renderDevice->pop2D();
|
||||||
|
debugAssertGLOk();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Demo::onKeyPressed(int key)
|
void Demo::onKeyPressed(int key)
|
||||||
@@ -1267,7 +1438,10 @@ void Demo::onKeyUp(int key)
|
|||||||
|
|
||||||
void Demo::onMouseLeftPressed(HWND hwnd,int x,int y)
|
void Demo::onMouseLeftPressed(HWND hwnd,int x,int y)
|
||||||
{
|
{
|
||||||
SetFocus(hwnd);
|
//Removed set focus
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
std::cout << "Click: " << x << "," << y << std::endl;
|
std::cout << "Click: " << x << "," << y << std::endl;
|
||||||
|
|
||||||
@@ -1293,7 +1467,7 @@ void Demo::onMouseLeftPressed(HWND hwnd,int x,int y)
|
|||||||
bool objFound = false;
|
bool objFound = false;
|
||||||
for(size_t i = 0; i < instances.size(); i++)
|
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());
|
float time = testRay.intersectionTime(test->getBox());
|
||||||
|
|
||||||
@@ -1332,8 +1506,8 @@ void Demo::onMouseLeftPressed(HWND hwnd,int x,int y)
|
|||||||
{
|
{
|
||||||
while(g_selectedInstances.size() > 0)
|
while(g_selectedInstances.size() > 0)
|
||||||
g_selectedInstances.erase(g_selectedInstances.begin());
|
g_selectedInstances.erase(g_selectedInstances.begin());
|
||||||
g_selectedInstances.push_back(dataModel->getWorkspace());
|
g_selectedInstances.push_back(dataModel);
|
||||||
_propWindow->SetProperties(dataModel->getWorkspace());
|
_propWindow->SetProperties(dataModel);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1346,7 +1520,7 @@ void Demo::onMouseLeftUp(int x,int y)
|
|||||||
//message = "Dragging = false.";
|
//message = "Dragging = false.";
|
||||||
//messageTime = System::time();
|
//messageTime = System::time();
|
||||||
std::vector<Instance*> instances_2D = dataModel->getGuiRoot()->getAllChildren();
|
std::vector<Instance*> instances_2D = dataModel->getGuiRoot()->getAllChildren();
|
||||||
std::vector<Instance*> instances = dataModel->getWorkspace()->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(BaseButtonInstance* button = dynamic_cast<BaseButtonInstance*>(instances_2D[i]))
|
if(BaseButtonInstance* button = dynamic_cast<BaseButtonInstance*>(instances_2D[i]))
|
||||||
@@ -1366,7 +1540,7 @@ void Demo::onMouseRightUp(int x,int y)
|
|||||||
}
|
}
|
||||||
void Demo::onMouseMoved(int x,int y)
|
void Demo::onMouseMoved(int x,int y)
|
||||||
{
|
{
|
||||||
oldMouse = dataModel->getMousePos();
|
//oldMouse = dataModel->getMousePos();
|
||||||
dataModel->mousex = x;
|
dataModel->mousex = x;
|
||||||
dataModel->mousey = y;
|
dataModel->mousey = y;
|
||||||
|
|
||||||
@@ -1492,6 +1666,27 @@ LRESULT CALLBACK G3DProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
|
|||||||
case WM_MOUSEMOVE:
|
case WM_MOUSEMOVE:
|
||||||
app->onMouseMoved(LOWORD(lParam),HIWORD(lParam));
|
app->onMouseMoved(LOWORD(lParam),HIWORD(lParam));
|
||||||
break;
|
break;
|
||||||
|
case WM_KEYDOWN:
|
||||||
|
if ((HIWORD(lParam)&0x4000)==0) // single key press
|
||||||
|
{
|
||||||
|
app->onKeyPressed(wParam);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case WM_KEYUP:
|
||||||
|
{
|
||||||
|
app->onKeyUp(wParam);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case WM_SYSKEYDOWN:
|
||||||
|
if ((HIWORD(lParam)&0x4000)==0) // single key press
|
||||||
|
{
|
||||||
|
app->onKeyPressed(wParam);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case WM_SYSKEYUP:
|
||||||
|
{
|
||||||
|
app->onKeyUp(wParam);
|
||||||
|
}
|
||||||
case WM_SIZE:
|
case WM_SIZE:
|
||||||
{
|
{
|
||||||
app->onGraphics(app->renderDevice);
|
app->onGraphics(app->renderDevice);
|
||||||
@@ -1505,6 +1700,37 @@ LRESULT CALLBACK G3DProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
|
|||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Demo::generateShadowMap(const CoordinateFrame& lightViewMatrix) const {
|
||||||
|
|
||||||
|
|
||||||
|
//debugAssert(shadowMapSize < app->renderDevice->getHeight());
|
||||||
|
//debugAssert(shadowMapSize < app->renderDevice->getWidth());
|
||||||
|
|
||||||
|
//app->renderDevice->clear(debugLightMap, true, false);
|
||||||
|
|
||||||
|
Rect2D rect = Rect2D::xywh(0, 0, 512, 512);
|
||||||
|
renderDevice->pushState();
|
||||||
|
renderDevice->setViewport(rect);
|
||||||
|
|
||||||
|
// Draw from the light's point of view
|
||||||
|
renderDevice->setProjectionMatrix(Matrix4::orthogonalProjection(-lightProjX, lightProjX, -lightProjY, lightProjY, lightProjNear, lightProjFar));
|
||||||
|
renderDevice->setCameraToWorldMatrix(lightViewMatrix);
|
||||||
|
|
||||||
|
renderDevice->disableColorWrite();
|
||||||
|
|
||||||
|
// We can choose to use a large bias or render from
|
||||||
|
// the backfaces in order to avoid front-face self
|
||||||
|
// shadowing. Here, we use a large offset.
|
||||||
|
renderDevice->setPolygonOffset(8);
|
||||||
|
|
||||||
|
dataModel->render(renderDevice);
|
||||||
|
renderDevice->popState();
|
||||||
|
|
||||||
|
shadowMap->copyFromScreen(rect);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void Demo::run() {
|
void Demo::run() {
|
||||||
usableApp = this;
|
usableApp = this;
|
||||||
//setDebugMode(false);
|
//setDebugMode(false);
|
||||||
@@ -1526,7 +1752,8 @@ void Demo::run() {
|
|||||||
UpdateWindow(_hWndMain);
|
UpdateWindow(_hWndMain);
|
||||||
|
|
||||||
// Load objects here=
|
// Load objects here=
|
||||||
cursor = Texture::fromFile(GetFileInPath("/content/cursor2.png"));
|
cursor = Texture::fromFile(GetFileInPath("/content/images/ArrowCursor.png"));
|
||||||
|
cursorOvr = Texture::fromFile(GetFileInPath("/content/images/DragCursor.png"));
|
||||||
Globals::surface = Texture::fromFile(GetFileInPath("/content/images/surfacebr.png"));
|
Globals::surface = Texture::fromFile(GetFileInPath("/content/images/surfacebr.png"));
|
||||||
Globals::surfaceId = Globals::surface->getOpenGLID();
|
Globals::surfaceId = Globals::surface->getOpenGLID();
|
||||||
fntdominant = GFont::fromFile(GetFileInPath("/content/font/dominant.fnt"));
|
fntdominant = GFont::fromFile(GetFileInPath("/content/font/dominant.fnt"));
|
||||||
@@ -1535,8 +1762,17 @@ void Demo::run() {
|
|||||||
clickSound = GetFileInPath("/content/sounds/switch.wav");
|
clickSound = GetFileInPath("/content/sounds/switch.wav");
|
||||||
dingSound = GetFileInPath("/content/sounds/electronicpingshort.wav");
|
dingSound = GetFileInPath("/content/sounds/electronicpingshort.wav");
|
||||||
sky = Sky::create(NULL, ExePath() + "/content/sky/");
|
sky = Sky::create(NULL, ExePath() + "/content/sky/");
|
||||||
cursorid = cursor->openGLID();
|
|
||||||
|
|
||||||
|
|
||||||
|
if (GLCaps::supports_GL_ARB_shadow()) {
|
||||||
|
shadowMap = Texture::createEmpty(512, 512, "Shadow map", TextureFormat::depth(),
|
||||||
|
Texture::CLAMP, Texture::BILINEAR_NO_MIPMAP, Texture::DIM_2D, Texture::DEPTH_LEQUAL);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
cursorid = cursor->openGLID();
|
||||||
|
currentcursorid = cursorid;
|
||||||
|
cursorOvrid = cursorOvr->openGLID();
|
||||||
RealTime now=0, lastTime=0;
|
RealTime now=0, lastTime=0;
|
||||||
double simTimeRate = 1.0f;
|
double simTimeRate = 1.0f;
|
||||||
float fps=30.0f;
|
float fps=30.0f;
|
||||||
|
|||||||
Reference in New Issue
Block a user