Compare commits
71 Commits
r297
...
XplicitNgi
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f42c5a4a08 | ||
|
|
4a82c67fdc | ||
|
|
3417a34f37 | ||
|
|
d16bf9e39b | ||
|
|
d12654b4d3 | ||
|
|
5a20b4aefc | ||
|
|
08a3f9f307 | ||
|
|
77ce5c9a5a | ||
|
|
8a097f7eb1 | ||
|
|
e9a13b8163 | ||
|
|
33a43c5072 | ||
|
|
f2347970c4 | ||
|
|
d0b0ffd7f1 | ||
|
|
ab242470b6 | ||
|
|
03eceeae93 | ||
|
|
2919f4ebaa | ||
|
|
1dd930af49 | ||
|
|
98e73cd7ca | ||
|
|
057d86e05a | ||
|
|
89f9e0bfa2 | ||
|
|
61d07a8557 | ||
|
|
948835df98 | ||
|
|
e83a67ade2 | ||
|
|
6ec4ab466d | ||
|
|
f5f5f269d5 | ||
|
|
d492e438d2 | ||
|
|
1700258001 | ||
|
|
ff5b855e12 | ||
|
|
c9bb2ae72b | ||
|
|
5773584f48 | ||
|
|
7e2eb2c694 | ||
|
|
f7d6781698 | ||
|
|
30a05af3b2 | ||
|
|
b1af53995a | ||
|
|
866d644c63 | ||
|
|
1108af7cf3 | ||
|
|
7b4abe3efe | ||
|
|
5dd6ae7d9c | ||
|
|
0566dd0217 | ||
|
|
99d5a1de38 | ||
|
|
5020de484c | ||
|
|
62208a14a5 | ||
|
|
d7b491e073 | ||
|
|
c50d2a8166 | ||
|
|
d2e0b29051 | ||
|
|
4df67897dc | ||
|
|
0f0be7f0b9 | ||
|
|
581f8a3413 | ||
|
|
0174605a3e | ||
|
|
edf1bc701b | ||
|
|
69d55d0a5c | ||
|
|
99ab8e1620 | ||
|
|
ebe7ad682e | ||
|
|
abe406990b | ||
|
|
78c6dec932 | ||
|
|
2c65001536 | ||
|
|
07a2eb4d98 | ||
|
|
ea072e424a | ||
|
|
8b3da447a4 | ||
|
|
77615c5b8f | ||
|
|
dc6c002250 | ||
|
|
70fba67b6e | ||
|
|
1159be9b1b | ||
|
|
6752c5da68 | ||
|
|
77b7c3e62b | ||
|
|
7d7552d141 | ||
|
|
7f7e015706 | ||
|
|
ebbbbb3a69 | ||
|
|
b608a3ab9e | ||
|
|
ccf3ade099 | ||
|
|
3c2ae53449 |
@@ -1,4 +0,0 @@
|
|||||||
#ifndef ACTIONTYPE_H
|
|
||||||
#define ACTIONTYPE_H
|
|
||||||
static enum ActionType {Nothing, Pause, Lose, Draw, Win};
|
|
||||||
#endif
|
|
||||||
@@ -1,4 +0,0 @@
|
|||||||
#ifndef AFFECTTYPE_H
|
|
||||||
#define AFFECTTYPE_H
|
|
||||||
static enum AffectType {NoChange, Increase, Decrease};
|
|
||||||
#endif
|
|
||||||
@@ -1,15 +1,12 @@
|
|||||||
#include "BaseButtonInstance.h"
|
#include "BaseButtonInstance.h"
|
||||||
#include "Globals.h"
|
#include "Globals.h"
|
||||||
|
|
||||||
bool floatBottom = false;
|
|
||||||
bool floatRight = false;
|
|
||||||
bool floatCenter = false;
|
|
||||||
bool disabled = false;
|
|
||||||
bool selected = false;
|
|
||||||
ButtonListener* listener = NULL;
|
ButtonListener* listener = NULL;
|
||||||
|
|
||||||
BaseButtonInstance::BaseButtonInstance(void)
|
BaseButtonInstance::BaseButtonInstance(void)
|
||||||
{
|
{
|
||||||
|
Instance::Instance();
|
||||||
listener = NULL;
|
listener = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ public:
|
|||||||
bool floatBottom;
|
bool floatBottom;
|
||||||
bool floatRight;
|
bool floatRight;
|
||||||
bool floatCenter;
|
bool floatCenter;
|
||||||
bool disabled;
|
volatile bool disabled;
|
||||||
bool selected;
|
bool selected;
|
||||||
protected:
|
protected:
|
||||||
bool mouseInArea(float, float, float, float, float, float);
|
bool mouseInArea(float, float, float, float, float, float);
|
||||||
|
|||||||
@@ -1,4 +0,0 @@
|
|||||||
#ifndef BINTYPE_H
|
|
||||||
#define BINTYPE_H
|
|
||||||
static enum ActionType {GameTool, Grab, Clone, Hammer};
|
|
||||||
#endif
|
|
||||||
@@ -1,24 +1,23 @@
|
|||||||
#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"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
CameraController::CameraController(){
|
CameraController::CameraController() :
|
||||||
yaw=0;
|
yaw(0),
|
||||||
pitch=0;
|
pitch(0),
|
||||||
moveRate=0.5f;
|
moveRate(1.0f),
|
||||||
forwards=false;
|
forwards(false),
|
||||||
backwards=false;
|
backwards(false),
|
||||||
left=false;
|
left(false),
|
||||||
right=false;
|
right(false),
|
||||||
zoom=7.f;
|
zoom(14.f),
|
||||||
rightButtonHolding=false;
|
rightButtonHolding(false),
|
||||||
focusPosition=Vector3(0,0,0);
|
focusPosition(Vector3(0,0,0)) {}
|
||||||
}
|
|
||||||
|
|
||||||
GCamera* CameraController::getCamera()
|
GCamera* CameraController::getCamera()
|
||||||
{
|
{
|
||||||
@@ -139,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)
|
||||||
@@ -209,10 +213,10 @@ void CameraController::update(Demo* demo)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if(GetHoldKeyState(VK_RSHIFT) || GetHoldKeyState(VK_LSHIFT)) {
|
if(GetHoldKeyState(VK_RSHIFT) || GetHoldKeyState(VK_LSHIFT)) {
|
||||||
moveRate = 1;
|
moveRate = 2;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
moveRate = 0.5;
|
moveRate = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(GetHoldKeyState(VK_RBUTTON))
|
if(GetHoldKeyState(VK_RBUTTON))
|
||||||
|
|||||||
@@ -1,4 +0,0 @@
|
|||||||
#ifndef CONTROLLERTYPE_H
|
|
||||||
#define CONTROLLERTYPE_H
|
|
||||||
static enum ControllerType {None, KeyboardRight, KeyboardLeft, Joypad1, Joypad2, Chase, Flee};
|
|
||||||
#endif
|
|
||||||
@@ -1,39 +1,515 @@
|
|||||||
|
#include <string>
|
||||||
#include "DataModelInstance.h"
|
#include "DataModelInstance.h"
|
||||||
|
#include <fstream>
|
||||||
|
#include <iostream>
|
||||||
|
#include <sstream>
|
||||||
|
#include <commdlg.h>
|
||||||
|
|
||||||
|
using namespace std;
|
||||||
|
using namespace rapidxml;
|
||||||
|
|
||||||
|
|
||||||
DataModelInstance::DataModelInstance(void)
|
DataModelInstance::DataModelInstance(void)
|
||||||
{
|
{
|
||||||
|
Instance::Instance();
|
||||||
workspace = new WorkspaceInstance();
|
workspace = new WorkspaceInstance();
|
||||||
guiRoot = new Instance();
|
guiRoot = new Instance();
|
||||||
children.push_back(workspace);
|
level = new LevelInstance();
|
||||||
|
//children.push_back(workspace);
|
||||||
|
//children.push_back(level);
|
||||||
className = "dataModel";
|
className = "dataModel";
|
||||||
mousex = 0;
|
mousex = 0;
|
||||||
mousey = 0;
|
mousey = 0;
|
||||||
mouseButton1Down = false;
|
mouseButton1Down = false;
|
||||||
showMessage = false;
|
showMessage = false;
|
||||||
|
canDelete = false;
|
||||||
|
_modY=0;
|
||||||
|
workspace->setParent(this);
|
||||||
|
level->setParent(this);
|
||||||
|
_loadedFileName="..//skooter.rbxm";
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
DataModelInstance::~DataModelInstance(void)
|
DataModelInstance::~DataModelInstance(void)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef _DEBUG
|
||||||
|
void DataModelInstance::modXMLLevel(float modY)
|
||||||
|
{
|
||||||
|
_modY += modY;
|
||||||
|
clearLevel();
|
||||||
|
debugGetOpen();
|
||||||
|
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
void DataModelInstance::clearLevel()
|
||||||
|
{
|
||||||
|
workspace->clearChildren();
|
||||||
|
}
|
||||||
|
PartInstance* DataModelInstance::makePart()
|
||||||
|
{
|
||||||
|
PartInstance* part = new PartInstance();
|
||||||
|
return part;
|
||||||
|
}
|
||||||
|
|
||||||
|
rapidxml::xml_node<>* DataModelInstance::getNode(xml_node<> * node,const char* name)
|
||||||
|
{
|
||||||
|
xml_node<> * tempNode = node->first_node(name);
|
||||||
|
if (!tempNode)
|
||||||
|
{
|
||||||
|
_errMsg = "Expected <";
|
||||||
|
_errMsg += name;
|
||||||
|
_errMsg+="> tag.";
|
||||||
|
_successfulLoad=true;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
return tempNode;
|
||||||
|
}
|
||||||
|
float DataModelInstance::getFloatValue(xml_node<> * node,const char* name)
|
||||||
|
{
|
||||||
|
xml_node<> * tempNode = node->first_node(name);
|
||||||
|
if (!tempNode)
|
||||||
|
{
|
||||||
|
_errMsg = "Expected <";
|
||||||
|
_errMsg += name;
|
||||||
|
_errMsg+="> tag.";
|
||||||
|
_successfulLoad=true;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
float newFloat;
|
||||||
|
stringstream converter;
|
||||||
|
converter << tempNode->value();
|
||||||
|
converter >> newFloat;
|
||||||
|
return newFloat;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Color3 bcToRGB(short bc)
|
||||||
|
{
|
||||||
|
switch(bc)
|
||||||
|
{
|
||||||
|
case 1: return Color3(0.94901967048645,0.95294123888016,0.95294123888016);
|
||||||
|
case 2: return Color3(0.63137257099152,0.64705884456635,0.63529413938522);
|
||||||
|
case 3: return Color3(0.9764706492424,0.91372555494308,0.60000002384186);
|
||||||
|
case 5: return Color3(0.84313732385635,0.77254909276962,0.60392159223557);
|
||||||
|
case 6: return Color3(0.7607843875885,0.85490202903748,0.72156864404678);
|
||||||
|
case 9: return Color3(0.90980398654938,0.7294117808342,0.78431379795074);
|
||||||
|
case 11: return Color3(0.50196081399918,0.73333334922791,0.85882359743118);
|
||||||
|
case 12: return Color3(0.79607850313187,0.51764708757401,0.258823543787);
|
||||||
|
case 18: return Color3(0.80000007152557,0.55686277151108,0.41176474094391);
|
||||||
|
case 21: return Color3(0.76862752437592,0.15686275064945,0.10980392992496);
|
||||||
|
case 22: return Color3(0.76862752437592,0.43921571969986,0.62745100259781);
|
||||||
|
case 23: return Color3(0.050980396568775,0.41176474094391,0.6745098233223);
|
||||||
|
case 24: return Color3(0.96078437566757,0.80392163991928,0.18823531270027);
|
||||||
|
case 25: return Color3(0.38431376218796,0.27843138575554,0.19607844948769);
|
||||||
|
case 26: return Color3(0.10588236153126,0.16470588743687,0.20784315466881);
|
||||||
|
case 27: return Color3(0.42745101451874,0.43137258291245,0.42352944612503);
|
||||||
|
case 28: return Color3(0.15686275064945,0.49803924560547,0.27843138575554);
|
||||||
|
case 29: return Color3(0.63137257099152,0.76862752437592,0.54901963472366);
|
||||||
|
case 36: return Color3(0.95294123888016,0.8117647767067,0.60784316062927);
|
||||||
|
case 37: return Color3(0.29411765933037,0.59215688705444,0.29411765933037);
|
||||||
|
case 38: return Color3(0.62745100259781,0.37254902720451,0.20784315466881);
|
||||||
|
case 39: return Color3(0.75686281919479,0.79215693473816,0.8705883026123);
|
||||||
|
case 40: return Color3(0.92549026012421,0.92549026012421,0.92549026012421);
|
||||||
|
case 41: return Color3(0.80392163991928,0.32941177487373,0.29411765933037);
|
||||||
|
case 42: return Color3(0.75686281919479,0.87450987100601,0.94117653369904);
|
||||||
|
case 43: return Color3(0.48235297203064,0.71372550725937,0.90980398654938);
|
||||||
|
case 44: return Color3(0.96862751245499,0.94509810209274,0.55294120311737);
|
||||||
|
case 45: return Color3(0.70588237047195,0.82352948188782,0.89411771297455);
|
||||||
|
case 47: return Color3(0.85098046064377,0.52156865596771,0.42352944612503);
|
||||||
|
case 48: return Color3(0.51764708757401,0.71372550725937,0.55294120311737);
|
||||||
|
case 49: return Color3(0.97254908084869,0.94509810209274,0.51764708757401);
|
||||||
|
case 50: return Color3(0.92549026012421,0.90980398654938,0.8705883026123);
|
||||||
|
case 100: return Color3(0.93333339691162,0.76862752437592,0.71372550725937);
|
||||||
|
case 101: return Color3(0.85490202903748,0.52549022436142,0.47843140363693);
|
||||||
|
case 102: return Color3(0.43137258291245,0.60000002384186,0.79215693473816);
|
||||||
|
case 103: return Color3(0.78039222955704,0.75686281919479,0.71764707565308);
|
||||||
|
case 104: return Color3(0.41960787773132,0.19607844948769,0.48627454042435);
|
||||||
|
case 105: return Color3(0.88627457618713,0.60784316062927,0.25098040699959);
|
||||||
|
case 106: return Color3(0.85490202903748,0.52156865596771,0.2549019753933);
|
||||||
|
case 107: return Color3(0,0.56078433990479,0.61176472902298);
|
||||||
|
case 108: return Color3(0.4078431725502,0.36078432202339,0.26274511218071);
|
||||||
|
case 110: return Color3(0.26274511218071,0.32941177487373,0.57647061347961);
|
||||||
|
case 111: return Color3(0.74901962280273,0.71764707565308,0.69411766529083);
|
||||||
|
case 112: return Color3(0.4078431725502,0.45490199327469,0.6745098233223);
|
||||||
|
case 113: return Color3(0.89411771297455,0.678431391716,0.78431379795074);
|
||||||
|
case 115: return Color3(0.78039222955704,0.82352948188782,0.23529413342476);
|
||||||
|
case 116: return Color3(0.33333334326744,0.64705884456635,0.68627452850342);
|
||||||
|
case 118: return Color3(0.71764707565308,0.84313732385635,0.83529418706894);
|
||||||
|
case 119: return Color3(0.64313727617264,0.74117648601532,0.27843138575554);
|
||||||
|
case 120: return Color3(0.85098046064377,0.89411771297455,0.65490198135376);
|
||||||
|
case 121: return Color3(0.90588241815567,0.6745098233223,0.34509804844856);
|
||||||
|
case 123: return Color3(0.82745105028152,0.43529415130615,0.29803922772408);
|
||||||
|
case 124: return Color3(0.57254904508591,0.22352942824364,0.47058826684952);
|
||||||
|
case 125: return Color3(0.91764712333679,0.72156864404678,0.57254904508591);
|
||||||
|
case 126: return Color3(0.64705884456635,0.64705884456635,0.79607850313187);
|
||||||
|
case 127: return Color3(0.86274516582489,0.73725491762161,0.50588238239288);
|
||||||
|
case 128: return Color3(0.68235296010971,0.47843140363693,0.34901961684227);
|
||||||
|
case 131: return Color3(0.61176472902298,0.63921570777893,0.65882354974747);
|
||||||
|
case 133: return Color3(0.83529418706894,0.45098042488098,0.23921570181847);
|
||||||
|
case 134: return Color3(0.84705889225006,0.8666667342186,0.33725491166115);
|
||||||
|
case 135: return Color3(0.45490199327469,0.52549022436142,0.61568629741669);
|
||||||
|
case 136: return Color3(0.52941179275513,0.48627454042435,0.56470590829849);
|
||||||
|
case 137: return Color3(0.87843143939972,0.59607845544815,0.39215689897537);
|
||||||
|
case 138: return Color3(0.58431375026703,0.54117649793625,0.45098042488098);
|
||||||
|
case 140: return Color3(0.12549020349979,0.22745099663734,0.33725491166115);
|
||||||
|
case 141: return Color3(0.15294118225574,0.27450981736183,0.17647059261799);
|
||||||
|
case 143: return Color3(0.8117647767067,0.88627457618713,0.96862751245499);
|
||||||
|
case 145: return Color3(0.47450983524323,0.53333336114883,0.63137257099152);
|
||||||
|
case 146: return Color3(0.58431375026703,0.55686277151108,0.63921570777893);
|
||||||
|
case 147: return Color3(0.57647061347961,0.52941179275513,0.40392160415649);
|
||||||
|
case 148: return Color3(0.34117648005486,0.34509804844856,0.34117648005486);
|
||||||
|
case 149: return Color3(0.086274512112141,0.11372549831867,0.19607844948769);
|
||||||
|
case 150: return Color3(0.67058825492859,0.678431391716,0.6745098233223);
|
||||||
|
case 151: return Color3(0.47058826684952,0.56470590829849,0.50980395078659);
|
||||||
|
case 153: return Color3(0.58431375026703,0.47450983524323,0.46666669845581);
|
||||||
|
case 154: return Color3(0.48235297203064,0.1803921610117,0.1843137294054);
|
||||||
|
case 157: return Color3(1,0.96470594406128,0.48235297203064);
|
||||||
|
case 158: return Color3(0.88235300779343,0.64313727617264,0.7607843875885);
|
||||||
|
case 168: return Color3(0.4588235616684,0.42352944612503,0.38431376218796);
|
||||||
|
case 176: return Color3(0.59215688705444,0.41176474094391,0.35686275362968);
|
||||||
|
case 178: return Color3(0.70588237047195,0.51764708757401,0.33333334326744);
|
||||||
|
case 179: return Color3(0.53725492954254,0.52941179275513,0.53333336114883);
|
||||||
|
case 180: return Color3(0.84313732385635,0.66274511814117,0.29411765933037);
|
||||||
|
case 190: return Color3(0.9764706492424,0.83921575546265,0.1803921610117);
|
||||||
|
case 191: return Color3(0.90980398654938,0.67058825492859,0.17647059261799);
|
||||||
|
case 192: return Color3(0.41176474094391,0.25098040699959,0.15686275064945);
|
||||||
|
case 193: return Color3(0.8117647767067,0.37647062540054,0.14117647707462);
|
||||||
|
case 195: return Color3(0.27450981736183,0.40392160415649,0.64313727617264);
|
||||||
|
case 196: return Color3(0.13725490868092,0.27843138575554,0.54509806632996);
|
||||||
|
case 198: return Color3(0.55686277151108,0.258823543787,0.52156865596771);
|
||||||
|
case 199: return Color3(0.38823533058167,0.37254902720451,0.38431376218796);
|
||||||
|
case 200: return Color3(0.50980395078659,0.54117649793625,0.3647058904171);
|
||||||
|
case 208: return Color3(0.89803928136826,0.89411771297455,0.87450987100601);
|
||||||
|
case 209: return Color3(0.69019609689713,0.55686277151108,0.26666668057442);
|
||||||
|
case 210: return Color3(0.43921571969986,0.58431375026703,0.47058826684952);
|
||||||
|
case 211: return Color3(0.47450983524323,0.70980393886566,0.70980393886566);
|
||||||
|
case 212: return Color3(0.6235294342041,0.76470595598221,0.91372555494308);
|
||||||
|
case 213: return Color3(0.42352944612503,0.50588238239288,0.71764707565308);
|
||||||
|
case 216: return Color3(0.56078433990479,0.29803922772408,0.16470588743687);
|
||||||
|
case 217: return Color3(0.48627454042435,0.36078432202339,0.27450981736183);
|
||||||
|
case 218: return Color3(0.58823531866074,0.43921571969986,0.6235294342041);
|
||||||
|
case 219: return Color3(0.41960787773132,0.38431376218796,0.60784316062927);
|
||||||
|
case 220: return Color3(0.65490198135376,0.66274511814117,0.80784320831299);
|
||||||
|
case 221: return Color3(0.80392163991928,0.38431376218796,0.59607845544815);
|
||||||
|
case 222: return Color3(0.89411771297455,0.678431391716,0.78431379795074);
|
||||||
|
case 223: return Color3(0.86274516582489,0.56470590829849,0.58431375026703);
|
||||||
|
case 224: return Color3(0.94117653369904,0.83529418706894,0.62745100259781);
|
||||||
|
case 225: return Color3(0.9215686917305,0.72156864404678,0.49803924560547);
|
||||||
|
case 226: return Color3(0.99215692281723,0.91764712333679,0.55294120311737);
|
||||||
|
case 232: return Color3(0.49019610881805,0.73333334922791,0.8666667342186);
|
||||||
|
case 268: return Color3(0.2039215862751,0.16862745583057,0.4588235616684);
|
||||||
|
case 1001: return Color3(0.97254908084869,0.97254908084869,0.97254908084869);
|
||||||
|
case 1002: return Color3(0.80392163991928,0.80392163991928,0.80392163991928);
|
||||||
|
case 1003: return Color3(0.066666670143604,0.066666670143604,0.066666670143604);
|
||||||
|
case 1004: return Color3(1,0,0);
|
||||||
|
case 1005: return Color3(1,0.68627452850342,0);
|
||||||
|
case 1006: return Color3(0.70588237047195,0.50196081399918,1);
|
||||||
|
case 1007: return Color3(0.63921570777893,0.29411765933037,0.29411765933037);
|
||||||
|
case 1008: return Color3(0.75686281919479,0.74509805440903,0.258823543787);
|
||||||
|
case 1009: return Color3(1,1,0);
|
||||||
|
case 1010: return Color3(0,0,1);
|
||||||
|
case 1011: return Color3(0,0.12549020349979,0.37647062540054);
|
||||||
|
case 1012: return Color3(0.1294117718935,0.32941177487373,0.72549021244049);
|
||||||
|
case 1013: return Color3(0.015686275437474,0.68627452850342,0.92549026012421);
|
||||||
|
case 1014: return Color3(0.66666668653488,0.33333334326744,0);
|
||||||
|
case 1015: return Color3(0.66666668653488,0,0.66666668653488);
|
||||||
|
case 1016: return Color3(1,0.40000003576279,0.80000007152557);
|
||||||
|
case 1017: return Color3(1,0.68627452850342,0);
|
||||||
|
case 1018: return Color3(0.070588238537312,0.93333339691162,0.83137261867523);
|
||||||
|
case 1019: return Color3(0,1,1);
|
||||||
|
case 1020: return Color3(0,1,0);
|
||||||
|
case 1021: return Color3(0.22745099663734,0.49019610881805,0.082352943718433);
|
||||||
|
case 1022: return Color3(0.49803924560547,0.55686277151108,0.39215689897537);
|
||||||
|
case 1023: return Color3(0.54901963472366,0.35686275362968,0.6235294342041);
|
||||||
|
case 1024: return Color3(0.68627452850342,0.8666667342186,1);
|
||||||
|
case 1025: return Color3(1,0.78823536634445,0.78823536634445);
|
||||||
|
case 1026: return Color3(0.69411766529083,0.65490198135376,1);
|
||||||
|
case 1027: return Color3(0.6235294342041,0.95294123888016,0.91372555494308);
|
||||||
|
case 1028: return Color3(0.80000007152557,1,0.80000007152557);
|
||||||
|
case 1029: return Color3(1,1,0.80000007152557);
|
||||||
|
case 1030: return Color3(1,0.80000007152557,0.60000002384186);
|
||||||
|
case 1031: return Color3(0.38431376218796,0.14509804546833,0.81960791349411);
|
||||||
|
case 1032: return Color3(1,0,0.74901962280273);
|
||||||
|
default: return Color3::gray();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
bool DataModelInstance::scanXMLObject(xml_node<> * scanNode)
|
||||||
|
{
|
||||||
|
xml_node<> * watchFirstNode = scanNode->first_node();
|
||||||
|
|
||||||
|
for (xml_node<> *node = scanNode->first_node();node; node = node->next_sibling())
|
||||||
|
{
|
||||||
|
|
||||||
|
if (strncmp(node->name(),"Item",4)==0)
|
||||||
|
{
|
||||||
|
xml_attribute<> *classAttr = node->first_attribute("class");
|
||||||
|
std::string className = classAttr->value();
|
||||||
|
if (className=="Part") {
|
||||||
|
xml_node<> *propNode = node->first_node();
|
||||||
|
xml_node<> *cFrameNode=0;
|
||||||
|
xml_node<> *sizeNode=0;
|
||||||
|
xml_node<> *colorNode=0;
|
||||||
|
xml_node<> *brickColorNode=0;
|
||||||
|
xml_node<> *nameNode=0;
|
||||||
|
|
||||||
|
for (xml_node<> *partPropNode = propNode->first_node();partPropNode; partPropNode = partPropNode->next_sibling())
|
||||||
|
{
|
||||||
|
for (xml_attribute<> *attr = partPropNode->first_attribute();attr; attr = attr->next_attribute())
|
||||||
|
{
|
||||||
|
std::string xmlName = attr->name();
|
||||||
|
std::string xmlValue = attr->value();
|
||||||
|
|
||||||
|
if (xmlValue=="CFrame" | xmlValue=="CoordinateFrame")
|
||||||
|
{
|
||||||
|
cFrameNode = partPropNode;
|
||||||
|
}
|
||||||
|
if (xmlValue=="Name")
|
||||||
|
{
|
||||||
|
nameNode = partPropNode;
|
||||||
|
}
|
||||||
|
if (xmlValue=="Color")
|
||||||
|
{
|
||||||
|
colorNode=partPropNode;
|
||||||
|
}
|
||||||
|
if (xmlValue=="BrickColor")
|
||||||
|
{
|
||||||
|
brickColorNode=partPropNode;
|
||||||
|
}
|
||||||
|
if (xmlValue=="size")
|
||||||
|
{
|
||||||
|
sizeNode = partPropNode;
|
||||||
|
_legacyLoad=false;
|
||||||
|
}
|
||||||
|
if (xmlValue=="Part")
|
||||||
|
{
|
||||||
|
for (xml_node<> *featureNode = partPropNode->first_node();featureNode; featureNode = featureNode->next_sibling())
|
||||||
|
{
|
||||||
|
for (xml_attribute<> *attr = featureNode->first_attribute();attr; attr = attr->next_attribute())
|
||||||
|
{
|
||||||
|
std::string xmlName = attr->name();
|
||||||
|
std::string xmlValue = attr->value();
|
||||||
|
if (xmlValue=="size")
|
||||||
|
{
|
||||||
|
sizeNode=featureNode;
|
||||||
|
_legacyLoad=true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!cFrameNode) {
|
||||||
|
_errMsg="CFrame is missing in Part";
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (!sizeNode) {
|
||||||
|
_errMsg="Size is missing in Part";
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
float R=1;
|
||||||
|
float G=1;
|
||||||
|
float B=1;
|
||||||
|
|
||||||
|
if (colorNode)
|
||||||
|
{
|
||||||
|
R = getFloatValue(colorNode,"R");
|
||||||
|
G = getFloatValue(colorNode,"G");
|
||||||
|
B = getFloatValue(colorNode,"B");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
std::string newName = nameNode->value();
|
||||||
|
float X = getFloatValue(cFrameNode,"X");
|
||||||
|
float Y = getFloatValue(cFrameNode,"Y");
|
||||||
|
float Z = getFloatValue(cFrameNode,"Z");
|
||||||
|
float R00 = getFloatValue(cFrameNode,"R00");
|
||||||
|
float R01 = getFloatValue(cFrameNode,"R01");
|
||||||
|
float R02 = getFloatValue(cFrameNode,"R02");
|
||||||
|
float R10 = getFloatValue(cFrameNode,"R10");
|
||||||
|
float R11 = getFloatValue(cFrameNode,"R11");
|
||||||
|
float R12 = getFloatValue(cFrameNode,"R12");
|
||||||
|
float R20 = getFloatValue(cFrameNode,"R20");
|
||||||
|
float R21 = getFloatValue(cFrameNode,"R21");
|
||||||
|
float R22 = getFloatValue(cFrameNode,"R22");
|
||||||
|
|
||||||
|
float sizeX = getFloatValue(sizeNode,"X");
|
||||||
|
float sizeY = getFloatValue(sizeNode,"Y");
|
||||||
|
float sizeZ = getFloatValue(sizeNode,"Z");
|
||||||
|
//sizeX=1;
|
||||||
|
//sizeY=1;
|
||||||
|
//sizeZ=1;
|
||||||
|
if (_successfulLoad) {
|
||||||
|
PartInstance* test = makePart();
|
||||||
|
test->setParent(getWorkspace());
|
||||||
|
test->color = Color3(R,G,B);
|
||||||
|
if(brickColorNode)
|
||||||
|
{
|
||||||
|
test->color = bcToRGB(atoi(brickColorNode->value()));
|
||||||
|
}
|
||||||
|
test->setSize(Vector3(sizeX,sizeY+_modY,sizeZ));
|
||||||
|
test->setName(newName);
|
||||||
|
CoordinateFrame cf;
|
||||||
|
|
||||||
|
if (_legacyLoad)
|
||||||
|
{
|
||||||
|
|
||||||
|
cf = CoordinateFrame(Vector3(-X,Y,Z))*CoordinateFrame(Vector3(-sizeX/2,(sizeY+_modY)/2,sizeZ/2)*Matrix3(R00,R01,R02,R10,R11,R12,R20,R21,R22));
|
||||||
|
cf.rotation = Matrix3(R00,R01,R02,R10,R11,R12,R20,R21,R22);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
cf.translation = Vector3(X,Y,Z);
|
||||||
|
cf.rotation = Matrix3(R00,R01,R02,R10,R11,R12,R20,R21,R22);
|
||||||
|
}
|
||||||
|
|
||||||
|
test->setCFrame(cf);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/*
|
||||||
|
for (xml_attribute<> *attr = node->first_attribute();attr; attr = attr->next_attribute())
|
||||||
|
{
|
||||||
|
std::string xmlName = attr->name();
|
||||||
|
std::string xmlValue = attr->value();
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
scanXMLObject(node);
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool DataModelInstance::load(const char* filename, bool clearObjects)
|
||||||
|
{
|
||||||
|
ifstream levelFile(filename,ios::binary);
|
||||||
|
if (levelFile)
|
||||||
|
{
|
||||||
|
if (clearObjects)
|
||||||
|
clearLevel();
|
||||||
|
readXMLFileStream(&levelFile);
|
||||||
|
std::string sfilename = std::string(filename);
|
||||||
|
std::size_t begin = sfilename.rfind('\\') + 1;
|
||||||
|
std::size_t end = sfilename.find(".rbx");
|
||||||
|
std::string hname = sfilename.substr(begin);
|
||||||
|
std::string tname = hname.substr(0, hname.length() - 5);
|
||||||
|
name = tname;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
bool DataModelInstance::readXMLFileStream(std::ifstream* file)
|
||||||
|
{
|
||||||
|
file->seekg(0,file->end);
|
||||||
|
int length = file->tellg();
|
||||||
|
file->seekg(0,file->beg);
|
||||||
|
char * buffer = new char[length+1];
|
||||||
|
buffer[length]=0;
|
||||||
|
file->read(buffer,length);
|
||||||
|
file->close();
|
||||||
|
xml_document<> doc;
|
||||||
|
doc.parse<0>(buffer);
|
||||||
|
xml_node<> *mainNode = doc.first_node();
|
||||||
|
_legacyLoad=false;
|
||||||
|
//std::string xmlName = mainNode->name();
|
||||||
|
//node = node->first_node();
|
||||||
|
//xmlName = node->name();
|
||||||
|
scanXMLObject(mainNode);
|
||||||
|
delete[] buffer;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool DataModelInstance::debugGetOpen()
|
||||||
|
{
|
||||||
|
ifstream levelFile(_loadedFileName.c_str(),ios::binary);
|
||||||
|
if (levelFile)
|
||||||
|
readXMLFileStream(&levelFile);
|
||||||
|
else
|
||||||
|
getOpen();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool DataModelInstance::getOpen()
|
||||||
|
{
|
||||||
|
_modY=0;
|
||||||
|
OPENFILENAME of;
|
||||||
|
ZeroMemory( &of , sizeof( of));
|
||||||
|
of.lStructSize = sizeof(OPENFILENAME);
|
||||||
|
of.lpstrFilter = "Roblox Files\0*.rbxm;*.rbxl\0\0";
|
||||||
|
char szFile[512];
|
||||||
|
of.lpstrFile = szFile ;
|
||||||
|
of.lpstrFile[0]='\0';
|
||||||
|
of.nMaxFile=500;
|
||||||
|
of.lpstrTitle="Hello";
|
||||||
|
of.Flags = OFN_FILEMUSTEXIST;
|
||||||
|
ShowCursor(TRUE);
|
||||||
|
BOOL file = GetOpenFileName(&of);
|
||||||
|
if (file)
|
||||||
|
{
|
||||||
|
_loadedFileName = of.lpstrFile;
|
||||||
|
load(of.lpstrFile,true);
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
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;
|
||||||
@@ -67,3 +543,9 @@ Instance* DataModelInstance::getGuiRoot()
|
|||||||
{
|
{
|
||||||
return guiRoot;
|
return guiRoot;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
LevelInstance* DataModelInstance::getLevel()
|
||||||
|
{
|
||||||
|
return level;
|
||||||
|
}
|
||||||
@@ -1,6 +1,8 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
#include "instance.h"
|
|
||||||
#include "WorkspaceInstance.h"
|
#include "WorkspaceInstance.h"
|
||||||
|
#include "LevelInstance.h"
|
||||||
|
#include "PartInstance.h"
|
||||||
|
#include "rapidxml/rapidxml.hpp"
|
||||||
|
|
||||||
class DataModelInstance :
|
class DataModelInstance :
|
||||||
public Instance
|
public Instance
|
||||||
@@ -8,20 +10,42 @@ class DataModelInstance :
|
|||||||
public:
|
public:
|
||||||
DataModelInstance(void);
|
DataModelInstance(void);
|
||||||
~DataModelInstance(void);
|
~DataModelInstance(void);
|
||||||
void setMessage(std::string);
|
void setMessage(std::string);
|
||||||
void clearMessage();
|
void setMessageBrickCount();
|
||||||
void drawMessage(RenderDevice*);
|
void clearMessage();
|
||||||
WorkspaceInstance* getWorkspace();
|
bool debugGetOpen();
|
||||||
WorkspaceInstance* workspace;
|
bool getOpen();
|
||||||
Instance* guiRoot;
|
bool load(const char* filename,bool clearObjects);
|
||||||
std::string message;
|
bool readXMLFileStream(std::ifstream* file);
|
||||||
bool showMessage;
|
void drawMessage(RenderDevice*);
|
||||||
G3D::GFontRef font;
|
WorkspaceInstance* getWorkspace();
|
||||||
Instance* getGuiRoot();
|
WorkspaceInstance* workspace;
|
||||||
float mousex;
|
LevelInstance * level;
|
||||||
float mousey;
|
LevelInstance * getLevel();
|
||||||
Vector2 getMousePos();
|
Instance* guiRoot;
|
||||||
void setMousePos(int x,int y);
|
std::string message;
|
||||||
void setMousePos(Vector2 pos);
|
std::string _loadedFileName;
|
||||||
bool mouseButton1Down;
|
bool showMessage;
|
||||||
|
G3D::GFontRef font;
|
||||||
|
Instance* getGuiRoot();
|
||||||
|
float mousex;
|
||||||
|
float mousey;
|
||||||
|
Vector2 getMousePos();
|
||||||
|
void setMousePos(int x,int y);
|
||||||
|
void setMousePos(Vector2 pos);
|
||||||
|
bool mouseButton1Down;
|
||||||
|
PartInstance* makePart();
|
||||||
|
void clearLevel();
|
||||||
|
#if _DEBUG
|
||||||
|
void modXMLLevel(float modY);
|
||||||
|
#endif
|
||||||
|
private:
|
||||||
|
bool isBrickCount;
|
||||||
|
bool scanXMLObject(rapidxml::xml_node<>* node);
|
||||||
|
rapidxml::xml_node<>* getNode(rapidxml::xml_node<> * node,const char* name );
|
||||||
|
float getFloatValue(rapidxml::xml_node<> * node,const char* name);
|
||||||
|
bool _successfulLoad;
|
||||||
|
std::string _errMsg;
|
||||||
|
bool _legacyLoad;
|
||||||
|
float _modY;
|
||||||
};
|
};
|
||||||
|
|||||||
5
Demo.h
5
Demo.h
@@ -34,6 +34,8 @@ class Demo { // : public GApp {
|
|||||||
CameraController cameraController;
|
CameraController cameraController;
|
||||||
RenderDevice* renderDevice;
|
RenderDevice* renderDevice;
|
||||||
UserInput* userInput;
|
UserInput* userInput;
|
||||||
|
PropertyWindow* _propWindow;
|
||||||
|
void generateShadowMap(const CoordinateFrame& lightViewMatrix) const;
|
||||||
private:
|
private:
|
||||||
void initGUI();
|
void initGUI();
|
||||||
HWND _hWndMain;
|
HWND _hWndMain;
|
||||||
@@ -46,7 +48,8 @@ class Demo { // : public GApp {
|
|||||||
HWND _hwndToolbox;
|
HWND _hwndToolbox;
|
||||||
HWND _buttonTest;
|
HWND _buttonTest;
|
||||||
HWND _hwndRenderer;
|
HWND _hwndRenderer;
|
||||||
PropertyWindow* _propWindow;
|
G3D::TextureRef shadowMap;
|
||||||
|
double lightProjX, lightProjY, lightProjNear, lightProjFar;
|
||||||
protected:
|
protected:
|
||||||
Stopwatch m_graphicsWatch;
|
Stopwatch m_graphicsWatch;
|
||||||
Stopwatch m_logicWatch;
|
Stopwatch m_logicWatch;
|
||||||
|
|||||||
BIN
Dialogs.aps
BIN
Dialogs.aps
Binary file not shown.
@@ -67,6 +67,13 @@ LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_CAN
|
|||||||
// Icon with lowest ID value placed first to ensure application icon
|
// Icon with lowest ID value placed first to ensure application icon
|
||||||
// remains consistent on all systems.
|
// remains consistent on all systems.
|
||||||
IDI_ICON1 ICON "icon1.ico"
|
IDI_ICON1 ICON "icon1.ico"
|
||||||
|
|
||||||
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
|
// Bitmap
|
||||||
|
//
|
||||||
|
|
||||||
|
IDB_BITMAP1 BITMAP "Parts.bmp"
|
||||||
#endif // English (Canada) resources
|
#endif // English (Canada) resources
|
||||||
/////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
|||||||
17
Enum.h
Normal file
17
Enum.h
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
namespace Enum
|
||||||
|
{
|
||||||
|
namespace SurfaceType
|
||||||
|
{
|
||||||
|
enum Value {
|
||||||
|
Smooth, Bumps, Welds, Glue
|
||||||
|
};
|
||||||
|
}
|
||||||
|
namespace Shape
|
||||||
|
{
|
||||||
|
enum Value {
|
||||||
|
Block, Sphere, Cylinder
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
14
Enums.h
Normal file
14
Enums.h
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
#ifndef ENUM_H
|
||||||
|
#define ENUM_H
|
||||||
|
static enum BinType {GameTool, Grab, Clone, Hammer};
|
||||||
|
static enum ControllerType {None, KeyboardRight, KeyboardLeft, Joypad1, Joypad2, Chase, Flee};
|
||||||
|
//static enum JointType {UNK0, WeldJoint, SnapJoint, UNK3, Rotate, RotateP, RotateV, GlueJoint, UNK8, UNK9, None};
|
||||||
|
static enum ActionType {Nothing, Pause, Lose, Draw, Win};
|
||||||
|
static enum AffectType {NoChange, Increase, Decrease};
|
||||||
|
static enum InputType {NoInput, LeftTread, RightTread, Steer, Throtle, UpDown, Action1, Action2, Action3, Action4, Action5, Constant, Sin};
|
||||||
|
//static enum SurfaceConstraint {None, Hinge, SteppingMotor, Motor};
|
||||||
|
static enum SurfaceType{Smooth, Snaps, Inlets, Glue, Weld, Spawn, Hinge, Motor, Bumps};
|
||||||
|
static enum SoundType {NoSound, Boing, Bomb, Break, Click, Clock, Slingshot, Page, Ping, Snap, Splat, Step, StepOn, Swoosh, Victory};
|
||||||
|
static enum PartType {Ball, Block, Cylinder};
|
||||||
|
static enum KeywordFilterType {Include, Exclude};
|
||||||
|
#endif
|
||||||
102
G3DTest.vcproj
102
G3DTest.vcproj
@@ -3,7 +3,7 @@
|
|||||||
ProjectType="Visual C++"
|
ProjectType="Visual C++"
|
||||||
Version="8.00"
|
Version="8.00"
|
||||||
Name="G3DTest"
|
Name="G3DTest"
|
||||||
ProjectGUID="{6C4D6EEF-B1D1-456A-B850-92CAB17124BE}"
|
ProjectGUID="{277D185B-AEBA-4F75-A7FC-F1EBE787C200}"
|
||||||
RootNamespace="G3DTest"
|
RootNamespace="G3DTest"
|
||||||
>
|
>
|
||||||
<Platforms>
|
<Platforms>
|
||||||
@@ -258,6 +258,10 @@
|
|||||||
RelativePath=".\Globals.cpp"
|
RelativePath=".\Globals.cpp"
|
||||||
>
|
>
|
||||||
</File>
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath=".\GroupInstance.cpp"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
<File
|
<File
|
||||||
RelativePath=".\IEBrowser.cpp"
|
RelativePath=".\IEBrowser.cpp"
|
||||||
>
|
>
|
||||||
@@ -270,6 +274,10 @@
|
|||||||
RelativePath=".\IEDispatcher.cpp"
|
RelativePath=".\IEDispatcher.cpp"
|
||||||
>
|
>
|
||||||
</File>
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath=".\LevelInstance.cpp"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
<File
|
<File
|
||||||
RelativePath="main.cpp"
|
RelativePath="main.cpp"
|
||||||
>
|
>
|
||||||
@@ -290,6 +298,10 @@
|
|||||||
/>
|
/>
|
||||||
</FileConfiguration>
|
</FileConfiguration>
|
||||||
</File>
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath=".\PartInstance.cpp"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
<File
|
<File
|
||||||
RelativePath=".\propertyGrid.cpp"
|
RelativePath=".\propertyGrid.cpp"
|
||||||
>
|
>
|
||||||
@@ -298,6 +310,10 @@
|
|||||||
RelativePath=".\PropertyWindow.cpp"
|
RelativePath=".\PropertyWindow.cpp"
|
||||||
>
|
>
|
||||||
</File>
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath=".\PVInstance.cpp"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
<File
|
<File
|
||||||
RelativePath=".\WindowFunctions.cpp"
|
RelativePath=".\WindowFunctions.cpp"
|
||||||
>
|
>
|
||||||
@@ -321,10 +337,6 @@
|
|||||||
RelativePath=".\Instance.cpp"
|
RelativePath=".\Instance.cpp"
|
||||||
>
|
>
|
||||||
</File>
|
</File>
|
||||||
<File
|
|
||||||
RelativePath=".\PhysicalInstance.cpp"
|
|
||||||
>
|
|
||||||
</File>
|
|
||||||
<File
|
<File
|
||||||
RelativePath=".\TextButtonInstance.cpp"
|
RelativePath=".\TextButtonInstance.cpp"
|
||||||
>
|
>
|
||||||
@@ -339,14 +351,6 @@
|
|||||||
Name="Header Files"
|
Name="Header Files"
|
||||||
Filter="h;hpp;hxx;hm;inl"
|
Filter="h;hpp;hxx;hm;inl"
|
||||||
>
|
>
|
||||||
<File
|
|
||||||
RelativePath=".\ActionType.h"
|
|
||||||
>
|
|
||||||
</File>
|
|
||||||
<File
|
|
||||||
RelativePath=".\AffectType.h"
|
|
||||||
>
|
|
||||||
</File>
|
|
||||||
<File
|
<File
|
||||||
RelativePath=".\AudioPlayer.h"
|
RelativePath=".\AudioPlayer.h"
|
||||||
>
|
>
|
||||||
@@ -355,10 +359,6 @@
|
|||||||
RelativePath=".\ax.h"
|
RelativePath=".\ax.h"
|
||||||
>
|
>
|
||||||
</File>
|
</File>
|
||||||
<File
|
|
||||||
RelativePath=".\BinType.h"
|
|
||||||
>
|
|
||||||
</File>
|
|
||||||
<File
|
<File
|
||||||
RelativePath=".\BrowserCallHandler.h"
|
RelativePath=".\BrowserCallHandler.h"
|
||||||
>
|
>
|
||||||
@@ -372,35 +372,35 @@
|
|||||||
>
|
>
|
||||||
</File>
|
</File>
|
||||||
<File
|
<File
|
||||||
RelativePath=".\ControllerType.h"
|
RelativePath=".\Demo.h"
|
||||||
>
|
>
|
||||||
</File>
|
</File>
|
||||||
<File
|
<File
|
||||||
RelativePath=".\Demo.h"
|
RelativePath=".\Enum.h"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath=".\Enums.h"
|
||||||
>
|
>
|
||||||
</File>
|
</File>
|
||||||
<File
|
<File
|
||||||
RelativePath=".\Globals.h"
|
RelativePath=".\Globals.h"
|
||||||
>
|
>
|
||||||
</File>
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath=".\GroupInstance.h"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
<File
|
<File
|
||||||
RelativePath=".\IEDispatcher.h"
|
RelativePath=".\IEDispatcher.h"
|
||||||
>
|
>
|
||||||
</File>
|
</File>
|
||||||
<File
|
<File
|
||||||
RelativePath=".\InputType.h"
|
RelativePath=".\LevelInstance.h"
|
||||||
>
|
>
|
||||||
</File>
|
</File>
|
||||||
<File
|
<File
|
||||||
RelativePath=".\JointType.h"
|
RelativePath=".\PartInstance.h"
|
||||||
>
|
|
||||||
</File>
|
|
||||||
<File
|
|
||||||
RelativePath=".\KeywordFilterType.h"
|
|
||||||
>
|
|
||||||
</File>
|
|
||||||
<File
|
|
||||||
RelativePath=".\PartType.h"
|
|
||||||
>
|
>
|
||||||
</File>
|
</File>
|
||||||
<File
|
<File
|
||||||
@@ -411,26 +411,30 @@
|
|||||||
RelativePath=".\PropertyWindow.h"
|
RelativePath=".\PropertyWindow.h"
|
||||||
>
|
>
|
||||||
</File>
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath=".\PVInstance.h"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath=".\rapidxml\rapidxml.hpp"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath=".\rapidxml\rapidxml_iterators.hpp"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath=".\rapidxml\rapidxml_print.hpp"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath=".\rapidxml\rapidxml_utils.hpp"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
<File
|
<File
|
||||||
RelativePath=".\resource.h"
|
RelativePath=".\resource.h"
|
||||||
>
|
>
|
||||||
</File>
|
</File>
|
||||||
<File
|
|
||||||
RelativePath=".\SoundType.h"
|
|
||||||
>
|
|
||||||
</File>
|
|
||||||
<File
|
|
||||||
RelativePath=".\Surface.h"
|
|
||||||
>
|
|
||||||
</File>
|
|
||||||
<File
|
|
||||||
RelativePath=".\SurfaceConstraint.h"
|
|
||||||
>
|
|
||||||
</File>
|
|
||||||
<File
|
|
||||||
RelativePath=".\SurfaceType.h"
|
|
||||||
>
|
|
||||||
</File>
|
|
||||||
<File
|
<File
|
||||||
RelativePath=".\win32Defines.h"
|
RelativePath=".\win32Defines.h"
|
||||||
>
|
>
|
||||||
@@ -458,10 +462,6 @@
|
|||||||
RelativePath=".\Instance.h"
|
RelativePath=".\Instance.h"
|
||||||
>
|
>
|
||||||
</File>
|
</File>
|
||||||
<File
|
|
||||||
RelativePath=".\PhysicalInstance.h"
|
|
||||||
>
|
|
||||||
</File>
|
|
||||||
<File
|
<File
|
||||||
RelativePath=".\TextButtonInstance.h"
|
RelativePath=".\TextButtonInstance.h"
|
||||||
>
|
>
|
||||||
@@ -484,6 +484,10 @@
|
|||||||
RelativePath=".\icon1.ico"
|
RelativePath=".\icon1.ico"
|
||||||
>
|
>
|
||||||
</File>
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath=".\Parts.bmp"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
</Filter>
|
</Filter>
|
||||||
</Files>
|
</Files>
|
||||||
<Globals>
|
<Globals>
|
||||||
|
|||||||
@@ -8,10 +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*>();
|
||||||
|
bool running = false;
|
||||||
G3D::TextureRef Globals::surface;
|
G3D::TextureRef Globals::surface;
|
||||||
POINT Globals::mousepoint;
|
POINT Globals::mousepoint;
|
||||||
Globals::Globals(void){}
|
Globals::Globals(void){}
|
||||||
|
|||||||
@@ -19,3 +19,7 @@ public:
|
|||||||
static int surfaceId;
|
static int surfaceId;
|
||||||
static const std::string PlaceholderName;
|
static const std::string PlaceholderName;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
extern std::vector<Instance*> postRenderStack;
|
||||||
|
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);
|
||||||
|
};
|
||||||
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
ImageButtonInstance::ImageButtonInstance(G3D::TextureRef newImage, G3D::TextureRef overImage = NULL, G3D::TextureRef downImage = NULL, G3D::TextureRef disableImage = NULL)
|
ImageButtonInstance::ImageButtonInstance(G3D::TextureRef newImage, G3D::TextureRef overImage = NULL, G3D::TextureRef downImage = NULL, G3D::TextureRef disableImage = NULL)
|
||||||
{
|
{
|
||||||
|
BaseButtonInstance::BaseButtonInstance();
|
||||||
image = newImage;
|
image = newImage;
|
||||||
openGLID = image->getOpenGLID();
|
openGLID = image->getOpenGLID();
|
||||||
image_ovr = overImage;
|
image_ovr = overImage;
|
||||||
@@ -85,7 +85,7 @@ void ImageButtonInstance::drawObj(RenderDevice* rd, Vector2 mousePos, bool mouse
|
|||||||
positionRelative = Vector2(rd->getWidth() + position.x, position.y);
|
positionRelative = Vector2(rd->getWidth() + position.x, position.y);
|
||||||
}
|
}
|
||||||
int renderimage = openGLID;
|
int renderimage = openGLID;
|
||||||
if(selected == true && !image_dn.isNull())
|
if(selected == true && !image_dn.isNull() && !disabled)
|
||||||
{
|
{
|
||||||
renderimage = openGLID_dn;
|
renderimage = openGLID_dn;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +0,0 @@
|
|||||||
#ifndef INPUTTYPE_H
|
|
||||||
#define INPUTTYPE_H
|
|
||||||
static enum InputType {NoInput, LeftTread, RightTread, Steer, Throtle, UpDown, Action1, Action2, Action3, Action4, Action5, Constant, Sin};
|
|
||||||
#endif
|
|
||||||
32
Instance.cpp
32
Instance.cpp
@@ -8,23 +8,34 @@ Instance::Instance(void)
|
|||||||
parent = NULL;
|
parent = NULL;
|
||||||
name = "Default Game Instance";
|
name = "Default Game Instance";
|
||||||
className = "BaseInstance";
|
className = "BaseInstance";
|
||||||
|
listicon = 0;
|
||||||
|
canDelete = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
Instance::Instance(const Instance &oinst)
|
Instance::Instance(const Instance &oinst)
|
||||||
{
|
{
|
||||||
setParent(oinst.parent);
|
|
||||||
name = oinst.name;
|
name = oinst.name;
|
||||||
className = oinst.className;
|
className = oinst.className;
|
||||||
|
canDelete = oinst.canDelete;
|
||||||
|
//setParent(oinst.parent);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void Instance::render(RenderDevice* rd)
|
void Instance::render(RenderDevice* rd)
|
||||||
{
|
{
|
||||||
|
glEnableClientState(GL_VERTEX_ARRAY);
|
||||||
|
glEnableClientState(GL_COLOR_ARRAY);
|
||||||
|
glEnableClientState(GL_NORMAL_ARRAY);
|
||||||
|
|
||||||
for(size_t i = 0; i < children.size(); i++)
|
for(size_t i = 0; i < children.size(); i++)
|
||||||
{
|
{
|
||||||
children.at(i)->render(rd);
|
children.at(i)->render(rd);
|
||||||
}
|
}
|
||||||
|
glDisableClientState(GL_VERTEX_ARRAY);
|
||||||
|
glDisableClientState(GL_COLOR_ARRAY);
|
||||||
|
glDisableClientState(GL_NORMAL_ARRAY);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -45,7 +56,7 @@ void Instance::PropUpdate(LPPROPGRIDITEM &item)
|
|||||||
{
|
{
|
||||||
if(strcmp(item->lpszPropName, "Name") == 0)
|
if(strcmp(item->lpszPropName, "Name") == 0)
|
||||||
{
|
{
|
||||||
name = item->lpCurValue;
|
name = (LPSTR)item->lpCurValue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -74,6 +85,11 @@ Instance::~Instance(void)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Instance::setName(std::string newName)
|
||||||
|
{
|
||||||
|
name = newName;
|
||||||
|
}
|
||||||
|
|
||||||
std::string Instance::getClassName()
|
std::string Instance::getClassName()
|
||||||
{
|
{
|
||||||
return className;
|
return className;
|
||||||
@@ -123,6 +139,10 @@ void Instance::addChild(Instance* newChild)
|
|||||||
children.push_back(newChild);
|
children.push_back(newChild);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Instance::clearChildren()
|
||||||
|
{
|
||||||
|
children.clear();
|
||||||
|
}
|
||||||
void Instance::removeChild(Instance* oldChild)
|
void Instance::removeChild(Instance* oldChild)
|
||||||
{
|
{
|
||||||
for(size_t i = 0; i < children.size(); i++)
|
for(size_t i = 0; i < children.size(); i++)
|
||||||
@@ -136,16 +156,14 @@ void Instance::removeChild(Instance* oldChild)
|
|||||||
|
|
||||||
Instance* Instance::findFirstChild(std::string name)
|
Instance* Instance::findFirstChild(std::string name)
|
||||||
{
|
{
|
||||||
Instance* child = NULL;
|
|
||||||
for(size_t i = 0; i < children.size(); i++)
|
for(size_t i = 0; i < children.size(); i++)
|
||||||
{
|
{
|
||||||
if(children.at(i)->name == name)
|
if(children.at(i)->name.compare(name) == 0)
|
||||||
{
|
{
|
||||||
child = children.at(i);
|
return children.at(i);
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return child;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -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);
|
||||||
@@ -16,12 +17,15 @@ public:
|
|||||||
std::vector<Instance* > getChildren();
|
std::vector<Instance* > getChildren();
|
||||||
std::vector<Instance* > getAllChildren();
|
std::vector<Instance* > getAllChildren();
|
||||||
void setParent(Instance*);
|
void setParent(Instance*);
|
||||||
|
void setName(std::string newName);
|
||||||
void addChild(Instance*);
|
void addChild(Instance*);
|
||||||
void removeChild(Instance*);
|
void removeChild(Instance*);
|
||||||
|
void clearChildren();
|
||||||
Instance* getParent();
|
Instance* getParent();
|
||||||
virtual Instance* clone() const { return new Instance(*this); }
|
virtual Instance* clone() const { return new Instance(*this); }
|
||||||
virtual std::vector<PROPGRIDITEM> getProperties();
|
virtual std::vector<PROPGRIDITEM> getProperties();
|
||||||
virtual void PropUpdate(LPPROPGRIDITEM &pItem);
|
virtual void PropUpdate(LPPROPGRIDITEM &pItem);
|
||||||
|
int listicon;
|
||||||
protected:
|
protected:
|
||||||
std::string className;
|
std::string className;
|
||||||
Instance* parent; // Another pointer.
|
Instance* parent; // Another pointer.
|
||||||
|
|||||||
@@ -1,4 +0,0 @@
|
|||||||
#ifndef JOINTTYPE_H
|
|
||||||
#define JOINTTYPE_H
|
|
||||||
static enum ActionType {UNK0, Weld, Snap, UNK3, Rotate, RotateP, RotateV, Glue, UNK8, UNK9, None};
|
|
||||||
#endif
|
|
||||||
@@ -1,4 +0,0 @@
|
|||||||
#ifndef KEYWORDFILTERTYPE_H
|
|
||||||
#define KEYWORDFILTERTYPE_H
|
|
||||||
static enum KeywordFilterType {Include, Exclude};
|
|
||||||
#endif
|
|
||||||
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;
|
||||||
|
};
|
||||||
603
PartInstance.cpp
Normal file
603
PartInstance.cpp
Normal file
@@ -0,0 +1,603 @@
|
|||||||
|
#include "PartInstance.h"
|
||||||
|
#include "Globals.h"
|
||||||
|
#include <sstream>
|
||||||
|
#include <iomanip>
|
||||||
|
|
||||||
|
|
||||||
|
PartInstance::PartInstance(void) : _bevelSize(0.07f), _parseVert(0), _debugTimer(0)
|
||||||
|
{
|
||||||
|
PVInstance::PVInstance();
|
||||||
|
glList = glGenLists(1);
|
||||||
|
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);
|
||||||
|
glList = glGenLists(1);
|
||||||
|
//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));
|
||||||
|
}
|
||||||
|
|
||||||
|
// Start Physics stuff
|
||||||
|
float PartInstance::getMass()
|
||||||
|
{
|
||||||
|
if(shape == Enum::Shape::Sphere || shape == Enum::Shape::Cylinder){
|
||||||
|
return (4/3) * 3.1415926535 * pow(size.x/2, 3);
|
||||||
|
}
|
||||||
|
return size.x * size.y * size.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::addSingularNormal(Vector3 normal)
|
||||||
|
{
|
||||||
|
_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());
|
||||||
|
addSingularNormal(cross(v2-v1,v3-v1).direction());
|
||||||
|
addSingularNormal(cross(v3-v2,v1-v2).direction());
|
||||||
|
addSingularNormal(cross(v1-v3,v2-v3).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;
|
||||||
|
|
||||||
|
glNewList(glList, GL_COMPILE);
|
||||||
|
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();
|
||||||
|
glEndList();
|
||||||
|
}
|
||||||
|
rd->setObjectToWorldMatrix(cFrame);
|
||||||
|
glCallList(glList);
|
||||||
|
//rd->setObjectToWorldMatrix(cFrame);
|
||||||
|
|
||||||
|
}
|
||||||
|
#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)
|
||||||
|
{
|
||||||
|
glDeleteLists(glList, 1);
|
||||||
|
}
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
66
PartInstance.h
Normal file
66
PartInstance.h
Normal file
@@ -0,0 +1,66 @@
|
|||||||
|
#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 addSingularNormal(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);
|
||||||
|
float getMass();
|
||||||
|
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;
|
||||||
|
GLuint glList;
|
||||||
|
};
|
||||||
@@ -1,4 +0,0 @@
|
|||||||
#ifndef PARTTYPE_H
|
|
||||||
#define PARTTYPE_H
|
|
||||||
static enum PartType {Ball, Block, Cylinder};
|
|
||||||
#endif
|
|
||||||
@@ -1,280 +0,0 @@
|
|||||||
#include "PhysicalInstance.h"
|
|
||||||
#include "Globals.h"
|
|
||||||
|
|
||||||
|
|
||||||
PhysicalInstance::PhysicalInstance(void)
|
|
||||||
{
|
|
||||||
name = "Default PhysicalInstance";
|
|
||||||
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 = Smooth;
|
|
||||||
front = Smooth;
|
|
||||||
right = Smooth;
|
|
||||||
back = Smooth;
|
|
||||||
left = Smooth;
|
|
||||||
bottom = Smooth;
|
|
||||||
}
|
|
||||||
|
|
||||||
PhysicalInstance::PhysicalInstance(const PhysicalInstance &oinst)
|
|
||||||
{
|
|
||||||
name = oinst.name;
|
|
||||||
className = "Part";
|
|
||||||
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;
|
|
||||||
}
|
|
||||||
|
|
||||||
void PhysicalInstance::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;
|
|
||||||
|
|
||||||
size = Vector3(sizex, sizey, sizez);
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
Vector3 PhysicalInstance::getSize()
|
|
||||||
{
|
|
||||||
return size;
|
|
||||||
}
|
|
||||||
Vector3 PhysicalInstance::getPosition()
|
|
||||||
{
|
|
||||||
return position;
|
|
||||||
}
|
|
||||||
void PhysicalInstance::setPosition(Vector3 pos)
|
|
||||||
{
|
|
||||||
position = pos;
|
|
||||||
cFrame = CoordinateFrame(pos);
|
|
||||||
changed = true;
|
|
||||||
}
|
|
||||||
CoordinateFrame PhysicalInstance::getCFrame()
|
|
||||||
{
|
|
||||||
return cFrame;
|
|
||||||
}
|
|
||||||
void PhysicalInstance::setCFrame(CoordinateFrame coordinateFrame)
|
|
||||||
{
|
|
||||||
cFrame = coordinateFrame;
|
|
||||||
position = coordinateFrame.translation;
|
|
||||||
changed = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
CoordinateFrame PhysicalInstance::getCFrameRenderBased()
|
|
||||||
{
|
|
||||||
return CoordinateFrame(getCFrame().rotation,Vector3(getCFrame().translation.x/2, getCFrame().translation.y/2, getCFrame().translation.z/2));
|
|
||||||
}
|
|
||||||
|
|
||||||
Box PhysicalInstance::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);
|
|
||||||
vertecies[f*16] = v0.x;
|
|
||||||
vertecies[(f*16)+1] = v0.y;
|
|
||||||
vertecies[(f*16)+2] = v0.z;
|
|
||||||
vertecies[(f*16)+3] = v1.x;
|
|
||||||
vertecies[(f*16)+4] = v1.y;
|
|
||||||
vertecies[(f*16)+5] = v1.z;
|
|
||||||
vertecies[(f*16)+6] = v2.x;
|
|
||||||
vertecies[(f*16)+7] = v2.y;
|
|
||||||
vertecies[(f*16)+8] = v2.z;
|
|
||||||
vertecies[(f*16)+9] = v3.x;
|
|
||||||
vertecies[(f*16)+10] = v3.y;
|
|
||||||
vertecies[(f*16)+11] = v3.z;
|
|
||||||
vertecies[(f*16)+12] = color.r;
|
|
||||||
vertecies[(f*16)+13] = color.g;
|
|
||||||
vertecies[(f*16)+14] = color.b;
|
|
||||||
vertecies[(f*16)+15] = 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return itemBox;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool PhysicalInstance::collides(Box box)
|
|
||||||
{
|
|
||||||
return CollisionDetection::fixedSolidBoxIntersectsFixedSolidBox(getBox(), box);
|
|
||||||
}
|
|
||||||
|
|
||||||
void PhysicalInstance::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;
|
|
||||||
Surface 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(vertecies[i], vertecies[i+1], vertecies[i+2]), v1 = Vector3(vertecies[i+3], vertecies[i+4], vertecies[i+5]), v3 = Vector3(vertecies[i+9], vertecies[i+10], vertecies[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(vertecies[i+6], vertecies[i+7], vertecies[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(vertecies[i+6], vertecies[i+7], vertecies[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);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
PhysicalInstance::~PhysicalInstance(void)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
char pto[512];
|
|
||||||
#include <sstream>
|
|
||||||
|
|
||||||
void PhysicalInstance::PropUpdate(LPPROPGRIDITEM &item)
|
|
||||||
{
|
|
||||||
if(strcmp(item->lpszPropName, "Name") == 0)
|
|
||||||
{
|
|
||||||
name = (LPTSTR)item->lpCurValue;
|
|
||||||
}
|
|
||||||
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;
|
|
||||||
MessageBox(NULL, "NO","NO", MB_OK);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
Vector3 pos(vect.at(0),vect.at(1),vect.at(2));
|
|
||||||
setPosition(pos);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
std::vector<PROPGRIDITEM> PhysicalInstance::getProperties()
|
|
||||||
{
|
|
||||||
std::vector<PROPGRIDITEM> properties;
|
|
||||||
|
|
||||||
|
|
||||||
properties.push_back(createPGI(
|
|
||||||
"Properties",
|
|
||||||
"Name",
|
|
||||||
"The name of this instance",
|
|
||||||
(LPARAM)name.c_str(),
|
|
||||||
PIT_EDIT
|
|
||||||
));
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
sprintf(pto, "%g, %g, %g", cFrame.translation.x, cFrame.translation.y, cFrame.translation.z, "what");
|
|
||||||
LPCSTR str = LPCSTR(pto);
|
|
||||||
properties.push_back(createPGI(
|
|
||||||
"Item",
|
|
||||||
"Offset",
|
|
||||||
"The position of the object in the workspace",
|
|
||||||
(LPARAM)str,
|
|
||||||
PIT_EDIT
|
|
||||||
));
|
|
||||||
return properties;
|
|
||||||
}
|
|
||||||
|
|
||||||
@@ -1,44 +0,0 @@
|
|||||||
#pragma once
|
|
||||||
#include "instance.h"
|
|
||||||
#include "Surface.h"
|
|
||||||
|
|
||||||
class PhysicalInstance :
|
|
||||||
public Instance
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
PhysicalInstance(void);
|
|
||||||
PhysicalInstance(const PhysicalInstance &oinst);
|
|
||||||
Instance* clone() const { return new PhysicalInstance(*this); }
|
|
||||||
~PhysicalInstance(void);
|
|
||||||
virtual void render(RenderDevice*);
|
|
||||||
Vector3 velocity;
|
|
||||||
Surface top;
|
|
||||||
Surface front;
|
|
||||||
Surface right;
|
|
||||||
Surface back;
|
|
||||||
Surface left;
|
|
||||||
Surface bottom;
|
|
||||||
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);
|
|
||||||
private:
|
|
||||||
Vector3 position;
|
|
||||||
Vector3 size;
|
|
||||||
GLfloat vertecies[96];
|
|
||||||
bool changed;
|
|
||||||
Box itemBox;
|
|
||||||
};
|
|
||||||
@@ -3,16 +3,23 @@
|
|||||||
#include "WindowFunctions.h"
|
#include "WindowFunctions.h"
|
||||||
#include "resource.h"
|
#include "resource.h"
|
||||||
#include "PropertyWindow.h"
|
#include "PropertyWindow.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 ∝
|
||||||
} PRGP;*/
|
} PRGP;*/
|
||||||
|
|
||||||
std::vector<PROPGRIDITEM> prop;
|
std::vector<PROPGRIDITEM> prop;
|
||||||
Instance* selectedInstance;
|
std::vector<Instance*> children;
|
||||||
|
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)
|
||||||
{
|
{
|
||||||
@@ -25,11 +32,127 @@ 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:
|
||||||
|
{
|
||||||
|
LPMEASUREITEMSTRUCT lpmis = (LPMEASUREITEMSTRUCT) lParam;
|
||||||
|
if (lpmis->itemHeight < 18)
|
||||||
|
lpmis->itemHeight = 18;
|
||||||
|
}
|
||||||
|
break;
|
||||||
case WM_SIZE:
|
case WM_SIZE:
|
||||||
{
|
{
|
||||||
propWind->onResize();
|
propWind->onResize();
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
case WM_COMMAND:
|
||||||
|
{
|
||||||
|
if(HIWORD(wParam) == CBN_SELCHANGE)
|
||||||
|
{
|
||||||
|
int ItemIndex = SendMessage((HWND) lParam, (UINT) CB_GETCURSEL, (WPARAM) 0, (LPARAM) 0);
|
||||||
|
CHAR ListItem[256];
|
||||||
|
SendMessage((HWND) lParam, (UINT) CB_GETLBTEXT, (WPARAM) ItemIndex, (LPARAM) ListItem);
|
||||||
|
if(ItemIndex != 0)
|
||||||
|
{
|
||||||
|
propWind->ClearProperties();
|
||||||
|
while(g_selectedInstances.size() != 0)
|
||||||
|
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));
|
||||||
|
propWind->SetProperties(children.at(ItemIndex-1));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
case WM_NOTIFY:
|
case WM_NOTIFY:
|
||||||
{
|
{
|
||||||
switch(((LPNMHDR)lParam)->code)
|
switch(((LPNMHDR)lParam)->code)
|
||||||
@@ -41,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;
|
||||||
@@ -54,10 +178,34 @@ LRESULT CALLBACK PropProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool PropertyWindow::onCreate(int x, int y, int sx, int sy, HMODULE hThisInstance) {
|
void PropertyWindow::refreshExplorer()
|
||||||
|
{
|
||||||
|
SendMessage(_explorerComboBox,CB_RESETCONTENT,0,0);
|
||||||
|
parent = NULL;
|
||||||
|
for (unsigned int i=0;i<g_selectedInstances.size();i++) {
|
||||||
|
|
||||||
|
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();
|
||||||
|
for(size_t z = 0; z < children.size(); z++)
|
||||||
|
{
|
||||||
|
SendMessage(_explorerComboBox,CB_ADDSTRING, 0,(LPARAM)children.at(z)->name.c_str());
|
||||||
|
}
|
||||||
|
SendMessage(_explorerComboBox,CB_SETCURSEL,0,(LPARAM)0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
bool PropertyWindow::onCreate(int x, int y, int sx, int sy, HMODULE hThisInstance) {
|
||||||
if (!createWindowClass("propHWND",PropProc,hThisInstance))
|
if (!createWindowClass("propHWND",PropProc,hThisInstance))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
_hwndProp = CreateWindowEx(
|
_hwndProp = CreateWindowEx(
|
||||||
WS_EX_TOOLWINDOW,
|
WS_EX_TOOLWINDOW,
|
||||||
"propHWND",
|
"propHWND",
|
||||||
@@ -72,6 +220,22 @@ bool PropertyWindow::onCreate(int x, int y, int sx, int sy, HMODULE hThisInstanc
|
|||||||
hThisInstance,
|
hThisInstance,
|
||||||
NULL
|
NULL
|
||||||
);
|
);
|
||||||
|
|
||||||
|
_explorerComboBox = CreateWindowEx(
|
||||||
|
NULL,
|
||||||
|
"COMBOBOX",
|
||||||
|
"Combo",
|
||||||
|
WS_VISIBLE | WS_CHILD | CBS_DROPDOWNLIST,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
_hwndProp, // parent
|
||||||
|
NULL, // menu
|
||||||
|
hThisInstance,
|
||||||
|
NULL
|
||||||
|
);
|
||||||
|
SendMessage(_explorerComboBox, WM_SETFONT, (WPARAM)GetStockObject(DEFAULT_GUI_FONT), 0);
|
||||||
|
|
||||||
_propGrid = New_PropertyGrid(_hwndProp,IDC_PROPERTYGRID);
|
_propGrid = New_PropertyGrid(_hwndProp,IDC_PROPERTYGRID);
|
||||||
|
|
||||||
@@ -115,9 +279,12 @@ bool PropertyWindow::onCreate(int x, int y, int sx, int sy, HMODULE hThisInstanc
|
|||||||
PropGrid_ShowToolTips(_propGrid,TRUE);
|
PropGrid_ShowToolTips(_propGrid,TRUE);
|
||||||
PropGrid_ShowPropertyDescriptions(_propGrid,TRUE);
|
PropGrid_ShowPropertyDescriptions(_propGrid,TRUE);
|
||||||
PropGrid_ExpandAllCatalogs(_propGrid);
|
PropGrid_ExpandAllCatalogs(_propGrid);
|
||||||
|
|
||||||
|
|
||||||
SetWindowLongPtr(_hwndProp,GWL_USERDATA,(LONG)this);
|
SetWindowLongPtr(_hwndProp,GWL_USERDATA,(LONG)this);
|
||||||
_redraw();
|
|
||||||
|
refreshExplorer();
|
||||||
|
_resize();
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -128,14 +295,15 @@ PropertyWindow::PropertyWindow(int x, int y, int sx, int sy, HMODULE hThisInstan
|
|||||||
|
|
||||||
void PropertyWindow::onResize()
|
void PropertyWindow::onResize()
|
||||||
{
|
{
|
||||||
_redraw();
|
_resize();
|
||||||
}
|
}
|
||||||
|
|
||||||
void PropertyWindow::_redraw()
|
void PropertyWindow::_resize()
|
||||||
{
|
{
|
||||||
RECT rect;
|
RECT rect;
|
||||||
GetClientRect(_hwndProp,&rect);
|
GetClientRect(_hwndProp,&rect);
|
||||||
SetWindowPos(_propGrid, NULL, 0, 20, rect.right, rect.bottom-20, SWP_NOZORDER | SWP_NOACTIVATE);
|
SetWindowPos(_propGrid, NULL, 0, 20, rect.right, rect.bottom-20, SWP_NOZORDER | SWP_NOACTIVATE);
|
||||||
|
SetWindowPos(_explorerComboBox, NULL, 0, 0, rect.right, 400, SWP_NOMOVE | SWP_NOZORDER | SWP_NOACTIVATE);
|
||||||
}
|
}
|
||||||
|
|
||||||
void PropertyWindow::SetProperties(Instance * instance)
|
void PropertyWindow::SetProperties(Instance * instance)
|
||||||
@@ -152,8 +320,10 @@ void PropertyWindow::SetProperties(Instance * instance)
|
|||||||
//propgp.prop = prop.at(i);
|
//propgp.prop = prop.at(i);
|
||||||
}
|
}
|
||||||
PropGrid_ExpandAllCatalogs(_propGrid);
|
PropGrid_ExpandAllCatalogs(_propGrid);
|
||||||
SetWindowLongPtr(_propGrid,GWL_USERDATA,(LONG)this);
|
//SetWindowLongPtr(_propGrid,GWL_USERDATA,(LONG)this);
|
||||||
_redraw();
|
|
||||||
|
refreshExplorer();
|
||||||
|
_resize();
|
||||||
}
|
}
|
||||||
|
|
||||||
void PropertyWindow::ClearProperties()
|
void PropertyWindow::ClearProperties()
|
||||||
|
|||||||
@@ -7,9 +7,10 @@ public:
|
|||||||
void SetProperties(Instance *);
|
void SetProperties(Instance *);
|
||||||
void ClearProperties();
|
void ClearProperties();
|
||||||
void onResize();
|
void onResize();
|
||||||
|
void refreshExplorer();
|
||||||
HWND _hwndProp;
|
HWND _hwndProp;
|
||||||
private:
|
private:
|
||||||
HWND _propGrid;
|
HWND _propGrid;
|
||||||
void _redraw();
|
HWND _explorerComboBox;
|
||||||
|
void _resize();
|
||||||
};
|
};
|
||||||
@@ -1,4 +0,0 @@
|
|||||||
#ifndef SOUNDTYPE_H
|
|
||||||
#define SOUNDTYPE_H
|
|
||||||
static enum SoundType {NoSound, Boing, Bomb, Break, Click, Clock, Slingshot, Page, Ping, Snap, Splat, Step, StepOn, Swoosh, Victory};
|
|
||||||
#endif
|
|
||||||
@@ -1,4 +0,0 @@
|
|||||||
#ifndef SURFACE_H
|
|
||||||
#define SURFACE_H
|
|
||||||
static enum Surface {Smooth, Snaps, Inlets, Glue, Weld, Hinge, Motor};
|
|
||||||
#endif
|
|
||||||
@@ -1,4 +0,0 @@
|
|||||||
#ifndef SURFACECONSTRAINT_H
|
|
||||||
#define SURFACECONSTRAINT_H
|
|
||||||
static enum SurfaceConstraint {None, Hinge, SteppingMotor, Motor};
|
|
||||||
#endif
|
|
||||||
@@ -1,4 +0,0 @@
|
|||||||
#ifndef SURFACETYPE_H
|
|
||||||
#define SURFACETYPE_H
|
|
||||||
static enum SurfaceType {Smooth, Bumps, Weld, Snaps, Inlet};
|
|
||||||
#endif
|
|
||||||
@@ -3,6 +3,7 @@
|
|||||||
|
|
||||||
TextButtonInstance::TextButtonInstance(void)
|
TextButtonInstance::TextButtonInstance(void)
|
||||||
{
|
{
|
||||||
|
BaseButtonInstance::BaseButtonInstance();
|
||||||
boxBegin = Vector2(0,0);
|
boxBegin = Vector2(0,0);
|
||||||
boxEnd = Vector2(0,0);
|
boxEnd = Vector2(0,0);
|
||||||
fontLocationRelativeTo = Vector2(0,0);
|
fontLocationRelativeTo = Vector2(0,0);
|
||||||
@@ -20,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)
|
||||||
@@ -57,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)
|
||||||
@@ -67,6 +73,9 @@ void TextButtonInstance::drawObj(RenderDevice* rd, Vector2 mousePos, bool mouseD
|
|||||||
{
|
{
|
||||||
Vector3 point1;
|
Vector3 point1;
|
||||||
Vector3 point2;
|
Vector3 point2;
|
||||||
|
glEnableClientState(GL_TEXTURE_COORD_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);
|
||||||
@@ -79,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);
|
||||||
@@ -89,11 +103,18 @@ 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);
|
||||||
font->draw2D(rd, title, RelativeTo, textSize, textColor, textOutlineColor);
|
font->draw2D(rd, title, RelativeTo, textSize, textColor, textOutlineColor);
|
||||||
}
|
}
|
||||||
|
glDisableClientState(GL_TEXTURE_COORD_ARRAY);
|
||||||
|
glEnableClientState(GL_COLOR_ARRAY);
|
||||||
}
|
}
|
||||||
|
|
||||||
void doNullCheck()
|
void doNullCheck()
|
||||||
|
|||||||
@@ -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,9 +3,10 @@
|
|||||||
|
|
||||||
WorkspaceInstance::WorkspaceInstance(void)
|
WorkspaceInstance::WorkspaceInstance(void)
|
||||||
{
|
{
|
||||||
|
GroupInstance::GroupInstance();
|
||||||
|
name = "Workspace";
|
||||||
className = "Workspace";
|
className = "Workspace";
|
||||||
timer = 60.0F;
|
canDelete = false;
|
||||||
score = 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
WorkspaceInstance::~WorkspaceInstance(void)
|
WorkspaceInstance::~WorkspaceInstance(void)
|
||||||
|
|||||||
@@ -1,12 +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 |
524
main.cpp
524
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,14 +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;
|
||||||
std::vector<Instance*> selectedInstances = std::vector<Instance*>();
|
|
||||||
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);
|
||||||
@@ -157,7 +163,7 @@ void OnError(int err, std::string msg = "")
|
|||||||
//usableApp->window()->setMouseVisible(true);
|
//usableApp->window()->setMouseVisible(true);
|
||||||
std::string emsg = "An unexpected error has occured and "+PlaceholderName+" has to quit. We're sorry!" + msg;
|
std::string emsg = "An unexpected error has occured and "+PlaceholderName+" has to quit. We're sorry!" + msg;
|
||||||
std::string title = PlaceholderName+"Crash";
|
std::string title = PlaceholderName+"Crash";
|
||||||
clearInstances();
|
//clearInstances();
|
||||||
MessageBox(NULL, emsg.c_str(), title.c_str(), MB_OK);
|
MessageBox(NULL, emsg.c_str(), title.c_str(), MB_OK);
|
||||||
exit(err);
|
exit(err);
|
||||||
}
|
}
|
||||||
@@ -192,9 +198,9 @@ std::string Convert (float number){
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
PhysicalInstance* makePart()
|
PartInstance* makePart()
|
||||||
{
|
{
|
||||||
PhysicalInstance* part = new PhysicalInstance();
|
PartInstance* part = new PartInstance();
|
||||||
return part;
|
return part;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -223,8 +229,8 @@ void CameraButtonListener::onButton1MouseClick(BaseButtonInstance* button)
|
|||||||
{
|
{
|
||||||
AudioPlayer::playSound(cameraSound);
|
AudioPlayer::playSound(cameraSound);
|
||||||
CoordinateFrame frame = usableApp->cameraController.getCamera()->getCoordinateFrame();
|
CoordinateFrame frame = usableApp->cameraController.getCamera()->getCoordinateFrame();
|
||||||
if(button->name == "CenterCam" && selectedInstances.size() > 0)
|
if(button->name == "CenterCam" && g_selectedInstances.size() > 0)
|
||||||
usableApp->cameraController.centerCamera(selectedInstances.at(0));
|
usableApp->cameraController.centerCamera(g_selectedInstances.at(0));
|
||||||
else if(button->name == "ZoomIn")
|
else if(button->name == "ZoomIn")
|
||||||
usableApp->cameraController.Zoom(1);
|
usableApp->cameraController.Zoom(1);
|
||||||
else if(button->name == "ZoomOut")
|
else if(button->name == "ZoomOut")
|
||||||
@@ -246,25 +252,35 @@ public:
|
|||||||
|
|
||||||
void GUDButtonListener::onButton1MouseClick(BaseButtonInstance* button)
|
void GUDButtonListener::onButton1MouseClick(BaseButtonInstance* button)
|
||||||
{
|
{
|
||||||
if(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")
|
||||||
{
|
{
|
||||||
std::vector<Instance*> newinst;
|
std::vector<Instance*> newinst;
|
||||||
for(size_t i = 0; i < selectedInstances.size(); i++)
|
for(size_t i = 0; i < g_selectedInstances.size(); i++)
|
||||||
{
|
{
|
||||||
PhysicalInstance* tempinst = (PhysicalInstance*) selectedInstances.at(i);
|
if(g_selectedInstances.at(i)->canDelete)
|
||||||
Vector3 tempPos = tempinst->getPosition();
|
{
|
||||||
Vector3 tempSize = tempinst->getSize();
|
Instance* tempinst = g_selectedInstances.at(i);
|
||||||
|
|
||||||
PhysicalInstance* clonedInstance = (PhysicalInstance*) selectedInstances.at(i)->clone();
|
Instance* clonedInstance = g_selectedInstances.at(i)->clone();
|
||||||
|
|
||||||
newinst.push_back(tempinst);
|
newinst.push_back(tempinst);
|
||||||
|
}
|
||||||
/*tempinst->setPosition(Vector3(tempPos.x, tempPos.y + tempSize.y, tempPos.z));
|
/*tempinst->setPosition(Vector3(tempPos.x, tempPos.y + tempSize.y, tempPos.z));
|
||||||
usableApp->cameraController.centerCamera(selectedInstances.at(0));*/
|
usableApp->cameraController.centerCamera(g_selectedInstances.at(0));*/
|
||||||
}
|
}
|
||||||
selectedInstances = newinst;
|
g_selectedInstances = newinst;
|
||||||
|
if(g_selectedInstances.size() > 0)
|
||||||
|
usableApp->_propWindow->SetProperties(newinst.at(0));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -276,11 +292,11 @@ public:
|
|||||||
|
|
||||||
void RotateButtonListener::onButton1MouseClick(BaseButtonInstance* button)
|
void RotateButtonListener::onButton1MouseClick(BaseButtonInstance* button)
|
||||||
{
|
{
|
||||||
if(selectedInstances.size() > 0)
|
if(g_selectedInstances.size() > 0)
|
||||||
{
|
{
|
||||||
Instance* selectedInstance = 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)));
|
||||||
@@ -294,19 +310,29 @@ void RotateButtonListener::onButton1MouseClick(BaseButtonInstance* button)
|
|||||||
|
|
||||||
void deleteInstance()
|
void deleteInstance()
|
||||||
{
|
{
|
||||||
if(selectedInstances.size() > 0)
|
if(g_selectedInstances.size() > 0)
|
||||||
{
|
{
|
||||||
while(selectedInstances.size() > 0)
|
size_t undeletable = 0;
|
||||||
|
while(g_selectedInstances.size() > undeletable)
|
||||||
{
|
{
|
||||||
Instance* selectedInstance = selectedInstances.at(0);
|
if(g_selectedInstances.at(0)->canDelete)
|
||||||
if(selectedInstance->getParent() != NULL)
|
{
|
||||||
selectedInstance->getParent()->removeChild(selectedInstance);
|
AudioPlayer::playSound(GetFileInPath("/content/sounds/pageturn.wav"));
|
||||||
delete selectedInstance;
|
Instance* selectedInstance = g_selectedInstances.at(0);
|
||||||
selectedInstance = NULL;
|
if(selectedInstance->getParent() != NULL)
|
||||||
selectedInstances.erase(selectedInstances.begin());
|
selectedInstance->getParent()->removeChild(selectedInstance);
|
||||||
AudioPlayer::playSound(GetFileInPath("/content/sounds/pageturn.wav"));
|
delete selectedInstance;
|
||||||
|
selectedInstance = NULL;
|
||||||
|
g_selectedInstances.erase(g_selectedInstances.begin());
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
undeletable++;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if(g_selectedInstances.size() == 0)
|
||||||
|
usableApp->_propWindow->ClearProperties();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -366,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);
|
||||||
@@ -378,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);
|
||||||
@@ -390,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);
|
||||||
@@ -402,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);
|
||||||
@@ -410,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);
|
||||||
@@ -427,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);
|
||||||
@@ -440,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);
|
||||||
@@ -453,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);
|
||||||
@@ -466,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);
|
||||||
@@ -479,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);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -490,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->setAllColorsSame();
|
button->name = "Group";
|
||||||
|
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());
|
||||||
@@ -504,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());
|
||||||
@@ -518,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());
|
||||||
@@ -696,13 +736,13 @@ void Demo::onInit() {
|
|||||||
|
|
||||||
initGUI();
|
initGUI();
|
||||||
|
|
||||||
|
#ifdef LEGACY_LOAD_G3DFUN_LEVEL
|
||||||
PhysicalInstance* test = makePart();
|
PartInstance* 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)));
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -759,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();
|
||||||
@@ -773,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->debugGetOpen();
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -802,16 +844,8 @@ void Demo::onCleanup() {
|
|||||||
|
|
||||||
void Demo::onLogic() {
|
void Demo::onLogic() {
|
||||||
// Add non-simulation game logic and AI code here
|
// Add non-simulation game logic and AI code here
|
||||||
|
|
||||||
Instance* obj = dataModel->getGuiRoot()->findFirstChild("Delete");
|
|
||||||
if(obj != NULL)
|
|
||||||
{
|
|
||||||
ImageButtonInstance* button = (ImageButtonInstance*)obj;
|
|
||||||
if(selectedInstances.size() > 0)
|
|
||||||
button->disabled = true;
|
|
||||||
else
|
|
||||||
button->disabled = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -829,9 +863,61 @@ void Demo::onNetwork() {
|
|||||||
|
|
||||||
std::vector<Instance*> Demo::getSelection()
|
std::vector<Instance*> Demo::getSelection()
|
||||||
{
|
{
|
||||||
return selectedInstances;
|
return g_selectedInstances;
|
||||||
}
|
}
|
||||||
void Demo::onSimulation(RealTime rdt, SimTime sdt, SimTime idt) {
|
void Demo::onSimulation(RealTime rdt, SimTime sdt, SimTime idt) {
|
||||||
|
if(running)
|
||||||
|
{
|
||||||
|
std::vector <Instance* > objects = dataModel->getWorkspace()->getAllChildren();
|
||||||
|
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;
|
||||||
|
button2->disabled = true;
|
||||||
|
button3->disabled = true;
|
||||||
|
button4->disabled = true;
|
||||||
|
button5->disabled = true;
|
||||||
|
button6->disabled = true;
|
||||||
|
for(size_t i = 0; i < g_selectedInstances.size(); i++)
|
||||||
|
if(g_selectedInstances.at(i)->canDelete)
|
||||||
|
{
|
||||||
|
button->disabled = false;
|
||||||
|
button2->disabled = false;
|
||||||
|
button3->disabled = false;
|
||||||
|
button4->disabled = false;
|
||||||
|
button5->disabled = false;
|
||||||
|
button6->disabled = false;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
if(dataModel->name != title)
|
if(dataModel->name != title)
|
||||||
{
|
{
|
||||||
title = dataModel->name;
|
title = dataModel->name;
|
||||||
@@ -860,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);
|
||||||
}
|
}
|
||||||
@@ -893,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(selectedInstances.size() > 0)
|
if(g_selectedInstances.size() > 0)
|
||||||
part = (PhysicalInstance*) 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();
|
||||||
@@ -963,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)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
@@ -975,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)
|
||||||
@@ -991,18 +1108,18 @@ void drawOutline(Vector3 from, Vector3 to, RenderDevice* rd, LightingParameters
|
|||||||
{
|
{
|
||||||
|
|
||||||
Color3 outline = Color3::cyan();//Color3(0.098F,0.6F,1.0F);
|
Color3 outline = Color3::cyan();//Color3(0.098F,0.6F,1.0F);
|
||||||
float offsetSize = 0.05F;
|
float offsetSize = 0.1F;
|
||||||
//X
|
//X
|
||||||
Draw::box(c.toWorldSpace(Box(Vector3(from.x - offsetSize, from.y + offsetSize, from.z + offsetSize), Vector3(to.x + offsetSize, from.y - offsetSize, from.z - offsetSize))), rd, outline, Color4::clear());
|
Draw::box(c.toWorldSpace(Box(Vector3(from.x - offsetSize, from.y + offsetSize, from.z + offsetSize), Vector3(to.x + offsetSize, from.y - offsetSize, from.z - offsetSize))), rd, outline, Color4::clear());
|
||||||
Draw::box(c.toWorldSpace(Box(Vector3(from.x - offsetSize, to.y + offsetSize, from.z + offsetSize), Vector3(to.x + offsetSize, to.y - offsetSize, from.z - offsetSize))), rd, outline, Color4::clear());
|
Draw::box(c.toWorldSpace(Box(Vector3(from.x - offsetSize, to.y + offsetSize, from.z + offsetSize), Vector3(to.x + offsetSize, to.y - offsetSize, from.z - offsetSize))), rd, outline, Color4::clear());
|
||||||
Draw::box(c.toWorldSpace(Box(Vector3(from.x - offsetSize, to.y + offsetSize, to.z + offsetSize), Vector3(to.x + offsetSize, to.y - offsetSize, to.z - offsetSize))), rd, outline, Color4::clear());
|
Draw::box(c.toWorldSpace(Box(Vector3(from.x - offsetSize, to.y + offsetSize, to.z + offsetSize), Vector3(to.x + offsetSize, to.y - offsetSize, to.z - offsetSize))), rd, outline, Color4::clear());
|
||||||
Draw::box(c.toWorldSpace(Box(Vector3(from.x - offsetSize, from.y + offsetSize, to.z + offsetSize), Vector3(to.x + offsetSize, from.y - offsetSize, to.z - offsetSize))), rd, outline, Color4::clear());
|
Draw::box(c.toWorldSpace(Box(Vector3(from.x - offsetSize, from.y + offsetSize, to.z + offsetSize), Vector3(to.x + offsetSize, from.y - offsetSize, to.z - offsetSize))), rd, outline, Color4::clear());
|
||||||
//Y
|
//Y
|
||||||
Draw::box(c.toWorldSpace(Box(Vector3(from.x + offsetSize, from.y - offsetSize + 0.1, from.z + offsetSize), Vector3(from.x - offsetSize, to.y + offsetSize - 0.1, from.z - offsetSize))), rd, outline, Color4::clear());
|
Draw::box(c.toWorldSpace(Box(Vector3(from.x + offsetSize, from.y - offsetSize + 0.2, from.z + offsetSize), Vector3(from.x - offsetSize, to.y + offsetSize - 0.2, from.z - offsetSize))), rd, outline, Color4::clear());
|
||||||
Draw::box(c.toWorldSpace(Box(Vector3(to.x + offsetSize, from.y - offsetSize + 0.1, from.z + offsetSize), Vector3(to.x - offsetSize, to.y + offsetSize - 0.1, from.z - offsetSize))), rd, outline, Color4::clear());
|
Draw::box(c.toWorldSpace(Box(Vector3(to.x + offsetSize, from.y - offsetSize + 0.2, from.z + offsetSize), Vector3(to.x - offsetSize, to.y + offsetSize - 0.2, from.z - offsetSize))), rd, outline, Color4::clear());
|
||||||
Draw::box(c.toWorldSpace(Box(Vector3(to.x + offsetSize, from.y - offsetSize + 0.1, to.z + offsetSize), Vector3(to.x - offsetSize, to.y + offsetSize-0.1, to.z - offsetSize))), rd, outline, Color4::clear());
|
Draw::box(c.toWorldSpace(Box(Vector3(to.x + offsetSize, from.y - offsetSize + 0.2, to.z + offsetSize), Vector3(to.x - offsetSize, to.y + offsetSize-0.2, to.z - offsetSize))), rd, outline, Color4::clear());
|
||||||
Draw::box(c.toWorldSpace(Box(Vector3(from.x + offsetSize, from.y - offsetSize + 0.1, to.z + offsetSize), Vector3(from.x - offsetSize, to.y + offsetSize - 0.1, to.z - offsetSize))), rd, outline, Color4::clear());
|
Draw::box(c.toWorldSpace(Box(Vector3(from.x + offsetSize, from.y - offsetSize + 0.2, to.z + offsetSize), Vector3(from.x - offsetSize, to.y + offsetSize - 0.2, to.z - offsetSize))), rd, outline, Color4::clear());
|
||||||
|
|
||||||
//Z
|
//Z
|
||||||
Draw::box(c.toWorldSpace(Box(Vector3(from.x + offsetSize, from.y + offsetSize, from.z - offsetSize), Vector3(from.x - offsetSize, from.y - offsetSize, to.z + offsetSize))), rd, outline, Color4::clear());
|
Draw::box(c.toWorldSpace(Box(Vector3(from.x + offsetSize, from.y + offsetSize, from.z - offsetSize), Vector3(from.x - offsetSize, from.y - offsetSize, to.z + offsetSize))), rd, outline, Color4::clear());
|
||||||
Draw::box(c.toWorldSpace(Box(Vector3(from.x + offsetSize, to.y + offsetSize, from.z - offsetSize), Vector3(from.x - offsetSize, to.y - offsetSize, to.z + offsetSize))), rd, outline, Color4::clear());
|
Draw::box(c.toWorldSpace(Box(Vector3(from.x + offsetSize, to.y + offsetSize, from.z - offsetSize), Vector3(from.x - offsetSize, to.y - offsetSize, to.z + offsetSize))), rd, outline, Color4::clear());
|
||||||
@@ -1011,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));
|
||||||
|
|
||||||
@@ -1018,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)
|
||||||
{
|
{
|
||||||
@@ -1046,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));
|
||||||
@@ -1080,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);
|
||||||
@@ -1107,6 +1229,8 @@ void Demo::onGraphics(RenderDevice* rd) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if(Globals::useMousePoint)
|
if(Globals::useMousePoint)
|
||||||
{
|
{
|
||||||
mousepos = Globals::mousepoint;
|
mousepos = Globals::mousepoint;
|
||||||
@@ -1114,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
|
||||||
@@ -1133,32 +1271,59 @@ 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();
|
||||||
|
|
||||||
|
CoordinateFrame forDraw = rd->getObjectToWorldMatrix();
|
||||||
dataModel->getWorkspace()->render(rd);
|
dataModel->getWorkspace()->render(rd);
|
||||||
|
rd->setObjectToWorldMatrix(forDraw);
|
||||||
|
//if (dataModel->children[0]->children.size()>0)
|
||||||
|
//((PartInstance*)dataModel->children[0]->children[0])->debugPrintVertexIDs(rd,fntdominant,-cameraController.getCoordinateFrame().rotation);
|
||||||
rd->afterPrimitive();
|
rd->afterPrimitive();
|
||||||
|
|
||||||
if(selectedInstances.size() > 0)
|
rd->popState();
|
||||||
|
if(g_selectedInstances.size() > 0)
|
||||||
{
|
{
|
||||||
for(size_t i = 0; i < selectedInstances.size(); i++)
|
for(size_t i = 0; i < g_selectedInstances.size(); i++)
|
||||||
{
|
{
|
||||||
PhysicalInstance* part = (PhysicalInstance*)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();
|
||||||
drawOutline(Vector3(0+size.x/4, 0+size.y/4, 0+size.z/4) ,Vector3(0-size.x/4,0-size.y/4,0-size.z/4), rd, lighting, Vector3(size.x/2, size.y/2, size.z/2), Vector3(pos.x/2, pos.y/2, pos.z/2), part->getCFrameRenderBased());
|
drawOutline(Vector3(size.x/2, size.y/2, size.z/2) ,Vector3(-size.x/2,-size.y/2,-size.z/2), rd, lighting, Vector3(size.x/2, size.y/2, size.z/2), Vector3(pos.x, pos.y, pos.z), part->getCFrameRenderBased());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//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))
|
||||||
//{
|
{
|
||||||
// if(distance < 0)
|
pinst->postRender(rd);
|
||||||
// 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();
|
||||||
|
|
||||||
@@ -1174,9 +1339,13 @@ void Demo::onGraphics(RenderDevice* rd) {
|
|||||||
//TODO--Move these to their own instance
|
//TODO--Move these to their own instance
|
||||||
|
|
||||||
std::stringstream stream;
|
std::stringstream stream;
|
||||||
stream << std::fixed << std::setprecision(1) << dataModel->getWorkspace()->timer;
|
stream << std::fixed << std::setprecision(3) << m_graphicsWatch.FPS();
|
||||||
|
fntdominant->draw2D(rd, "FPS: " + stream.str(), Vector2(120, 25), 10, Color3::fromARGB(0xFFFF00), Color3::black());
|
||||||
|
stream.str("");
|
||||||
|
stream.clear();
|
||||||
|
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));
|
||||||
@@ -1202,19 +1371,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 );
|
||||||
@@ -1223,6 +1422,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)
|
||||||
@@ -1231,6 +1431,23 @@ void Demo::onKeyPressed(int key)
|
|||||||
{
|
{
|
||||||
deleteInstance();
|
deleteInstance();
|
||||||
}
|
}
|
||||||
|
if (GetHoldKeyState(VK_RCONTROL))
|
||||||
|
{
|
||||||
|
if (key=='O')
|
||||||
|
{
|
||||||
|
dataModel->getOpen();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#ifdef _DEBUG
|
||||||
|
if (key==VK_ADD)
|
||||||
|
{
|
||||||
|
dataModel->modXMLLevel(1);
|
||||||
|
}
|
||||||
|
if (key==VK_SUBTRACT)
|
||||||
|
{
|
||||||
|
dataModel->modXMLLevel(-1);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
void Demo::onKeyUp(int key)
|
void Demo::onKeyUp(int key)
|
||||||
{
|
{
|
||||||
@@ -1239,7 +1456,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;
|
||||||
|
|
||||||
@@ -1265,7 +1485,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());
|
||||||
|
|
||||||
@@ -1276,9 +1496,9 @@ void Demo::onMouseLeftPressed(HWND hwnd,int x,int y)
|
|||||||
{
|
{
|
||||||
nearest=time;
|
nearest=time;
|
||||||
bool found = false;
|
bool found = false;
|
||||||
for(size_t i = 0; i < selectedInstances.size(); i++)
|
for(size_t i = 0; i < g_selectedInstances.size(); i++)
|
||||||
{
|
{
|
||||||
if(selectedInstances.at(i) == test)
|
if(g_selectedInstances.at(i) == test)
|
||||||
{
|
{
|
||||||
found = true;
|
found = true;
|
||||||
ShowWindow(_propWindow->_hwndProp, SW_SHOW);
|
ShowWindow(_propWindow->_hwndProp, SW_SHOW);
|
||||||
@@ -1288,9 +1508,9 @@ void Demo::onMouseLeftPressed(HWND hwnd,int x,int y)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(!found)
|
if(!found)
|
||||||
{while(selectedInstances.size() > 0)
|
{while(g_selectedInstances.size() > 0)
|
||||||
selectedInstances.erase(selectedInstances.begin());
|
g_selectedInstances.erase(g_selectedInstances.begin());
|
||||||
selectedInstances.push_back(test);
|
g_selectedInstances.push_back(test);
|
||||||
}
|
}
|
||||||
_propWindow->SetProperties(test);
|
_propWindow->SetProperties(test);
|
||||||
//message = "Dragging = true.";
|
//message = "Dragging = true.";
|
||||||
@@ -1302,9 +1522,11 @@ void Demo::onMouseLeftPressed(HWND hwnd,int x,int y)
|
|||||||
}
|
}
|
||||||
if(!objFound)
|
if(!objFound)
|
||||||
{
|
{
|
||||||
while(selectedInstances.size() > 0)
|
while(g_selectedInstances.size() > 0)
|
||||||
selectedInstances.erase(selectedInstances.begin());
|
g_selectedInstances.erase(g_selectedInstances.begin());
|
||||||
_propWindow->ClearProperties();
|
g_selectedInstances.push_back(dataModel);
|
||||||
|
_propWindow->SetProperties(dataModel);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1316,7 +1538,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]))
|
||||||
@@ -1336,7 +1558,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;
|
||||||
|
|
||||||
@@ -1462,6 +1684,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);
|
||||||
@@ -1475,6 +1718,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);
|
||||||
@@ -1496,7 +1770,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"));
|
||||||
@@ -1505,8 +1780,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;
|
||||||
@@ -1614,7 +1898,7 @@ int main(int argc, char** argv) {
|
|||||||
|
|
||||||
|
|
||||||
INITCOMMONCONTROLSEX icc;
|
INITCOMMONCONTROLSEX icc;
|
||||||
WNDCLASSEX wcx;
|
// WNDCLASSEX wcx;
|
||||||
|
|
||||||
/* Initialize common controls. Also needed for MANIFEST's */
|
/* Initialize common controls. Also needed for MANIFEST's */
|
||||||
|
|
||||||
|
|||||||
52
rapidxml/license.txt
Normal file
52
rapidxml/license.txt
Normal file
@@ -0,0 +1,52 @@
|
|||||||
|
Use of this software is granted under one of the following two licenses,
|
||||||
|
to be chosen freely by the user.
|
||||||
|
|
||||||
|
1. Boost Software License - Version 1.0 - August 17th, 2003
|
||||||
|
===============================================================================
|
||||||
|
|
||||||
|
Copyright (c) 2006, 2007 Marcin Kalicinski
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person or organization
|
||||||
|
obtaining a copy of the software and accompanying documentation covered by
|
||||||
|
this license (the "Software") to use, reproduce, display, distribute,
|
||||||
|
execute, and transmit the Software, and to prepare derivative works of the
|
||||||
|
Software, and to permit third-parties to whom the Software is furnished to
|
||||||
|
do so, all subject to the following:
|
||||||
|
|
||||||
|
The copyright notices in the Software and this entire statement, including
|
||||||
|
the above license grant, this restriction and the following disclaimer,
|
||||||
|
must be included in all copies of the Software, in whole or in part, and
|
||||||
|
all derivative works of the Software, unless such copies or derivative
|
||||||
|
works are solely in the form of machine-executable object code generated by
|
||||||
|
a source language processor.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
|
||||||
|
SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
|
||||||
|
FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
|
||||||
|
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||||
|
DEALINGS IN THE SOFTWARE.
|
||||||
|
|
||||||
|
2. The MIT License
|
||||||
|
===============================================================================
|
||||||
|
|
||||||
|
Copyright (c) 2006, 2007 Marcin Kalicinski
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
|
in the Software without restriction, including without limitation the rights
|
||||||
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
|
||||||
|
of the Software, and to permit persons to whom the Software is furnished to do so,
|
||||||
|
subject to the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be included in all
|
||||||
|
copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||||
|
THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
|
||||||
|
IN THE SOFTWARE.
|
||||||
406
rapidxml/manual.html
Normal file
406
rapidxml/manual.html
Normal file
File diff suppressed because one or more lines are too long
2596
rapidxml/rapidxml.hpp
Normal file
2596
rapidxml/rapidxml.hpp
Normal file
File diff suppressed because it is too large
Load Diff
174
rapidxml/rapidxml_iterators.hpp
Normal file
174
rapidxml/rapidxml_iterators.hpp
Normal file
@@ -0,0 +1,174 @@
|
|||||||
|
#ifndef RAPIDXML_ITERATORS_HPP_INCLUDED
|
||||||
|
#define RAPIDXML_ITERATORS_HPP_INCLUDED
|
||||||
|
|
||||||
|
// Copyright (C) 2006, 2009 Marcin Kalicinski
|
||||||
|
// Version 1.13
|
||||||
|
// Revision $DateTime: 2009/05/13 01:46:17 $
|
||||||
|
//! \file rapidxml_iterators.hpp This file contains rapidxml iterators
|
||||||
|
|
||||||
|
#include "rapidxml.hpp"
|
||||||
|
|
||||||
|
namespace rapidxml
|
||||||
|
{
|
||||||
|
|
||||||
|
//! Iterator of child nodes of xml_node
|
||||||
|
template<class Ch>
|
||||||
|
class node_iterator
|
||||||
|
{
|
||||||
|
|
||||||
|
public:
|
||||||
|
|
||||||
|
typedef typename xml_node<Ch> value_type;
|
||||||
|
typedef typename xml_node<Ch> &reference;
|
||||||
|
typedef typename xml_node<Ch> *pointer;
|
||||||
|
typedef std::ptrdiff_t difference_type;
|
||||||
|
typedef std::bidirectional_iterator_tag iterator_category;
|
||||||
|
|
||||||
|
node_iterator()
|
||||||
|
: m_node(0)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
node_iterator(xml_node<Ch> *node)
|
||||||
|
: m_node(node->first_node())
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
reference operator *() const
|
||||||
|
{
|
||||||
|
assert(m_node);
|
||||||
|
return *m_node;
|
||||||
|
}
|
||||||
|
|
||||||
|
pointer operator->() const
|
||||||
|
{
|
||||||
|
assert(m_node);
|
||||||
|
return m_node;
|
||||||
|
}
|
||||||
|
|
||||||
|
node_iterator& operator++()
|
||||||
|
{
|
||||||
|
assert(m_node);
|
||||||
|
m_node = m_node->next_sibling();
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
node_iterator operator++(int)
|
||||||
|
{
|
||||||
|
node_iterator tmp = *this;
|
||||||
|
++this;
|
||||||
|
return tmp;
|
||||||
|
}
|
||||||
|
|
||||||
|
node_iterator& operator--()
|
||||||
|
{
|
||||||
|
assert(m_node && m_node->previous_sibling());
|
||||||
|
m_node = m_node->previous_sibling();
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
node_iterator operator--(int)
|
||||||
|
{
|
||||||
|
node_iterator tmp = *this;
|
||||||
|
++this;
|
||||||
|
return tmp;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool operator ==(const node_iterator<Ch> &rhs)
|
||||||
|
{
|
||||||
|
return m_node == rhs.m_node;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool operator !=(const node_iterator<Ch> &rhs)
|
||||||
|
{
|
||||||
|
return m_node != rhs.m_node;
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
|
||||||
|
xml_node<Ch> *m_node;
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
//! Iterator of child attributes of xml_node
|
||||||
|
template<class Ch>
|
||||||
|
class attribute_iterator
|
||||||
|
{
|
||||||
|
|
||||||
|
public:
|
||||||
|
|
||||||
|
typedef typename xml_attribute<Ch> value_type;
|
||||||
|
typedef typename xml_attribute<Ch> &reference;
|
||||||
|
typedef typename xml_attribute<Ch> *pointer;
|
||||||
|
typedef std::ptrdiff_t difference_type;
|
||||||
|
typedef std::bidirectional_iterator_tag iterator_category;
|
||||||
|
|
||||||
|
attribute_iterator()
|
||||||
|
: m_attribute(0)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
attribute_iterator(xml_node<Ch> *node)
|
||||||
|
: m_attribute(node->first_attribute())
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
reference operator *() const
|
||||||
|
{
|
||||||
|
assert(m_attribute);
|
||||||
|
return *m_attribute;
|
||||||
|
}
|
||||||
|
|
||||||
|
pointer operator->() const
|
||||||
|
{
|
||||||
|
assert(m_attribute);
|
||||||
|
return m_attribute;
|
||||||
|
}
|
||||||
|
|
||||||
|
attribute_iterator& operator++()
|
||||||
|
{
|
||||||
|
assert(m_attribute);
|
||||||
|
m_attribute = m_attribute->next_attribute();
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
attribute_iterator operator++(int)
|
||||||
|
{
|
||||||
|
attribute_iterator tmp = *this;
|
||||||
|
++this;
|
||||||
|
return tmp;
|
||||||
|
}
|
||||||
|
|
||||||
|
attribute_iterator& operator--()
|
||||||
|
{
|
||||||
|
assert(m_attribute && m_attribute->previous_attribute());
|
||||||
|
m_attribute = m_attribute->previous_attribute();
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
attribute_iterator operator--(int)
|
||||||
|
{
|
||||||
|
attribute_iterator tmp = *this;
|
||||||
|
++this;
|
||||||
|
return tmp;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool operator ==(const attribute_iterator<Ch> &rhs)
|
||||||
|
{
|
||||||
|
return m_attribute == rhs.m_attribute;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool operator !=(const attribute_iterator<Ch> &rhs)
|
||||||
|
{
|
||||||
|
return m_attribute != rhs.m_attribute;
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
|
||||||
|
xml_attribute<Ch> *m_attribute;
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
421
rapidxml/rapidxml_print.hpp
Normal file
421
rapidxml/rapidxml_print.hpp
Normal file
@@ -0,0 +1,421 @@
|
|||||||
|
#ifndef RAPIDXML_PRINT_HPP_INCLUDED
|
||||||
|
#define RAPIDXML_PRINT_HPP_INCLUDED
|
||||||
|
|
||||||
|
// Copyright (C) 2006, 2009 Marcin Kalicinski
|
||||||
|
// Version 1.13
|
||||||
|
// Revision $DateTime: 2009/05/13 01:46:17 $
|
||||||
|
//! \file rapidxml_print.hpp This file contains rapidxml printer implementation
|
||||||
|
|
||||||
|
#include "rapidxml.hpp"
|
||||||
|
|
||||||
|
// Only include streams if not disabled
|
||||||
|
#ifndef RAPIDXML_NO_STREAMS
|
||||||
|
#include <ostream>
|
||||||
|
#include <iterator>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
namespace rapidxml
|
||||||
|
{
|
||||||
|
|
||||||
|
///////////////////////////////////////////////////////////////////////
|
||||||
|
// Printing flags
|
||||||
|
|
||||||
|
const int print_no_indenting = 0x1; //!< Printer flag instructing the printer to suppress indenting of XML. See print() function.
|
||||||
|
|
||||||
|
///////////////////////////////////////////////////////////////////////
|
||||||
|
// Internal
|
||||||
|
|
||||||
|
//! \cond internal
|
||||||
|
namespace internal
|
||||||
|
{
|
||||||
|
|
||||||
|
///////////////////////////////////////////////////////////////////////////
|
||||||
|
// Internal character operations
|
||||||
|
|
||||||
|
// Copy characters from given range to given output iterator
|
||||||
|
template<class OutIt, class Ch>
|
||||||
|
inline OutIt copy_chars(const Ch *begin, const Ch *end, OutIt out)
|
||||||
|
{
|
||||||
|
while (begin != end)
|
||||||
|
*out++ = *begin++;
|
||||||
|
return out;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Copy characters from given range to given output iterator and expand
|
||||||
|
// characters into references (< > ' " &)
|
||||||
|
template<class OutIt, class Ch>
|
||||||
|
inline OutIt copy_and_expand_chars(const Ch *begin, const Ch *end, Ch noexpand, OutIt out)
|
||||||
|
{
|
||||||
|
while (begin != end)
|
||||||
|
{
|
||||||
|
if (*begin == noexpand)
|
||||||
|
{
|
||||||
|
*out++ = *begin; // No expansion, copy character
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
switch (*begin)
|
||||||
|
{
|
||||||
|
case Ch('<'):
|
||||||
|
*out++ = Ch('&'); *out++ = Ch('l'); *out++ = Ch('t'); *out++ = Ch(';');
|
||||||
|
break;
|
||||||
|
case Ch('>'):
|
||||||
|
*out++ = Ch('&'); *out++ = Ch('g'); *out++ = Ch('t'); *out++ = Ch(';');
|
||||||
|
break;
|
||||||
|
case Ch('\''):
|
||||||
|
*out++ = Ch('&'); *out++ = Ch('a'); *out++ = Ch('p'); *out++ = Ch('o'); *out++ = Ch('s'); *out++ = Ch(';');
|
||||||
|
break;
|
||||||
|
case Ch('"'):
|
||||||
|
*out++ = Ch('&'); *out++ = Ch('q'); *out++ = Ch('u'); *out++ = Ch('o'); *out++ = Ch('t'); *out++ = Ch(';');
|
||||||
|
break;
|
||||||
|
case Ch('&'):
|
||||||
|
*out++ = Ch('&'); *out++ = Ch('a'); *out++ = Ch('m'); *out++ = Ch('p'); *out++ = Ch(';');
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
*out++ = *begin; // No expansion, copy character
|
||||||
|
}
|
||||||
|
}
|
||||||
|
++begin; // Step to next character
|
||||||
|
}
|
||||||
|
return out;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Fill given output iterator with repetitions of the same character
|
||||||
|
template<class OutIt, class Ch>
|
||||||
|
inline OutIt fill_chars(OutIt out, int n, Ch ch)
|
||||||
|
{
|
||||||
|
for (int i = 0; i < n; ++i)
|
||||||
|
*out++ = ch;
|
||||||
|
return out;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Find character
|
||||||
|
template<class Ch, Ch ch>
|
||||||
|
inline bool find_char(const Ch *begin, const Ch *end)
|
||||||
|
{
|
||||||
|
while (begin != end)
|
||||||
|
if (*begin++ == ch)
|
||||||
|
return true;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
///////////////////////////////////////////////////////////////////////////
|
||||||
|
// Internal printing operations
|
||||||
|
|
||||||
|
// Print node
|
||||||
|
template<class OutIt, class Ch>
|
||||||
|
inline OutIt print_node(OutIt out, const xml_node<Ch> *node, int flags, int indent)
|
||||||
|
{
|
||||||
|
// Print proper node type
|
||||||
|
switch (node->type())
|
||||||
|
{
|
||||||
|
|
||||||
|
// Document
|
||||||
|
case node_document:
|
||||||
|
out = print_children(out, node, flags, indent);
|
||||||
|
break;
|
||||||
|
|
||||||
|
// Element
|
||||||
|
case node_element:
|
||||||
|
out = print_element_node(out, node, flags, indent);
|
||||||
|
break;
|
||||||
|
|
||||||
|
// Data
|
||||||
|
case node_data:
|
||||||
|
out = print_data_node(out, node, flags, indent);
|
||||||
|
break;
|
||||||
|
|
||||||
|
// CDATA
|
||||||
|
case node_cdata:
|
||||||
|
out = print_cdata_node(out, node, flags, indent);
|
||||||
|
break;
|
||||||
|
|
||||||
|
// Declaration
|
||||||
|
case node_declaration:
|
||||||
|
out = print_declaration_node(out, node, flags, indent);
|
||||||
|
break;
|
||||||
|
|
||||||
|
// Comment
|
||||||
|
case node_comment:
|
||||||
|
out = print_comment_node(out, node, flags, indent);
|
||||||
|
break;
|
||||||
|
|
||||||
|
// Doctype
|
||||||
|
case node_doctype:
|
||||||
|
out = print_doctype_node(out, node, flags, indent);
|
||||||
|
break;
|
||||||
|
|
||||||
|
// Pi
|
||||||
|
case node_pi:
|
||||||
|
out = print_pi_node(out, node, flags, indent);
|
||||||
|
break;
|
||||||
|
|
||||||
|
// Unknown
|
||||||
|
default:
|
||||||
|
assert(0);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
// If indenting not disabled, add line break after node
|
||||||
|
if (!(flags & print_no_indenting))
|
||||||
|
*out = Ch('\n'), ++out;
|
||||||
|
|
||||||
|
// Return modified iterator
|
||||||
|
return out;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Print children of the node
|
||||||
|
template<class OutIt, class Ch>
|
||||||
|
inline OutIt print_children(OutIt out, const xml_node<Ch> *node, int flags, int indent)
|
||||||
|
{
|
||||||
|
for (xml_node<Ch> *child = node->first_node(); child; child = child->next_sibling())
|
||||||
|
out = print_node(out, child, flags, indent);
|
||||||
|
return out;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Print attributes of the node
|
||||||
|
template<class OutIt, class Ch>
|
||||||
|
inline OutIt print_attributes(OutIt out, const xml_node<Ch> *node, int flags)
|
||||||
|
{
|
||||||
|
for (xml_attribute<Ch> *attribute = node->first_attribute(); attribute; attribute = attribute->next_attribute())
|
||||||
|
{
|
||||||
|
if (attribute->name() && attribute->value())
|
||||||
|
{
|
||||||
|
// Print attribute name
|
||||||
|
*out = Ch(' '), ++out;
|
||||||
|
out = copy_chars(attribute->name(), attribute->name() + attribute->name_size(), out);
|
||||||
|
*out = Ch('='), ++out;
|
||||||
|
// Print attribute value using appropriate quote type
|
||||||
|
if (find_char<Ch, Ch('"')>(attribute->value(), attribute->value() + attribute->value_size()))
|
||||||
|
{
|
||||||
|
*out = Ch('\''), ++out;
|
||||||
|
out = copy_and_expand_chars(attribute->value(), attribute->value() + attribute->value_size(), Ch('"'), out);
|
||||||
|
*out = Ch('\''), ++out;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
*out = Ch('"'), ++out;
|
||||||
|
out = copy_and_expand_chars(attribute->value(), attribute->value() + attribute->value_size(), Ch('\''), out);
|
||||||
|
*out = Ch('"'), ++out;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return out;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Print data node
|
||||||
|
template<class OutIt, class Ch>
|
||||||
|
inline OutIt print_data_node(OutIt out, const xml_node<Ch> *node, int flags, int indent)
|
||||||
|
{
|
||||||
|
assert(node->type() == node_data);
|
||||||
|
if (!(flags & print_no_indenting))
|
||||||
|
out = fill_chars(out, indent, Ch('\t'));
|
||||||
|
out = copy_and_expand_chars(node->value(), node->value() + node->value_size(), Ch(0), out);
|
||||||
|
return out;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Print data node
|
||||||
|
template<class OutIt, class Ch>
|
||||||
|
inline OutIt print_cdata_node(OutIt out, const xml_node<Ch> *node, int flags, int indent)
|
||||||
|
{
|
||||||
|
assert(node->type() == node_cdata);
|
||||||
|
if (!(flags & print_no_indenting))
|
||||||
|
out = fill_chars(out, indent, Ch('\t'));
|
||||||
|
*out = Ch('<'); ++out;
|
||||||
|
*out = Ch('!'); ++out;
|
||||||
|
*out = Ch('['); ++out;
|
||||||
|
*out = Ch('C'); ++out;
|
||||||
|
*out = Ch('D'); ++out;
|
||||||
|
*out = Ch('A'); ++out;
|
||||||
|
*out = Ch('T'); ++out;
|
||||||
|
*out = Ch('A'); ++out;
|
||||||
|
*out = Ch('['); ++out;
|
||||||
|
out = copy_chars(node->value(), node->value() + node->value_size(), out);
|
||||||
|
*out = Ch(']'); ++out;
|
||||||
|
*out = Ch(']'); ++out;
|
||||||
|
*out = Ch('>'); ++out;
|
||||||
|
return out;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Print element node
|
||||||
|
template<class OutIt, class Ch>
|
||||||
|
inline OutIt print_element_node(OutIt out, const xml_node<Ch> *node, int flags, int indent)
|
||||||
|
{
|
||||||
|
assert(node->type() == node_element);
|
||||||
|
|
||||||
|
// Print element name and attributes, if any
|
||||||
|
if (!(flags & print_no_indenting))
|
||||||
|
out = fill_chars(out, indent, Ch('\t'));
|
||||||
|
*out = Ch('<'), ++out;
|
||||||
|
out = copy_chars(node->name(), node->name() + node->name_size(), out);
|
||||||
|
out = print_attributes(out, node, flags);
|
||||||
|
|
||||||
|
// If node is childless
|
||||||
|
if (node->value_size() == 0 && !node->first_node())
|
||||||
|
{
|
||||||
|
// Print childless node tag ending
|
||||||
|
*out = Ch('/'), ++out;
|
||||||
|
*out = Ch('>'), ++out;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// Print normal node tag ending
|
||||||
|
*out = Ch('>'), ++out;
|
||||||
|
|
||||||
|
// Test if node contains a single data node only (and no other nodes)
|
||||||
|
xml_node<Ch> *child = node->first_node();
|
||||||
|
if (!child)
|
||||||
|
{
|
||||||
|
// If node has no children, only print its value without indenting
|
||||||
|
out = copy_and_expand_chars(node->value(), node->value() + node->value_size(), Ch(0), out);
|
||||||
|
}
|
||||||
|
else if (child->next_sibling() == 0 && child->type() == node_data)
|
||||||
|
{
|
||||||
|
// If node has a sole data child, only print its value without indenting
|
||||||
|
out = copy_and_expand_chars(child->value(), child->value() + child->value_size(), Ch(0), out);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// Print all children with full indenting
|
||||||
|
if (!(flags & print_no_indenting))
|
||||||
|
*out = Ch('\n'), ++out;
|
||||||
|
out = print_children(out, node, flags, indent + 1);
|
||||||
|
if (!(flags & print_no_indenting))
|
||||||
|
out = fill_chars(out, indent, Ch('\t'));
|
||||||
|
}
|
||||||
|
|
||||||
|
// Print node end
|
||||||
|
*out = Ch('<'), ++out;
|
||||||
|
*out = Ch('/'), ++out;
|
||||||
|
out = copy_chars(node->name(), node->name() + node->name_size(), out);
|
||||||
|
*out = Ch('>'), ++out;
|
||||||
|
}
|
||||||
|
return out;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Print declaration node
|
||||||
|
template<class OutIt, class Ch>
|
||||||
|
inline OutIt print_declaration_node(OutIt out, const xml_node<Ch> *node, int flags, int indent)
|
||||||
|
{
|
||||||
|
// Print declaration start
|
||||||
|
if (!(flags & print_no_indenting))
|
||||||
|
out = fill_chars(out, indent, Ch('\t'));
|
||||||
|
*out = Ch('<'), ++out;
|
||||||
|
*out = Ch('?'), ++out;
|
||||||
|
*out = Ch('x'), ++out;
|
||||||
|
*out = Ch('m'), ++out;
|
||||||
|
*out = Ch('l'), ++out;
|
||||||
|
|
||||||
|
// Print attributes
|
||||||
|
out = print_attributes(out, node, flags);
|
||||||
|
|
||||||
|
// Print declaration end
|
||||||
|
*out = Ch('?'), ++out;
|
||||||
|
*out = Ch('>'), ++out;
|
||||||
|
|
||||||
|
return out;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Print comment node
|
||||||
|
template<class OutIt, class Ch>
|
||||||
|
inline OutIt print_comment_node(OutIt out, const xml_node<Ch> *node, int flags, int indent)
|
||||||
|
{
|
||||||
|
assert(node->type() == node_comment);
|
||||||
|
if (!(flags & print_no_indenting))
|
||||||
|
out = fill_chars(out, indent, Ch('\t'));
|
||||||
|
*out = Ch('<'), ++out;
|
||||||
|
*out = Ch('!'), ++out;
|
||||||
|
*out = Ch('-'), ++out;
|
||||||
|
*out = Ch('-'), ++out;
|
||||||
|
out = copy_chars(node->value(), node->value() + node->value_size(), out);
|
||||||
|
*out = Ch('-'), ++out;
|
||||||
|
*out = Ch('-'), ++out;
|
||||||
|
*out = Ch('>'), ++out;
|
||||||
|
return out;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Print doctype node
|
||||||
|
template<class OutIt, class Ch>
|
||||||
|
inline OutIt print_doctype_node(OutIt out, const xml_node<Ch> *node, int flags, int indent)
|
||||||
|
{
|
||||||
|
assert(node->type() == node_doctype);
|
||||||
|
if (!(flags & print_no_indenting))
|
||||||
|
out = fill_chars(out, indent, Ch('\t'));
|
||||||
|
*out = Ch('<'), ++out;
|
||||||
|
*out = Ch('!'), ++out;
|
||||||
|
*out = Ch('D'), ++out;
|
||||||
|
*out = Ch('O'), ++out;
|
||||||
|
*out = Ch('C'), ++out;
|
||||||
|
*out = Ch('T'), ++out;
|
||||||
|
*out = Ch('Y'), ++out;
|
||||||
|
*out = Ch('P'), ++out;
|
||||||
|
*out = Ch('E'), ++out;
|
||||||
|
*out = Ch(' '), ++out;
|
||||||
|
out = copy_chars(node->value(), node->value() + node->value_size(), out);
|
||||||
|
*out = Ch('>'), ++out;
|
||||||
|
return out;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Print pi node
|
||||||
|
template<class OutIt, class Ch>
|
||||||
|
inline OutIt print_pi_node(OutIt out, const xml_node<Ch> *node, int flags, int indent)
|
||||||
|
{
|
||||||
|
assert(node->type() == node_pi);
|
||||||
|
if (!(flags & print_no_indenting))
|
||||||
|
out = fill_chars(out, indent, Ch('\t'));
|
||||||
|
*out = Ch('<'), ++out;
|
||||||
|
*out = Ch('?'), ++out;
|
||||||
|
out = copy_chars(node->name(), node->name() + node->name_size(), out);
|
||||||
|
*out = Ch(' '), ++out;
|
||||||
|
out = copy_chars(node->value(), node->value() + node->value_size(), out);
|
||||||
|
*out = Ch('?'), ++out;
|
||||||
|
*out = Ch('>'), ++out;
|
||||||
|
return out;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
//! \endcond
|
||||||
|
|
||||||
|
///////////////////////////////////////////////////////////////////////////
|
||||||
|
// Printing
|
||||||
|
|
||||||
|
//! Prints XML to given output iterator.
|
||||||
|
//! \param out Output iterator to print to.
|
||||||
|
//! \param node Node to be printed. Pass xml_document to print entire document.
|
||||||
|
//! \param flags Flags controlling how XML is printed.
|
||||||
|
//! \return Output iterator pointing to position immediately after last character of printed text.
|
||||||
|
template<class OutIt, class Ch>
|
||||||
|
inline OutIt print(OutIt out, const xml_node<Ch> &node, int flags = 0)
|
||||||
|
{
|
||||||
|
return internal::print_node(out, &node, flags, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifndef RAPIDXML_NO_STREAMS
|
||||||
|
|
||||||
|
//! Prints XML to given output stream.
|
||||||
|
//! \param out Output stream to print to.
|
||||||
|
//! \param node Node to be printed. Pass xml_document to print entire document.
|
||||||
|
//! \param flags Flags controlling how XML is printed.
|
||||||
|
//! \return Output stream.
|
||||||
|
template<class Ch>
|
||||||
|
inline std::basic_ostream<Ch> &print(std::basic_ostream<Ch> &out, const xml_node<Ch> &node, int flags = 0)
|
||||||
|
{
|
||||||
|
print(std::ostream_iterator<Ch>(out), node, flags);
|
||||||
|
return out;
|
||||||
|
}
|
||||||
|
|
||||||
|
//! Prints formatted XML to given output stream. Uses default printing flags. Use print() function to customize printing process.
|
||||||
|
//! \param out Output stream to print to.
|
||||||
|
//! \param node Node to be printed.
|
||||||
|
//! \return Output stream.
|
||||||
|
template<class Ch>
|
||||||
|
inline std::basic_ostream<Ch> &operator <<(std::basic_ostream<Ch> &out, const xml_node<Ch> &node)
|
||||||
|
{
|
||||||
|
return print(out, node);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
122
rapidxml/rapidxml_utils.hpp
Normal file
122
rapidxml/rapidxml_utils.hpp
Normal file
@@ -0,0 +1,122 @@
|
|||||||
|
#ifndef RAPIDXML_UTILS_HPP_INCLUDED
|
||||||
|
#define RAPIDXML_UTILS_HPP_INCLUDED
|
||||||
|
|
||||||
|
// Copyright (C) 2006, 2009 Marcin Kalicinski
|
||||||
|
// Version 1.13
|
||||||
|
// Revision $DateTime: 2009/05/13 01:46:17 $
|
||||||
|
//! \file rapidxml_utils.hpp This file contains high-level rapidxml utilities that can be useful
|
||||||
|
//! in certain simple scenarios. They should probably not be used if maximizing performance is the main objective.
|
||||||
|
|
||||||
|
#include "rapidxml.hpp"
|
||||||
|
#include <vector>
|
||||||
|
#include <string>
|
||||||
|
#include <fstream>
|
||||||
|
#include <stdexcept>
|
||||||
|
|
||||||
|
namespace rapidxml
|
||||||
|
{
|
||||||
|
|
||||||
|
//! Represents data loaded from a file
|
||||||
|
template<class Ch = char>
|
||||||
|
class file
|
||||||
|
{
|
||||||
|
|
||||||
|
public:
|
||||||
|
|
||||||
|
//! Loads file into the memory. Data will be automatically destroyed by the destructor.
|
||||||
|
//! \param filename Filename to load.
|
||||||
|
file(const char *filename)
|
||||||
|
{
|
||||||
|
using namespace std;
|
||||||
|
|
||||||
|
// Open stream
|
||||||
|
basic_ifstream<Ch> stream(filename, ios::binary);
|
||||||
|
if (!stream)
|
||||||
|
throw runtime_error(string("cannot open file ") + filename);
|
||||||
|
stream.unsetf(ios::skipws);
|
||||||
|
|
||||||
|
// Determine stream size
|
||||||
|
stream.seekg(0, ios::end);
|
||||||
|
size_t size = stream.tellg();
|
||||||
|
stream.seekg(0);
|
||||||
|
|
||||||
|
// Load data and add terminating 0
|
||||||
|
m_data.resize(size + 1);
|
||||||
|
stream.read(&m_data.front(), static_cast<streamsize>(size));
|
||||||
|
m_data[size] = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
//! Loads file into the memory. Data will be automatically destroyed by the destructor
|
||||||
|
//! \param stream Stream to load from
|
||||||
|
file(std::basic_istream<Ch> &stream)
|
||||||
|
{
|
||||||
|
using namespace std;
|
||||||
|
|
||||||
|
// Load data and add terminating 0
|
||||||
|
stream.unsetf(ios::skipws);
|
||||||
|
m_data.assign(istreambuf_iterator<Ch>(stream), istreambuf_iterator<Ch>());
|
||||||
|
if (stream.fail() || stream.bad())
|
||||||
|
throw runtime_error("error reading stream");
|
||||||
|
m_data.push_back(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
//! Gets file data.
|
||||||
|
//! \return Pointer to data of file.
|
||||||
|
Ch *data()
|
||||||
|
{
|
||||||
|
return &m_data.front();
|
||||||
|
}
|
||||||
|
|
||||||
|
//! Gets file data.
|
||||||
|
//! \return Pointer to data of file.
|
||||||
|
const Ch *data() const
|
||||||
|
{
|
||||||
|
return &m_data.front();
|
||||||
|
}
|
||||||
|
|
||||||
|
//! Gets file data size.
|
||||||
|
//! \return Size of file data, in characters.
|
||||||
|
std::size_t size() const
|
||||||
|
{
|
||||||
|
return m_data.size();
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
|
||||||
|
std::vector<Ch> m_data; // File data
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
//! Counts children of node. Time complexity is O(n).
|
||||||
|
//! \return Number of children of node
|
||||||
|
template<class Ch>
|
||||||
|
inline std::size_t count_children(xml_node<Ch> *node)
|
||||||
|
{
|
||||||
|
xml_node<Ch> *child = node->first_node();
|
||||||
|
std::size_t count = 0;
|
||||||
|
while (child)
|
||||||
|
{
|
||||||
|
++count;
|
||||||
|
child = child->next_sibling();
|
||||||
|
}
|
||||||
|
return count;
|
||||||
|
}
|
||||||
|
|
||||||
|
//! Counts attributes of node. Time complexity is O(n).
|
||||||
|
//! \return Number of attributes of node
|
||||||
|
template<class Ch>
|
||||||
|
inline std::size_t count_attributes(xml_node<Ch> *node)
|
||||||
|
{
|
||||||
|
xml_attribute<Ch> *attr = node->first_attribute();
|
||||||
|
std::size_t count = 0;
|
||||||
|
while (attr)
|
||||||
|
{
|
||||||
|
++count;
|
||||||
|
attr = attr->next_attribute();
|
||||||
|
}
|
||||||
|
return count;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
@@ -3,13 +3,14 @@
|
|||||||
// Used by Dialogs.rc
|
// Used by Dialogs.rc
|
||||||
//
|
//
|
||||||
#define IDI_ICON1 102
|
#define IDI_ICON1 102
|
||||||
#define IDC_PROPERTYGRID 2000
|
#define IDB_BITMAP1 103
|
||||||
|
#define IDC_PROPERTYGRID 2000
|
||||||
|
|
||||||
// Next default values for new objects
|
// Next default values for new objects
|
||||||
//
|
//
|
||||||
#ifdef APSTUDIO_INVOKED
|
#ifdef APSTUDIO_INVOKED
|
||||||
#ifndef APSTUDIO_READONLY_SYMBOLS
|
#ifndef APSTUDIO_READONLY_SYMBOLS
|
||||||
#define _APS_NEXT_RESOURCE_VALUE 103
|
#define _APS_NEXT_RESOURCE_VALUE 104
|
||||||
#define _APS_NEXT_COMMAND_VALUE 40001
|
#define _APS_NEXT_COMMAND_VALUE 40001
|
||||||
#define _APS_NEXT_CONTROL_VALUE 1001
|
#define _APS_NEXT_CONTROL_VALUE 1001
|
||||||
#define _APS_NEXT_SYMED_VALUE 101
|
#define _APS_NEXT_SYMED_VALUE 101
|
||||||
|
|||||||
Reference in New Issue
Block a user