Compare commits
48 Commits
cb2
...
DataModelR
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
4b580ef5ad | ||
|
|
5232d5e97f | ||
|
|
011d817321 | ||
|
|
60c7a386f0 | ||
|
|
3ee06b6c62 | ||
|
|
57b407c894 | ||
|
|
9999eb62e4 | ||
|
|
930aee06dc | ||
|
|
e6ca1cd502 | ||
|
|
c875454b40 | ||
|
|
388962a5e7 | ||
|
|
9986f2ee5f | ||
|
|
529821ab9f | ||
|
|
d72d09f95d | ||
|
|
d810c213f6 | ||
|
|
ce66ec6f5d | ||
|
|
faaa59f58b | ||
|
|
8dff73d5f5 | ||
|
|
4bdb1d6939 | ||
|
|
f0f16a3a69 | ||
|
|
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 |
112
AudioPlayer.cpp
Normal file
112
AudioPlayer.cpp
Normal file
@@ -0,0 +1,112 @@
|
|||||||
|
#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());
|
||||||
|
}
|
||||||
|
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();
|
||||||
|
};
|
||||||
27
DataModelInstance.cpp
Normal file
27
DataModelInstance.cpp
Normal file
@@ -0,0 +1,27 @@
|
|||||||
|
#include "DataModelInstance.h"
|
||||||
|
|
||||||
|
|
||||||
|
WorkspaceInstance* workspace;
|
||||||
|
Instance* guiRoot;
|
||||||
|
|
||||||
|
DataModelInstance::DataModelInstance(void)
|
||||||
|
{
|
||||||
|
workspace = new WorkspaceInstance();
|
||||||
|
guiRoot = new Instance();
|
||||||
|
children.push_back(workspace);
|
||||||
|
className = "dataModel";
|
||||||
|
}
|
||||||
|
|
||||||
|
DataModelInstance::~DataModelInstance(void)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
WorkspaceInstance* DataModelInstance::getWorkspace()
|
||||||
|
{
|
||||||
|
return workspace;
|
||||||
|
}
|
||||||
|
|
||||||
|
Instance* DataModelInstance::getGuiRoot()
|
||||||
|
{
|
||||||
|
return guiRoot;
|
||||||
|
}
|
||||||
13
DataModelInstance.h
Normal file
13
DataModelInstance.h
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
#pragma once
|
||||||
|
#include "instance.h"
|
||||||
|
#include "WorkspaceInstance.h"
|
||||||
|
|
||||||
|
class DataModelInstance :
|
||||||
|
public Instance
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
DataModelInstance(void);
|
||||||
|
~DataModelInstance(void);
|
||||||
|
WorkspaceInstance* getWorkspace();
|
||||||
|
Instance* getGuiRoot();
|
||||||
|
};
|
||||||
@@ -231,7 +231,7 @@
|
|||||||
Filter="cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
|
Filter="cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
|
||||||
>
|
>
|
||||||
<File
|
<File
|
||||||
RelativePath=".\BaseButtonInstance.cpp"
|
RelativePath=".\AudioPlayer.cpp"
|
||||||
>
|
>
|
||||||
</File>
|
</File>
|
||||||
<File
|
<File
|
||||||
@@ -242,14 +242,6 @@
|
|||||||
RelativePath=".\Dialogs.rc"
|
RelativePath=".\Dialogs.rc"
|
||||||
>
|
>
|
||||||
</File>
|
</File>
|
||||||
<File
|
|
||||||
RelativePath=".\ImageButtonInstance.cpp"
|
|
||||||
>
|
|
||||||
</File>
|
|
||||||
<File
|
|
||||||
RelativePath=".\Instance.cpp"
|
|
||||||
>
|
|
||||||
</File>
|
|
||||||
<File
|
<File
|
||||||
RelativePath="main.cpp"
|
RelativePath="main.cpp"
|
||||||
>
|
>
|
||||||
@@ -270,47 +262,87 @@
|
|||||||
/>
|
/>
|
||||||
</FileConfiguration>
|
</FileConfiguration>
|
||||||
</File>
|
</File>
|
||||||
<File
|
<Filter
|
||||||
RelativePath=".\PhysicalInstance.cpp"
|
Name="Instances"
|
||||||
>
|
>
|
||||||
</File>
|
<File
|
||||||
<File
|
RelativePath=".\BaseButtonInstance.cpp"
|
||||||
RelativePath=".\TextButtonInstance.cpp"
|
>
|
||||||
>
|
</File>
|
||||||
</File>
|
<File
|
||||||
|
RelativePath=".\DataModelInstance.cpp"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath=".\ImageButtonInstance.cpp"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath=".\Instance.cpp"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath=".\PhysicalInstance.cpp"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath=".\TextButtonInstance.cpp"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath=".\WorkspaceInstance.cpp"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
|
</Filter>
|
||||||
</Filter>
|
</Filter>
|
||||||
<Filter
|
<Filter
|
||||||
Name="Header Files"
|
Name="Header Files"
|
||||||
Filter="h;hpp;hxx;hm;inl"
|
Filter="h;hpp;hxx;hm;inl"
|
||||||
>
|
>
|
||||||
<File
|
<File
|
||||||
RelativePath=".\BaseButtonInstance.h"
|
RelativePath=".\AudioPlayer.h"
|
||||||
>
|
>
|
||||||
</File>
|
</File>
|
||||||
<File
|
<File
|
||||||
RelativePath=".\ButtonListener.h"
|
RelativePath=".\ButtonListener.h"
|
||||||
>
|
>
|
||||||
</File>
|
</File>
|
||||||
<File
|
|
||||||
RelativePath=".\ImageButtonInstance.h"
|
|
||||||
>
|
|
||||||
</File>
|
|
||||||
<File
|
|
||||||
RelativePath=".\Instance.h"
|
|
||||||
>
|
|
||||||
</File>
|
|
||||||
<File
|
|
||||||
RelativePath=".\PhysicalInstance.h"
|
|
||||||
>
|
|
||||||
</File>
|
|
||||||
<File
|
<File
|
||||||
RelativePath=".\resource.h"
|
RelativePath=".\resource.h"
|
||||||
>
|
>
|
||||||
</File>
|
</File>
|
||||||
<File
|
<Filter
|
||||||
RelativePath=".\TextButtonInstance.h"
|
Name="Instances"
|
||||||
>
|
>
|
||||||
</File>
|
<File
|
||||||
|
RelativePath=".\BaseButtonInstance.h"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath=".\DataModelInstance.h"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath=".\ImageButtonInstance.h"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath=".\Instance.h"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath=".\PhysicalInstance.h"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath=".\TextButtonInstance.h"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath=".\WorkspaceInstance.h"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
|
</Filter>
|
||||||
</Filter>
|
</Filter>
|
||||||
<Filter
|
<Filter
|
||||||
Name="Resource Files"
|
Name="Resource Files"
|
||||||
|
|||||||
91
Instance.cpp
91
Instance.cpp
@@ -3,20 +3,103 @@
|
|||||||
#include "Instance.h"
|
#include "Instance.h"
|
||||||
|
|
||||||
std::string name;
|
std::string name;
|
||||||
Instance* parent;
|
Instance* parent = NULL;
|
||||||
static std::string className = "DataModel";
|
std::vector<Instance* > children;
|
||||||
|
static std::string className = "BaseInstance";
|
||||||
|
|
||||||
Instance::Instance(void)
|
Instance::Instance(void)
|
||||||
{
|
{
|
||||||
|
parent = NULL;
|
||||||
name = "Default Game Instance";
|
name = "Default Game Instance";
|
||||||
className = "DataModel";
|
className = "BaseInstance";
|
||||||
|
}
|
||||||
|
|
||||||
|
void Instance::render(RenderDevice* rd)
|
||||||
|
{
|
||||||
|
for(size_t i = 0; i < children.size(); i++)
|
||||||
|
{
|
||||||
|
children.at(i)->render(rd);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Instance::~Instance(void)
|
Instance::~Instance(void)
|
||||||
{
|
{
|
||||||
name = "Default Game Instance";
|
for(size_t i = 0; i < children.size(); i++)
|
||||||
|
{
|
||||||
|
delete children.at(i);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::string Instance::getClassName()
|
||||||
|
{
|
||||||
|
return className;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::vector<Instance* > Instance::getChildren()
|
||||||
|
{
|
||||||
|
return children;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::vector<Instance* > Instance::getAllChildren()
|
||||||
|
{
|
||||||
|
if(!children.empty())
|
||||||
|
{
|
||||||
|
std::vector<Instance* > totalchildren = children;
|
||||||
|
for(size_t i = 0; i < children.size(); i++)
|
||||||
|
{
|
||||||
|
std::vector<Instance* > subchildren = children.at(i)->getAllChildren();
|
||||||
|
if(!subchildren.empty())
|
||||||
|
totalchildren.insert(totalchildren.end(), subchildren.begin(), subchildren.end());
|
||||||
|
}
|
||||||
|
return totalchildren;
|
||||||
|
}
|
||||||
|
return children;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Instance::setParent(Instance* newParent)
|
||||||
|
{
|
||||||
|
if(parent != NULL)
|
||||||
|
{
|
||||||
|
parent->removeChild(this);
|
||||||
|
}
|
||||||
|
parent = newParent;
|
||||||
|
if(newParent != NULL)
|
||||||
|
{
|
||||||
|
newParent->addChild(this);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Instance* Instance::getParent()
|
||||||
|
{
|
||||||
|
return parent;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Instance::addChild(Instance* newChild)
|
||||||
|
{
|
||||||
|
children.push_back(newChild);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Instance::removeChild(Instance* oldChild)
|
||||||
|
{
|
||||||
|
for(size_t i = 0; i < children.size(); i++)
|
||||||
|
{
|
||||||
|
if(children.at(i) == oldChild)
|
||||||
|
{
|
||||||
|
children.erase(children.begin() + i);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Instance* Instance::findFirstChild(std::string name)
|
||||||
|
{
|
||||||
|
Instance* child = NULL;
|
||||||
|
for(size_t i = 0; i < children.size(); i++)
|
||||||
|
{
|
||||||
|
if(children.at(i)->name == name)
|
||||||
|
{
|
||||||
|
child = children.at(i);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return child;
|
||||||
|
}
|
||||||
|
|||||||
13
Instance.h
13
Instance.h
@@ -7,6 +7,17 @@ public:
|
|||||||
Instance(void);
|
Instance(void);
|
||||||
virtual ~Instance(void);
|
virtual ~Instance(void);
|
||||||
std::string name;
|
std::string name;
|
||||||
Instance* parent; // Another pointer.
|
virtual void render(RenderDevice*);
|
||||||
|
std::vector<Instance*> children; // All children.
|
||||||
|
std::string getClassName();
|
||||||
|
Instance* findFirstChild(std::string);
|
||||||
|
std::vector<Instance* > getChildren();
|
||||||
|
std::vector<Instance* > getAllChildren();
|
||||||
|
void setParent(Instance*);
|
||||||
|
void addChild(Instance*);
|
||||||
|
void removeChild(Instance*);
|
||||||
|
Instance* getParent();
|
||||||
|
protected:
|
||||||
std::string className;
|
std::string className;
|
||||||
|
Instance* parent; // Another pointer.
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -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,9 @@ 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)
|
||||||
{
|
{
|
||||||
@@ -22,7 +24,38 @@ PhysicalInstance::PhysicalInstance(void)
|
|||||||
velocity = Vector3(0,0,0);
|
velocity = Vector3(0,0,0);
|
||||||
rotVelocity = Vector3(0,0,0);
|
rotVelocity = Vector3(0,0,0);
|
||||||
}
|
}
|
||||||
|
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()
|
Vector3 PhysicalInstance::getPosition()
|
||||||
{
|
{
|
||||||
return position;
|
return position;
|
||||||
@@ -31,6 +64,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 +74,37 @@ 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;
|
||||||
|
}
|
||||||
|
|
||||||
|
void PhysicalInstance::render(RenderDevice* rd)
|
||||||
|
{
|
||||||
|
Draw::box(getBox(), rd, color, Color4::clear());
|
||||||
|
if(!children.empty())
|
||||||
|
{
|
||||||
|
for(size_t i = 0; i < children.size(); i++)
|
||||||
|
{
|
||||||
|
children.at(i)->render(rd);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
PhysicalInstance::~PhysicalInstance(void)
|
PhysicalInstance::~PhysicalInstance(void)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ class PhysicalInstance :
|
|||||||
public:
|
public:
|
||||||
PhysicalInstance(void);
|
PhysicalInstance(void);
|
||||||
~PhysicalInstance(void);
|
~PhysicalInstance(void);
|
||||||
Vector3 size;
|
virtual void render(RenderDevice*);
|
||||||
Vector3 velocity;
|
Vector3 velocity;
|
||||||
Vector3 rotvelocity;
|
Vector3 rotvelocity;
|
||||||
CoordinateFrame cFrame;
|
CoordinateFrame cFrame;
|
||||||
@@ -16,6 +16,11 @@ public:
|
|||||||
void setPosition(Vector3);
|
void setPosition(Vector3);
|
||||||
CoordinateFrame getCFrame();
|
CoordinateFrame getCFrame();
|
||||||
void setCFrame(CoordinateFrame);
|
void setCFrame(CoordinateFrame);
|
||||||
|
Box getBox();
|
||||||
|
CoordinateFrame getCFrameRenderBased();
|
||||||
|
Vector3 getSize();
|
||||||
|
void setSize(Vector3);
|
||||||
private:
|
private:
|
||||||
Vector3 position;
|
Vector3 position;
|
||||||
|
Vector3 size;
|
||||||
};
|
};
|
||||||
|
|||||||
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.
|
||||||
14
WorkspaceInstance.cpp
Normal file
14
WorkspaceInstance.cpp
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
#include "WorkspaceInstance.h"
|
||||||
|
float timer = 60.0F;
|
||||||
|
int score = 0;
|
||||||
|
|
||||||
|
WorkspaceInstance::WorkspaceInstance(void)
|
||||||
|
{
|
||||||
|
className = "Workspace";
|
||||||
|
timer = 60.0F;
|
||||||
|
score = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
WorkspaceInstance::~WorkspaceInstance(void)
|
||||||
|
{
|
||||||
|
}
|
||||||
12
WorkspaceInstance.h
Normal file
12
WorkspaceInstance.h
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
#pragma once
|
||||||
|
#include "instance.h"
|
||||||
|
|
||||||
|
class WorkspaceInstance :
|
||||||
|
public Instance
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
float timer;
|
||||||
|
int score;
|
||||||
|
WorkspaceInstance(void);
|
||||||
|
~WorkspaceInstance(void);
|
||||||
|
};
|
||||||
75
building.md
Normal file
75
building.md
Normal file
@@ -0,0 +1,75 @@
|
|||||||
|
# Building Setup
|
||||||
|
|
||||||
|
##### G3D is super delicate, meaning that you have to go about building in a special way
|
||||||
|
|
||||||
|
#### Skip to steps 7-13 if you have already built this program
|
||||||
|
|
||||||
|
1. Install Visual Studio 2005. Google where to find it. Make note of which version you downloaded.
|
||||||
|
|
||||||
|
2. Download and install G3D from [this link here](https://sourceforge.net/projects/g3d/files/g3d-cpp/6.10/g3d-6_10_win32.exe/download).
|
||||||
|
|
||||||
|
3. Make sure G3D is included under your build directories by going under Tools -> Options -> Projects and Solutions -> VC++ Directories and check and see if:
|
||||||
|
|
||||||
|
* `g3d-6_10\bin` is under executable files
|
||||||
|
|
||||||
|
* `g3d-6_10\include` is under include files
|
||||||
|
|
||||||
|
* `g3d-6_10\bin` is under executable files
|
||||||
|
|
||||||
|
* `g3d-6_10\win32-vc8-lib` is under library files
|
||||||
|
|
||||||
|
* Ex: `C:\libraries\g3d-6_10\bin`
|
||||||
|
|
||||||
|
4. Download SDL version 1.2.7 from [this link](http://www.libsdl.org/release/SDL-devel-1.2.7-VC6.zip)
|
||||||
|
|
||||||
|
5. Extract the file to a folder on your computer. Keep note of this folder.
|
||||||
|
|
||||||
|
6. Include the extracted files by going to Tools -> Options -> Projects and Solutions -> VC++ Directories and adding the following links:
|
||||||
|
|
||||||
|
* Include files - extractpath\`include`
|
||||||
|
|
||||||
|
* Library files - extractpath\`lib`
|
||||||
|
|
||||||
|
* Ex: `C:\libraries\SDL-1.2.7\bin`
|
||||||
|
|
||||||
|
#### Steps 7-11 are optional if you are using Visual Studio Professional. Check the Error stuff section if it doesn't work, most reference steps from here.
|
||||||
|
|
||||||
|
7. Download and install the [platform SDK](https://www.microsoft.com/en-us/download/details.aspx?id=6510).
|
||||||
|
|
||||||
|
8. Put the platform SDK into your directories (Tools -> Options -> Projects and Solutions -> VC++ Directories) by replacing all mentions of $(VCInstallDir)PlatformSDK with the actual path.
|
||||||
|
Ex: `$(VCInstallDir)PlatformSDK\include` -> `C:\Program Files\Microsoft Platform SDK\Include`
|
||||||
|
|
||||||
|
9. Right click Source files -> Dialogs.rc -> View Code
|
||||||
|
|
||||||
|
10. Edit line 10 to say
|
||||||
|
```cpp
|
||||||
|
#include "WinResrc.h"
|
||||||
|
#define IDC_STATIC -1
|
||||||
|
```
|
||||||
|
|
||||||
|
instead of
|
||||||
|
|
||||||
|
```cpp
|
||||||
|
#include "afxres.h"
|
||||||
|
```
|
||||||
|
|
||||||
|
11. Right click the project -> Properties -> Configuration Properties -> Linker -> Input, and add `AdvAPI32.lib` under Additional Dependencies.
|
||||||
|
|
||||||
|
### Continue back here if you're skipping steps 7-11
|
||||||
|
|
||||||
|
12. Right click the project -> Properties -> Configuration Properties -> Linker -> General, and make sure Additional Library Directories is blank.
|
||||||
|
|
||||||
|
13. Try building using Build -> Build G3DTest.
|
||||||
|
|
||||||
|
|
||||||
|
## Error stuff
|
||||||
|
|
||||||
|
```c:\libraries\g3d-6_10\include\G3D/platform.h(235) : fatal error C1083: Cannot open include file: 'windows.h': No such file or directory``` > Download and install platform SDK (lines 7-8)
|
||||||
|
|
||||||
|
```G3D-debug.lib(RegistryUtil.obj) : error LNK2019: unresolved external symbol __imp__RegCloseKey@4 referenced in function "public: static bool __cdecl G3D::RegistryUtil::keyExists(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &)" (?keyExists@RegistryUtil@G3D@@SA_NABV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@Z)``` > Add AdvAPI32.lib under Additional Dependencies (step 11)
|
||||||
|
|
||||||
|
```.\Dialogs.rc(10) : fatal error RC1015: cannot open include file 'afxres.h'.``` > Perform steps 9-10
|
||||||
|
|
||||||
|
Enjoy!
|
||||||
|
|
||||||
|
please report unfriendliness of this page
|
||||||
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.
Reference in New Issue
Block a user