diff --git a/Blocks3D.vcproj b/Blocks3D.vcproj
index e67dd6c..5634c0d 100644
--- a/Blocks3D.vcproj
+++ b/Blocks3D.vcproj
@@ -457,6 +457,10 @@
/>
+
+
@@ -505,6 +509,14 @@
RelativePath=".\src\source\DataModel\SelectionService.cpp"
>
+
+
+
+
@@ -866,6 +878,10 @@
RelativePath=".\src\include\DataModelV2\LevelInstance.h"
>
+
+
@@ -878,6 +894,14 @@
RelativePath=".\src\include\DataModelV2\SelectionService.h"
>
+
+
+
+
diff --git a/ThumbnailGeneratorInstance.cpp b/ThumbnailGeneratorInstance.cpp
index 898f67c..b2c078f 100644
--- a/ThumbnailGeneratorInstance.cpp
+++ b/ThumbnailGeneratorInstance.cpp
@@ -21,9 +21,15 @@ ThumbnailGeneratorInstance::~ThumbnailGeneratorInstance(void) {}
*/
std::string ThumbnailGeneratorInstance::click(std::string fileType, int cx, int cy, bool hideSky)
{
+ if(!G3D::GImage::supportedFormat(fileType)) {
+ printf("%s is not a valid fileType.", fileType);
+ return "";
+ }
+
RenderDevice* rd = g_usableApp->getRenderDevice();
GuiRootInstance* guiRoot = g_dataModel->getGuiRoot();
const G3D::GImage::Format format = G3D::GImage::stringToFormat(fileType);
+
int prevWidth = rd->width();
int prevHeight = rd->height();
G3D::GImage imgBuffer(cx, cy, 4);
@@ -33,7 +39,7 @@ std::string ThumbnailGeneratorInstance::click(std::string fileType, int cx, int
g_usableApp->resize3DView(cx, cy);
if(hideSky)
- g_usableApp->toggleSky();
+ g_dataModel->getLighting()->suppressSky(true);
g_usableApp->onGraphics(rd);
rd->screenshotPic(imgBuffer, true, hideSky);
diff --git a/content/sounds/bass.wav b/content/sounds/bass.wav
new file mode 100644
index 0000000..5f4b791
Binary files /dev/null and b/content/sounds/bass.wav differ
diff --git a/content/sounds/collide.wav b/content/sounds/collide.wav
new file mode 100644
index 0000000..ef4b9ec
Binary files /dev/null and b/content/sounds/collide.wav differ
diff --git a/content/sounds/glassbreak.wav b/content/sounds/glassbreak.wav
new file mode 100644
index 0000000..9b69670
Binary files /dev/null and b/content/sounds/glassbreak.wav differ
diff --git a/content/sounds/snap.wav b/content/sounds/snap.wav
new file mode 100644
index 0000000..79bd439
Binary files /dev/null and b/content/sounds/snap.wav differ
diff --git a/content/sounds/splat.wav b/content/sounds/splat.wav
new file mode 100644
index 0000000..33dc4bd
Binary files /dev/null and b/content/sounds/splat.wav differ
diff --git a/content/sounds/swoosh.wav b/content/sounds/swoosh.wav
new file mode 100644
index 0000000..e0d42da
Binary files /dev/null and b/content/sounds/swoosh.wav differ
diff --git a/content/sounds/victory.wav b/content/sounds/victory.wav
new file mode 100644
index 0000000..0c021f3
Binary files /dev/null and b/content/sounds/victory.wav differ
diff --git a/src/include/Application.h b/src/include/Application.h
index d72fd0f..fc84aeb 100644
--- a/src/include/Application.h
+++ b/src/include/Application.h
@@ -48,7 +48,6 @@ class Application { // : public GApp {
int getMode();
void unSetMode();
- void toggleSky();
CameraController cameraController;
UserInput* userInput;
PropertyWindow* _propWindow;
@@ -56,7 +55,6 @@ class Application { // : public GApp {
RenderDevice* getRenderDevice();
void selectInstance(Instance* selectedInstance,PropertyWindow* propWindow);
void setMode(int mode);
- SkyRef getSky();
void resize3DView(int w, int h);
Tool * tool;
@@ -68,7 +66,6 @@ class Application { // : public GApp {
RenderDevice* renderDevice;
//void initGUI();
HWND _hWndMain;
- SkyRef sky;
bool quit;
bool mouseOnScreen;
bool rightButtonHolding;
@@ -85,7 +82,6 @@ class Application { // : public GApp {
GAppSettings _settings;
double lightProjX, lightProjY, lightProjNear, lightProjFar;
IEBrowser* webBrowser;
- bool _hideSky;
protected:
Stopwatch m_graphicsWatch;
Stopwatch m_logicWatch;
diff --git a/src/include/AudioPlayer.h b/src/include/AudioPlayer.h
index 7467064..7068099 100644
--- a/src/include/AudioPlayer.h
+++ b/src/include/AudioPlayer.h
@@ -6,6 +6,7 @@ class AudioPlayer
public:
AudioPlayer(void);
~AudioPlayer(void);
- static void playSound(std::string);
+
static void init();
+ static void playSound(std::string);
};
diff --git a/src/include/DataModelV2/DataModelInstance.h b/src/include/DataModelV2/DataModelInstance.h
index 9591ffa..aceaf86 100644
--- a/src/include/DataModelV2/DataModelInstance.h
+++ b/src/include/DataModelV2/DataModelInstance.h
@@ -1,12 +1,18 @@
#pragma once
+
+// Instances
#include "WorkspaceInstance.h"
#include "LevelInstance.h"
#include "PartInstance.h"
-#include "ThumbnailGeneratorInstance.h"
#include "SelectionService.h"
-#include "rapidxml/rapidxml.hpp"
#include "GuiRootInstance.h"
+#include "ThumbnailGeneratorInstance.h"
#include "XplicitNgine/XplicitNgine.h"
+#include "SoundService.h"
+#include "LightingInstance.h"
+
+// Libraries
+#include "rapidxml/rapidxml.hpp"
class GuiRootInstance;
@@ -25,10 +31,13 @@ public:
bool readXMLFileStream(std::ifstream* file);
void drawMessage(RenderDevice*);
+ // Instance getters
WorkspaceInstance* getWorkspace();
LevelInstance* getLevel();
XplicitNgine* getEngine();
ThumbnailGeneratorInstance* getThumbnailGenerator();
+ SoundService* getSoundService();
+ LightingInstance* getLighting();
std::string message;
std::string _loadedFileName;
@@ -53,11 +62,16 @@ private:
std::string _errMsg;
bool _legacyLoad;
float _modY;
+
+ // Instances
WorkspaceInstance* workspace;
LevelInstance* level;
GuiRootInstance* guiRoot;
SelectionService* selectionService;
- ThumbnailGeneratorInstance * thumbnailGenerator;
+ ThumbnailGeneratorInstance* thumbnailGenerator;
+ XplicitNgine* xplicitNgine;
+ SoundService* soundService;
+ LightingInstance* lightingInstance;
bool running;
- XplicitNgine * xplicitNgine;
+
};
diff --git a/src/include/DataModelV2/Instance.h b/src/include/DataModelV2/Instance.h
index 532a1f1..be7eae1 100644
--- a/src/include/DataModelV2/Instance.h
+++ b/src/include/DataModelV2/Instance.h
@@ -2,7 +2,6 @@
#include
#include "propertyGrid.h"
#include "map"
-//#include "Properties/BoolProperty.h"
class Instance
{
diff --git a/src/include/DataModelV2/LightingInstance.h b/src/include/DataModelV2/LightingInstance.h
new file mode 100644
index 0000000..588b2ad
--- /dev/null
+++ b/src/include/DataModelV2/LightingInstance.h
@@ -0,0 +1,44 @@
+#pragma once
+#include "Instance.h"
+
+class LightingInstance :
+ public Instance
+{
+public:
+ LightingInstance(void);
+ ~LightingInstance(void);
+
+ // Getters
+ G3D::Color3 getTopAmbient();
+ G3D::Color3 getBottomAmbient();
+ G3D::Color3 getSpotLight();
+ G3D::Color4 getClearColor();
+ G3D::SkyRef getSky();
+ G3D::LightingParameters getLightingParameters();
+
+ // Setters
+ void setTopAmbient(G3D::Color3 newValue);
+ void setBottomAmbient(G3D::Color3 newValue);
+ void setSpotLight(G3D::Color3 newValue);
+ void setClearColor(G3D::Color4 clearColor);
+
+ // Functions
+ void drawSky();
+ void suppressSky(bool doSuppress);
+ void update();
+ void drawEffects();
+ void drawOutlines(Vector3 from, Vector3 to, RenderDevice* rd, Vector3 size, Vector3 pos, CoordinateFrame c);
+
+ // Properties
+ void PropUpdate(LPPROPGRIDITEM &pItem);
+ std::vector getProperties();
+
+private:
+ G3D::Color3 topAmbient;
+ G3D::Color3 bottomAmbient;
+ G3D::Color3 spotLight;
+ G3D::Color4 clearColor;
+ G3D::SkyRef sky;
+ G3D::LightingParameters lighting;
+ bool _hideSky;
+};
diff --git a/src/include/DataModelV2/PartInstance.h b/src/include/DataModelV2/PartInstance.h
index 5d8715b..ffbfce4 100644
--- a/src/include/DataModelV2/PartInstance.h
+++ b/src/include/DataModelV2/PartInstance.h
@@ -17,7 +17,7 @@ public:
virtual void PartInstance::postRender(RenderDevice* rd);
virtual void render(RenderDevice*);
virtual void renderName(RenderDevice*);
-
+
//Surfaces
Enum::SurfaceType::Value top;
Enum::SurfaceType::Value front;
@@ -25,8 +25,14 @@ public:
Enum::SurfaceType::Value back;
Enum::SurfaceType::Value left;
Enum::SurfaceType::Value bottom;
+
+ //Shapes
Enum::Shape::Value shape;
+ //OnTocuh
+ Enum::ActionType::Value OnTouchAction;
+ Enum::Sound::Value OnTouchSound;
+
//Variables
Color3 color;
bool canCollide;
@@ -43,6 +49,13 @@ public:
Box getScaledBox();
CoordinateFrame getCFrame();
+ //OnTouch Getters
+ bool isSingleShot();
+ int getTouchesToTrigger();
+ int getUniqueObjectsToTrigger();
+ int getChangeScore();
+ float getChangeTimer();
+
//Setters
void setParent(Instance* parent);
void setPosition(Vector3);
@@ -64,6 +77,9 @@ public:
bool collides(PartInstance * part);
bool collides(Box);
+ // onTouch
+ void onTouch();
+
//Properties
virtual std::vector getProperties();
virtual void PropUpdate(LPPROPGRIDITEM &pItem);
@@ -77,4 +93,12 @@ private:
bool dragging;
Box itemBox;
GLuint glList;
-};
+
+ // OnTouch
+ bool singleShot;
+ int touchesToTrigger;
+ int uniqueObjectsToTrigger;
+ int changeScore;
+ float changeTimer;
+ bool _touchedOnce;
+};
\ No newline at end of file
diff --git a/src/include/DataModelV2/SoundInstance.h b/src/include/DataModelV2/SoundInstance.h
new file mode 100644
index 0000000..c70d168
--- /dev/null
+++ b/src/include/DataModelV2/SoundInstance.h
@@ -0,0 +1,30 @@
+#pragma once
+#include "Instance.h"
+
+class SoundInstance :
+ public Instance
+{
+public:
+ SoundInstance(void);
+ ~SoundInstance(void);
+
+ // Getters
+ float getSoundVolume();
+ std::string getSoundId();
+ bool isPlayedOnRemove();
+ bool isLooped();
+
+ // Setters
+ void setSoundVolume(float newVolume);
+ void setSoundId(std::string newSoundId);
+ void setIsPlayedOnRemove(bool isPlayed);
+ void setIsLooped(bool isLooped);
+
+ // Functions
+ void play();
+private:
+ float soundVolume;
+ std::string soundId;
+ bool playOnRemove;
+ bool looped;
+};
diff --git a/src/include/DataModelV2/SoundService.h b/src/include/DataModelV2/SoundService.h
new file mode 100644
index 0000000..9063438
--- /dev/null
+++ b/src/include/DataModelV2/SoundService.h
@@ -0,0 +1,16 @@
+#pragma once
+#include "Instance.h"
+#include "SoundInstance.h"
+
+class SoundService :
+ public Instance
+{
+public:
+ SoundService(void);
+ ~SoundService(void);
+
+ float getMusicVolume();
+ void playSound(Instance* sound);
+private:
+ float musicVolume;
+};
diff --git a/src/include/Enum.h b/src/include/Enum.h
index 8d9fbe6..0643d95 100644
--- a/src/include/Enum.h
+++ b/src/include/Enum.h
@@ -32,4 +32,12 @@ namespace Enum
NoChange = 0, Increase = 1, Decrease = 2
};
}
+ namespace Sound
+ {
+ enum Value {
+ NoSound = 0, Victory = 1, Boing = 2, Bomb = 3,
+ Ping = 4, Break = 5, Splat = 6, Swoosh = 7,
+ Snap = 8, Page = 9
+ };
+ }
}
\ No newline at end of file
diff --git a/src/source/Application.cpp b/src/source/Application.cpp
index b76a100..9f4818b 100644
--- a/src/source/Application.cpp
+++ b/src/source/Application.cpp
@@ -71,7 +71,6 @@ Application::Application(HWND parentWindow) : _propWindow(NULL) { //: GApp(setti
CreateDirectory(tempPath.c_str(), NULL);
_hWndMain = parentWindow;
- _hideSky = false;
HMODULE hThisInstance = GetModuleHandle(NULL);
@@ -130,6 +129,8 @@ Application::Application(HWND parentWindow) : _propWindow(NULL) { //: GApp(setti
return;
}
+ AudioPlayer::init();
+
_window = renderDevice->window();
_window->makeCurrent();
@@ -294,7 +295,6 @@ void Application::onInit() {
void Application::onCleanup() {
clearInstances();
- sky->~Sky();
}
void Application::onLogic() {
@@ -407,90 +407,10 @@ int Application::getMode()
return _mode;
}
-
-void Application::drawOutline(Vector3 from, Vector3 to, RenderDevice* rd, LightingParameters lighting, Vector3 size, Vector3 pos, CoordinateFrame c)
-{
- rd->disableLighting();
- Color3 outline = Color3::cyan();
- float offsetSize = 0.05F;
- //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, 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, from.y + offsetSize, to.z + offsetSize), Vector3(to.x + offsetSize, from.y - offsetSize, to.z - offsetSize))), rd, outline, Color4::clear());
- //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(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.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(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());
-
- //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, 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(to.x + offsetSize, from.y + offsetSize, from.z - offsetSize), Vector3(to.x - offsetSize, from.y - offsetSize, to.z + offsetSize))), rd, outline, Color4::clear());
- Draw::box(c.toWorldSpace(Box(Vector3(to.x + offsetSize, to.y + offsetSize, from.z - offsetSize), Vector3(to.x - offsetSize, to.y - offsetSize, to.z + offsetSize))), rd, outline, Color4::clear());
-
- if(_mode == ARROWS)
- {
-
- AABox box;
- c.toWorldSpace(Box(from, to)).getBounds(box);
- float max = box.high().y - pos.y;
-
- Draw::arrow(pos, Vector3(0, 1.5+max, 0), rd);
- Draw::arrow(pos, Vector3(0, (-1.5)-max, 0), rd);
-
- max = box.high().x - pos.x;
-
- Draw::arrow(pos, Vector3(1.5+max, 0, 0), rd);
- Draw::arrow(pos, Vector3((-1.5)-max, 0, 0), rd);
-
- max = box.high().z - pos.z;
-
- Draw::arrow(pos, Vector3(0, 0, 1.5+max), rd);
- Draw::arrow(pos, Vector3(0, 0, (-1.5)-max), rd);
-
-
-
- }
- else if(_mode == RESIZE)
- {
- Color3 sphereColor = outline;
- Vector3 gamepoint = pos;
- 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 < 200)
- {
-
- float multiplier = distance * 0.025F/2;
- if(multiplier < 0.25F)
- multiplier = 0.25F;
- Vector3 position = pos + (c.lookVector()*((size.z)+1));
- Draw::sphere(Sphere(position, multiplier), rd, sphereColor, Color4::clear());
- position = pos - (c.lookVector()*((size.z)+1));
- Draw::sphere(Sphere(position, multiplier), rd, sphereColor, Color4::clear());
-
- position = pos + (c.rightVector()*((size.x)+1));
- Draw::sphere(Sphere(position, multiplier), rd, sphereColor, Color4::clear());
- position = pos - (c.rightVector()*((size.x)+1));
- Draw::sphere(Sphere(position, multiplier), rd, sphereColor, Color4::clear());
-
- position = pos + (c.upVector()*((size.y)+1));
- Draw::sphere(Sphere(position, multiplier), rd, sphereColor, Color4::clear());
- position = pos - (c.upVector()*((size.y)+1));
- Draw::sphere(Sphere(position, multiplier), rd, sphereColor, Color4::clear());
- }
- }
- rd->enableLighting();
-}
-
void Application::exitApplication()
{
}
-
-
-
void Application::onGraphics(RenderDevice* rd) {
G3D::uint8 num = 0;
@@ -519,57 +439,11 @@ void Application::onGraphics(RenderDevice* rd) {
ScreenToClient(_hWndMain, &mousepos);
}
- LightingParameters lighting(G3D::toSeconds(2, 00, 00, PM));
- lighting.ambient = Color3(0.6F,0.6F,0.6F);
- renderDevice->setProjectionAndCameraMatrix(*cameraController.getCamera());
+ renderDevice->setProjectionAndCameraMatrix(*cameraController.getCamera());
- // TODO: stick this into its own rendering thing
- if(!_hideSky) {
- renderDevice->clear(sky.isNull(), true, true);
- if (sky.notNull()) sky->render(renderDevice, lighting);
- } else {
- rd->setColorClearValue(Color4(0.0f, 0.0f, 0.0f, 0.0f));
- renderDevice->clear(true, true, true);
- toggleSky();
- }
-
- // Setup lighting
- renderDevice->enableLighting();
+ // Moved a lot of code to lighting
+ g_dataModel->getLighting()->update();
- renderDevice->setShadeMode(RenderDevice::SHADE_SMOOTH);
- renderDevice->setAmbientLightColor(Color3(1,1,1));
-
- renderDevice->setLight(0, GLight::directional(lighting.lightDirection, lighting.lightColor, true, true));
- renderDevice->setAmbientLightColor(lighting.ambient);
-
- rd->beforePrimitive();
- CoordinateFrame forDraw = rd->getObjectToWorldMatrix();
- glEnableClientState(GL_VERTEX_ARRAY);
- glEnableClientState(GL_COLOR_ARRAY);
- glEnableClientState(GL_NORMAL_ARRAY);
- _dataModel->getWorkspace()->render(rd);
- _dataModel->getWorkspace()->renderName(rd);
- glDisableClientState(GL_VERTEX_ARRAY);
- glDisableClientState(GL_COLOR_ARRAY);
- glDisableClientState(GL_NORMAL_ARRAY);
- rd->setObjectToWorldMatrix(forDraw);
- rd->afterPrimitive();
-
- for(size_t i = 0; i < _dataModel->getSelectionService()->getSelection().size(); i++)
- {
- if(PartInstance* part = dynamic_cast(g_dataModel->getSelectionService()->getSelection()[i]))
- {
- Vector3 size = part->getSize();
- Vector3 pos = part->getPosition();
- drawOutline(Vector3(0+size.x/2, 0+size.y/2, 0+size.z/2) ,Vector3(0-size.x/2,0-size.y/2,0-size.z/2), rd, lighting, Vector3(size.x/2, size.y/2, size.z/2), Vector3(pos.x, pos.y, pos.z), part->getCFrame());
- }
- }
-
- renderDevice->disableLighting();
-
- if (sky.notNull()) {
- sky->renderLensFlare(renderDevice, lighting);
- }
renderDevice->push2D();
_dataModel->getGuiRoot()->renderGUI(renderDevice, m_graphicsWatch.FPS());
renderDevice->pop2D();
@@ -653,7 +527,6 @@ void Application::run() {
cameraSound = GetFileInPath("/content/sounds/SWITCH3.wav");
clickSound = GetFileInPath("/content/sounds/switch.wav");
dingSound = GetFileInPath("/content/sounds/electronicpingshort.wav");
- sky = Sky::create(NULL, ExePath() + "/content/sky/");
RealTime now=0, lastTime=0;
double simTimeRate = 1.0f;
float fps=30.0f;
@@ -732,17 +605,6 @@ void Application::resizeWithParent(HWND parentWindow)
}
-// These should be moved into a "Lighting" class
-G3D::SkyRef Application::getSky()
-{
- return sky;
-}
-
-void Application::toggleSky()
-{
- _hideSky = !_hideSky;
-}
-
void Application::resize3DView(int w, int h)
{
Rect2D newViewport = Rect2D::xywh(0, 0, w, h);
diff --git a/src/source/AudioPlayer.cpp b/src/source/AudioPlayer.cpp
index 5c5e595..f23c280 100644
--- a/src/source/AudioPlayer.cpp
+++ b/src/source/AudioPlayer.cpp
@@ -4,7 +4,7 @@
#include
#include
#include
-#define NUM_SOUNDS 10
+#define NUM_SOUNDS 32
static SDL_AudioSpec fmt;
static bool initiated = false;
@@ -23,7 +23,7 @@ void AudioPlayer::init()
initiated = true;
extern void mixaudio(void *unused, Uint8 *stream, int len);
fmt.freq = 22050;
- fmt.format = AUDIO_S16;
+ fmt.format = AUDIO_S16LSB;
fmt.channels = 2;
fmt.samples = 1024; /* A good value for games */
fmt.callback = mixaudio;
diff --git a/src/source/DataModelV2/DataModelInstance.cpp b/src/source/DataModelV2/DataModelInstance.cpp
index 4da558f..79f0c84 100644
--- a/src/source/DataModelV2/DataModelInstance.cpp
+++ b/src/source/DataModelV2/DataModelInstance.cpp
@@ -1,8 +1,12 @@
#include
+
+// Instances
#include "DataModelV2/GuiRootInstance.h"
#include "DataModelV2/ToggleImageButtonInstance.h"
#include "DataModelV2/DataModelInstance.h"
#include "DataModelV2/ThumbnailGeneratorInstance.h"
+#include "DataModelV2/LightingInstance.h"
+
#include
#include
#include
@@ -14,14 +18,16 @@
using namespace std;
using namespace rapidxml;
-
DataModelInstance::DataModelInstance(void)
{
+ // Instances
Instance::Instance();
workspace = new WorkspaceInstance();
guiRoot = new GuiRootInstance();
level = new LevelInstance();
thumbnailGenerator = new ThumbnailGeneratorInstance();
+ soundService = new SoundService();
+ lightingInstance = new LightingInstance();
selectionService = new SelectionService();
selectionService->setPropertyWindow(g_usableApp->_propWindow);
@@ -29,8 +35,13 @@ DataModelInstance::DataModelInstance(void)
showMessage = false;
canDelete = false;
_modY=0;
+
+ // Parent stuff
workspace->setParent(this);
level->setParent(this);
+ soundService->setParent(this);
+ lightingInstance->setParent(this);
+
_loadedFileName="..//skooter.rbxm";
listicon = 5;
running = false;
@@ -655,3 +666,13 @@ ThumbnailGeneratorInstance* DataModelInstance::getThumbnailGenerator()
{
return thumbnailGenerator;
}
+
+SoundService* DataModelInstance::getSoundService()
+{
+ return soundService;
+}
+
+LightingInstance* DataModelInstance::getLighting()
+{
+ return lightingInstance;
+}
\ No newline at end of file
diff --git a/src/source/DataModelV2/GuiRootInstance.cpp b/src/source/DataModelV2/GuiRootInstance.cpp
index fa83d96..72bb220 100644
--- a/src/source/DataModelV2/GuiRootInstance.cpp
+++ b/src/source/DataModelV2/GuiRootInstance.cpp
@@ -157,6 +157,8 @@ GuiRootInstance::GuiRootInstance() : _message(""), _messageTime(0)
button->fontLocationRelativeTo = Vector2(10, 0);
button->setAllColorsSame();
button->boxColorOvr = Color4(0.6F,0.6F,0.6F,0.4F);
+ button->name = "edit";
+ button->setButtonListener(menuListener);
button = makeTextButton();
button->boxBegin = Vector2(250, 0);
@@ -171,6 +173,8 @@ GuiRootInstance::GuiRootInstance() : _message(""), _messageTime(0)
button->fontLocationRelativeTo = Vector2(10, 0);
button->setAllColorsSame();
button->boxColorOvr = Color4(0.6F,0.6F,0.6F,0.4F);
+ button->name = "view";
+ button->setButtonListener(menuListener);
button = makeTextButton();
button->boxBegin = Vector2(375, 0);
@@ -185,6 +189,8 @@ GuiRootInstance::GuiRootInstance() : _message(""), _messageTime(0)
button->fontLocationRelativeTo = Vector2(10, 0);
button->setAllColorsSame();
button->boxColorOvr = Color4(0.6F,0.6F,0.6F,0.4F);
+ button->name = "insert";
+ button->setButtonListener(menuListener);
button = makeTextButton();
button->boxBegin = Vector2(500, 0);
@@ -199,7 +205,8 @@ GuiRootInstance::GuiRootInstance() : _message(""), _messageTime(0)
button->fontLocationRelativeTo = Vector2(10, 0);
button->setAllColorsSame();
button->boxColorOvr = Color4(0.6F,0.6F,0.6F,0.4F);
-
+ button->name = "format";
+ button->setButtonListener(menuListener);
//Menu
button = makeTextButton();
diff --git a/src/source/DataModelV2/Instance.cpp b/src/source/DataModelV2/Instance.cpp
index ed2d162..a83a9a8 100644
--- a/src/source/DataModelV2/Instance.cpp
+++ b/src/source/DataModelV2/Instance.cpp
@@ -20,11 +20,8 @@ Instance::Instance(const Instance &oinst)
className = oinst.className;
canDelete = oinst.canDelete;
listicon = oinst.listicon;
- //setParent(oinst.parent);
}
-
-
void Instance::render(RenderDevice* rd)
{
for(size_t i = 0; i < children.size(); i++)
diff --git a/src/source/DataModelV2/LevelInstance.cpp b/src/source/DataModelV2/LevelInstance.cpp
index cd51b6d..53c20a4 100644
--- a/src/source/DataModelV2/LevelInstance.cpp
+++ b/src/source/DataModelV2/LevelInstance.cpp
@@ -123,7 +123,7 @@ std::vector LevelInstance::getProperties()
(LPARAM)scoreTxt,
PIT_EDIT));
- properties.push_back(createPGI("Gameplay",
+ properties.push_back(createPGI("Gameplay",
"TimerUpAction",
"Some temporary string here",
(LPARAM)strActionType(TimerUpAction),
@@ -131,7 +131,7 @@ std::vector LevelInstance::getProperties()
TEXT("Nothing\0Pause\0Lose\0Draw\0Win\0")
));
- properties.push_back(createPGI("Gameplay",
+ properties.push_back(createPGI("Gameplay",
"TimerAffectsScore",
"Some temporary string here",
(LPARAM)strAffectType(TimerAffectsScore),
@@ -140,6 +140,7 @@ std::vector LevelInstance::getProperties()
));
return properties;
}
+
void LevelInstance::PropUpdate(LPPROPGRIDITEM &pItem)
{
if(strcmp(pItem->lpszPropName, "InitialTimerValue") == 0)
diff --git a/src/source/DataModelV2/LightingInstance.cpp b/src/source/DataModelV2/LightingInstance.cpp
new file mode 100644
index 0000000..489ff9a
--- /dev/null
+++ b/src/source/DataModelV2/LightingInstance.cpp
@@ -0,0 +1,260 @@
+#include "DataModelV2/LightingInstance.h"
+#include "Application.h"
+#include "Globals.h"
+#include "StringFunctions.h"
+#include "Listener/ModeSelectionListener.h"
+
+LightingInstance::LightingInstance(void)
+{
+ Instance::Instance();
+ name = "Lighting";
+ className = "Lighting";
+ listicon = 10;
+ canDelete = false;
+
+ _hideSky = false;
+
+ lighting.setTime(G3D::toSeconds(2, 00, 00, PM));
+
+ // Maybe this is Top and Bottom Ambient?
+ lighting.ambient = Color3(0.5F, 0.5F, 0.5F);
+ lighting.lightColor = Color3(0.8F, 0.8F, 0.8F);
+
+ sky = Sky::create(NULL, ExePath() + "/content/sky/");
+ clearColor = Color4(0.0F, 0.0F, 0.0F, 0.0F);
+}
+
+LightingInstance::~LightingInstance(void)
+{
+ sky->~Sky();
+}
+
+// Getters
+G3D::SkyRef LightingInstance::getSky()
+{
+ return sky;
+}
+
+G3D::LightingParameters LightingInstance::getLightingParameters()
+{
+ return lighting;
+}
+
+std::vector LightingInstance::getProperties()
+{
+ std::vector properties = Instance::getProperties();
+
+ properties.push_back(createPGI("Appearance",
+ "TopAmbient",
+ "The color of the TopAmbient for 3D Objects",
+ RGB((topAmbient.r*255),(topAmbient.g*255),(topAmbient.b*255)),
+ PIT_COLOR
+ ));
+
+ properties.push_back(createPGI("Appearance",
+ "BottomAmbient",
+ "The color of the BottomAmbient for 3D Objects",
+ RGB((bottomAmbient.r*255),(bottomAmbient.g*255),(bottomAmbient.b*255)),
+ PIT_COLOR
+ ));
+
+ properties.push_back(createPGI("Appearance",
+ "SpotLight",
+ "The color of the SpotLight",
+ RGB((spotLight.r*255),(spotLight.g*255),(spotLight.b*255)),
+ PIT_COLOR
+ ));
+
+ properties.push_back(createPGI("Appearance",
+ "ClearColor",
+ "",
+ RGB((clearColor.r*255),(clearColor.g*255),(clearColor.b*255)),
+ PIT_COLOR
+ ));
+ return properties;
+}
+
+
+void LightingInstance::PropUpdate(LPPROPGRIDITEM &item)
+{
+ if(strcmp(item->lpszPropName, "TopAmbient") == 0)
+ {
+ topAmbient = Color3(
+ GetRValue(item->lpCurValue)/255.0F,
+ GetGValue(item->lpCurValue)/255.0F,
+ GetBValue(item->lpCurValue)/255.0F
+ );
+ }
+ if(strcmp(item->lpszPropName, "BottomAmbient") == 0)
+ {
+ bottomAmbient = Color3(
+ GetRValue(item->lpCurValue)/255.0F,
+ GetGValue(item->lpCurValue)/255.0F,
+ GetBValue(item->lpCurValue)/255.0F
+ );
+ }
+ if(strcmp(item->lpszPropName, "SpotLight") == 0)
+ {
+ spotLight = Color3(
+ GetRValue(item->lpCurValue)/255.0F,
+ GetGValue(item->lpCurValue)/255.0F,
+ GetBValue(item->lpCurValue)/255.0F
+ );
+ }
+ if(strcmp(item->lpszPropName, "ClearColor") == 0)
+ {
+ clearColor = Color3(
+ GetRValue(item->lpCurValue)/255.0F,
+ GetGValue(item->lpCurValue)/255.0F,
+ GetBValue(item->lpCurValue)/255.0F
+ );
+ }
+
+ else
+ Instance::PropUpdate(item);
+}
+
+
+// Functions
+void LightingInstance::suppressSky(bool doSuppress)
+{
+ _hideSky = doSuppress;
+}
+
+void LightingInstance::update()
+{
+ RenderDevice* rd = g_usableApp->getRenderDevice();
+
+
+ if(!_hideSky) {
+ rd->clear(sky.isNull(), true, true);
+ if (sky.notNull()) sky->render(rd, lighting);
+ } else {
+ rd->setColorClearValue(clearColor);
+ rd->clear(true, true, true);
+ suppressSky(false);
+ }
+
+ // Setup lighting
+ rd->enableLighting();
+
+ rd->setShadeMode(RenderDevice::SHADE_SMOOTH);
+ rd->setAmbientLightColor(Color3(1,1,1));
+
+ rd->setLight(0, GLight::directional(lighting.lightDirection, lighting.lightColor, true, true));
+ rd->setAmbientLightColor(lighting.ambient);
+
+ rd->beforePrimitive();
+ CoordinateFrame forDraw = rd->getObjectToWorldMatrix();
+ glEnableClientState(GL_VERTEX_ARRAY);
+ glEnableClientState(GL_COLOR_ARRAY);
+ glEnableClientState(GL_NORMAL_ARRAY);
+ g_dataModel->getWorkspace()->render(rd);
+ g_dataModel->getWorkspace()->renderName(rd);
+ glDisableClientState(GL_VERTEX_ARRAY);
+ glDisableClientState(GL_COLOR_ARRAY);
+ glDisableClientState(GL_NORMAL_ARRAY);
+ rd->setObjectToWorldMatrix(forDraw);
+ rd->afterPrimitive();
+
+ // Draw outlines
+ for(size_t i = 0; i < g_dataModel->getSelectionService()->getSelection().size(); i++)
+ {
+ if(PartInstance* part = dynamic_cast(g_dataModel->getSelectionService()->getSelection()[i]))
+ {
+ Vector3 size = part->getSize();
+ Vector3 pos = part->getPosition();
+ drawOutlines(
+ Vector3(0+size.x/2, 0+size.y/2, 0+size.z/2) ,
+ Vector3(0-size.x/2,0-size.y/2,0-size.z/2),
+ rd,
+ Vector3(size.x/2, size.y/2, size.z/2),
+ Vector3(pos.x, pos.y, pos.z),
+ part->getCFrame()
+ );
+ }
+ }
+
+ rd->disableLighting();
+
+ drawEffects();
+}
+
+void LightingInstance::drawEffects()
+{
+ RenderDevice* rd = g_usableApp->getRenderDevice();
+ if (sky.notNull()) {
+ sky->renderLensFlare(rd, lighting);
+ }
+}
+
+void LightingInstance::drawOutlines(Vector3 from, Vector3 to, RenderDevice* rd, Vector3 size, Vector3 pos, CoordinateFrame c)
+{
+ Color3 outline = Color3::cyan();
+ float offsetSize = 0.05F;
+
+ //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, 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, from.y + offsetSize, to.z + offsetSize), Vector3(to.x + offsetSize, from.y - offsetSize, to.z - offsetSize))), rd, outline, Color4::clear());
+ //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(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.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(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());
+
+ //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, 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(to.x + offsetSize, from.y + offsetSize, from.z - offsetSize), Vector3(to.x - offsetSize, from.y - offsetSize, to.z + offsetSize))), rd, outline, Color4::clear());
+ Draw::box(c.toWorldSpace(Box(Vector3(to.x + offsetSize, to.y + offsetSize, from.z - offsetSize), Vector3(to.x - offsetSize, to.y - offsetSize, to.z + offsetSize))), rd, outline, Color4::clear());
+
+ if(g_usableApp->getMode() == ARROWS)
+ {
+ AABox box;
+ c.toWorldSpace(Box(from, to)).getBounds(box);
+ float max = box.high().y - pos.y;
+
+ Draw::arrow(pos, Vector3(0, 1.5+max, 0), rd);
+ Draw::arrow(pos, Vector3(0, (-1.5)-max, 0), rd);
+
+ max = box.high().x - pos.x;
+
+ Draw::arrow(pos, Vector3(1.5+max, 0, 0), rd);
+ Draw::arrow(pos, Vector3((-1.5)-max, 0, 0), rd);
+
+ max = box.high().z - pos.z;
+
+ Draw::arrow(pos, Vector3(0, 0, 1.5+max), rd);
+ Draw::arrow(pos, Vector3(0, 0, (-1.5)-max), rd);
+ }
+ else if(g_usableApp->getMode() == RESIZE)
+ {
+ Color3 sphereColor = outline;
+ Vector3 gamepoint = pos;
+ 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 < 200)
+ {
+
+ float multiplier = distance * 0.025F/2;
+ if(multiplier < 0.25F)
+ multiplier = 0.25F;
+ Vector3 position = pos + (c.lookVector()*((size.z)+1));
+ Draw::sphere(Sphere(position, multiplier), rd, sphereColor, Color4::clear());
+ position = pos - (c.lookVector()*((size.z)+1));
+ Draw::sphere(Sphere(position, multiplier), rd, sphereColor, Color4::clear());
+
+ position = pos + (c.rightVector()*((size.x)+1));
+ Draw::sphere(Sphere(position, multiplier), rd, sphereColor, Color4::clear());
+ position = pos - (c.rightVector()*((size.x)+1));
+ Draw::sphere(Sphere(position, multiplier), rd, sphereColor, Color4::clear());
+
+ position = pos + (c.upVector()*((size.y)+1));
+ Draw::sphere(Sphere(position, multiplier), rd, sphereColor, Color4::clear());
+ position = pos - (c.upVector()*((size.y)+1));
+ Draw::sphere(Sphere(position, multiplier), rd, sphereColor, Color4::clear());
+ }
+ }
+}
\ No newline at end of file
diff --git a/src/source/DataModelV2/PartInstance.cpp b/src/source/DataModelV2/PartInstance.cpp
index b33e9b7..8463f2b 100644
--- a/src/source/DataModelV2/PartInstance.cpp
+++ b/src/source/DataModelV2/PartInstance.cpp
@@ -4,6 +4,8 @@
#include
#include
#include "Faces.h"
+#include "AudioPlayer.h"
+#include "StringFunctions.h"
PartInstance::PartInstance(void)
{
@@ -27,6 +29,15 @@ PartInstance::PartInstance(void)
left = Enum::SurfaceType::Smooth;
bottom = Enum::SurfaceType::Smooth;
shape = Enum::Shape::Block;
+ _touchedOnce = false;
+
+ // OnTouch
+ singleShot = true;
+ touchesToTrigger = 1;
+ uniqueObjectsToTrigger = 1;
+ changeScore = 0;
+ changeTimer = 0;
+ singleShot = true;
}
bool PartInstance::isDragging()
@@ -60,6 +71,32 @@ Vector3 PartInstance::getRotVelocity()
return rotVelocity;
}
+// OnTouch
+bool PartInstance::isSingleShot()
+{
+ return singleShot;
+}
+
+int PartInstance::getTouchesToTrigger()
+{
+ return touchesToTrigger;
+}
+
+int PartInstance::getUniqueObjectsToTrigger()
+{
+ return uniqueObjectsToTrigger;
+}
+
+int PartInstance::getChangeScore()
+{
+ return changeScore;
+}
+
+float PartInstance::getChangeTimer()
+{
+ return changeTimer;
+}
+
void PartInstance::setVelocity(Vector3 v)
{
velocity = v;
@@ -169,8 +206,6 @@ PartInstance::PartInstance(const PartInstance &oinst)
PVInstance::PVInstance(oinst);
physBody = NULL;
glList = glGenLists(1);
- //name = oinst.name;
- //className = "Part";
name = oinst.name;
canCollide = oinst.canCollide;
setParent(oinst.parent);
@@ -188,6 +223,17 @@ PartInstance::PartInstance(const PartInstance &oinst)
bottom = oinst.bottom;
shape = oinst.shape;
changed = true;
+
+ // OnTouch
+ singleShot = oinst.singleShot;
+ touchesToTrigger = oinst.touchesToTrigger;
+ uniqueObjectsToTrigger = oinst.uniqueObjectsToTrigger;
+ changeScore = oinst.changeScore;
+ changeTimer = oinst.changeTimer;
+ OnTouchAction = oinst.OnTouchAction;
+ OnTouchSound = oinst.OnTouchSound;
+ singleShot = oinst.singleShot;
+ _touchedOnce = false;
}
void PartInstance::setSize(Vector3 newSize)
@@ -368,6 +414,7 @@ char pto[512];
char pto2[512];
#include
+// Shape
static Enum::Shape::Value strEnum(TCHAR* shape)
{
if(strcmp("Block", shape) == 0)
@@ -391,12 +438,166 @@ static TCHAR* enumStr(int shape)
return "Block";
}
+// ActionType
+static TCHAR* strActionType(int option)
+{
+ switch(option)
+ {
+ case Enum::ActionType::Nothing:
+ return "Nothing";
+ case Enum::ActionType::Pause:
+ return "Pause";
+ case Enum::ActionType::Lose:
+ return "Lose";
+ case Enum::ActionType::Draw:
+ return "Draw";
+ case Enum::ActionType::Win:
+ return "Win";
+ }
+ return "Nothing";
+}
+
+static Enum::ActionType::Value EnumOnTouchActionType(TCHAR* option)
+{
+ if(strcmp("Nothing", option) == 0)
+ return Enum::ActionType::Nothing;
+ if(strcmp("Pause", option) == 0)
+ return Enum::ActionType::Pause;
+ if(strcmp("Lose", option) == 0)
+ return Enum::ActionType::Lose;
+ if(strcmp("Draw", option) == 0)
+ return Enum::ActionType::Draw;
+ return Enum::ActionType::Win;
+}
+
+// SoundType
+static TCHAR* strSoundType(int option)
+{
+ switch(option)
+ {
+ case Enum::Sound::NoSound:
+ return "NoSound";
+ case Enum::Sound::Victory:
+ return "Victory";
+ case Enum::Sound::Boing:
+ return "Boing";
+ case Enum::Sound::Splat:
+ return "Splat";
+ case Enum::Sound::Snap:
+ return "Snap";
+ case Enum::Sound::Bomb:
+ return "Bomb";
+ case Enum::Sound::Break:
+ return "Break";
+ case Enum::Sound::Ping:
+ return "Ping";
+ case Enum::Sound::Swoosh:
+ return "Swoosh";
+ case Enum::Sound::Page:
+ return "Page";
+ }
+ return "NoSound";
+}
+
+static Enum::Sound::Value EnumOnTouchSoundType(TCHAR* option)
+{
+ if(strcmp("Nothing", option) == 0)
+ return Enum::Sound::NoSound;
+ if(strcmp("Victory", option) == 0)
+ return Enum::Sound::Victory;
+ if(strcmp("Boing", option) == 0)
+ return Enum::Sound::Boing;
+ if(strcmp("Splat", option) == 0)
+ return Enum::Sound::Splat;
+ if(strcmp("Bomb", option) == 0)
+ return Enum::Sound::Bomb;
+ if(strcmp("Break", option) == 0)
+ return Enum::Sound::Break;
+ if(strcmp("Swoosh", option) == 0)
+ return Enum::Sound::Swoosh;
+ if(strcmp("Page", option) == 0)
+ return Enum::Sound::Page;
+ if(strcmp("Ping", option) == 0)
+ return Enum::Sound::Ping;
+ if(strcmp("Snap", option) == 0)
+ return Enum::Sound::Snap;
+
+ return Enum::Sound::NoSound;
+}
+
+void PartInstance::onTouch()
+{
+ if(singleShot && _touchedOnce)
+ return;
+
+ if(singleShot && !_touchedOnce)
+ _touchedOnce = true;
+
+ g_dataModel->getLevel()->score += changeScore;
+ g_dataModel->getLevel()->timer += changeTimer;
+
+ switch(OnTouchAction)
+ {
+ case Enum::ActionType::Nothing:
+ break;
+ case Enum::ActionType::Pause:
+ break;
+ case Enum::ActionType::Lose:
+ g_dataModel->getLevel()->loseCondition();
+ break;
+ case Enum::ActionType::Draw:
+ break;
+ case Enum::ActionType::Win:
+ g_dataModel->getLevel()->winCondition();
+ break;
+ }
+
+ SoundService* sndService = g_dataModel->getSoundService();
+
+ switch(OnTouchSound)
+ {
+ case Enum::Sound::NoSound:
+ break;
+ case Enum::Sound::Victory:
+ sndService->playSound(sndService->findFirstChild("Victory"));
+ break;
+ case Enum::Sound::Boing:
+ sndService->playSound(sndService->findFirstChild("Boing"));
+ break;
+ case Enum::Sound::Break:
+ sndService->playSound(sndService->findFirstChild("Break"));
+ break;
+ case Enum::Sound::Snap:
+ sndService->playSound(sndService->findFirstChild("Snap"));
+ break;
+ case Enum::Sound::Bomb:
+ sndService->playSound(sndService->findFirstChild("Bomb"));
+ break;
+ case Enum::Sound::Splat:
+ sndService->playSound(sndService->findFirstChild("Splat"));
+ break;
+ case Enum::Sound::Page:
+ sndService->playSound(sndService->findFirstChild("Page"));
+ break;
+ case Enum::Sound::Ping:
+ sndService->playSound(sndService->findFirstChild("Ping"));
+ break;
+ case Enum::Sound::Swoosh:
+ sndService->playSound(sndService->findFirstChild("Swoosh"));
+ break;
+ }
+}
+
void PartInstance::PropUpdate(LPPROPGRIDITEM &item)
{
setChanged();
if(strcmp(item->lpszPropName, "Color3") == 0)
{
- color = Color3(GetRValue(item->lpCurValue)/255.0F,GetGValue(item->lpCurValue)/255.0F,GetBValue(item->lpCurValue)/255.0F);
+ color = Color3(
+ GetRValue(item->lpCurValue)/255.0F,
+ GetGValue(item->lpCurValue)/255.0F,
+ GetBValue(item->lpCurValue)/255.0F
+ );
}
else if(strcmp(item->lpszPropName, "Anchored") == 0)
{
@@ -417,13 +618,6 @@ void PartInstance::PropUpdate(LPPROPGRIDITEM &item)
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
if(vect.size() == 3)
{
Vector3 pos(vect.at(0),vect.at(1),vect.at(2));
@@ -446,13 +640,6 @@ void PartInstance::PropUpdate(LPPROPGRIDITEM &item)
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*/
if(vect.size() == 3)
{
Vector3 size(vect.at(0),vect.at(1),vect.at(2));
@@ -464,52 +651,104 @@ void PartInstance::PropUpdate(LPPROPGRIDITEM &item)
printf("%s", enumStr(strEnum((TCHAR*)item->lpCurValue)));
setShape(strEnum((TCHAR*)item->lpCurValue));
}
+ else if(strcmp(item->lpszPropName, "Action") == 0)
+ {
+ OnTouchAction = EnumOnTouchActionType((TCHAR*)item->lpCurValue);
+ }
+ else if (strcmp(item->lpszPropName, "Sound") == 0)
+ {
+ OnTouchSound = EnumOnTouchSoundType((TCHAR*)item->lpCurValue);
+ }
+ else if (strcmp(item->lpszPropName, "ChangeScore") == 0)
+ {
+ changeScore = atoi((LPSTR)item->lpCurValue);
+ }
+ else if (strcmp(item->lpszPropName, "ChangeTimer") == 0)
+ {
+ changeTimer = atof((LPSTR)item->lpCurValue);
+ }
+ else if (strcmp(item->lpszPropName, "SingleShot") == 0)
+ {
+ singleShot = item->lpCurValue == TRUE;
+ }
else PVInstance::PropUpdate(item);
}
+// This needs to be changed, buffer size of 12 is way too small
+// Crash occurs if you put a huge number in
+char changeTimerTxt[12];
+char changeScoreTxt[12];
std::vector PartInstance::getProperties()
{
std::vector properties = PVInstance::getProperties();
- properties.push_back(createPGI(
- "Properties",
+ properties.push_back(createPGI("Properties",
"Color3",
"The color of the selected part",
RGB((color.r*255),(color.g*255),(color.b*255)),
PIT_COLOR
));
- properties.push_back(createPGI(
- "Item",
+ properties.push_back(createPGI("Item",
"Anchored",
"Whether the block can move or not",
(LPARAM)anchored,
PIT_CHECK
));
sprintf_s(pto, "%g, %g, %g", position.x, position.y, position.z);
- properties.push_back(createPGI(
- "Item",
+ properties.push_back(createPGI("Item",
"Offset",
"The position of the object in the workspace",
(LPARAM)pto,
PIT_EDIT
));
sprintf_s(pto2, "%g, %g, %g", size.x, size.y, size.z);
- properties.push_back(createPGI(
- "Item",
+ properties.push_back(createPGI("Item",
"Size",
- "The position of the object in the workspace",
+ "The size of the object in the workspace",
(LPARAM)pto2,
PIT_EDIT
));
- properties.push_back(createPGI(
- "Item",
+ properties.push_back(createPGI("Item",
"Shape",
"The shape of the object in the workspace",
(LPARAM)enumStr(shape),
PIT_COMBO,
TEXT("Ball\0Block\0Cylinder\0")
));
+ properties.push_back(createPGI("OnTouch",
+ "Action",
+ "What action is taken when touched",
+ (LPARAM)strActionType(OnTouchAction),
+ PIT_COMBO,
+ TEXT("Nothing\0Pause\0Lose\0Draw\0Win\0")
+ ));
+ properties.push_back(createPGI("OnTouch",
+ "Sound",
+ "What sound plays when touched",
+ (LPARAM)strSoundType(OnTouchSound),
+ PIT_COMBO,
+ TEXT("NoSound\0Victory\0Boing\0Break\0Snap\0Bomb\0Splat\0Page\0Ping\0Swoosh\0")
+ ));
+
+ sprintf_s(changeScoreTxt, "%d", changeScore);
+ sprintf_s(changeTimerTxt, "%g", changeTimer);
+ properties.push_back(createPGI("OnTouch",
+ "ChangeScore",
+ "How the score is affected when touched",
+ (LPARAM)changeScoreTxt,
+ PIT_EDIT));
+ properties.push_back(createPGI("OnTouch",
+ "ChangeTimer",
+ "How the timer is affected when touched",
+ (LPARAM)changeTimerTxt,
+ PIT_EDIT));
+ properties.push_back(createPGI("OnTouch",
+ "SingleShot",
+ "Whether or not Action happens only once",
+ (LPARAM)singleShot,
+ PIT_CHECK
+ ));
return properties;
}
diff --git a/src/source/DataModelV2/SoundInstance.cpp b/src/source/DataModelV2/SoundInstance.cpp
new file mode 100644
index 0000000..b53cc74
--- /dev/null
+++ b/src/source/DataModelV2/SoundInstance.cpp
@@ -0,0 +1,53 @@
+#include "DataModelV2/SoundInstance.h"
+#include "Globals.h"
+
+SoundInstance::SoundInstance()
+{
+ name = "Sound";
+ className = "Sound";
+ listicon = 8;
+
+ soundVolume = 0.5;
+ soundId = "";
+ playOnRemove = false;
+ looped = false;
+}
+
+SoundInstance::~SoundInstance(void)
+{
+ if(isPlayedOnRemove())
+ play();
+}
+
+// Functions
+void SoundInstance::play()
+{
+ g_dataModel->getSoundService()->playSound(this);
+}
+
+// Getters
+float SoundInstance::getSoundVolume()
+{
+ return soundVolume;
+}
+
+bool SoundInstance::isPlayedOnRemove()
+{
+ return playOnRemove;
+}
+
+std::string SoundInstance::getSoundId()
+{
+ return soundId;
+}
+
+bool SoundInstance::isLooped()
+{
+ return looped;
+}
+
+// Setters
+void SoundInstance::setSoundId(std::string newSoundId)
+{
+ soundId = newSoundId;
+}
\ No newline at end of file
diff --git a/src/source/DataModelV2/SoundService.cpp b/src/source/DataModelV2/SoundService.cpp
new file mode 100644
index 0000000..bd26307
--- /dev/null
+++ b/src/source/DataModelV2/SoundService.cpp
@@ -0,0 +1,90 @@
+#include "DataModelV2/SoundService.h"
+#include "StringFunctions.h"
+#include "AudioPlayer.h"
+#include "Globals.h"
+
+SoundService::SoundService()
+{
+ name = "SoundService";
+ className = "SoundService";
+ musicVolume = 0.3f;
+ listicon = 8;
+ canDelete = false;
+
+ // Create stock sounds
+ SoundInstance* stockSound = new SoundInstance();
+
+ // Victory
+ stockSound = new SoundInstance();
+ stockSound->setName("Victory");
+ stockSound->setSoundId("/content/sounds/victory.wav");
+ stockSound->setParent(this);
+
+ // Boing
+ stockSound = new SoundInstance();
+ stockSound->setName("Boing");
+ stockSound->setSoundId("/content/sounds/bass.wav");
+ stockSound->setParent(this);
+
+ // Bomb
+ stockSound = new SoundInstance();
+ stockSound->setName("Bomb");
+ stockSound->setSoundId("/content/sounds/collide.wav");
+ stockSound->setParent(this);
+
+ // Ping
+ stockSound = new SoundInstance();
+ stockSound->setName("Ping");
+ stockSound->setSoundId("/content/sounds/electronicpingshort.wav");
+ stockSound->setParent(this);
+
+ // Break
+ stockSound = new SoundInstance();
+ stockSound->setName("Break");
+ stockSound->setSoundId("/content/sounds/glassbreak.wav");
+ stockSound->setParent(this);
+
+ // Splat
+ stockSound = new SoundInstance();
+ stockSound->setName("Splat");
+ stockSound->setSoundId("/content/sounds/splat.wav");
+ stockSound->setParent(this);
+
+ // Swoosh
+ stockSound = new SoundInstance();
+ stockSound->setName("Swoosh");
+ stockSound->setSoundId("/content/sounds/swoosh.wav");
+ stockSound->setParent(this);
+
+ // Snap
+ stockSound = new SoundInstance();
+ stockSound->setName("Snap");
+ stockSound->setSoundId("/content/sounds/snap.wav");
+ stockSound->setParent(this);
+
+ // Page
+ stockSound = new SoundInstance();
+ stockSound->setName("Page");
+ stockSound->setSoundId("/content/sounds/pageturn.wav");
+ stockSound->setParent(this);
+}
+
+SoundService::~SoundService(void)
+{
+}
+
+void SoundService::playSound(Instance* sound)
+{
+ // Try to dynamic_cast it to SoundInstance
+ SoundInstance* sndInst = dynamic_cast(sound);
+ if(sndInst != NULL)
+ {
+ std::string soundId = sndInst->getSoundId();
+ AudioPlayer::playSound(GetFileInPath(soundId));
+ }
+}
+
+float SoundService::getMusicVolume()
+{
+ return musicVolume;
+}
\ No newline at end of file
diff --git a/src/source/Listener/MenuButtonListener.cpp b/src/source/Listener/MenuButtonListener.cpp
index 4f0b02b..fbd6d67 100644
--- a/src/source/Listener/MenuButtonListener.cpp
+++ b/src/source/Listener/MenuButtonListener.cpp
@@ -34,4 +34,19 @@ void MenuButtonListener::onButton1MouseClick(BaseButtonInstance* button)
break;
}
}
+ else if(button->name == "view")
+ {
+ HMENU mainmenu = CreatePopupMenu();
+ AppendMenu(mainmenu, MF_STRING, 103, "Image Server Model View");
+
+ POINT p;
+ GetCursorPos(&p);
+ int menuClick = TrackPopupMenu(mainmenu, TPM_LEFTBUTTON | TPM_RETURNCMD, p.x, p.y, 0, Globals::mainHwnd, 0);
+ switch (menuClick)
+ {
+ case 103:
+ g_dataModel->getThumbnailGenerator()->click("PNG", 512, 512, true);
+ break;
+ }
+ }
}
\ No newline at end of file
diff --git a/src/source/XplicitNgine/XplicitNgine.cpp b/src/source/XplicitNgine/XplicitNgine.cpp
index 7421fb7..8373c8f 100644
--- a/src/source/XplicitNgine/XplicitNgine.cpp
+++ b/src/source/XplicitNgine/XplicitNgine.cpp
@@ -25,10 +25,10 @@ XplicitNgine::~XplicitNgine()
dCloseODE();
}
-void XplicitNgine::resetBody(PartInstance* partInstance)
-{
- deleteBody(partInstance);
- createBody(partInstance);
+void XplicitNgine::resetBody(PartInstance* partInstance)
+{
+ deleteBody(partInstance);
+ createBody(partInstance);
}
void collisionCallback(void *data, dGeomID o1, dGeomID o2)
@@ -37,10 +37,12 @@ void collisionCallback(void *data, dGeomID o1, dGeomID o2)
dBodyID b1 = dGeomGetBody(o1);
dBodyID b2 = dGeomGetBody(o2);
-
+
if (b1 && b2 && dAreConnected(b1, b2))
return;
+
+
const int N = 4;
dContact contact[N];
n = dCollide (o1,o2,N,&contact[0].geom,sizeof(dContact));
@@ -62,8 +64,17 @@ void collisionCallback(void *data, dGeomID o1, dGeomID o2)
g_xplicitNgine->contactgroup,
contact+i
);
-
+
dJointAttach (c,b1,b2);
+
+ if(b1 != NULL)
+ {
+ PartInstance* touched = (PartInstance*)dGeomGetData(o2);
+ if(touched != NULL)
+ {
+ touched->onTouch();
+ }
+ }
}
}
}
@@ -123,6 +134,7 @@ void XplicitNgine::createBody(PartInstance* partInstance)
partInstance->physBody = dBodyCreate(physWorld);
dBodySetData(partInstance->physBody, partInstance);
+
// Create geom
if(partInstance->shape == Enum::Shape::Block)
{
@@ -140,6 +152,9 @@ void XplicitNgine::createBody(PartInstance* partInstance)
partInstance->physGeom[0] = dCreateSphere(physSpace, partSize[0]/2);
}
+ if(partInstance->physGeom[0])
+ dGeomSetData(partInstance->physGeom[0], partInstance);
+
dMass mass;
mass.setBox(sqrt(partSize.x*2), sqrt(partSize.y*2), sqrt(partSize.z*2), 0.7F);
dBodySetMass(partInstance->physBody, &mass);
diff --git a/src/source/main.cpp b/src/source/main.cpp
index 18a8bd3..856768b 100644
--- a/src/source/main.cpp
+++ b/src/source/main.cpp
@@ -159,8 +159,6 @@ int main(int argc, char** argv) {
icc.dwICC = ICC_WIN95_CLASSES/*|ICC_COOL_CLASSES|ICC_DATE_CLASSES|
ICC_PAGESCROLLER_CLASS|ICC_USEREX_CLASSES*/;
InitCommonControlsEx(&icc);
-
- AudioPlayer::init();
HMODULE hThisInstance = GetModuleHandle(NULL);
if (!createWindowClass("mainHWND",WndProc,hThisInstance))