Compare commits
31 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
09c6a73e80 | ||
|
|
3108021007 | ||
|
|
fa3a0f9aa4 | ||
|
|
f45e8afb37 | ||
|
|
739f116895 | ||
|
|
f281103ca1 | ||
|
|
b7d14dcf2a | ||
|
|
5659a1e13c | ||
|
|
fb48c4d85d | ||
|
|
ce3ca419e8 | ||
|
|
c3b9e1f6c8 | ||
|
|
9ba0db1ab9 | ||
|
|
70d9aded42 | ||
|
|
a99f58b62f | ||
|
|
fcb1ad05fd | ||
|
|
50f8c7ec10 | ||
|
|
4094631f30 | ||
|
|
1cae1135b9 | ||
|
|
f78ca49ec0 | ||
|
|
e9c7607a4b | ||
|
|
6d49e266dd | ||
|
|
78cdb01ef1 | ||
|
|
1ed434c858 | ||
|
|
f4acbaacdc | ||
|
|
e777f3ccc4 | ||
|
|
9e61c9e4d2 | ||
|
|
3fb730ceba | ||
|
|
811ac871a3 | ||
|
|
54ed0299c0 | ||
|
|
09fcd72e43 | ||
|
|
0371836dc8 |
113
AudioPlayer.cpp
Normal file
113
AudioPlayer.cpp
Normal file
@@ -0,0 +1,113 @@
|
|||||||
|
#include "AudioPlayer.h"
|
||||||
|
#include "SDL.h"
|
||||||
|
#include "SDL_audio.h"
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <malloc.h>
|
||||||
|
#include <string.h>
|
||||||
|
#define NUM_SOUNDS 10
|
||||||
|
static SDL_AudioSpec fmt;
|
||||||
|
static bool initiated = false;
|
||||||
|
|
||||||
|
AudioPlayer::AudioPlayer(void)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
AudioPlayer::~AudioPlayer(void)
|
||||||
|
{
|
||||||
|
SDL_CloseAudio();
|
||||||
|
}
|
||||||
|
|
||||||
|
void AudioPlayer::init()
|
||||||
|
{
|
||||||
|
initiated = true;
|
||||||
|
extern void mixaudio(void *unused, Uint8 *stream, int len);
|
||||||
|
fmt.freq = 22050;
|
||||||
|
fmt.format = AUDIO_S16;
|
||||||
|
fmt.channels = 2;
|
||||||
|
fmt.samples = 1024; /* A good value for games */
|
||||||
|
fmt.callback = mixaudio;
|
||||||
|
fmt.userdata = NULL;
|
||||||
|
|
||||||
|
/* Open the audio device and start playing sound! */
|
||||||
|
if ( SDL_OpenAudio(&fmt, NULL) < 0 ) {
|
||||||
|
fprintf(stderr, "Unable to open audio: %s\n", SDL_GetError());
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
SDL_PauseAudio(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static struct sample {
|
||||||
|
Uint8 *data;
|
||||||
|
Uint32 dpos;
|
||||||
|
Uint32 dlen;
|
||||||
|
} sounds[NUM_SOUNDS];
|
||||||
|
|
||||||
|
void mixaudio(void *unused, Uint8 *stream, int len)
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
Uint32 amount;
|
||||||
|
|
||||||
|
for ( i=0; i<NUM_SOUNDS; ++i ) {
|
||||||
|
amount = (sounds[i].dlen-sounds[i].dpos);
|
||||||
|
if ( amount > (Uint32)len ) {
|
||||||
|
amount = len;
|
||||||
|
}
|
||||||
|
SDL_MixAudio(stream, &sounds[i].data[sounds[i].dpos], amount, SDL_MIX_MAXVOLUME);
|
||||||
|
sounds[i].dpos += amount;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void AudioPlayer::PlaySound(std::string fileString)
|
||||||
|
{
|
||||||
|
|
||||||
|
if(initiated)
|
||||||
|
{
|
||||||
|
char *file = new char[fileString.length() + 1];
|
||||||
|
strcpy(file, fileString.c_str());
|
||||||
|
|
||||||
|
|
||||||
|
int index;
|
||||||
|
SDL_AudioSpec wave;
|
||||||
|
Uint8 *data;
|
||||||
|
Uint32 dlen;
|
||||||
|
SDL_AudioCVT cvt;
|
||||||
|
|
||||||
|
/* Look for an empty (or finished) sound slot */
|
||||||
|
for ( index=0; index<NUM_SOUNDS; ++index ) {
|
||||||
|
if ( sounds[index].dpos == sounds[index].dlen ) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if ( index == NUM_SOUNDS )
|
||||||
|
return;
|
||||||
|
|
||||||
|
/* Load the sound file and convert it to 16-bit stereo at 22kHz */
|
||||||
|
if ( SDL_LoadWAV(file, &wave, &data, &dlen) == NULL ) {
|
||||||
|
fprintf(stderr, "Couldn't load %s: %s\n", file, SDL_GetError());
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
SDL_BuildAudioCVT(&cvt, wave.format, wave.channels, wave.freq,
|
||||||
|
AUDIO_S16, 2, fmt.freq);
|
||||||
|
cvt.buf = (Uint8*)malloc(dlen*cvt.len_mult);
|
||||||
|
memcpy(cvt.buf, data, dlen);
|
||||||
|
cvt.len = dlen;
|
||||||
|
SDL_ConvertAudio(&cvt);
|
||||||
|
SDL_FreeWAV(data);
|
||||||
|
|
||||||
|
/* Put the sound data in the slot (it starts playing immediately) */
|
||||||
|
if ( sounds[index].data ) {
|
||||||
|
free(sounds[index].data);
|
||||||
|
}
|
||||||
|
SDL_LockAudio();
|
||||||
|
sounds[index].data = cvt.buf;
|
||||||
|
sounds[index].dlen = cvt.len_cvt;
|
||||||
|
sounds[index].dpos = 0;
|
||||||
|
SDL_UnlockAudio();
|
||||||
|
delete [] file;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
OutputDebugString("Audio player not initialized, sound will not play\r\n");
|
||||||
|
}
|
||||||
|
}
|
||||||
11
AudioPlayer.h
Normal file
11
AudioPlayer.h
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
#include <G3DAll.h>
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
class AudioPlayer
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
AudioPlayer(void);
|
||||||
|
~AudioPlayer(void);
|
||||||
|
static void PlaySound(std::string);
|
||||||
|
static void init();
|
||||||
|
};
|
||||||
@@ -230,6 +230,10 @@
|
|||||||
Name="Source Files"
|
Name="Source Files"
|
||||||
Filter="cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
|
Filter="cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
|
||||||
>
|
>
|
||||||
|
<File
|
||||||
|
RelativePath=".\AudioPlayer.cpp"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
<File
|
<File
|
||||||
RelativePath=".\BaseButtonInstance.cpp"
|
RelativePath=".\BaseButtonInstance.cpp"
|
||||||
>
|
>
|
||||||
@@ -283,6 +287,10 @@
|
|||||||
Name="Header Files"
|
Name="Header Files"
|
||||||
Filter="h;hpp;hxx;hm;inl"
|
Filter="h;hpp;hxx;hm;inl"
|
||||||
>
|
>
|
||||||
|
<File
|
||||||
|
RelativePath=".\AudioPlayer.h"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
<File
|
<File
|
||||||
RelativePath=".\BaseButtonInstance.h"
|
RelativePath=".\BaseButtonInstance.h"
|
||||||
>
|
>
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
#include "PhysicalInstance.h"
|
#include "PhysicalInstance.h"
|
||||||
|
|
||||||
bool canCollide = true;
|
bool canCollide = true;
|
||||||
bool anchored = false;
|
bool anchored = false;
|
||||||
Vector3 size;
|
Vector3 size;
|
||||||
@@ -8,6 +7,8 @@ Vector3 velocity;
|
|||||||
Vector3 rotVelocity;
|
Vector3 rotVelocity;
|
||||||
CoordinateFrame cFrame;
|
CoordinateFrame cFrame;
|
||||||
Color3 color;
|
Color3 color;
|
||||||
|
bool changed = true;
|
||||||
|
Box itemBox = Box();
|
||||||
|
|
||||||
PhysicalInstance::PhysicalInstance(void)
|
PhysicalInstance::PhysicalInstance(void)
|
||||||
{
|
{
|
||||||
@@ -31,6 +32,7 @@ void PhysicalInstance::setPosition(Vector3 pos)
|
|||||||
{
|
{
|
||||||
position = pos;
|
position = pos;
|
||||||
cFrame = CoordinateFrame(pos);
|
cFrame = CoordinateFrame(pos);
|
||||||
|
changed = true;
|
||||||
}
|
}
|
||||||
CoordinateFrame PhysicalInstance::getCFrame()
|
CoordinateFrame PhysicalInstance::getCFrame()
|
||||||
{
|
{
|
||||||
@@ -40,8 +42,24 @@ void PhysicalInstance::setCFrame(CoordinateFrame coordinateFrame)
|
|||||||
{
|
{
|
||||||
cFrame = coordinateFrame;
|
cFrame = coordinateFrame;
|
||||||
position = coordinateFrame.translation;
|
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);
|
||||||
|
}
|
||||||
|
return itemBox;
|
||||||
|
}
|
||||||
|
|
||||||
PhysicalInstance::~PhysicalInstance(void)
|
PhysicalInstance::~PhysicalInstance(void)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -16,6 +16,8 @@ public:
|
|||||||
void setPosition(Vector3);
|
void setPosition(Vector3);
|
||||||
CoordinateFrame getCFrame();
|
CoordinateFrame getCFrame();
|
||||||
void setCFrame(CoordinateFrame);
|
void setCFrame(CoordinateFrame);
|
||||||
|
Box getBox();
|
||||||
|
CoordinateFrame getCFrameRenderBased();
|
||||||
private:
|
private:
|
||||||
Vector3 position;
|
Vector3 position;
|
||||||
};
|
};
|
||||||
|
|||||||
14
README.md
Normal file
14
README.md
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
# G3D-Fun
|
||||||
|
|
||||||
|
Despite its name, this is actually a recreation of ROBLOX as it was in 2005. Early development. Uses roughly time-accurate development tools.
|
||||||
|
|
||||||
|
# COMPILE WITH
|
||||||
|
|
||||||
|
Graphics3D 6.10 (Released July 21, 2006)
|
||||||
|
SDL 1.2.7 (1.2.9 could work as well)
|
||||||
|
Visual Studio 2005 Professional or Visual Studio 2005 Express with Platform SDK
|
||||||
|
|
||||||
|
# NOTE
|
||||||
|
|
||||||
|
Please know that there currently is no documentation and minimal commenting. As such, it may be confusing to follow the code.
|
||||||
|
Code for this project is written quickly at random intervals, where each individual thinks of a solution to a problem and adds it.
|
||||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
content/sounds/SWITCH3.wav
Normal file
BIN
content/sounds/SWITCH3.wav
Normal file
Binary file not shown.
BIN
content/sounds/electronicpingshort.wav
Normal file
BIN
content/sounds/electronicpingshort.wav
Normal file
Binary file not shown.
BIN
content/sounds/pageturn.wav
Normal file
BIN
content/sounds/pageturn.wav
Normal file
Binary file not shown.
BIN
content/sounds/switch.wav
Normal file
BIN
content/sounds/switch.wav
Normal file
Binary file not shown.
373
main.cpp
373
main.cpp
@@ -16,7 +16,8 @@
|
|||||||
#include "PhysicalInstance.h"
|
#include "PhysicalInstance.h"
|
||||||
#include "TextButtonInstance.h"
|
#include "TextButtonInstance.h"
|
||||||
#include "ImageButtonInstance.h"
|
#include "ImageButtonInstance.h"
|
||||||
|
#include "AudioPlayer.h"
|
||||||
|
#include <limits.h>
|
||||||
|
|
||||||
#if G3D_VER < 61000
|
#if G3D_VER < 61000
|
||||||
#error Requires G3D 6.10
|
#error Requires G3D 6.10
|
||||||
@@ -30,17 +31,23 @@ static std::vector<Instance*> instances_2D;
|
|||||||
static Instance* dataModel;
|
static Instance* dataModel;
|
||||||
GFontRef fntdominant = NULL;
|
GFontRef fntdominant = NULL;
|
||||||
GFontRef fntlighttrek = NULL;
|
GFontRef fntlighttrek = NULL;
|
||||||
|
Ray testRay;
|
||||||
static bool democ = true;
|
static bool democ = true;
|
||||||
static std::string message = "";
|
static std::string message = "";
|
||||||
static G3D::RealTime messageTime = 0;
|
static G3D::RealTime messageTime = 0;
|
||||||
|
static std::string tempPath = "";
|
||||||
static G3D::RealTime inputTime = 0;
|
static G3D::RealTime inputTime = 0;
|
||||||
static int FPSVal[8] = {10, 20, 30, 60, 120, 240, INT_MAX,1};
|
static int FPSVal[8] = {10, 20, 30, 60, 120, 240, INT_MAX,1};
|
||||||
static int index = 2;
|
static int index = 2;
|
||||||
|
static std::string cameraSound = "";
|
||||||
|
static std::string clickSound = "";
|
||||||
|
static std::string dingSound = "";
|
||||||
static float TIMERVAL = 60.0F;
|
static float TIMERVAL = 60.0F;
|
||||||
static int SCOREVAL = 0;
|
static int SCOREVAL = 0;
|
||||||
static G3D::TextureRef go = NULL;
|
static G3D::TextureRef go = NULL;
|
||||||
static G3D::TextureRef go_ovr = NULL;
|
static G3D::TextureRef go_ovr = NULL;
|
||||||
static G3D::TextureRef go_dn = NULL;
|
static G3D::TextureRef go_dn = NULL;
|
||||||
|
VARAreaRef varStatic = NULL;
|
||||||
static float mousex = 0;
|
static float mousex = 0;
|
||||||
static float mousey = 0;
|
static float mousey = 0;
|
||||||
static int cursorid = 0;
|
static int cursorid = 0;
|
||||||
@@ -161,6 +168,7 @@ HWND App::getMainHWND()
|
|||||||
|
|
||||||
|
|
||||||
Demo::Demo(App* _app) : GApplet(_app), app(_app) {
|
Demo::Demo(App* _app) : GApplet(_app), app(_app) {
|
||||||
|
varStatic = VARArea::create(1024 * 1024);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -246,6 +254,7 @@ public:
|
|||||||
|
|
||||||
void CameraButtonListener::onButton1MouseClick(BaseButtonInstance* button)
|
void CameraButtonListener::onButton1MouseClick(BaseButtonInstance* button)
|
||||||
{
|
{
|
||||||
|
AudioPlayer::PlaySound(cameraSound);
|
||||||
CoordinateFrame frame = usableApp->debugCamera.getCoordinateFrame();
|
CoordinateFrame frame = usableApp->debugCamera.getCoordinateFrame();
|
||||||
if(button->name == "CenterCam")
|
if(button->name == "CenterCam")
|
||||||
centerCam = true;
|
centerCam = true;
|
||||||
@@ -259,12 +268,85 @@ void CameraButtonListener::onButton1MouseClick(BaseButtonInstance* button)
|
|||||||
tiltUp = true;
|
tiltUp = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
class GUDButtonListener : public ButtonListener {
|
||||||
|
public:
|
||||||
|
void onButton1MouseClick(BaseButtonInstance*);
|
||||||
|
};
|
||||||
|
|
||||||
|
void GUDButtonListener::onButton1MouseClick(BaseButtonInstance* button)
|
||||||
|
{
|
||||||
|
if(selectedInstance != NULL)
|
||||||
|
{
|
||||||
|
AudioPlayer::PlaySound(dingSound);
|
||||||
|
if(button->name == "Duplicate")
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
class RotateButtonListener : public ButtonListener {
|
||||||
|
public:
|
||||||
|
void onButton1MouseClick(BaseButtonInstance*);
|
||||||
|
};
|
||||||
|
|
||||||
|
void RotateButtonListener::onButton1MouseClick(BaseButtonInstance* button)
|
||||||
|
{
|
||||||
|
if(selectedInstance != NULL)
|
||||||
|
{
|
||||||
|
AudioPlayer::PlaySound(clickSound);
|
||||||
|
if(selectedInstance->className == "Part")
|
||||||
|
{
|
||||||
|
PhysicalInstance* part = (PhysicalInstance*) selectedInstance;
|
||||||
|
if(button->name == "Tilt")
|
||||||
|
part->setCFrame(part->getCFrame()*Matrix3::fromEulerAnglesXYZ(0,0,toRadians(90)));
|
||||||
|
else if(button->name == "Rotate")
|
||||||
|
part->setCFrame(part->getCFrame()*Matrix3::fromEulerAnglesXYZ(0,toRadians(90),0));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void deleteInstance()
|
||||||
|
{
|
||||||
|
if(selectedInstance != NULL)
|
||||||
|
{
|
||||||
|
for(size_t i = 0; i < instances.size(); i++)
|
||||||
|
{
|
||||||
|
if(instances.at(i) == selectedInstance)
|
||||||
|
{
|
||||||
|
Instance* deleting = instances.at(i);
|
||||||
|
instances.erase(instances.begin() + i);
|
||||||
|
delete deleting;
|
||||||
|
selectedInstance = NULL;
|
||||||
|
AudioPlayer::PlaySound(GetFileInPath("/content/sounds/pageturn.wav"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
class DeleteListener : public ButtonListener {
|
||||||
|
public:
|
||||||
|
void onButton1MouseClick(BaseButtonInstance*);
|
||||||
|
};
|
||||||
|
|
||||||
|
void DeleteListener::onButton1MouseClick(BaseButtonInstance* button)
|
||||||
|
{
|
||||||
|
deleteInstance();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class ModeSelectionListener : public ButtonListener {
|
class ModeSelectionListener : public ButtonListener {
|
||||||
public:
|
public:
|
||||||
void onButton1MouseClick(BaseButtonInstance*);
|
void onButton1MouseClick(BaseButtonInstance*);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
void ModeSelectionListener::onButton1MouseClick(BaseButtonInstance* button)
|
void ModeSelectionListener::onButton1MouseClick(BaseButtonInstance* button)
|
||||||
{
|
{
|
||||||
CoordinateFrame frame = usableApp->debugCamera.getCoordinateFrame();
|
CoordinateFrame frame = usableApp->debugCamera.getCoordinateFrame();
|
||||||
@@ -416,6 +498,51 @@ void initGUI()
|
|||||||
button->fontLocationRelativeTo = Vector2(10, 0);
|
button->fontLocationRelativeTo = Vector2(10, 0);
|
||||||
button->setAllColorsSame();
|
button->setAllColorsSame();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
button = makeTextButton();
|
||||||
|
button->boxBegin = Vector2(0,215);
|
||||||
|
button->boxEnd = Vector2(80,235);
|
||||||
|
button->textOutlineColor = Color4(0.5F,0.5F,0.5F,0.5F);
|
||||||
|
button->textColor = Color3::white();
|
||||||
|
button->boxColor = Color4::clear();
|
||||||
|
button->textSize = 12;
|
||||||
|
button->title = "Group";
|
||||||
|
button->setAllColorsSame();
|
||||||
|
button->font = fntlighttrek;
|
||||||
|
button->fontLocationRelativeTo = Vector2(10, 0);
|
||||||
|
button->parent = dataModel;
|
||||||
|
|
||||||
|
|
||||||
|
button = makeTextButton();
|
||||||
|
button->boxBegin = Vector2(0,240);
|
||||||
|
button->boxEnd = Vector2(80,260);
|
||||||
|
button->textOutlineColor = Color4(0.5F,0.5F,0.5F,0.5F);
|
||||||
|
button->textColor = Color3::white();
|
||||||
|
button->boxColor = Color4::clear();
|
||||||
|
button->textSize = 12;
|
||||||
|
button->title = "UnGroup";
|
||||||
|
button->setAllColorsSame();
|
||||||
|
button->font = fntlighttrek;
|
||||||
|
button->fontLocationRelativeTo = Vector2(10, 0);
|
||||||
|
button->parent = dataModel;
|
||||||
|
|
||||||
|
button = makeTextButton();
|
||||||
|
button->boxBegin = Vector2(0,265);
|
||||||
|
button->boxEnd = Vector2(80,285);
|
||||||
|
button->textOutlineColor = Color4(0.5F,0.5F,0.5F,0.5F);
|
||||||
|
button->textColor = Color3::white();
|
||||||
|
button->boxColor = Color4::clear();
|
||||||
|
button->textSize = 12;
|
||||||
|
button->title = "Duplicate";
|
||||||
|
button->setAllColorsSame();
|
||||||
|
button->font = fntlighttrek;
|
||||||
|
button->fontLocationRelativeTo = Vector2(10, 0);
|
||||||
|
button->parent = dataModel;
|
||||||
|
button->name = "Duplicate";
|
||||||
|
button->setButtonListener(new GUDButtonListener());
|
||||||
|
|
||||||
|
|
||||||
ImageButtonInstance* instance = makeImageButton(go, go_ovr, go_dn);
|
ImageButtonInstance* instance = makeImageButton(go, go_ovr, go_dn);
|
||||||
instance->name = "go";
|
instance->name = "go";
|
||||||
instance->size = Vector2(65,65);
|
instance->size = Vector2(65,65);
|
||||||
@@ -462,6 +589,8 @@ void initGUI()
|
|||||||
instance->size = Vector2(30,30);
|
instance->size = Vector2(30,30);
|
||||||
instance->position = Vector2(10, 175);
|
instance->position = Vector2(10, 175);
|
||||||
instance->parent = dataModel;
|
instance->parent = dataModel;
|
||||||
|
instance->name = "Rotate";
|
||||||
|
instance->setButtonListener(new RotateButtonListener());
|
||||||
|
|
||||||
instance = makeImageButton(
|
instance = makeImageButton(
|
||||||
Texture::fromFile(GetFileInPath("/content/images/SelectionTilt.png")),
|
Texture::fromFile(GetFileInPath("/content/images/SelectionTilt.png")),
|
||||||
@@ -471,6 +600,8 @@ void initGUI()
|
|||||||
instance->size = Vector2(30,30);
|
instance->size = Vector2(30,30);
|
||||||
instance->position = Vector2(40, 175);
|
instance->position = Vector2(40, 175);
|
||||||
instance->parent = dataModel;
|
instance->parent = dataModel;
|
||||||
|
instance->name = "Tilt";
|
||||||
|
instance->setButtonListener(new RotateButtonListener());
|
||||||
|
|
||||||
|
|
||||||
instance = makeImageButton(
|
instance = makeImageButton(
|
||||||
@@ -481,15 +612,8 @@ void initGUI()
|
|||||||
instance->size = Vector2(40,46);
|
instance->size = Vector2(40,46);
|
||||||
instance->position = Vector2(20, 284);
|
instance->position = Vector2(20, 284);
|
||||||
instance->parent = dataModel;
|
instance->parent = dataModel;
|
||||||
|
instance->name = "Delete";
|
||||||
instance = makeImageButton(
|
instance->setButtonListener(new DeleteListener());
|
||||||
Texture::fromFile(GetFileInPath("/content/images/Delete.png")),
|
|
||||||
Texture::fromFile(GetFileInPath("/content/images/Delete_ovr.png")),
|
|
||||||
Texture::fromFile(GetFileInPath("/content/images/Delete_dn.png")),
|
|
||||||
Texture::fromFile(GetFileInPath("/content/images/Delete_ds.png")));
|
|
||||||
instance->size = Vector2(40,46);
|
|
||||||
instance->position = Vector2(20, 284);
|
|
||||||
instance->parent = dataModel;
|
|
||||||
|
|
||||||
instance = makeImageButton(
|
instance = makeImageButton(
|
||||||
Texture::fromFile(GetFileInPath("/content/images/CameraZoomIn.png")),
|
Texture::fromFile(GetFileInPath("/content/images/CameraZoomIn.png")),
|
||||||
@@ -593,27 +717,22 @@ void Demo::onInit() {
|
|||||||
test->parent = dataModel;
|
test->parent = dataModel;
|
||||||
test->color = Color3(0.2F,0.3F,1);
|
test->color = Color3(0.2F,0.3F,1);
|
||||||
test->size = Vector3(24,1,24);
|
test->size = Vector3(24,1,24);
|
||||||
test->setCFrame(CoordinateFrame(Matrix3::fromEulerAnglesXYZ(toRadians(90),toRadians(45),toRadians(45)), Vector3(0,0,0)));
|
test->setPosition(Vector3(0,0,0));
|
||||||
selectedInstance = test;
|
test->setCFrame(test->getCFrame() * Matrix3::fromEulerAnglesXYZ(0,toRadians(90),0));
|
||||||
|
//selectedInstance = test;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
test = makePart();
|
|
||||||
test->parent = dataModel;
|
|
||||||
test->color = Color3(.5F,1,.5F);
|
|
||||||
test->size = Vector3(4,1,2);
|
|
||||||
test->setPosition(Vector3(10,1,0));
|
|
||||||
test = makePart();
|
test = makePart();
|
||||||
test->parent = dataModel;
|
test->parent = dataModel;
|
||||||
test->color = Color3(.5F,1,.5F);
|
test->color = Color3(.5F,1,.5F);
|
||||||
test->size = Vector3(4,1,2);
|
test->size = Vector3(4,1,2);
|
||||||
test->setPosition(Vector3(-10,1,0));
|
test->setPosition(Vector3(-10,1,0));
|
||||||
|
|
||||||
test = makePart();
|
test = makePart();
|
||||||
test->parent = dataModel;
|
test->parent = dataModel;
|
||||||
test->color = Color3::gray();
|
test->color = Color3(.5F,1,.5F);
|
||||||
test->size = Vector3(4,1,2);
|
test->size = Vector3(4,1,2);
|
||||||
test->setPosition(Vector3(-7,2,0));
|
test->setPosition(Vector3(10,1,0));
|
||||||
|
|
||||||
test = makePart();
|
test = makePart();
|
||||||
test->parent = dataModel;
|
test->parent = dataModel;
|
||||||
@@ -625,31 +744,38 @@ void Demo::onInit() {
|
|||||||
test->parent = dataModel;
|
test->parent = dataModel;
|
||||||
test->color = Color3::gray();
|
test->color = Color3::gray();
|
||||||
test->size = Vector3(4,1,2);
|
test->size = Vector3(4,1,2);
|
||||||
test->setPosition(Vector3(-4,3,0));
|
test->setPosition(Vector3(-7,2,0));
|
||||||
|
|
||||||
test = makePart();
|
test = makePart();
|
||||||
test->parent = dataModel;
|
test->parent = dataModel;
|
||||||
test->color = Color3::gray();
|
test->color = Color3::gray();
|
||||||
test->size = Vector3(4,1,2);
|
test->size = Vector3(4,1,2);
|
||||||
test->setPosition(Vector3(5,3,0));
|
test->setPosition(Vector3(4,3,0));
|
||||||
|
|
||||||
test = makePart();
|
test = makePart();
|
||||||
test->parent = dataModel;
|
test->parent = dataModel;
|
||||||
test->color = Color3::gray();
|
test->color = Color3::gray();
|
||||||
test->size = Vector3(4,1,2);
|
test->size = Vector3(4,1,2);
|
||||||
test->setPosition(Vector3(-1,4,0));
|
test->setPosition(Vector3(-5,3,0));
|
||||||
|
|
||||||
test = makePart();
|
test = makePart();
|
||||||
test->parent = dataModel;
|
test->parent = dataModel;
|
||||||
test->color = Color3::gray();
|
test->color = Color3::gray();
|
||||||
test->size = Vector3(4,1,2);
|
test->size = Vector3(4,1,2);
|
||||||
test->setPosition(Vector3(3,4,0));
|
test->setPosition(Vector3(1,4,0));
|
||||||
|
|
||||||
test = makePart();
|
test = makePart();
|
||||||
test->parent = dataModel;
|
test->parent = dataModel;
|
||||||
test->color = Color3::gray();
|
test->color = Color3::gray();
|
||||||
test->size = Vector3(4,1,2);
|
test->size = Vector3(4,1,2);
|
||||||
test->setPosition(Vector3(2,5,0));
|
test->setPosition(Vector3(-3,4,0));
|
||||||
|
|
||||||
|
test = makePart();
|
||||||
|
test->parent = dataModel;
|
||||||
|
test->color = Color3::gray();
|
||||||
|
test->size = Vector3(4,1,2);
|
||||||
|
test->setPosition(Vector3(-2,5,0));
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -662,8 +788,8 @@ void Demo::onInit() {
|
|||||||
test = makePart();
|
test = makePart();
|
||||||
test->parent = dataModel;
|
test->parent = dataModel;
|
||||||
test->color = Color3::gray();
|
test->color = Color3::gray();
|
||||||
test->size = Vector3(4,1,2);
|
test->size = Vector3(-4,-1,-2);
|
||||||
test->setPosition(Vector3(-2,7,0));
|
test->setPosition(Vector3(2,7,0));
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -703,6 +829,19 @@ void Demo::onCleanup() {
|
|||||||
|
|
||||||
void Demo::onLogic() {
|
void Demo::onLogic() {
|
||||||
// Add non-simulation game logic and AI code here
|
// Add non-simulation game logic and AI code here
|
||||||
|
for(size_t i = 0; i < instances_2D.size(); i++)
|
||||||
|
{
|
||||||
|
if(instances_2D.at(i)->name == "Delete")
|
||||||
|
{
|
||||||
|
ImageButtonInstance* button = (ImageButtonInstance*)instances_2D.at(i);
|
||||||
|
if(selectedInstance == NULL)
|
||||||
|
button->disabled = true;
|
||||||
|
else
|
||||||
|
button->disabled = false;
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -711,6 +850,11 @@ void Demo::onNetwork() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
double getVectorDistance(Vector3 vector1, Vector3 vector2)
|
||||||
|
{
|
||||||
|
return pow(pow((double)vector1.x - (double)vector2.x, 2) + pow((double)vector1.y - (double)vector2.y, 2) + pow((double)vector1.z - (double)vector2.z, 2), 0.5);
|
||||||
|
}
|
||||||
|
|
||||||
void Demo::onSimulation(RealTime rdt, SimTime sdt, SimTime idt) {
|
void Demo::onSimulation(RealTime rdt, SimTime sdt, SimTime idt) {
|
||||||
if(dataModel->name != title)
|
if(dataModel->name != title)
|
||||||
{
|
{
|
||||||
@@ -755,14 +899,48 @@ void Demo::onSimulation(RealTime rdt, SimTime sdt, SimTime idt) {
|
|||||||
if(panRight)
|
if(panRight)
|
||||||
{
|
{
|
||||||
panRight = false;
|
panRight = false;
|
||||||
CoordinateFrame frame = CoordinateFrame(app->debugCamera.getCoordinateFrame().rotation, app->debugCamera.getCoordinateFrame().translation);
|
CoordinateFrame frame = app->debugCamera.getCoordinateFrame();
|
||||||
Vector3 camerapoint = frame.translation;
|
Vector3 camerapoint = frame.translation;
|
||||||
Vector3 angles;
|
Vector3 focalPoint = camerapoint + frame.lookVector() * 25;
|
||||||
float radian = 0;
|
|
||||||
frame.rotation.toAxisAngle(angles, radian);
|
|
||||||
message = Convert(angles.x) + ", " + Convert(angles.y) + ", " + Convert(angles.z) + ", " + Convert(radian);
|
float distb = getVectorDistance(Vector3(focalPoint.x, camerapoint.y, focalPoint.z), Vector3(camerapoint.x, camerapoint.y, focalPoint.z));
|
||||||
|
float distc = abs(((float)getVectorDistance(Vector3(focalPoint.x, camerapoint.y, focalPoint.z), camerapoint)));
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
float angle = toRadians(90);
|
||||||
|
|
||||||
|
|
||||||
|
//message = Convert(angle);
|
||||||
|
messageTime = System::time();
|
||||||
|
//frame.rotation.toEulerAnglesXYZ(x, angle, z);
|
||||||
|
//angle = toDegrees(angle);
|
||||||
|
|
||||||
|
// if(camerapoint.z < focalPoint.z)
|
||||||
|
// {
|
||||||
|
// float angleadd = abs(angle - 90);
|
||||||
|
// angle = angleadd + 5 + 90;
|
||||||
|
// }
|
||||||
|
// else
|
||||||
|
// {
|
||||||
|
// angle = angle + 5;
|
||||||
|
// }
|
||||||
|
|
||||||
|
|
||||||
messageTime = System::time();
|
messageTime = System::time();
|
||||||
|
|
||||||
|
//abs(((float)(getVectorDistance(Vector3(focalPoint.x, camerapoint.y, focalPoint.z), camerapoint))));
|
||||||
|
float x = distc * cos(angle-toRadians(2)) + focalPoint.x;
|
||||||
|
float z = distc * sin(angle-toRadians(2)) + focalPoint.z;
|
||||||
|
message = "NOT 0, " + Convert(x) + ", " + Convert(z);
|
||||||
|
//camerapoint = Vector3(sin(angle)*distc,camerapoint.y,cos(angle)*distc);
|
||||||
|
camerapoint = Vector3(x,camerapoint.y,z);
|
||||||
|
CoordinateFrame newFrame = CoordinateFrame(camerapoint);
|
||||||
|
newFrame.lookAt(focalPoint);
|
||||||
|
cameraPos = camerapoint;
|
||||||
|
app->debugController.setCoordinateFrame(newFrame);
|
||||||
|
|
||||||
}
|
}
|
||||||
if(tiltUp)
|
if(tiltUp)
|
||||||
{
|
{
|
||||||
@@ -781,6 +959,7 @@ void Demo::onSimulation(RealTime rdt, SimTime sdt, SimTime idt) {
|
|||||||
cameraPos = camerapoint;
|
cameraPos = camerapoint;
|
||||||
app->debugController.setCoordinateFrame(newFrame);
|
app->debugController.setCoordinateFrame(newFrame);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -802,6 +981,7 @@ double getOSVersion() {
|
|||||||
return ::atof(version.c_str());
|
return ::atof(version.c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//User Input
|
||||||
void Demo::onUserInput(UserInput* ui) {
|
void Demo::onUserInput(UserInput* ui) {
|
||||||
|
|
||||||
if (ui->keyPressed(SDLK_ESCAPE)) {
|
if (ui->keyPressed(SDLK_ESCAPE)) {
|
||||||
@@ -840,15 +1020,22 @@ void Demo::onUserInput(UserInput* ui) {
|
|||||||
|
|
||||||
if(ui->keyPressed(SDL_MOUSE_WHEEL_UP_KEY))
|
if(ui->keyPressed(SDL_MOUSE_WHEEL_UP_KEY))
|
||||||
{
|
{
|
||||||
|
AudioPlayer::PlaySound(cameraSound);
|
||||||
CoordinateFrame frame = app->debugCamera.getCoordinateFrame();
|
CoordinateFrame frame = app->debugCamera.getCoordinateFrame();
|
||||||
cameraPos = cameraPos + frame.lookVector()*2;
|
cameraPos = cameraPos + frame.lookVector()*2;
|
||||||
}
|
}
|
||||||
if(ui->keyPressed(SDL_MOUSE_WHEEL_DOWN_KEY))
|
if(ui->keyPressed(SDL_MOUSE_WHEEL_DOWN_KEY))
|
||||||
{
|
{
|
||||||
|
AudioPlayer::PlaySound(cameraSound);
|
||||||
CoordinateFrame frame = app->debugCamera.getCoordinateFrame();
|
CoordinateFrame frame = app->debugCamera.getCoordinateFrame();
|
||||||
cameraPos = cameraPos - frame.lookVector()*2;
|
cameraPos = cameraPos - frame.lookVector()*2;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(ui->keyPressed(SDLK_DELETE))
|
||||||
|
{
|
||||||
|
deleteInstance();
|
||||||
|
}
|
||||||
|
|
||||||
if(ui->keyDown(SDLK_LCTRL))
|
if(ui->keyDown(SDLK_LCTRL))
|
||||||
{
|
{
|
||||||
if(ui->keyPressed('d'))
|
if(ui->keyPressed('d'))
|
||||||
@@ -901,6 +1088,51 @@ void Demo::onUserInput(UserInput* ui) {
|
|||||||
right = true;
|
right = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(ui->keyPressed(SDL_LEFT_MOUSE_KEY))
|
||||||
|
{
|
||||||
|
bool onGUI = false;
|
||||||
|
for(size_t i = 0; i < instances_2D.size(); i++)
|
||||||
|
{
|
||||||
|
if(instances_2D.at(i)->className == "TextButton" || instances_2D.at(i)->className == "ImageButton")
|
||||||
|
{
|
||||||
|
BaseButtonInstance* button = (BaseButtonInstance*)instances_2D.at(i);
|
||||||
|
if(button->mouseInButton(ui->mouseXY().x, ui->mouseXY().y, app->renderDevice))
|
||||||
|
{
|
||||||
|
onGUI = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(!onGUI)
|
||||||
|
{
|
||||||
|
selectedInstance = NULL;
|
||||||
|
testRay = app->debugCamera.worldRay(mousex, mousey, app->renderDevice->getViewport());
|
||||||
|
float nearest=std::numeric_limits<float>::infinity();
|
||||||
|
Vector3 camPos = app->debugCamera.getCoordinateFrame().translation;
|
||||||
|
for(size_t i = 0; i < instances.size(); i++)
|
||||||
|
{
|
||||||
|
if(instances.at(i)->className == "Part" && instances.at(i)->parent == dataModel)
|
||||||
|
{
|
||||||
|
PhysicalInstance* test = (PhysicalInstance*)instances.at(i);
|
||||||
|
float time = testRay.intersectionTime(test->getBox());
|
||||||
|
if (time != inf())
|
||||||
|
{
|
||||||
|
if (nearest>time)
|
||||||
|
{
|
||||||
|
nearest=time;
|
||||||
|
selectedInstance = test;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
//message = Convert(closest);
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if(ui->keyReleased(SDL_LEFT_MOUSE_KEY))
|
if(ui->keyReleased(SDL_LEFT_MOUSE_KEY))
|
||||||
{
|
{
|
||||||
|
|
||||||
@@ -1060,11 +1292,35 @@ void Demo::exitApplication()
|
|||||||
app->endProgram = true;
|
app->endProgram = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void makeBeveledBox(Box box, RenderDevice* rd, Color4 color, CoordinateFrame cFrame)
|
||||||
|
{
|
||||||
|
Vector3 v0, v1, v2, v3;
|
||||||
|
//glDiffuse();
|
||||||
|
rd->setColor(color);
|
||||||
|
rd->setObjectToWorldMatrix(CoordinateFrame());
|
||||||
|
rd->beginPrimitive(RenderDevice::QUADS);
|
||||||
|
for (int f = 0; f < 6; ++f) {
|
||||||
|
box.getFaceCorners(f, v0, v1, v2, v3);
|
||||||
|
glShadeModel(GL_SMOOTH);
|
||||||
|
//rd->setNormal((v1 - v0).cross(v3 - v0).direction());
|
||||||
|
rd->sendVertex(v0);
|
||||||
|
rd->sendVertex(v1);
|
||||||
|
rd->sendVertex(v2);
|
||||||
|
rd->sendVertex(v3);
|
||||||
|
}
|
||||||
|
rd->setColor(Color3::white());
|
||||||
|
rd->endPrimitive();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void Demo::onGraphics(RenderDevice* rd) {
|
void Demo::onGraphics(RenderDevice* rd) {
|
||||||
|
|
||||||
|
float angle, x, z;
|
||||||
|
app->debugCamera.getCoordinateFrame().rotation.toEulerAnglesXYZ(x, angle, z);
|
||||||
|
//message = Convert(toDegrees(angle)) + " X: " + Convert(app->debugCamera.getCoordinateFrame().translation.x) + " Z: " + Convert(app->debugCamera.getCoordinateFrame().translation.z);
|
||||||
|
//messageTime = System::time();
|
||||||
|
|
||||||
|
CoordinateFrame frame = CoordinateFrame(app->debugCamera.getCoordinateFrame().rotation, app->debugCamera.getCoordinateFrame().translation);
|
||||||
Vector2 mousepos = Vector2(0,0);
|
Vector2 mousepos = Vector2(0,0);
|
||||||
G3D::uint8 num = 0;
|
G3D::uint8 num = 0;
|
||||||
rd->window()->getRelativeMouseState(mousepos, num);
|
rd->window()->getRelativeMouseState(mousepos, num);
|
||||||
@@ -1101,13 +1357,12 @@ void Demo::onGraphics(RenderDevice* rd) {
|
|||||||
// Setup lighting
|
// Setup lighting
|
||||||
app->renderDevice->enableLighting();
|
app->renderDevice->enableLighting();
|
||||||
|
|
||||||
|
app->renderDevice->setShadeMode(RenderDevice::SHADE_SMOOTH);
|
||||||
app->renderDevice->setAmbientLightColor(Color3(1,1,1));
|
app->renderDevice->setAmbientLightColor(Color3(1,1,1));
|
||||||
Draw::axes(CoordinateFrame(Vector3(0, 0, 0)), app->renderDevice);
|
//Draw::axes(CoordinateFrame(Vector3(0, 0, 0)), app->renderDevice);
|
||||||
|
//makeFlag(Vector3(-1, 3.5, 0), rd);
|
||||||
makeFlag(Vector3(-1, 3.5, 0), rd);
|
|
||||||
|
|
||||||
//Vector3 vector = app->debugCamera.getCoordinateFrame().translation + app->debugCamera.getCoordinateFrame().lookVector()*20;
|
//Vector3 vector = app->debugCamera.getCoordinateFrame().translation + app->debugCamera.getCoordinateFrame().lookVector()*20;
|
||||||
Draw::axes(CoordinateFrame(focalPointT) , rd);
|
|
||||||
|
|
||||||
app->renderDevice->setLight(0, GLight::directional(lighting.lightDirection, lighting.lightColor));
|
app->renderDevice->setLight(0, GLight::directional(lighting.lightDirection, lighting.lightColor));
|
||||||
app->renderDevice->setAmbientLightColor(lighting.ambient);
|
app->renderDevice->setAmbientLightColor(lighting.ambient);
|
||||||
@@ -1120,27 +1375,24 @@ void Demo::onGraphics(RenderDevice* rd) {
|
|||||||
Instance* instance = instances.at(i);
|
Instance* instance = instances.at(i);
|
||||||
if(instance->className == "Part" && instance->parent != NULL)
|
if(instance->className == "Part" && instance->parent != NULL)
|
||||||
{
|
{
|
||||||
|
|
||||||
PhysicalInstance* part = (PhysicalInstance*)instance;
|
PhysicalInstance* part = (PhysicalInstance*)instance;
|
||||||
Vector3 size = part->size;
|
Draw::box(part->getBox(), app->renderDevice, part->color, Color4::clear());
|
||||||
Vector3 pos = part->getCFrame().translation;
|
|
||||||
rd->setObjectToWorldMatrix(CoordinateFrame());
|
|
||||||
Vector3 pos2 = Vector3((pos.x-size.x/2)/2,(pos.y-size.y/2)/2,(pos.z-size.z/2)/2);
|
|
||||||
Vector3 pos3 = Vector3((pos.x+size.x/2)/2,(pos.y+size.y/2)/2,(pos.z+size.z/2)/2);
|
|
||||||
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 = CoordinateFrame(part->getCFrame().rotation,Vector3(part->getCFrame().translation.x/2, part->getCFrame().translation.y/2, part->getCFrame().translation.z/2));
|
|
||||||
Draw::box(c.toWorldSpace(box), app->renderDevice, part->color, Color4::clear());
|
|
||||||
if(selectedInstance == part)
|
if(selectedInstance == part)
|
||||||
{
|
{
|
||||||
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), c);
|
Vector3 size = part->size;
|
||||||
|
Vector3 pos = part->getCFrame().translation;
|
||||||
|
drawOutline(Vector3(0+size.x/4, 0+size.y/4, 0+size.z/4) ,Vector3(0-size.x/4,0-size.y/4,0-size.z/4), rd, lighting, Vector3(size.x/2, size.y/2, size.z/2), Vector3(pos.x/2, pos.y/2, pos.z/2), part->getCFrameRenderBased());
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Box box;
|
||||||
|
|
||||||
|
//Draw::ray(testRay, rd, Color3::orange(), 1);
|
||||||
|
|
||||||
Vector3 gamepoint = Vector3(0, 5, 0);
|
/*Vector3 gamepoint = Vector3(0, 5, 0);
|
||||||
Vector3 camerapoint = rd->getCameraToWorldMatrix().translation;
|
Vector3 camerapoint = rd->getCameraToWorldMatrix().translation;
|
||||||
float distance = pow(pow((double)gamepoint.x - (double)camerapoint.x, 2) + pow((double)gamepoint.y - (double)camerapoint.y, 2) + pow((double)gamepoint.z - (double)camerapoint.z, 2), 0.5);
|
float distance = pow(pow((double)gamepoint.x - (double)camerapoint.x, 2) + pow((double)gamepoint.y - (double)camerapoint.y, 2) + pow((double)gamepoint.z - (double)camerapoint.z, 2), 0.5);
|
||||||
if(distance < 50 && distance > -50)
|
if(distance < 50 && distance > -50)
|
||||||
@@ -1149,7 +1401,8 @@ void Demo::onGraphics(RenderDevice* rd) {
|
|||||||
if(distance < 0)
|
if(distance < 0)
|
||||||
distance = distance*-1;
|
distance = distance*-1;
|
||||||
fntdominant->draw3D(rd, "Testing", CoordinateFrame(rd->getCameraToWorldMatrix().rotation, gamepoint), 0.04*distance, Color3::yellow(), Color3::black(), G3D::GFont::XALIGN_CENTER, G3D::GFont::YALIGN_CENTER);
|
fntdominant->draw3D(rd, "Testing", CoordinateFrame(rd->getCameraToWorldMatrix().rotation, gamepoint), 0.04*distance, Color3::yellow(), Color3::black(), G3D::GFont::XALIGN_CENTER, G3D::GFont::YALIGN_CENTER);
|
||||||
}
|
}*/
|
||||||
|
|
||||||
app->renderDevice->disableLighting();
|
app->renderDevice->disableLighting();
|
||||||
|
|
||||||
if (app->sky.notNull()) {
|
if (app->sky.notNull()) {
|
||||||
@@ -1199,9 +1452,6 @@ void Demo::onGraphics(RenderDevice* rd) {
|
|||||||
|
|
||||||
//Tools menu
|
//Tools menu
|
||||||
Draw::box(G3D::Box(Vector3(5, 185+offset,0),Vector3(75, 185+offset,0)),rd,Color4(0.6F,0.6F,0.6F,0.4F), Color4(0.6F,0.6F,0.6F,0.4F));
|
Draw::box(G3D::Box(Vector3(5, 185+offset,0),Vector3(75, 185+offset,0)),rd,Color4(0.6F,0.6F,0.6F,0.4F), Color4(0.6F,0.6F,0.6F,0.4F));
|
||||||
fntlighttrek->draw2D(rd,"Group", Vector2(10,190+offset), 12, Color3::white(), Color4(0.5F,0.5F,0.5F,0.5F));
|
|
||||||
fntlighttrek->draw2D(rd,"UnGroup", Vector2(10,215+offset), 12, Color3::white(), Color4(0.5F,0.5F,0.5F,0.5F));
|
|
||||||
fntlighttrek->draw2D(rd,"Duplicate", Vector2(10,240+offset), 12, Color3::white(), Color4(0.5F,0.5F,0.5F,0.5F));
|
|
||||||
fntlighttrek->draw2D(rd,"MENU", Vector2(10,307+offset), 14, Color3::white(), Color4(0.5F,0.5F,0.5F,0.5F));
|
fntlighttrek->draw2D(rd,"MENU", Vector2(10,307+offset), 14, Color3::white(), Color4(0.5F,0.5F,0.5F,0.5F));
|
||||||
//G3D::GFont::draw2D("Debug Mode Enabled", Vector2(0,30), 20, Color3::white(), Color3::black());
|
//G3D::GFont::draw2D("Debug Mode Enabled", Vector2(0,30), 20, Color3::white(), Color3::black());
|
||||||
//app->debugFont->draw2D("Dynamica 2004-2005 Simulation Client version " + VERSION + str, Vector2(0,0), 20, Color3::white(), Color3::black());
|
//app->debugFont->draw2D("Dynamica 2004-2005 Simulation Client version " + VERSION + str, Vector2(0,0), 20, Color3::white(), Color3::black());
|
||||||
@@ -1266,6 +1516,9 @@ void App::main() {
|
|||||||
cursor = Texture::fromFile(GetFileInPath("/content/cursor2.png"));
|
cursor = Texture::fromFile(GetFileInPath("/content/cursor2.png"));
|
||||||
fntdominant = GFont::fromFile(GetFileInPath("/content/font/dominant.fnt"));
|
fntdominant = GFont::fromFile(GetFileInPath("/content/font/dominant.fnt"));
|
||||||
fntlighttrek = GFont::fromFile(GetFileInPath("/content/font/lighttrek.fnt"));
|
fntlighttrek = GFont::fromFile(GetFileInPath("/content/font/lighttrek.fnt"));
|
||||||
|
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/");
|
sky = Sky::create(NULL, ExePath() + "/content/sky/");
|
||||||
cursorid = cursor->openGLID();
|
cursorid = cursor->openGLID();
|
||||||
applet->run();
|
applet->run();
|
||||||
@@ -1359,11 +1612,18 @@ LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
|
|||||||
int main(int argc, char** argv) {
|
int main(int argc, char** argv) {
|
||||||
//_CrtSetDbgFlag( _CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF );
|
//_CrtSetDbgFlag( _CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF );
|
||||||
//_CrtSetBreakAlloc(1279);
|
//_CrtSetBreakAlloc(1279);
|
||||||
|
try{
|
||||||
|
tempPath = ((std::string)getenv("temp")) + "/Dynamica";
|
||||||
|
CreateDirectory(tempPath.c_str(), NULL);
|
||||||
|
|
||||||
|
message = tempPath;
|
||||||
|
messageTime = System::time();
|
||||||
|
AudioPlayer::init();
|
||||||
GAppSettings settings;
|
GAppSettings settings;
|
||||||
settings.window.resizable = true;
|
settings.window.resizable = true;
|
||||||
settings.window.fsaaSamples = 8;
|
//settings.window.fsaaSamples = 8;
|
||||||
settings.writeLicenseFile = false;
|
settings.writeLicenseFile = false;
|
||||||
|
settings.logFilename = tempPath + "/g3dlog.txt";
|
||||||
settings.window.center = true;
|
settings.window.center = true;
|
||||||
//Using the damned SDL window now
|
//Using the damned SDL window now
|
||||||
G3D::SDLWindow* wnd = new SDLWindow(settings.window);
|
G3D::SDLWindow* wnd = new SDLWindow(settings.window);
|
||||||
@@ -1451,5 +1711,10 @@ int main(int argc, char** argv) {
|
|||||||
//messageTime = G3D::System::time();
|
//messageTime = G3D::System::time();
|
||||||
|
|
||||||
app.run();
|
app.run();
|
||||||
|
}
|
||||||
|
catch(std::exception)
|
||||||
|
{
|
||||||
|
OnError(-1);
|
||||||
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user