diff --git a/Meinkraft/Block.cpp b/Meinkraft/Block.cpp deleted file mode 100644 index 1d86086..0000000 --- a/Meinkraft/Block.cpp +++ /dev/null @@ -1,119 +0,0 @@ -#include "Block.h" -#include - -Block::Block(Vec3f position, int textureTop, int textureSides) -{ - this->position = position; - - int rowNum = textureSides / 16; - int columnNum = textureSides % 16; - - float part = (float)1 / 16; - - float row = rowNum * part; - float column = columnNum * part; - float rowEnd = row + part; - float columnEnd = column + part; - - texColsSides = Vec2f(column, columnEnd); - texRowsSides = Vec2f(row, rowEnd); - - if (textureTop == textureSides) - { - texColsTop = texColsSides; - texRowsTop = texRowsSides; - } - else - { - if (textureTop != -1) - { - hasTopTexture = true; - - int rowNum = textureTop / 16; - int columnNum = textureTop% 16; - - float part = (float)1 / 16; - - row = rowNum * part; - column = columnNum * part; - rowEnd = row + part; - columnEnd = column + part; - - texColsTop = Vec2f(column, columnEnd); - texRowsTop = Vec2f(row, rowEnd); - } - } -} - -Block::~Block() -{ -} - -void Block::draw() -{ - glPushMatrix(); - - glTranslatef(position.x, position.y, position.z); - - glBegin(GL_QUADS); - - glColor4f(1.0, 1.0, 1.0, 1.0); - - float column = texColsSides.x; - float columnEnd = texColsSides.y; - - float row = texRowsSides.x; - float rowEnd = texRowsSides.y; - - //Side size - glTexCoord2f(column, rowEnd); glVertex3f(0, 0, 0); //Linksonder - glTexCoord2f(columnEnd, rowEnd); glVertex3f(size, 0, 0); //Rechtsonder - glTexCoord2f(columnEnd, row); glVertex3f(size, size, 0); //Rechtsboven - glTexCoord2f(column, row); glVertex3f(0, size, 0); //Linksboven - - //Side 2 - glTexCoord2f(column, rowEnd); glVertex3f(0, 0, size); - glTexCoord2f(columnEnd, rowEnd); glVertex3f(size, 0, size); - glTexCoord2f(columnEnd, row); glVertex3f(size, size, size); - glTexCoord2f(column, row); glVertex3f(0, size, size); - - //Side 3 - glTexCoord2f(column, rowEnd); glVertex3f(0, 0, 0); - glTexCoord2f(column, row); glVertex3f(0, size, 0); - glTexCoord2f(columnEnd, row); glVertex3f(0, size, size); - glTexCoord2f(columnEnd, rowEnd); glVertex3f(0, 0, size); - - //Side 4 - glTexCoord2f(column, rowEnd); glVertex3f(size, 0, 0); - glTexCoord2f(column, row); glVertex3f(size, size, 0); - glTexCoord2f(columnEnd, row); glVertex3f(size, size, size); - glTexCoord2f(columnEnd, rowEnd); glVertex3f(size, 0, size); - - if (!hasTopTexture) - { - glEnd(); - glPopMatrix(); - return; - } - - //Different textures - column = texColsTop.x; - columnEnd = texColsTop.y; - - row = texRowsTop.x; - rowEnd = texRowsTop.y; - - //Bottom - glTexCoord2f(column, row); glVertex3f(0, 0, 0); - glTexCoord2f(column, rowEnd); glVertex3f(size, 0, 0); - glTexCoord2f(columnEnd, rowEnd); glVertex3f(size, 0, size); - glTexCoord2f(columnEnd, row); glVertex3f(0, 0, size); - - //Top - glTexCoord2f(column, row); glVertex3f(0, size, 0); - glTexCoord2f(column, rowEnd); glVertex3f(size, size, 0); - glTexCoord2f(columnEnd, rowEnd); glVertex3f(size, size, size); - glTexCoord2f(columnEnd, row); glVertex3f(0, size, size); - glEnd(); - glPopMatrix(); -} diff --git a/Meinkraft/Block.h b/Meinkraft/Block.h deleted file mode 100644 index 603a963..0000000 --- a/Meinkraft/Block.h +++ /dev/null @@ -1,23 +0,0 @@ -#pragma once -#include "Vector.h" - -class Block -{ -private: - float size = 1; - bool hasTopTexture = false; - - Vec2f texColsTop; - Vec2f texRowsTop; - Vec2f texColsSides; - Vec2f texRowsSides; - -public: - Block(Vec3f position, int top, int sides); - ~Block(); - - void draw(void); - - Vec3f position; -}; - diff --git a/Meinkraft/Meinkraft.cpp b/Meinkraft/Meinkraft.cpp deleted file mode 100644 index 078d225..0000000 --- a/Meinkraft/Meinkraft.cpp +++ /dev/null @@ -1,131 +0,0 @@ - -#include "Meinkraft.h" -#include -#include -#include "Player.h" -#include "StateHandler.h" - -#define _USE_MATH_DEFINES -#include - -#include "stb_image.h" -#include "stb_perlin.h" - -int Meinkraft::width = 0; -int Meinkraft::height = 0; -GLuint Meinkraft::texture = NULL; - -void Meinkraft::loadTexture(void) -{ - //Load Textures :: blocks - int img_width, img_height, bpp; - unsigned char* imgData = stbi_load("/resources/terrain.png", &img_width, &img_height, &bpp, 4); - - glGenTextures(1, &texture); - glBindTexture(GL_TEXTURE_2D, texture); - - glTexImage2D(GL_TEXTURE_2D, - 0, //level - GL_RGBA, //internal format - img_width, //width - img_height, //height - 0, //border - GL_RGBA, //data format - GL_UNSIGNED_BYTE, //data type - imgData); //data - - glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); - glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); - - stbi_image_free(imgData); -} - -void Meinkraft::init() -{ - player = Player::getInstance(); - statehandler = StateHandler::getInstance(); - //cursor = Cursor::getInstance(); - - loadTexture(); - - lastFrameTime = 0; - - glClearColor(0.7f, 0.7f, 1.0f, 1.0f); - - mousePosition = Vec2f(width / 2, height / 2); -} - - -void Meinkraft::draw() -{ - glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); - - //Draw world - glEnable(GL_LIGHTING); - glEnable(GL_DEPTH_TEST); - - glMatrixMode(GL_PROJECTION); - glLoadIdentity(); - gluPerspective(70, width / (float)height, 0.1f, 500); - glMatrixMode(GL_MODELVIEW); - glLoadIdentity(); - - glEnable(GL_TEXTURE_2D); - glBindTexture(GL_TEXTURE_2D, texture); - - statehandler->draw(); - - //cursor->draw(); - - glutSwapBuffers(); -} - - -void Meinkraft::update() -{ - float frameTime = glutGet(GLUT_ELAPSED_TIME) / 1000.0f; - float deltaTime = frameTime - lastFrameTime; - lastFrameTime = frameTime; - - if (keyboardState.keys[27]) - exit(0); - - Player* player = Player::getInstance(); - - player->rotation.y += mouseOffset.x / 10.0f; - player->rotation.x += mouseOffset.y / 10.0f; - if (player->rotation.x > 90) - player->rotation.x = 90; - if (player->rotation.x < -90) - player->rotation.x = -90; - - float speed = 10; - - Vec3f oldPosition = player->position; - if (keyboardState.keys['a']) player->setPosition(0, deltaTime*speed, false); - if (keyboardState.keys['d']) player->setPosition(180, deltaTime*speed, false); - if (keyboardState.keys['w']) player->setPosition(90, deltaTime*speed, false); - if (keyboardState.keys['s']) player->setPosition(270, deltaTime*speed, false); - if (keyboardState.keys['q']) player->setPosition(1, deltaTime*speed, true); - if (keyboardState.keys['e']) player->setPosition(-1, deltaTime*speed, true); - - //if (!worldhandler->isPlayerPositionValid()) - // player->position = oldPosition; - - //player->position.y = worldhandler->getHeight(player->position.x, player->position.z) + 1.7f; - - statehandler->update(deltaTime); - - mousePosition = mousePosition + mouseOffset; - //cursor->update(mousePosition); - - mouseOffset = Vec2f(0, 0); - prevKeyboardState = keyboardState; - glutPostRedisplay(); -} - -KeyboardState::KeyboardState() -{ - memset(keys, 0, sizeof(keys)); - memset(special, 0, sizeof(special)); -} diff --git a/Meinkraft/Meinkraft.sln b/Meinkraft/Meinkraft.sln deleted file mode 100644 index c70ee29..0000000 --- a/Meinkraft/Meinkraft.sln +++ /dev/null @@ -1,28 +0,0 @@ - -Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio 14 -VisualStudioVersion = 14.0.24720.0 -MinimumVisualStudioVersion = 10.0.40219.1 -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Meinkraft", "Meinkraft.vcxproj", "{05A43DED-C24F-41E3-93C3-AB634336B0A2}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|x64 = Debug|x64 - Debug|x86 = Debug|x86 - Release|x64 = Release|x64 - Release|x86 = Release|x86 - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {05A43DED-C24F-41E3-93C3-AB634336B0A2}.Debug|x64.ActiveCfg = Debug|x64 - {05A43DED-C24F-41E3-93C3-AB634336B0A2}.Debug|x64.Build.0 = Debug|x64 - {05A43DED-C24F-41E3-93C3-AB634336B0A2}.Debug|x86.ActiveCfg = Debug|Win32 - {05A43DED-C24F-41E3-93C3-AB634336B0A2}.Debug|x86.Build.0 = Debug|Win32 - {05A43DED-C24F-41E3-93C3-AB634336B0A2}.Release|x64.ActiveCfg = Release|x64 - {05A43DED-C24F-41E3-93C3-AB634336B0A2}.Release|x64.Build.0 = Release|x64 - {05A43DED-C24F-41E3-93C3-AB634336B0A2}.Release|x86.ActiveCfg = Release|Win32 - {05A43DED-C24F-41E3-93C3-AB634336B0A2}.Release|x86.Build.0 = Release|Win32 - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection -EndGlobal diff --git a/Meinkraft/Meinkraft.vcxproj.filters b/Meinkraft/Meinkraft.vcxproj.filters deleted file mode 100644 index 73f2a87..0000000 --- a/Meinkraft/Meinkraft.vcxproj.filters +++ /dev/null @@ -1,117 +0,0 @@ - - - - - {4FC737F1-C7A5-4376-A066-2A32D752A2FF} - cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx - - - {93995380-89BD-4b04-88EB-625FBE52EBFB} - h;hh;hpp;hxx;hm;inl;inc;xsd - - - {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} - rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms - - - {087c1e25-9bb6-45a3-9612-6773babfbbed} - - - {27bdcbff-0967-4c9a-904d-b7784c5b87d1} - - - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files\World - - - Source Files\World - - - Source Files\World - - - Source Files\World - - - Source Files\State - - - Source Files\State - - - Source Files\State - - - Source Files - - - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - \ No newline at end of file diff --git a/Meinkraft/MenuState.cpp b/Meinkraft/MenuState.cpp deleted file mode 100644 index ef550c9..0000000 --- a/Meinkraft/MenuState.cpp +++ /dev/null @@ -1,28 +0,0 @@ -#include "MenuState.h" - - - -MenuState::MenuState() -{ -} - - -MenuState::~MenuState() -{ -} - -void MenuState::init(void) -{ -} - -void MenuState::exit(void) -{ -} - -void MenuState::draw(void) -{ -} - -void MenuState::update(float deltaTime) -{ -} diff --git a/Meinkraft/MenuState.h b/Meinkraft/MenuState.h deleted file mode 100644 index 1b4748f..0000000 --- a/Meinkraft/MenuState.h +++ /dev/null @@ -1,16 +0,0 @@ -#pragma once -#include "State.h" - -class MenuState : public State -{ -public: - MenuState(); - ~MenuState(); - - void init(void); - void exit(void); - - void draw(void); - void update(float deltaTime); -}; - diff --git a/Meinkraft/State.cpp b/Meinkraft/State.cpp deleted file mode 100644 index 6e0fff0..0000000 --- a/Meinkraft/State.cpp +++ /dev/null @@ -1,9 +0,0 @@ -#include "State.h" - -State::State() -{ -} - -State::~State() -{ -} diff --git a/Meinkraft/State.h b/Meinkraft/State.h deleted file mode 100644 index 101994c..0000000 --- a/Meinkraft/State.h +++ /dev/null @@ -1,14 +0,0 @@ -#pragma once -class State -{ -public: - State(); - ~State(); - - virtual void init(void) = 0; - virtual void exit(void) = 0; - - virtual void draw(void) = 0; - virtual void update(float deltaTime) = 0; -}; - diff --git a/Meinkraft/StateHandler.cpp b/Meinkraft/StateHandler.cpp deleted file mode 100644 index e259a36..0000000 --- a/Meinkraft/StateHandler.cpp +++ /dev/null @@ -1,61 +0,0 @@ -#include "StateHandler.h" -#include "MenuState.h" -#include "WorldState.h" - -StateHandler* StateHandler::instance = nullptr; - -StateHandler::StateHandler() -{ - available = false; - CState = WORLD; - CurrentState = new WorldState(); - CurrentState->init(); - available = true; -} - -StateHandler::~StateHandler() -{ - delete CurrentState; -} - -StateHandler* StateHandler::getInstance() -{ - if (instance == nullptr) - instance = new StateHandler(); - - return instance; -} - -void StateHandler::update(float deltaTime) -{ - if(available) - CurrentState->update(deltaTime); -} -void StateHandler::draw() -{ - if(available) - CurrentState->draw(); -} - -void StateHandler::changeState(EState newState) -{ - if (CState == newState) - return; - - available = false; - - CurrentState->exit(); - - switch (newState) - { - case WORLD: - CurrentState = new WorldState(); - case MENU: - CurrentState = new MenuState(); - } - - CState = newState; - CurrentState->init(); - - available = true; -} diff --git a/Meinkraft/StateHandler.h b/Meinkraft/StateHandler.h deleted file mode 100644 index 755ec52..0000000 --- a/Meinkraft/StateHandler.h +++ /dev/null @@ -1,25 +0,0 @@ -#pragma once -#include "State.h" - -class StateHandler -{ -public: - ~StateHandler(); - - static StateHandler* getInstance(void); - - enum EState { WORLD, MENU }; - - void changeState(EState newState); - - void draw(void); - void update(float deltaTime); -private: - StateHandler(); - static StateHandler* instance; - - State* CurrentState; - EState CState; - bool available; -}; - diff --git a/Meinkraft/World.cpp b/Meinkraft/World.cpp deleted file mode 100644 index 6a2d25d..0000000 --- a/Meinkraft/World.cpp +++ /dev/null @@ -1,22 +0,0 @@ -#include "World.h" -#include "Block.h" - - -World::World() -{ -} - - -World::~World() -{ -} - -void World::draw(void) -{ - Block b = Block(Vec3f(0, 0, 0), 1, 3); - b.draw(); -} - -void World::update(float deltaTime) -{ -} diff --git a/Meinkraft/World.h b/Meinkraft/World.h deleted file mode 100644 index d3fd8b9..0000000 --- a/Meinkraft/World.h +++ /dev/null @@ -1,11 +0,0 @@ -#pragma once -class World -{ -public: - World(); - ~World(); - - void draw(void); - void update(float deltaTime); -}; - diff --git a/Meinkraft/WorldState.cpp b/Meinkraft/WorldState.cpp deleted file mode 100644 index 10f96da..0000000 --- a/Meinkraft/WorldState.cpp +++ /dev/null @@ -1,32 +0,0 @@ -#include "WorldState.h" - - - -WorldState::WorldState() -{ -} - - -WorldState::~WorldState() -{ -} - -void WorldState::init(void) -{ - world = new World(); -} - -void WorldState::exit(void) -{ - delete world; -} - -void WorldState::draw(void) -{ - world->draw(); -} - -void WorldState::update(float deltaTime) -{ - world->update(deltaTime); -} diff --git a/Meinkraft/WorldState.h b/Meinkraft/WorldState.h deleted file mode 100644 index 7b3f48e..0000000 --- a/Meinkraft/WorldState.h +++ /dev/null @@ -1,19 +0,0 @@ -#pragma once -#include "State.h" -#include "World.h" - -class WorldState : public State -{ -private: - World* world; -public: - WorldState(); - ~WorldState(); - - void init(void); - void exit(void); - - void draw(void); - void update(float deltaTime); -}; - diff --git a/Meinkraft/resources/logo.png b/Meinkraft/resources/logo.png deleted file mode 100644 index bc970e2..0000000 Binary files a/Meinkraft/resources/logo.png and /dev/null differ diff --git a/Meinkraft/resources/terrain.png b/Meinkraft/resources/terrain.png deleted file mode 100644 index 041e1c0..0000000 Binary files a/Meinkraft/resources/terrain.png and /dev/null differ diff --git a/Meinkraft/stb_perlin.h b/Meinkraft/stb_perlin.h deleted file mode 100644 index 0dac7d9..0000000 --- a/Meinkraft/stb_perlin.h +++ /dev/null @@ -1,182 +0,0 @@ -// stb_perlin.h - v0.2 - perlin noise -// public domain single-file C implementation by Sean Barrett -// -// LICENSE -// -// This software is dual-licensed to the public domain and under the following -// license: you are granted a perpetual, irrevocable license to copy, modify, -// publish, and distribute this file as you see fit. -// -// -// to create the implementation, -// #define STB_PERLIN_IMPLEMENTATION -// in *one* C/CPP file that includes this file. - - -// Documentation: -// -// float stb_perlin_noise3( float x, -// float y, -// float z, -// int x_wrap=0, -// int y_wrap=0, -// int z_wrap=0) -// -// This function computes a random value at the coordinate (x,y,z). -// Adjacent random values are continuous but the noise fluctuates -// its randomness with period 1, i.e. takes on wholly unrelated values -// at integer points. Specifically, this implements Ken Perlin's -// revised noise function from 2002. -// -// The "wrap" parameters can be used to create wraparound noise that -// wraps at powers of two. The numbers MUST be powers of two. Specify -// 0 to mean "don't care". (The noise always wraps every 256 due -// details of the implementation, even if you ask for larger or no -// wrapping.) - - -#ifdef __cplusplus -extern "C" float stb_perlin_noise3(float x, float y, float z, int x_wrap=0, int y_wrap=0, int z_wrap=0); -#else -extern float stb_perlin_noise3(float x, float y, float z, int x_wrap, int y_wrap, int z_wrap); -#endif - -#ifdef STB_PERLIN_IMPLEMENTATION - -#include // floor() - -// not same permutation table as Perlin's reference to avoid copyright issues; -// Perlin's table can be found at http://mrl.nyu.edu/~perlin/noise/ -// @OPTIMIZE: should this be unsigned char instead of int for cache? -static int stb__perlin_randtab[512] = -{ - 23, 125, 161, 52, 103, 117, 70, 37, 247, 101, 203, 169, 124, 126, 44, 123, - 152, 238, 145, 45, 171, 114, 253, 10, 192, 136, 4, 157, 249, 30, 35, 72, - 175, 63, 77, 90, 181, 16, 96, 111, 133, 104, 75, 162, 93, 56, 66, 240, - 8, 50, 84, 229, 49, 210, 173, 239, 141, 1, 87, 18, 2, 198, 143, 57, - 225, 160, 58, 217, 168, 206, 245, 204, 199, 6, 73, 60, 20, 230, 211, 233, - 94, 200, 88, 9, 74, 155, 33, 15, 219, 130, 226, 202, 83, 236, 42, 172, - 165, 218, 55, 222, 46, 107, 98, 154, 109, 67, 196, 178, 127, 158, 13, 243, - 65, 79, 166, 248, 25, 224, 115, 80, 68, 51, 184, 128, 232, 208, 151, 122, - 26, 212, 105, 43, 179, 213, 235, 148, 146, 89, 14, 195, 28, 78, 112, 76, - 250, 47, 24, 251, 140, 108, 186, 190, 228, 170, 183, 139, 39, 188, 244, 246, - 132, 48, 119, 144, 180, 138, 134, 193, 82, 182, 120, 121, 86, 220, 209, 3, - 91, 241, 149, 85, 205, 150, 113, 216, 31, 100, 41, 164, 177, 214, 153, 231, - 38, 71, 185, 174, 97, 201, 29, 95, 7, 92, 54, 254, 191, 118, 34, 221, - 131, 11, 163, 99, 234, 81, 227, 147, 156, 176, 17, 142, 69, 12, 110, 62, - 27, 255, 0, 194, 59, 116, 242, 252, 19, 21, 187, 53, 207, 129, 64, 135, - 61, 40, 167, 237, 102, 223, 106, 159, 197, 189, 215, 137, 36, 32, 22, 5, - - // and a second copy so we don't need an extra mask or static initializer - 23, 125, 161, 52, 103, 117, 70, 37, 247, 101, 203, 169, 124, 126, 44, 123, - 152, 238, 145, 45, 171, 114, 253, 10, 192, 136, 4, 157, 249, 30, 35, 72, - 175, 63, 77, 90, 181, 16, 96, 111, 133, 104, 75, 162, 93, 56, 66, 240, - 8, 50, 84, 229, 49, 210, 173, 239, 141, 1, 87, 18, 2, 198, 143, 57, - 225, 160, 58, 217, 168, 206, 245, 204, 199, 6, 73, 60, 20, 230, 211, 233, - 94, 200, 88, 9, 74, 155, 33, 15, 219, 130, 226, 202, 83, 236, 42, 172, - 165, 218, 55, 222, 46, 107, 98, 154, 109, 67, 196, 178, 127, 158, 13, 243, - 65, 79, 166, 248, 25, 224, 115, 80, 68, 51, 184, 128, 232, 208, 151, 122, - 26, 212, 105, 43, 179, 213, 235, 148, 146, 89, 14, 195, 28, 78, 112, 76, - 250, 47, 24, 251, 140, 108, 186, 190, 228, 170, 183, 139, 39, 188, 244, 246, - 132, 48, 119, 144, 180, 138, 134, 193, 82, 182, 120, 121, 86, 220, 209, 3, - 91, 241, 149, 85, 205, 150, 113, 216, 31, 100, 41, 164, 177, 214, 153, 231, - 38, 71, 185, 174, 97, 201, 29, 95, 7, 92, 54, 254, 191, 118, 34, 221, - 131, 11, 163, 99, 234, 81, 227, 147, 156, 176, 17, 142, 69, 12, 110, 62, - 27, 255, 0, 194, 59, 116, 242, 252, 19, 21, 187, 53, 207, 129, 64, 135, - 61, 40, 167, 237, 102, 223, 106, 159, 197, 189, 215, 137, 36, 32, 22, 5, -}; - -static float stb__perlin_lerp(float a, float b, float t) -{ - return a + (b-a) * t; -} - -// different grad function from Perlin's, but easy to modify to match reference -static float stb__perlin_grad(int hash, float x, float y, float z) -{ - static float basis[12][4] = - { - { 1, 1, 0 }, - { -1, 1, 0 }, - { 1,-1, 0 }, - { -1,-1, 0 }, - { 1, 0, 1 }, - { -1, 0, 1 }, - { 1, 0,-1 }, - { -1, 0,-1 }, - { 0, 1, 1 }, - { 0,-1, 1 }, - { 0, 1,-1 }, - { 0,-1,-1 }, - }; - - // perlin's gradient has 12 cases so some get used 1/16th of the time - // and some 2/16ths. We reduce bias by changing those fractions - // to 5/16ths and 6/16ths, and the same 4 cases get the extra weight. - static unsigned char indices[64] = - { - 0,1,2,3,4,5,6,7,8,9,10,11, - 0,9,1,11, - 0,1,2,3,4,5,6,7,8,9,10,11, - 0,1,2,3,4,5,6,7,8,9,10,11, - 0,1,2,3,4,5,6,7,8,9,10,11, - 0,1,2,3,4,5,6,7,8,9,10,11, - }; - - // if you use reference permutation table, change 63 below to 15 to match reference - float *grad = basis[indices[hash & 63]]; - return grad[0]*x + grad[1]*y + grad[2]*z; -} - -float stb_perlin_noise3(float x, float y, float z, int x_wrap, int y_wrap, int z_wrap) -{ - float u,v,w; - float n000,n001,n010,n011,n100,n101,n110,n111; - float n00,n01,n10,n11; - float n0,n1; - - unsigned int x_mask = (x_wrap-1) & 255; - unsigned int y_mask = (y_wrap-1) & 255; - unsigned int z_mask = (z_wrap-1) & 255; - int px = (int) floor(x); - int py = (int) floor(y); - int pz = (int) floor(z); - int x0 = px & x_mask, x1 = (px+1) & x_mask; - int y0 = py & y_mask, y1 = (py+1) & y_mask; - int z0 = pz & z_mask, z1 = (pz+1) & z_mask; - int r0,r1, r00,r01,r10,r11; - - #define stb__perlin_ease(a) (((a*6-15)*a + 10) * a * a * a) - - x -= px; u = stb__perlin_ease(x); - y -= py; v = stb__perlin_ease(y); - z -= pz; w = stb__perlin_ease(z); - - r0 = stb__perlin_randtab[x0]; - r1 = stb__perlin_randtab[x1]; - - r00 = stb__perlin_randtab[r0+y0]; - r01 = stb__perlin_randtab[r0+y1]; - r10 = stb__perlin_randtab[r1+y0]; - r11 = stb__perlin_randtab[r1+y1]; - - n000 = stb__perlin_grad(stb__perlin_randtab[r00+z0], x , y , z ); - n001 = stb__perlin_grad(stb__perlin_randtab[r00+z1], x , y , z-1 ); - n010 = stb__perlin_grad(stb__perlin_randtab[r01+z0], x , y-1, z ); - n011 = stb__perlin_grad(stb__perlin_randtab[r01+z1], x , y-1, z-1 ); - n100 = stb__perlin_grad(stb__perlin_randtab[r10+z0], x-1, y , z ); - n101 = stb__perlin_grad(stb__perlin_randtab[r10+z1], x-1, y , z-1 ); - n110 = stb__perlin_grad(stb__perlin_randtab[r11+z0], x-1, y-1, z ); - n111 = stb__perlin_grad(stb__perlin_randtab[r11+z1], x-1, y-1, z-1 ); - - n00 = stb__perlin_lerp(n000,n001,w); - n01 = stb__perlin_lerp(n010,n011,w); - n10 = stb__perlin_lerp(n100,n101,w); - n11 = stb__perlin_lerp(n110,n111,w); - - n0 = stb__perlin_lerp(n00,n01,v); - n1 = stb__perlin_lerp(n10,n11,v); - - return stb__perlin_lerp(n0,n1,u); -} -#endif // STB_PERLIN_IMPLEMENTATION diff --git a/Racer/.gitignore b/Racer/.gitignore new file mode 100644 index 0000000..56567d9 --- /dev/null +++ b/Racer/.gitignore @@ -0,0 +1,235 @@ +## Ignore Visual Studio temporary files, build results, and +## files generated by popular Visual Studio add-ons. + +# User-specific files +*.suo +*.user +*.userosscache +*.sln.docstates + +# User-specific files (MonoDevelop/Xamarin Studio) +*.userprefs + +# Build results +[Dd]ebug/ +[Dd]ebugPublic/ +[Rr]elease/ +[Rr]eleases/ +x64/ +x86/ +bld/ +[Bb]in/ +[Oo]bj/ + +# Visual Studio 2015 cache/options directory +.vs/ +# Uncomment if you have tasks that create the project's static files in wwwroot +#wwwroot/ + +# MSTest test Results +[Tt]est[Rr]esult*/ +[Bb]uild[Ll]og.* + +# NUNIT +*.VisualState.xml +TestResult.xml + +# Build Results of an ATL Project +[Dd]ebugPS/ +[Rr]eleasePS/ +dlldata.c + +# DNX +project.lock.json +artifacts/ + +*_i.c +*_p.c +*_i.h +*.ilk +*.meta +*.pch +*.pdb +*.pgc +*.pgd +*.rsp +*.sbr +*.tlb +*.tli +*.tlh +*.tmp +*.tmp_proj +*.log +*.vspscc +*.vssscc +.builds +*.pidb +*.svclog +*.scc + +# Chutzpah Test files +_Chutzpah* + +# Visual C++ cache files +ipch/ +*.aps +*.ncb +*.opendb +*.opensdf +*.sdf +*.cachefile + +# Visual Studio profiler +*.psess +*.vsp +*.vspx +*.sap + +# TFS 2012 Local Workspace +$tf/ + +# Guidance Automation Toolkit +*.gpState + +# ReSharper is a .NET coding add-in +_ReSharper*/ +*.[Rr]e[Ss]harper +*.DotSettings.user + +# JustCode is a .NET coding add-in +.JustCode + +# TeamCity is a build add-in +_TeamCity* + +# DotCover is a Code Coverage Tool +*.dotCover + +# NCrunch +_NCrunch_* +.*crunch*.local.xml +nCrunchTemp_* + +# MightyMoose +*.mm.* +AutoTest.Net/ + +# Web workbench (sass) +.sass-cache/ + +# Installshield output folder +[Ee]xpress/ + +# DocProject is a documentation generator add-in +DocProject/buildhelp/ +DocProject/Help/*.HxT +DocProject/Help/*.HxC +DocProject/Help/*.hhc +DocProject/Help/*.hhk +DocProject/Help/*.hhp +DocProject/Help/Html2 +DocProject/Help/html + +# Click-Once directory +publish/ + +# Publish Web Output +*.[Pp]ublish.xml +*.azurePubxml +# TODO: Comment the next line if you want to checkin your web deploy settings +# but database connection strings (with potential passwords) will be unencrypted +*.pubxml +*.publishproj + +# NuGet Packages +*.nupkg +# The packages folder can be ignored because of Package Restore +**/packages/* +# except build/, which is used as an MSBuild target. +!**/packages/build/ +# Uncomment if necessary however generally it will be regenerated when needed +#!**/packages/repositories.config +# NuGet v3's project.json files produces more ignoreable files +*.nuget.props +*.nuget.targets + +# Microsoft Azure Build Output +csx/ +*.build.csdef + +# Microsoft Azure Emulator +ecf/ +rcf/ + +# Microsoft Azure ApplicationInsights config file +ApplicationInsights.config + +# Windows Store app package directory +AppPackages/ +BundleArtifacts/ + +# Visual Studio cache files +# files ending in .cache can be ignored +*.[Cc]ache +# but keep track of directories ending in .cache +!*.[Cc]ache/ + +# Others +ClientBin/ +~$* +*~ +*.dbmdl +*.dbproj.schemaview +*.pfx +*.publishsettings +node_modules/ +orleans.codegen.cs + +# RIA/Silverlight projects +Generated_Code/ + +# Backup & report files from converting an old project file +# to a newer Visual Studio version. Backup files are not needed, +# because we have git ;-) +_UpgradeReport_Files/ +Backup*/ +UpgradeLog*.XML +UpgradeLog*.htm + +# SQL Server files +*.mdf +*.ldf + +# Business Intelligence projects +*.rdl.data +*.bim.layout +*.bim_*.settings + +# Microsoft Fakes +FakesAssemblies/ + +# GhostDoc plugin setting file +*.GhostDoc.xml + +# Node.js Tools for Visual Studio +.ntvs_analysis.dat + +# Visual Studio 6 build log +*.plg + +# Visual Studio 6 workspace options file +*.opt + +# Visual Studio LightSwitch build output +**/*.HTMLClient/GeneratedArtifacts +**/*.DesktopClient/GeneratedArtifacts +**/*.DesktopClient/ModelManifest.xml +**/*.Server/GeneratedArtifacts +**/*.Server/ModelManifest.xml +_Pvt_Extensions + +# Paket dependency manager +.paket/paket.exe + +# FAKE - F# Make +.fake/ diff --git a/Racer/.idea/.gitignore b/Racer/.idea/.gitignore new file mode 100644 index 0000000..9d0f847 --- /dev/null +++ b/Racer/.idea/.gitignore @@ -0,0 +1,6 @@ +/workspace.xml +/vcs.xml +/modules.xml +/misc.xml +/encodings.xml +/CrystalPoint.iml diff --git a/Racer/Button.cpp b/Racer/Button.cpp new file mode 100644 index 0000000..4672323 --- /dev/null +++ b/Racer/Button.cpp @@ -0,0 +1,76 @@ +#include "Button.h" +#include +#include "Util.h" +#include "Vector.h" +#include "Cursor.h" + +Button::Button(const std::string & text, Vec2f position, float width, float height) : Text(text,position) +{ + this->width = width; + this->height = height; + this->planePosition = position; + + cursorOnButton = false; + alfa = 0.5f; + background = Vec3f(10, 10, 10); + //foreground = Vec3f(255, 255, 255); + this->setColor(Vec3f(255, 255, 255)); + + this->position.x += width / 2 - textWidth / 2; + this->position.y += height / 2 - textHeight / 2; +} + +Button::~Button() +{ + /*if (action != nullptr) + delete action;*/ +} + +void Button::draw(void) +{ + + glColor4f(background.x/255.0f, background.y / 255.0f, background.z / 255.0f, alfa); + + glBegin(GL_QUADS); + glVertex2f(planePosition.x, planePosition.y); + glVertex2f(planePosition.x, planePosition.y + height); + glVertex2f(planePosition.x + width, planePosition.y + height); + glVertex2f(planePosition.x + width, planePosition.y); + glEnd(); + + /*glColor4f(foreground.x / 255.0f, foreground.y / 255.0f, foreground.z / 255.0f, 1.0f); + Util::glutBitmapString(text, position.x, position.y+height/2+14/2);*/ + Text::draw(); +} + +void Button::update(int x, int y) +{ + cursorOnButton = + (x > planePosition.x && x < planePosition.x + width) && + y > planePosition.y && y < planePosition.y + height; + + + if (cursorOnButton) + alfa = 1.0f; + else + alfa = 0.5f; + + if (cursorOnButton && Cursor::getInstance()->clicked) + if(action != nullptr) + action(this); +} + +void Button::addAction(action_function action) +{ + this->action = action; +} + +void Button::setForeground(Vec3f color) +{ + this->setColor(color); +} + +void Button::setBackground(Vec3f color) +{ + background = color; +} diff --git a/Racer/Button.h b/Racer/Button.h new file mode 100644 index 0000000..27d617e --- /dev/null +++ b/Racer/Button.h @@ -0,0 +1,30 @@ +#pragma once +#include "Text.h" + + + +class Button : public Text +{ +private: + typedef void(*action_function)(Button* b); + float width, height; + Vec3f background; + Vec2f planePosition; + bool cursorOnButton; + float alfa; + action_function action = nullptr; +public: + Button(const std::string &text, Vec2f position, float width, float height); + ~Button(); + + + + void draw(); + void update(int x, int y); + + void addAction(action_function action); + + void setForeground(Vec3f color); + void setBackground(Vec3f color); +}; + diff --git a/Racer/CMakeLists.txt b/Racer/CMakeLists.txt new file mode 100644 index 0000000..ca1bc26 --- /dev/null +++ b/Racer/CMakeLists.txt @@ -0,0 +1,17 @@ +cmake_minimum_required(VERSION 3.5) +project(CrystalPoint) + +file(GLOB_RECURSE SOURCE_FILES + "*.h" + "*.cpp" + "*.cc" + ) + +add_executable(CrystalPoint ${SOURCE_FILES}) + +find_package(OpenGL REQUIRED) +find_package(GLUT REQUIRED) +find_package(OpenAL REQUIRED) +include_directories( ${OPENGL_INCLUDE_DIRS} ${GLUT_INCLUDE_DIRS} ${OPENAL_INCLUDE_DIRS} ) +target_link_libraries(CrystalPoint ${OPENGL_LIBRARIES} ${GLUT_LIBRARY} ${OPENAL_LIBRARY} ) +set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -Wall -lpthread") \ No newline at end of file diff --git a/Racer/Cursor.cpp b/Racer/Cursor.cpp new file mode 100644 index 0000000..b892ee7 --- /dev/null +++ b/Racer/Cursor.cpp @@ -0,0 +1,80 @@ +#include "Cursor.h" +#include +#include +#include "Racer.h" + +Cursor* Cursor::instance = NULL; + +Cursor::Cursor() +{ + enabled = false; + mousePosition = Vec2f(Racer::width / 2, Racer::height / 2); + clicked = false; +} + +Cursor::~Cursor() +{ + +} + +Cursor* Cursor::getInstance(void) +{ + if (instance == nullptr) + instance = new Cursor(); + + return instance; +} + +void Cursor::enable(bool enable) +{ + enabled = enable; +} + +bool Cursor::isEnabled(void) +{ + return enabled; +} + +void Cursor::draw(void) +{ + //Draw Cursor + glMatrixMode(GL_PROJECTION); + glLoadIdentity(); + glOrtho(0, Racer::width, Racer::height, 0, -10, 10); + glMatrixMode(GL_MODELVIEW); + glLoadIdentity(); + + glDisable(GL_LIGHTING); + glDisable(GL_DEPTH_TEST); + glColor4f(1, cos(glutGet(GLUT_ELAPSED_TIME) / 1000.0f), sin(glutGet(GLUT_ELAPSED_TIME) / 1000.0f), 1); + + glBegin(GL_TRIANGLES); + glVertex2f(mousePosition.x, mousePosition.y); + glVertex2f(mousePosition.x + 15, mousePosition.y + 15); + glVertex2f(mousePosition.x + 5, mousePosition.y + 20); + glEnd(); +} + +void Cursor::update(Vec2f newPosition) +{ + if (newPosition.x < 0) + newPosition.x = 0; + + if (newPosition.y < 0) + newPosition.y = 0; + + if (newPosition.x > Racer::width) + newPosition.x = Racer::width; + + if (newPosition.y > Racer::height) + newPosition.y = Racer::height; + + mousePosition = newPosition; + + if (clicked) + clicked = !clicked; + if (state != prev) + if(state == GLUT_UP) + clicked = true; + prev = state; +} diff --git a/Racer/Cursor.h b/Racer/Cursor.h new file mode 100644 index 0000000..dd0835e --- /dev/null +++ b/Racer/Cursor.h @@ -0,0 +1,28 @@ +#pragma once +#include "Vector.h" + +class Cursor +{ +private: + Cursor(); + + static Cursor* instance; + bool enabled; + +public: + Vec2f mousePosition; + ~Cursor(); + + static Cursor* getInstance(void); + + void enable(bool enable); + bool isEnabled(void); + + bool clicked; + int state, prev; + + + void draw(void); + void update(Vec2f newPosition); +}; + diff --git a/Meinkraft/Entity.cpp b/Racer/Entity.cpp similarity index 87% rename from Meinkraft/Entity.cpp rename to Racer/Entity.cpp index 2096429..30703a6 100644 --- a/Meinkraft/Entity.cpp +++ b/Racer/Entity.cpp @@ -31,12 +31,7 @@ void Entity::draw() glRotatef(rotation.z, 0, 0, 1); glScalef(scale, scale, scale); - glEnable(GL_CULL_FACE); - glCullFace(GL_BACK); model->draw(); - glCullFace(GL_FRONT); - model->draw(); - glDisable(GL_CULL_FACE); glPopMatrix(); } diff --git a/Meinkraft/Entity.h b/Racer/Entity.h similarity index 90% rename from Meinkraft/Entity.h rename to Racer/Entity.h index a3dc294..8b19146 100644 --- a/Meinkraft/Entity.h +++ b/Racer/Entity.h @@ -13,6 +13,8 @@ public: virtual void draw(); virtual void update(float elapsedTime) {}; + virtual void collide() {}; + Vec3f position; Vec3f rotation; float scale; diff --git a/Racer/HeightMap.cpp b/Racer/HeightMap.cpp new file mode 100644 index 0000000..4bd0df7 --- /dev/null +++ b/Racer/HeightMap.cpp @@ -0,0 +1,192 @@ +#include "HeightMap.h" +#include "stb_image.h" +#include "Vector.h" + +#include "LevelObject.h" + +#include +#include +#include +#include "World.h" + +#define RED 0 +#define GREEN 1 +#define BLUE 2 +#define ALPHA 3 + +HeightMap::HeightMap(const std::string &file, World* world) +{ + int bpp; + unsigned char* imgData = stbi_load(file.c_str(), &width, &height, &bpp, 4); + + auto heightAt = [&](int x, int y) + { + return (imgData[(x + y * width) * 4 ] / 256.0f) * 10.0f; + }; + + auto valueAt = [&](int x, int y, int offset = 0) + { + return imgData[(x + y * width) * 4 + offset]; + }; + + std::vector> faceNormals(width-1, std::vector(height-1, Vec3f(0,1,0))); + for (int y = 0; y < height - 1; y++) + { + for (int x = 0; x < width - 1; x++) + { + int offsets[4][2] = { { 0, 0 },{ 1, 0 },{ 1, 1 },{ 0, 1 } }; + Vec3f ca(0, heightAt(x, y + 1) - heightAt(x, y), 1); + Vec3f ba(1, heightAt(x + 1, y) - heightAt(x, y), 0); + Vec3f normal = ca.cross(ba); + normal.Normalize(); + faceNormals[x][y] = normal; + } + } + + for (int y = 0; y < height-1; y++) + { + for (int x = 0; x < width-1; x++) + { + int offsets[4][2] = { { 0, 0 },{ 1, 0 },{ 1, 1 },{ 0, 1 } }; + + if (valueAt(x, y, GREEN) > 5) + { + ObjectTemplate obtp = world->getObjectFromValue(valueAt(x, y, GREEN)); + LevelObject* p = new LevelObject(obtp.file, Vec3f(x, heightAt(x, y), y), obtp.rotation, obtp.scale, obtp.canCollide); + + world->addLevelObject(p); + } + if (valueAt(x, y, BLUE) > 10) + { + world->addStar(new Star(Vec3f(x, heightAt(x, y), y))); + } + + for (int i = 0; i < 4; i++) + { + int xx = x + offsets[i][0]; + int yy = y + offsets[i][1]; + + Vec3f normal(0, 0, 0); + if(xx < width-1 && yy < height-1) + normal = normal + faceNormals[xx][yy]; + if(xx > 0 && yy < height-1) + normal = normal + faceNormals[xx-1][yy]; + if (xx > 0 && yy > 0) + normal = normal + faceNormals[xx-1][yy-1]; + if (yy > 0 && xx < width-1) + normal = normal + faceNormals[xx][yy-1]; + normal.Normalize(); + + float h = heightAt(xx, yy); + vertices.push_back(Vertex{ (float)(xx), h, (float)(yy), + normal.x, normal.y, normal.z, + (xx) / (float)height, (yy) / (float)width } ); + } + } + } + + glGenTextures(1, &imageIndex); + glBindTexture(GL_TEXTURE_2D, imageIndex); + + glTexImage2D(GL_TEXTURE_2D, + 0, //level + GL_RGBA, //internal format + width, //width + height, //height + 0, //border + GL_RGBA, //data format + GL_UNSIGNED_BYTE, //data type + imgData); //data + glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); + glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); + + stbi_image_free(imgData); +} + +HeightMap::~HeightMap() +{ + glDeleteTextures(1, &imageIndex); +} + +void HeightMap::Draw() +{ + glEnable(GL_LIGHTING); + float color[] = { 0.7f, 0.7f, 0.7f, 1 }; + glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, color); + glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT, color); + + glEnable(GL_TEXTURE_2D); + glBindTexture(GL_TEXTURE_2D, imageIndex); + + glEnableClientState(GL_VERTEX_ARRAY); + glEnableClientState(GL_TEXTURE_COORD_ARRAY); + //glEnableClientState(GL_COLOR_ARRAY); + glEnableClientState(GL_NORMAL_ARRAY); + + glVertexPointer(3, GL_FLOAT, sizeof(Vertex), ((float*)vertices.data()) + 0); + glTexCoordPointer(2, GL_FLOAT, sizeof(Vertex), ((float*)vertices.data()) + 6); + glNormalPointer(GL_FLOAT, sizeof(Vertex), ((float*)vertices.data()) + 3); + glDrawArrays(GL_QUADS, 0, vertices.size()); + + glDisableClientState(GL_VERTEX_ARRAY); + glDisableClientState(GL_TEXTURE_COORD_ARRAY); + //glDisableClientState(GL_COLOR_ARRAY); + glDisableClientState(GL_NORMAL_ARRAY); +} + +float HeightMap::GetHeight(float x, float y) +{ + int ix = x; + int iy = y; + + int index = (ix + (width - 1) * iy) * 4; + + if (index + 3 >= vertices.size()) + index = vertices.size() - 4; + + if (index < 0) + index = 0; + + Vertex& a = vertices[index]; + Vertex& b = vertices[index+1]; + Vertex& c = vertices[index+3]; + + float lowervalue = ((b.z - c.z)*(a.x - c.x) + (c.x - b.x)*(a.z - c.z)); + float labda1 = ((b.z - c.z)*(x - c.x) + (c.x - b.x)*(y - c.z)) / lowervalue; + float labda2 = ((c.y - a.y)*(x - c.x) + (a.x - c.x)*(y - c.y)) / lowervalue; + float labda3 = 1 - labda1 - labda2; + + Vertex z = a * labda1 + b * labda2 + c * labda3; +// Vertex z = (a * labda1) + (b * labda2) ; + + return z.y; +} + + +int HeightMap::GetSize() +{ + return height >= width ? height : width; +} + +void HeightMap::SetTexture(const std::string &file) +{ + int bpp, width2, height2; + stbi_set_flip_vertically_on_load(true); + unsigned char* imgData = stbi_load(file.c_str(), &width2, &height2, &bpp, 4); + + glBindTexture(GL_TEXTURE_2D, imageIndex); + + glTexImage2D(GL_TEXTURE_2D, + 0, //level + GL_RGBA, //internal format + width2, //width + height2, //height + 0, //border + GL_RGBA, //data format + GL_UNSIGNED_BYTE, //data type + imgData); //data + glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); + glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); + + stbi_image_free(imgData); +} \ No newline at end of file diff --git a/Racer/HeightMap.h b/Racer/HeightMap.h new file mode 100644 index 0000000..7ea9178 --- /dev/null +++ b/Racer/HeightMap.h @@ -0,0 +1,28 @@ +#pragma once +#include "Vertex.h" + +#include +#include +#include + +class World; + +class HeightMap +{ +private: + int height; + int width; + + GLuint imageIndex; +public: + HeightMap(const std::string &file, World* world); + ~HeightMap(); + + void Draw(); + float GetHeight(float x, float y); + int GetSize(); + void SetTexture(const std::string &file); + + std::vector vertices; +}; + diff --git a/Racer/Interface.cpp b/Racer/Interface.cpp new file mode 100644 index 0000000..c18990a --- /dev/null +++ b/Racer/Interface.cpp @@ -0,0 +1,75 @@ +#include "Interface.h" +#include +#include "Racer.h" + +#include + +#include "Player.h" +#include "Util.h" + +Interface::Interface() +{ +} + +Interface::Interface(int stars) +{ + this->stars = stars; +} + + +Interface::~Interface() +{ +} + +void Interface::draw() +{ + Player* player = Player::getInstance(); + + //Switch view to Ortho + glMatrixMode(GL_PROJECTION); + glLoadIdentity(); + glOrtho(0, 1000, 1000, 0, -10, 10); + glMatrixMode(GL_MODELVIEW); + glLoadIdentity(); + + glDisable(GL_LIGHTING); + glDisable(GL_DEPTH_TEST); + glDisable(GL_TEXTURE_2D); + + //Draw interface + + //Stars bar + glBegin(GL_QUADS); + glColor4f(0, 0, 0, 1.0); + glVertex2f(250, 980); + glVertex2f(250, 965); + glVertex2f(750, 965); + glVertex2f(750, 980); + glEnd(); + + glBegin(GL_QUADS); + glColor4f(1.0f, 1.0f, 0.1f, 1.0); + glVertex2f(250, 980); + glVertex2f(250, 965); + + glColor4f(1.0f, 1.0f, 0.5f, 1.0); + glVertex2f(250 + ((player->stars / (float)stars) * 500), 965); + glVertex2f(250 + ((player->stars / (float)stars) * 500), 980); + glEnd(); + + //Text: level + glColor4f(1.0f, 1.0f, 0.1f, 1.0); + Util::glutBitmapString("Stars: " + std::to_string(player->stars) + " / " + std::to_string(stars), 480, 940); + + //Text: weapons + //Util::glutBitmapString(player->leftWeapon->name, 850, 900); + //Util::glutBitmapString(player->rightWeapon->name, 10, 900); + + glEnable(GL_LIGHTING); + glEnable(GL_DEPTH_TEST); +} + +void Interface::update(float deltaTime) +{ + +} \ No newline at end of file diff --git a/Racer/Interface.h b/Racer/Interface.h new file mode 100644 index 0000000..f02a52b --- /dev/null +++ b/Racer/Interface.h @@ -0,0 +1,14 @@ +#pragma once +class Interface +{ +private: + int stars; +public: + Interface(); + Interface(int); + ~Interface(); + + void draw(void); + void update(float deltaTime); +}; + diff --git a/Racer/LevelObject.cpp b/Racer/LevelObject.cpp new file mode 100644 index 0000000..18cec8c --- /dev/null +++ b/Racer/LevelObject.cpp @@ -0,0 +1,22 @@ +#include "LevelObject.h" + +#include "Model.h" + + +LevelObject::LevelObject(const std::string &fileName, const Vec3f &position, const Vec3f &rotation, const float &scale, const bool &hasCollision) +{ + model = Model::load(fileName); + this->position = position; + this->position.x -= model->center.x; + this->position.z -= model->center.z; + this->rotation = rotation; + this->scale = scale; + this->canCollide = hasCollision; +} + + +LevelObject::~LevelObject() +{ + if (model) + Model::unload(model); +} diff --git a/Racer/LevelObject.h b/Racer/LevelObject.h new file mode 100644 index 0000000..4aa6267 --- /dev/null +++ b/Racer/LevelObject.h @@ -0,0 +1,17 @@ +#pragma once + +#include "Entity.h" +#include + + +class LevelObject : public Entity +{ +public: + LevelObject(const std::string &fileName, + const Vec3f &position, + const Vec3f &rotation, + const float &scale, + const bool &hasCollision); + ~LevelObject(); +}; + diff --git a/Meinkraft/Main.cpp b/Racer/Main.cpp similarity index 64% rename from Meinkraft/Main.cpp rename to Racer/Main.cpp index c1979e2..b19d3ff 100644 --- a/Meinkraft/Main.cpp +++ b/Racer/Main.cpp @@ -1,27 +1,35 @@ #include -#include "Meinkraft.h" +#include "Racer.h" #include #include "Vector.h" +#define STB_IMAGE_IMPLEMENTATION +#include "stb_image.h" +#include +#include +#include "Cursor.h" + void configureOpenGL(void); -Meinkraft* app; +Racer* app; bool justMoved = false; int main(int argc, char* argv[]) { - app = new Meinkraft(); + app = new Racer(); glutInit(&argc, argv); + srand (time(NULL)); + configureOpenGL(); app->init(); glutDisplayFunc([]() { app->draw(); } ); glutIdleFunc([]() { app->update(); } ); - glutReshapeFunc([](int w, int h) { Meinkraft::width = w; Meinkraft::height = h; glViewport(0, 0, w, h); }); + glutReshapeFunc([](int w, int h) { Racer::width = w; Racer::height = h; glViewport(0, 0, w, h); }); //Keyboard glutKeyboardFunc([](unsigned char c, int, int) { app->keyboardState.keys[c] = true; }); @@ -50,8 +58,20 @@ int main(int argc, char* argv[]) glutPassiveMotionFunc(mousemotion); glutMotionFunc(mousemotion); - Meinkraft::height = GLUT_WINDOW_HEIGHT; - Meinkraft::width = GLUT_WINDOW_WIDTH; + auto mouseclick = [](int button, int state, + int x, int y) + { + if (button == GLUT_LEFT_BUTTON) + Cursor::getInstance()->state = state; + + + //std::cout << "Left button is down" << std::endl; + }; + + glutMouseFunc(mouseclick); + + Racer::height = GLUT_WINDOW_HEIGHT; + Racer::width = GLUT_WINDOW_WIDTH; glutMainLoop(); @@ -63,10 +83,12 @@ void configureOpenGL() { //Init window and glut display mode glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH); - glutInitWindowSize(800, 600); - glutCreateWindow("Meinkraft Bta 0.1"); + glutInitWindowSize(1440, 900); + //glutInitWindowPosition(glutGet(GLUT_WINDOW_WIDTH) / 2 - 800/2, glutGet(GLUT_WINDOW_HEIGHT) / 2 - 600/2); + glutCreateWindow("Racer"); //glutFullScreen(); + //Depth testing glEnable(GL_DEPTH_TEST); @@ -78,21 +100,8 @@ void configureOpenGL() glEnable(GL_ALPHA_TEST); glAlphaFunc(GL_GREATER, 0.01f); - //Lighting - GLfloat mat_specular[] = { 0.2, 0.2, 0.2, 0 }; - //GLfloat mat_shininess[] = { 5.0 }; - GLfloat light_position[] = { 0.0, 2.0, 1.0, 0 }; - GLfloat light_diffuse[] = { 1.0, 1.0, 1.0, 0 }; - GLfloat light_ambient[] = { 0.3, 0.3, 0.3, 0 }; - glClearColor(0.7, 0.7, 1.0, 1.0); - - //glMaterialfv(GL_FRONT, GL_SPECULAR, mat_specular); - //glMaterialfv(GL_FRONT, GL_SHININESS, mat_shininess); - //glLightfv(GL_LIGHT0, GL_DIFFUSE, light_diffuse); - //glLightfv(GL_LIGHT0, GL_AMBIENT, light_ambient); - glEnable(GL_LIGHTING); glEnable(GL_LIGHT0); - glutSetCursor(GLUT_CURSOR_CROSSHAIR); + glutSetCursor(GLUT_CURSOR_NONE); } \ No newline at end of file diff --git a/Meinkraft/Main.h b/Racer/Main.h similarity index 100% rename from Meinkraft/Main.h rename to Racer/Main.h diff --git a/Racer/Menu.cpp b/Racer/Menu.cpp new file mode 100644 index 0000000..dadb7bc --- /dev/null +++ b/Racer/Menu.cpp @@ -0,0 +1,59 @@ +#include +#include "Menu.h" +#include "Racer.h" + +Menu::Menu() +{ + cursor = Cursor::getInstance(); +} + + +Menu::~Menu() +{ +} + +void Menu::draw(void) +{ + //Switch view to Ortho + glMatrixMode(GL_PROJECTION); + glLoadIdentity(); + glOrtho(0, Racer::width, Racer::height, 0, -10, 10); + glMatrixMode(GL_MODELVIEW); + glLoadIdentity(); + + glDisable(GL_LIGHTING); + glDisable(GL_DEPTH_TEST); + glDisable(GL_TEXTURE_2D); + + glColor4f(60/255.0f, 60/255.0f, 60/255.0f, 0.8f); + glBegin(GL_QUADS); + glVertex2f(0,0); + glVertex2f(0, Racer::height); + glVertex2f(Racer::width, Racer::height); + glVertex2f(Racer::width, 0); + glEnd(); + + + for (MenuElement* e : elements) + { + e->draw(); + } + + cursor->draw(); + + glEnable(GL_LIGHTING); + glEnable(GL_DEPTH_TEST); +} + +void Menu::update() +{ + for (MenuElement* e : elements) + { + e->update(cursor->mousePosition.x, cursor->mousePosition.y); + } +} + +void Menu::AddMenuElement(MenuElement * e) +{ + elements.push_back(e); +} diff --git a/Racer/Menu.h b/Racer/Menu.h new file mode 100644 index 0000000..afed8ee --- /dev/null +++ b/Racer/Menu.h @@ -0,0 +1,20 @@ +#pragma once +#include +#include "MenuElement.h" +#include "Cursor.h" + +class Menu +{ +private: + std::vector elements; + Cursor* cursor; +public: + Menu(); + ~Menu(); + + void draw(void); + void update(void); + + void AddMenuElement(MenuElement* e); +}; + diff --git a/Racer/MenuElement.cpp b/Racer/MenuElement.cpp new file mode 100644 index 0000000..e5bc349 --- /dev/null +++ b/Racer/MenuElement.cpp @@ -0,0 +1,12 @@ +#include "MenuElement.h" + +MenuElement::MenuElement(Vec2f position) +{ + hover = false; + this->position = position; +} + + +MenuElement::~MenuElement() +{ +} diff --git a/Racer/MenuElement.h b/Racer/MenuElement.h new file mode 100644 index 0000000..4f09c21 --- /dev/null +++ b/Racer/MenuElement.h @@ -0,0 +1,17 @@ +#pragma once +#include "Vector.h" +#include + +class MenuElement +{ +protected: + bool hover; + Vec2f position; +public: + MenuElement(Vec2f position); + ~MenuElement(); + + virtual void draw(void) {}; + virtual void update(int x, int y) {}; +}; + diff --git a/Meinkraft/Model.cpp b/Racer/Model.cpp similarity index 98% rename from Meinkraft/Model.cpp rename to Racer/Model.cpp index 48c91a5..f664111 100644 --- a/Meinkraft/Model.cpp +++ b/Racer/Model.cpp @@ -1,6 +1,5 @@ #include "Model.h" -#define STB_IMAGE_IMPLEMENTATION #include "stb_image.h" #include @@ -8,6 +7,7 @@ #include #include #include +#include //Prototypes std::vector split(std::string str, std::string sep); @@ -138,7 +138,7 @@ Model::Model(std::string fileName) radius = fmax(radius, (center.x - v.x) * (center.x - v.x) + (center.z - v.z) * (center.z - v.z)); radius = sqrt(radius); - for each(ObjGroup *group in groups) + for (ObjGroup *group : groups) { Optimise(group); } @@ -148,7 +148,7 @@ void Model::Optimise(ObjGroup *t) { for (Face &face : t->faces) { - for each(auto &vertex in face.vertices) + for (auto &vertex : face.vertices) { t->VertexArray.push_back(Vertex(vertices[vertex.position].x, vertices[vertex.position].y, vertices[vertex.position].z, normals[vertex.normal].x, normals[vertex.normal].y, normals[vertex.normal].z, @@ -370,6 +370,7 @@ void Model::unload(Model* model) { delete m.second.first; cache.erase(cache.find(m.first)); + break; } } @@ -378,8 +379,5 @@ void Model::unload(Model* model) Model::~Model(void) { - for (auto m : cache) - { - delete m.second.first; - } + } \ No newline at end of file diff --git a/Meinkraft/Model.h b/Racer/Model.h similarity index 99% rename from Meinkraft/Model.h rename to Racer/Model.h index e2778c3..4de546a 100644 --- a/Meinkraft/Model.h +++ b/Racer/Model.h @@ -70,7 +70,7 @@ private: Model(std::string filename); ~Model(void); -public: + public: static std::map > cache; static Model* load(const std::string &fileName); diff --git a/Racer/ObjectTemplate.cpp b/Racer/ObjectTemplate.cpp new file mode 100644 index 0000000..2f0629a --- /dev/null +++ b/Racer/ObjectTemplate.cpp @@ -0,0 +1,14 @@ +#include "ObjectTemplate.h" + +ObjectTemplate::ObjectTemplate(std::string file, int color, bool collide, float scale, Vec3f rotation) +{ + this->file = file; + this->color = color; + this->canCollide = collide; + this->scale = scale; + this->rotation = rotation; +} + +ObjectTemplate::~ObjectTemplate() +{ +} diff --git a/Racer/ObjectTemplate.h b/Racer/ObjectTemplate.h new file mode 100644 index 0000000..1aff9f6 --- /dev/null +++ b/Racer/ObjectTemplate.h @@ -0,0 +1,19 @@ +#pragma once +#include +#include "Vector.h" + +class ObjectTemplate +{ +public: + ObjectTemplate(std::string file, int color, bool collide, float scale, Vec3f rotation); + ~ObjectTemplate(); + + std::string file; + + int color; + bool canCollide; + + float scale; + Vec3f rotation; +}; + diff --git a/Meinkraft/Player.cpp b/Racer/Player.cpp similarity index 66% rename from Meinkraft/Player.cpp rename to Racer/Player.cpp index f905e93..985cd91 100644 --- a/Meinkraft/Player.cpp +++ b/Racer/Player.cpp @@ -3,14 +3,16 @@ #include "Player.h" #include +#include +#include +#include + Player* Player::instance = NULL; Player::Player() { speed = 10; - health = 50; - xp = 75; - level = 10; + stars = 0; } Player* Player::getInstance() @@ -26,21 +28,23 @@ void Player::init() instance = new Player(); } +void Player::setObject(LevelObject * obj) +{ + kart = obj; + kart->position = position; +} + Player::~Player() { - if (leftWeapon) - delete leftWeapon; - - if (rightWeapon) - delete rightWeapon; } void Player::setCamera() { + gluLookAt(0, 4, -6, 0, 0, 1, 0, 0.1f, 0); + glRotatef(rotation.x, 1, 0, 0); glRotatef(rotation.y, 0, 1, 0); - glTranslatef(-position.x, -position.y, -position.z); - + //glTranslatef(-position.x, -position.y, -position.z); } void Player::setPosition(float angle, float fac, bool height) @@ -52,4 +56,15 @@ void Player::setPosition(float angle, float fac, bool height) position.x -= (float)cos((rotation.y + angle) / 180 * M_PI) * fac; position.z -= (float)sin((rotation.y + angle) / 180 * M_PI) * fac; } + + kart->position = position; + kart->rotation = Vec3f(0, -rotation.y, 0); +} + +void Player::draw() { + + glTranslatef(-position.x, -position.y, -position.z); + + if (kart != nullptr) + kart->draw(); } \ No newline at end of file diff --git a/Meinkraft/Player.h b/Racer/Player.h similarity index 67% rename from Meinkraft/Player.h rename to Racer/Player.h index 18d3fb8..c4f09e5 100644 --- a/Meinkraft/Player.h +++ b/Racer/Player.h @@ -1,31 +1,33 @@ #pragma once #include "Vector.h" +#include "json.h" +#include "LevelObject.h" -class Model; +#include class Player { private: static Player* instance; + + LevelObject* kart; + public: Player(); ~Player(); void setCamera(); void setPosition(float angle, float fac, bool height); + void draw(void); static Player* getInstance(void); static void init(void); + void setObject(LevelObject * obj); + Vec3f position; Vec2f rotation; - Model* leftWeapon; - Model* rightWeapon; - - float health; - float xp; - int level; - float speed; + int stars; }; \ No newline at end of file diff --git a/Racer/Racer.cpp b/Racer/Racer.cpp new file mode 100644 index 0000000..39b8dd9 --- /dev/null +++ b/Racer/Racer.cpp @@ -0,0 +1,145 @@ + +#include "Racer.h" +#include +#include +#include +#include "WorldHandler.h" +#include "Player.h" +#include "Cursor.h" +#include "Menu.h" +#include "Text.h" +#include "Vector.h" +#include "Button.h" + +int Racer::width = 0; +int Racer::height = 0; + +SoundSystem Racer::sound_system; +bool state = false; + +void Racer::init() +{ + player = Player::getInstance(); + worldhandler = WorldHandler::getInstance(); + cursor = Cursor::getInstance(); + + menu = new Menu(); + buildMenu(); + + lastFrameTime = 0; + state = true; + + glClearColor(0.7f, 0.7f, 1.0f, 1.0f); +} + + +void Racer::draw() +{ + glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); + + //Draw world + glEnable(GL_LIGHTING); + glEnable(GL_DEPTH_TEST); + + glMatrixMode(GL_PROJECTION); + glLoadIdentity(); + gluPerspective(70, width / (float)height, 0.1f, 7500); + //gluLookAt() + glMatrixMode(GL_MODELVIEW); + glLoadIdentity(); + + worldhandler->draw(); + + if(!state) + menu->draw(); + + glutSwapBuffers(); +} + + +void Racer::update() +{ + float frameTime = glutGet(GLUT_ELAPSED_TIME) / 1000.0f; + float deltaTime = frameTime - lastFrameTime; + lastFrameTime = frameTime; + + if (keyboardState.keys[27] && !prevKeyboardState.keys[27]) + state = !state; + + if (state) + { + Player* player = Player::getInstance(); + + if (keyboardState.special[GLUT_KEY_LEFT] && !prevKeyboardState.special[GLUT_KEY_LEFT]) + worldhandler->PreviousWorld(); + if (keyboardState.special[GLUT_KEY_RIGHT] && !prevKeyboardState.special[GLUT_KEY_RIGHT]) + worldhandler->NextWorld(); + if (keyboardState.keys[27]) + state = false; + + player->rotation.y += mouseOffset.x / 10.0f; + player->rotation.x += mouseOffset.y / 10.0f; + + float speed = player->speed; + + Vec3f oldPosition = player->position; + + if (keyboardState.keys['w']) player->setPosition(270, deltaTime*speed, false); + if (keyboardState.keys['s']) player->setPosition(90, deltaTime*speed, false); + + + if (player->rotation.x > 25) + player->rotation.x = 25; + if (player->rotation.x < -20) + player->rotation.x = -20; + + player->position.y = worldhandler->getHeight(player->position.x, player->position.z) + 0.1f; + + if (!worldhandler->isPlayerPositionValid()) + player->position = oldPosition; + + worldhandler->update(deltaTime); + } + else + { + menu->update(); + cursor->update(cursor->mousePosition + mouseOffset); + } + + + mouseOffset = Vec2f(0, 0); + prevKeyboardState = keyboardState; + glutPostRedisplay(); + + sound_system.SetListener(player->position, Vec3f(), Vec3f()); +} + +void Racer::buildMenu() +{ + Button* start = new Button("Resume", Vec2f(1920 / 2 - 50, 1080 / 2 - 30), 100, 50); + auto toWorld = [](Button* b) + { + state = true; + }; + start->addAction(toWorld); + menu->AddMenuElement(start); + + + Button* test = new Button("Exit", Vec2f(1920 / 2 - 50, 1080 / 2 + 30), 100, 50); + test->addAction([](Button* b) + { + exit(0); + }); + menu->AddMenuElement(test); + Text* t = new Text("Pause", Vec2f(1920 / 2 - Util::glutTextWidth("Pause") / 2, 1080 / 2 - 75)); + t->setColor(Vec3f(255, 255, 0)); + menu->AddMenuElement(t); +} + + + +KeyboardState::KeyboardState() +{ + memset(keys, 0, sizeof(keys)); + memset(special, 0, sizeof(special)); +} diff --git a/Meinkraft/Meinkraft.h b/Racer/Racer.h similarity index 59% rename from Meinkraft/Meinkraft.h rename to Racer/Racer.h index 215da95..93ea2f3 100644 --- a/Meinkraft/Meinkraft.h +++ b/Racer/Racer.h @@ -1,9 +1,12 @@ #pragma once +class WorldHandler; +class SoundSystem; class Player; -class StateHandler; +class Cursor; +class Menu; #include "Vector.h" -#include +#include "SoundSystem.h" class KeyboardState { @@ -15,17 +18,17 @@ public: KeyboardState(); }; -class Meinkraft +class Racer { -private: - void loadTexture(void); public: void init(); void draw(); void update(); + WorldHandler* worldhandler; Player* player; - StateHandler* statehandler; + Cursor* cursor; + Menu* menu; static int width, height; KeyboardState keyboardState; @@ -36,5 +39,10 @@ public: float lastFrameTime; - static GLuint texture; + static SoundSystem& GetSoundSystem() { return sound_system; } + + +private: + static SoundSystem sound_system; + void buildMenu(); }; \ No newline at end of file diff --git a/Racer/Racer.sln b/Racer/Racer.sln new file mode 100644 index 0000000..a1e2dea --- /dev/null +++ b/Racer/Racer.sln @@ -0,0 +1,28 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 14 +VisualStudioVersion = 14.0.24720.0 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Racer", "Racer.vcxproj", "{F82158C7-7345-4CB0-9F90-3AB49A071904}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|x64 = Debug|x64 + Debug|x86 = Debug|x86 + Release|x64 = Release|x64 + Release|x86 = Release|x86 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {F82158C7-7345-4CB0-9F90-3AB49A071904}.Debug|x64.ActiveCfg = Debug|x64 + {F82158C7-7345-4CB0-9F90-3AB49A071904}.Debug|x64.Build.0 = Debug|x64 + {F82158C7-7345-4CB0-9F90-3AB49A071904}.Debug|x86.ActiveCfg = Debug|Win32 + {F82158C7-7345-4CB0-9F90-3AB49A071904}.Debug|x86.Build.0 = Debug|Win32 + {F82158C7-7345-4CB0-9F90-3AB49A071904}.Release|x64.ActiveCfg = Release|x64 + {F82158C7-7345-4CB0-9F90-3AB49A071904}.Release|x64.Build.0 = Release|x64 + {F82158C7-7345-4CB0-9F90-3AB49A071904}.Release|x86.ActiveCfg = Release|Win32 + {F82158C7-7345-4CB0-9F90-3AB49A071904}.Release|x86.Build.0 = Release|Win32 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/Meinkraft/Meinkraft.vcxproj b/Racer/Racer.vcxproj similarity index 69% rename from Meinkraft/Meinkraft.vcxproj rename to Racer/Racer.vcxproj index f42101e..4a641ed 100644 --- a/Meinkraft/Meinkraft.vcxproj +++ b/Racer/Racer.vcxproj @@ -19,10 +19,11 @@ - {05A43DED-C24F-41E3-93C3-AB634336B0A2} + {F82158C7-7345-4CB0-9F90-3AB49A071904} Win32Proj - Meinkraft + Racer 8.1 + Racer @@ -83,63 +84,66 @@ - - + NotUsing Level3 Disabled WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) - freeglut/include + + lib/serial;freeglut/include; openAL/include Console true - freeglut/lib + freeglut/lib; openAL/libs/Win32 + setupapi.lib;openal32.lib;%(AdditionalDependencies) - - + NotUsing Level3 Disabled _DEBUG;_CONSOLE;%(PreprocessorDefinitions) - freeglut/include + + lib/serial;freeglut/include;C:\Program Files (x86)\OpenAL 1.1 SDK\include Console true - freeglut/lib + freeglut/lib;C:\Program Files (x86)\OpenAL 1.1 SDK\libs\Win32 + setupapi.lib;openal32.lib;%(AdditionalDependencies) Level3 - - + NotUsing MaxSpeed true true WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) - freeglut/include + + lib/serial;freeglut/include; openAL/include Console true true true - freeglut/lib + freeglut/lib; openAL/libs/Win32 + setupapi.lib;openal32.lib;%(AdditionalDependencies) Level3 - - + NotUsing MaxSpeed true true NDEBUG;_CONSOLE;%(PreprocessorDefinitions) - freeglut/include + + lib/serial;freeglut/include; Console @@ -147,41 +151,71 @@ true true freeglut/lib + setupapi.lib;openal32.lib;%(AdditionalDependencies) - - + + + + + + + - + + + + - - + + + + - + - - + + + + + + + - + + + + - - + + - - + + + - + + + + + + + + + + + diff --git a/Racer/Racer.vcxproj.filters b/Racer/Racer.vcxproj.filters new file mode 100644 index 0000000..fa1f401 --- /dev/null +++ b/Racer/Racer.vcxproj.filters @@ -0,0 +1,199 @@ + + + + + {4FC737F1-C7A5-4376-A066-2A32D752A2FF} + cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx + + + {93995380-89BD-4b04-88EB-625FBE52EBFB} + h;hh;hpp;hxx;hm;inl;inc;xsd + + + {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} + rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms + + + {1e464995-b141-43fd-9e25-16d6ac47176b} + + + {0de1a037-e536-40df-a0d0-0d929f2fe752} + + + {9c655946-3f99-44ea-bc97-2817656954e0} + + + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files\Object + + + Source Files\Object + + + Source Files\Object + + + Source Files\Object + + + Source Files\World + + + Source Files\World + + + Source Files\World + + + Source Files + + + Source Files\World + + + Source Files\World + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + + + Source Files\json + + + Source Files\json + + + + + Resource Files + + + Resource Files + + + Resource Files + + + Resource Files + + + \ No newline at end of file diff --git a/Racer/ReadMe.txt b/Racer/ReadMe.txt new file mode 100644 index 0000000..2e988a3 --- /dev/null +++ b/Racer/ReadMe.txt @@ -0,0 +1,40 @@ +======================================================================== + CONSOLE APPLICATION : CrystalPoint Project Overview +======================================================================== + +AppWizard has created this CrystalPoint application for you. + +This file contains a summary of what you will find in each of the files that +make up your CrystalPoint application. + + +CrystalPoint.vcxproj + This is the main project file for VC++ projects generated using an Application Wizard. + It contains information about the version of Visual C++ that generated the file, and + information about the platforms, configurations, and project features selected with the + Application Wizard. + +CrystalPoint.vcxproj.filters + This is the filters file for VC++ projects generated using an Application Wizard. + It contains information about the association between the files in your project + and the filters. This association is used in the IDE to show grouping of files with + similar extensions under a specific node (for e.g. ".cpp" files are associated with the + "Source Files" filter). + +CrystalPoint.cpp + This is the main application source file. + +///////////////////////////////////////////////////////////////////////////// +Other standard files: + +StdAfx.h, StdAfx.cpp + These files are used to build a precompiled header (PCH) file + named CrystalPoint.pch and a precompiled types file named StdAfx.obj. + +///////////////////////////////////////////////////////////////////////////// +Other notes: + +AppWizard uses "TODO:" comments to indicate parts of the source code you +should add to or customize. + +///////////////////////////////////////////////////////////////////////////// diff --git a/Racer/Skybox.cpp b/Racer/Skybox.cpp new file mode 100644 index 0000000..d4241f9 --- /dev/null +++ b/Racer/Skybox.cpp @@ -0,0 +1,148 @@ +#include "cmath" +#include + +#include "Util.h" +#include "stb_image.h" +#include "Skybox.h" +#include +#include + +enum{SKY_LEFT=0,SKY_BACK,SKY_RIGHT,SKY_FRONT,SKY_TOP,SKY_BOTTOM}; +GLuint skybox[6]; + +Skybox::Skybox(const float &size, const std::string &folder) +{ + this->size = size; + this->folder = folder; +} + +Skybox::~Skybox() +{ + glDeleteTextures(6, &skybox[0]); +} + +void Skybox::init() +{ + skybox[SKY_LEFT] = Util::loadTexture(folder + "left.png"); + skybox[SKY_BACK] = Util::loadTexture(folder + "back.png"); + skybox[SKY_RIGHT] = Util::loadTexture(folder + "right.png"); + skybox[SKY_FRONT] = Util::loadTexture(folder + "front.png"); + skybox[SKY_TOP] = Util::loadTexture(folder + "top.png"); + skybox[SKY_BOTTOM] = Util::loadTexture(folder + "bottom.png"); +} + +void Skybox::draw() +{ + glColor4f(1.0f, 1.0f, 1.0f, 1); + + bool b1 = glIsEnabled(GL_TEXTURE_2D); + glDisable(GL_LIGHTING); + glDisable(GL_DEPTH_TEST); + glEnable(GL_TEXTURE_2D); + glDisable(GL_COLOR_MATERIAL); + + glBindTexture(GL_TEXTURE_2D, skybox[SKY_BACK]); + glBegin(GL_QUADS); + glTexCoord2f(1,1); + glVertex3f(size / 2, size / 2, size / 2); + glTexCoord2f(0,1); + glVertex3f(-size / 2, size / 2, size / 2); + glTexCoord2f(0,0); + glVertex3f(-size / 2, -size / 2, size / 2); + glTexCoord2f(1,0); + glVertex3f(size / 2, -size / 2, size / 2); + glEnd(); + + glBindTexture(GL_TEXTURE_2D, skybox[SKY_LEFT]); + glBegin(GL_QUADS); + //left face + glTexCoord2f(1,1); + glVertex3f(-size / 2, size / 2, size / 2); + glTexCoord2f(0,1); + glVertex3f(-size / 2, size / 2, -size / 2); + glTexCoord2f(0,0); + glVertex3f(-size / 2, -size / 2, -size / 2); + glTexCoord2f(1,0); + glVertex3f(-size / 2, -size / 2, size / 2); + glEnd(); + glBindTexture(GL_TEXTURE_2D, skybox[SKY_FRONT]); + glBegin(GL_QUADS); + //front face + glTexCoord2f(0, 1); + glVertex3f(size / 2, size / 2, -size / 2); + glTexCoord2f(1, 1); + glVertex3f(-size / 2, size / 2, -size / 2); + glTexCoord2f(1, 0); + glVertex3f(-size / 2, -size / 2, -size / 2); + glTexCoord2f(0, 0); + glVertex3f(size / 2, -size / 2, -size / 2); + glEnd(); + glBindTexture(GL_TEXTURE_2D, skybox[SKY_RIGHT]); + glBegin(GL_QUADS); + //right face + glTexCoord2f(1, 1); + glVertex3f(size / 2, size / 2, -size / 2); + glTexCoord2f(0,1); + glVertex3f(size / 2, size / 2, size / 2); + glTexCoord2f(0,0); + glVertex3f(size / 2, -size / 2, size / 2); + glTexCoord2f(1, 0); + glVertex3f(size / 2, -size / 2, -size / 2); + glEnd(); + glBindTexture(GL_TEXTURE_2D, skybox[SKY_TOP]); + glBegin(GL_QUADS); //top face + glTexCoord2f(0,0); + glVertex3f(size / 2, size / 2, size / 2); + glTexCoord2f(0,1); + glVertex3f(-size / 2, size / 2, size / 2); + glTexCoord2f(1,1); + glVertex3f(-size / 2, size / 2, -size / 2); + glTexCoord2f(1,0); + glVertex3f(size / 2, size / 2, -size / 2); + glEnd(); + glBindTexture(GL_TEXTURE_2D, skybox[SKY_BOTTOM]); + glBegin(GL_QUADS); + //bottom face + glTexCoord2f(0,1); + glVertex3f(size / 2, -size / 2, size / 2); + glTexCoord2f(0,0); + glVertex3f(-size / 2, -size / 2, size / 2); + glTexCoord2f(1,0); + glVertex3f(-size / 2, -size / 2, -size / 2); + glTexCoord2f(1,1); + glVertex3f(size / 2, -size / 2, -size / 2); + glEnd(); + glEnable(GL_LIGHTING); //turn everything back, which we turned on, and turn everything off, which we have turned on. + glEnable(GL_DEPTH_TEST); + if (!b1) + glDisable(GL_TEXTURE_2D); +} + +GLuint Skybox::loadTexture(const std::string & fileName) //load the filename named texture +{ + int width, height, bpp; + + stbi_set_flip_vertically_on_load(true); + unsigned char* imgData = stbi_load(fileName.c_str(), &width, &height, &bpp, 4); + GLuint num; + glGenTextures(1, &num); + glBindTexture(GL_TEXTURE_2D, num); + + glTexImage2D(GL_TEXTURE_2D, + 0, //level + GL_RGBA, //internal format + width, //width + height, //height + 0, //border + GL_RGBA, //data format + GL_UNSIGNED_BYTE, //data type + imgData); //data + glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); + glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP); + + stbi_image_free(imgData); + return num; +} + diff --git a/Racer/Skybox.h b/Racer/Skybox.h new file mode 100644 index 0000000..c2957d4 --- /dev/null +++ b/Racer/Skybox.h @@ -0,0 +1,18 @@ +#pragma once +#include + +class Skybox +{ +private: + float size; + std::string folder; +public: + Skybox(const float &size, const std::string &folder); + ~Skybox(); + + void init(); + void draw(); + + GLuint loadTexture(const std::string &fileName); + +}; diff --git a/Racer/Sound.cpp b/Racer/Sound.cpp new file mode 100644 index 0000000..a387d11 --- /dev/null +++ b/Racer/Sound.cpp @@ -0,0 +1,167 @@ +#include "Sound.h" + +#include +#ifdef WIN32 +#include +#include +#else +#include +typedef unsigned long DWORD; +typedef unsigned short WORD; +typedef unsigned int UNINT32; +typedef unsigned char BYTE; +#endif + + +Sound::Sound(const char* inWavPath, bool inLooping): + buffer_id(0), + source_id(0), + is_looping(inLooping) +{ + const char* path = inWavPath; + + FILE *fp = fopen(path, "rb"); // Open the WAVE file + if (!fp) + return; // Could not open file + + // Check that the WAVE file is OK + char type[4]; + fread(type, sizeof(char), 4, fp); // Reads the first bytes in the file + if (type[0] != 'R' || type[1] != 'I' || type[2] != 'F' || type[3] != 'F') // Should be "RIFF" + return; // Not RIFF + + DWORD size; + fread(&size, sizeof(DWORD), 1, fp); // Continue to read the file + fread(type, sizeof(char), 4, fp); // Continue to read the file + if (type[0] != 'W' || type[1] != 'A' || type[2] != 'V' || type[3] != 'E') // This part should be "WAVE" + return; // Not WAVE + + fread(type, sizeof(char), 4, fp); // Continue to read the file + if (type[0] != 'f' || type[1] != 'm' || type[2] != 't' || type[3] != ' ') // This part should be "fmt " + return; // Not fmt + + // Now we know that the file is a acceptable WAVE file + // Info about the WAVE data is now read and stored + DWORD chunkSize; + fread(&chunkSize, sizeof(DWORD), 1, fp); + short formatType; + fread(&formatType, sizeof(short), 1, fp); + short channels; + fread(&channels, sizeof(short), 1, fp); + DWORD sampleRate; + fread(&sampleRate, sizeof(DWORD), 1, fp); + DWORD avgBytesPerSec; + fread(&avgBytesPerSec, sizeof(DWORD), 1, fp); + short bytesPerSample; + fread(&bytesPerSample, sizeof(short), 1, fp); + short bitsPerSample; + fread(&bitsPerSample, sizeof(short), 1, fp); + ALenum format = 0; // The audio format (bits per sample, number of channels) + if (bitsPerSample == 8) + { + if (channels == 1) + format = AL_FORMAT_MONO8; + else if (channels == 2) + format = AL_FORMAT_STEREO8; + } + else if (bitsPerSample == 16) + { + if (channels == 1) + format = AL_FORMAT_MONO16; + else if (channels == 2) + format = AL_FORMAT_STEREO16; + } + if (!format) + return; // Not valid format + + fread(type, sizeof(char), 4, fp); + if (type[0] != 'd' || type[1] != 'a' || type[2] != 't' || type[3] != 'a') // This part should be "data" + return; // not data + + DWORD dataSize; + fread(&dataSize, sizeof(DWORD), 1, fp); // The size of the sound data is read + + // Display the info about the WAVE file + std::cout << "Chunk Size: " << chunkSize << "\n"; + std::cout << "Format Type: " << formatType << "\n"; + std::cout << "Channels: " << channels << "\n"; + std::cout << "Sample Rate: " << sampleRate << "\n"; + std::cout << "Average Bytes Per Second: " << avgBytesPerSec << "\n"; + std::cout << "Bytes Per Sample: " << bytesPerSample << "\n"; + std::cout << "Bits Per Sample: " << bitsPerSample << "\n"; + std::cout << "Data Size: " << dataSize << "\n"; + + unsigned char* buf = new unsigned char[dataSize]; // Allocate memory for the sound data + std::cout << fread(buf, sizeof(BYTE), dataSize, fp) << " bytes loaded\n"; // Read the sound data and display the + fclose(fp); + + alGenBuffers(1, &buffer_id); // Generate one OpenAL Buffer and link to "buffer" + alGenSources(1, &source_id); // Generate one OpenAL Source and link to "source" + if (alGetError() != AL_NO_ERROR) + return; // Error during buffer/source generation + + alBufferData(buffer_id, format, buf, dataSize, sampleRate); // Store the sound data in the OpenAL Buffer + if (alGetError() != AL_NO_ERROR) + return; // Error during buffer loading + + delete[] buf; // Delete the sound data buffer +} + + +Sound::~Sound() +{ + alSourceStop(source_id); + alDeleteSources(1, &source_id); // Delete the OpenAL Source + alDeleteBuffers(1, &buffer_id); // Delete the OpenAL Buffer +} + + +void Sound::SetPos(const Vec3f& inPos, const Vec3f& inVel) +{ + alSourcei(source_id, AL_BUFFER, buffer_id); // Link the buffer to the source + alSourcef(source_id, AL_PITCH, 1.0f); // Set the pitch of the source + alSourcef(source_id, AL_GAIN, 1.0f); // Set the gain of the source + alSourcefv(source_id, AL_POSITION, inPos.v); // Set the position of the source + alSourcefv(source_id, AL_VELOCITY, inVel.v); // Set the velocity of the source + alSourcei(source_id, AL_LOOPING, is_looping ? AL_TRUE : AL_FALSE); // Set if source is looping sound +} + + +void Sound::Play() +{ + alSourcePlay(source_id); + int e = alGetError(); // != AL_NO_ERROR) return; +} + + +void Sound::Pause() +{ + alSourcePause(source_id); +} + + +void Sound::Stop() +{ + alSourceStop(source_id); +} + +bool Sound::IsPlaying() +{ + ALenum state; + + alGetSourcei(source_id, AL_SOURCE_STATE, &state); + + return (state == AL_PLAYING); +} + +bool Sound::IsStopped() +{ + ALenum state; + + alGetSourcei(source_id, AL_SOURCE_STATE, &state); + + std::cout << "MUSIC STATE: " << state << std::endl; + + return (state == AL_STOPPED); +} + diff --git a/Racer/Sound.h b/Racer/Sound.h new file mode 100644 index 0000000..633ec42 --- /dev/null +++ b/Racer/Sound.h @@ -0,0 +1,24 @@ +#pragma once + +#include "Vector.h" + +class Sound +{ +public: + Sound(const char* inWavPath, bool inLooping); + ~Sound(); + + void SetPos(const Vec3f& inPos, const Vec3f& inVel); + + void Play(); + void Pause(); + void Stop(); + bool IsPlaying(); + bool IsStopped(); + +private: + unsigned int buffer_id; + unsigned int source_id; + + bool is_looping; +}; \ No newline at end of file diff --git a/Racer/SoundSystem.cpp b/Racer/SoundSystem.cpp new file mode 100644 index 0000000..84bdb6a --- /dev/null +++ b/Racer/SoundSystem.cpp @@ -0,0 +1,58 @@ +#include "SoundSystem.h" + +SoundSystem::SoundSystem(): + device(nullptr), + context(nullptr) +{ + device = alcOpenDevice(nullptr); + if (!device) + return; + context = alcCreateContext(device, nullptr); + if (!context) + return; + alcMakeContextCurrent(context); +} + + +SoundSystem::~SoundSystem() +{ + for (auto sound : sounds) + delete sound; + alcMakeContextCurrent(nullptr); + alcDestroyContext(context); + alcCloseDevice(device); +} + + +void SoundSystem::SetListener(const Vec3f& inPos, const Vec3f& inVel, const Vec3f& inOri) +{ + ALfloat orientation[] = { 0.0, 0.0, -1.0, 0.0, 1.0, 0.0 }; + + alListenerfv(AL_POSITION, inPos.v); + alListenerfv(AL_VELOCITY, inVel.v); + alListenerfv(AL_ORIENTATION, orientation); +} + + +unsigned int SoundSystem::LoadSound(const char* inWavPath, bool inLooping) +{ + Sound* sound = new Sound(inWavPath, inLooping); + sounds.push_back(sound); + return sounds.size() - 1; +} + + +Sound* SoundSystem::GetSound(unsigned int inID) +{ + if (inID > sounds.size()) + return nullptr; + return sounds[inID]; +} + +void SoundSystem::UnloadSound(unsigned int inID) +{ + if (inID > sounds.size()) + return; + delete sounds[inID]; + //sounds.erase(sounds.begin() + inID); +} diff --git a/Racer/SoundSystem.h b/Racer/SoundSystem.h new file mode 100644 index 0000000..df60ded --- /dev/null +++ b/Racer/SoundSystem.h @@ -0,0 +1,28 @@ +#pragma once + +#include + +#include +#include + +#include "Vector.h" +#include "Sound.h" + + +class SoundSystem +{ +public: + SoundSystem(); + ~SoundSystem(); + + void SetListener(const Vec3f& inPos, const Vec3f& inVel, const Vec3f& inOri); + + unsigned int LoadSound(const char* inWavPath, bool inLooping); + Sound* GetSound(unsigned int inID); + void UnloadSound(unsigned int inID); + +private: + ALCdevice* device; + ALCcontext* context; + std::vector sounds; +}; diff --git a/Racer/Star.cpp b/Racer/Star.cpp new file mode 100644 index 0000000..c9b38af --- /dev/null +++ b/Racer/Star.cpp @@ -0,0 +1,21 @@ +#include "Star.h" +#include "Model.h" + + +Star::Star(Vec3f position) +{ + model = Model::load("resources/models/star/I_star.obj"); + scale = 0.2; + this->position = position; + rotVal = 0; +} + + +Star::~Star() +{ +} + +void Star::update(float deltaTime) +{ + rotation.y += deltaTime * 100.0f; +} diff --git a/Racer/Star.h b/Racer/Star.h new file mode 100644 index 0000000..14d992c --- /dev/null +++ b/Racer/Star.h @@ -0,0 +1,15 @@ +#pragma once +#include "Entity.h" +#include "Vector.h" + +class Star : public Entity +{ +private: + float rotVal; +public: + Star(Vec3f position); + ~Star(); + + void update(float deltaTime); +}; + diff --git a/Racer/Text.cpp b/Racer/Text.cpp new file mode 100644 index 0000000..67afd42 --- /dev/null +++ b/Racer/Text.cpp @@ -0,0 +1,31 @@ +#include "Text.h" + + +Text::Text(const std::string &text, Vec2f position) : MenuElement(position) +{ + this->text = text; + color = Vec3f(50, 150, 150); + textHeight = 14; + textWidth = Util::glutTextWidth(text); +} + + +Text::~Text() +{ +} + +void Text::draw() +{ + glColor4f(color.x/255.0f, color.y/255.0f, color.z/255.0f, 1.0f); + Util::glutBitmapString(text, position.x-1, position.y+textHeight); +} + +void Text::update(int x, int y) +{ + //Do nothing +} + +void Text::setColor(Vec3f color) +{ + this->color = color; +} diff --git a/Racer/Text.h b/Racer/Text.h new file mode 100644 index 0000000..b24bb25 --- /dev/null +++ b/Racer/Text.h @@ -0,0 +1,23 @@ +#pragma once +#include "MenuElement.h" +#include "Vector.h" +#include "Util.h" + +class Text : public MenuElement +{ +private: + std::string text; + Vec3f color; +protected: + int textWidth; + int textHeight; +public: + Text(const std::string &text, Vec2f position); + ~Text(); + + virtual void draw(); + virtual void update(int x, int y); + + void setColor(Vec3f color); +}; + diff --git a/Racer/Util.cpp b/Racer/Util.cpp new file mode 100644 index 0000000..5f052de --- /dev/null +++ b/Racer/Util.cpp @@ -0,0 +1,65 @@ +#include "Util.h" +#include "stb_image.h" + +Util::Util() +{ + +} + + +Util::~Util() +{ +} + +GLuint Util::loadTexture(const std::string &filename) +{ + int width, height, bpp; + + stbi_set_flip_vertically_on_load(true); + unsigned char* imgData = stbi_load(filename.c_str(), &width, &height, &bpp, 4); + GLuint num; + glGenTextures(1, &num); + glBindTexture(GL_TEXTURE_2D, num); + + glTexImage2D(GL_TEXTURE_2D, + 0, //level + GL_RGBA, //internal format + width, //width + height, //height + 0, //border + GL_RGBA, //data format + GL_UNSIGNED_BYTE, //data type + imgData); //data + glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); + glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP); + + stbi_image_free(imgData); + return num; +} + +void Util::glutBitmapString(std::string str, int x, int y) +{ + glRasterPos2f(x, y); + for (int i = 0; i < str.size(); i++) + { + glutBitmapCharacter(GLUT_BITMAP_HELVETICA_18, str[i]); + } +} + +int Util::glutTextWidth(const std::string str) +{ + int total = 0; + for (int i = 0; i < str.size(); i++) + { + total += glutBitmapWidth(GLUT_BITMAP_HELVETICA_18, str[i]); + } + return total; +} + +//int Util::glutTextHeight() +//{ +// return glutBitmapHeight(GLUT_BITMAP_HELVETICA_18); +//} + diff --git a/Racer/Util.h b/Racer/Util.h new file mode 100644 index 0000000..089ab7c --- /dev/null +++ b/Racer/Util.h @@ -0,0 +1,16 @@ +#pragma once +#include +#include + +class Util +{ +private: + Util(); + ~Util(); +public: + static GLuint loadTexture(const std::string &filename); + static void glutBitmapString(std::string str, int x, int y); + static int glutTextWidth(const std::string str); + //static int glutTextHeight(); +}; + diff --git a/Meinkraft/Vector.cpp b/Racer/Vector.cpp similarity index 99% rename from Meinkraft/Vector.cpp rename to Racer/Vector.cpp index 35a6d41..c7ea763 100644 --- a/Meinkraft/Vector.cpp +++ b/Racer/Vector.cpp @@ -2,6 +2,7 @@ #include #include "Vector.h" + Vec3f::Vec3f(float x, float y, float z) { this->x = x; diff --git a/Meinkraft/Vector.h b/Racer/Vector.h similarity index 100% rename from Meinkraft/Vector.h rename to Racer/Vector.h diff --git a/Meinkraft/Vertex.cpp b/Racer/Vertex.cpp similarity index 75% rename from Meinkraft/Vertex.cpp rename to Racer/Vertex.cpp index 8afd8a1..35591cf 100644 --- a/Meinkraft/Vertex.cpp +++ b/Racer/Vertex.cpp @@ -18,22 +18,22 @@ Vertex::~Vertex() { } -Vertex Vertex::operator/(float &other) +Vertex Vertex::operator/(const float &other) const { return Vertex(x / other, y / other, z / other, normalX, normalY, normalZ, texX, texY); } -Vertex Vertex::operator*(Vertex & other) +Vertex Vertex::operator*(const Vertex & other) const { return Vertex(x*other.x, y*other.y, z*other.z, normalX, normalY, normalZ, texX, texY); } -Vertex Vertex::operator*(float & other) +Vertex Vertex::operator*(const float & other) const { return Vertex(x*other, y*other, z*other, normalX, normalY, normalZ, texX, texY); } -Vertex Vertex::operator+(Vertex & other) +Vertex Vertex::operator+(const Vertex & other) const { return Vertex(x+other.x, y+other.y, z+other.z, normalX, normalY, normalZ, texX, texY); } diff --git a/Meinkraft/Vertex.h b/Racer/Vertex.h similarity index 57% rename from Meinkraft/Vertex.h rename to Racer/Vertex.h index 3411000..ff3b2cc 100644 --- a/Meinkraft/Vertex.h +++ b/Racer/Vertex.h @@ -16,9 +16,9 @@ public: float texX; float texY; - Vertex operator/(float &other); - Vertex operator*(Vertex &other); - Vertex operator*(float &other); - Vertex operator+(Vertex &other); + Vertex operator/(const float &other) const; + Vertex operator*(const Vertex &other) const; + Vertex operator*(const float &other) const; + Vertex operator+(const Vertex &other) const; }; diff --git a/Racer/World.cpp b/Racer/World.cpp new file mode 100644 index 0000000..ccc94c3 --- /dev/null +++ b/Racer/World.cpp @@ -0,0 +1,257 @@ +#include "World.h" +#include +#include "Entity.h" +#include "json.h" +#include "Model.h" +#include +#include +#include +#include +#include +#include "WorldHandler.h" +#include "LevelObject.h" + +World::World(const std::string &fileName) +{ + nextworld = false; + + //Store player instance + player = Player::getInstance(); + + //Open world json file + std::ifstream file(fileName); + if(!file.is_open()) + std::cout<<"Error, can't open world file - " << fileName << "\n"; + + json::Value v = json::readJson(file); + file.close(); + + //Check file + if(v["world"].isNull() || v["world"]["heightmap"].isNull() || v["world"]["skybox"].isNull()) + std::cout << "Invalid world file: world - " << fileName << "\n"; + if (v["world"]["object-templates"].isNull()) + std::cout << "Invalid world file: object templates - " << fileName << "\n"; + if (v["player"].isNull() || v["player"]["startposition"].isNull() || v["player"]["kart"].isNull()) + std::cout << "Invalid world file: player - " << fileName << "\n"; + if (v["objects"].isNull()) + std::cout << "Invalid world file: objects - " << fileName << "\n"; + + //Load object templates + for (auto objt : v["world"]["object-templates"]) + { + //collision + bool cancollide = true; + if (!objt["collision"].isNull()) + cancollide = objt["collision"].asBool(); + + float scaleot = 1; + if (!objt["scale"].isNull()) + scaleot = objt["scale"].asFloat(); + + Vec3f rotationot = Vec3f(0,0,0); + if (!objt["rot"].isNull()) + rotationot = Vec3f(objt["rot"][0].asFloat(), objt["rot"][3].asFloat(), objt["rot"][2].asFloat()); + + objecttemplates.push_back(ObjectTemplate(objt["file"].asString(), objt["color"].asInt(), cancollide, scaleot, rotationot)); + } + + //Generate heightmap for this world + heightmap = new HeightMap(v["world"]["heightmap"].asString(), this); + + //Load skybox + skybox = new Skybox(7500.0f, v["world"]["skybox"].asString()); + skybox->init(); + + //Map different texture to heightmap if available + if(!v["world"]["texture"].isNull()) + heightmap->SetTexture(v["world"]["texture"].asString()); + + //Set player starting position + player->position.x = v["player"]["startposition"][0].asFloat(); + player->position.z = v["player"]["startposition"][2].asFloat(); + player->position.y = heightmap->GetHeight(player->position.x, player->position.z); + + float pscale = 1.0f; + if(!v["player"]["kart"]["scale"].isNull()) + pscale = v["player"]["kart"]["scale"].asFloat(); + + + player->setObject(new LevelObject(v["player"]["kart"]["file"].asString(), Vec3f(), Vec3f(), pscale, false)); + + //Create the interface + starsCount = stars.size(); + interface = new Interface(stars.size()); + + //Load and place objects into world + for (auto object : v["objects"]) + { + //Collision + bool hasCollision = true; + if (!object["collide"].isNull()) + hasCollision = object["collide"].asBool(); + + //Rotation + Vec3f rotation(0, 0, 0); + if(!object["rot"].isNull()) + rotation = Vec3f(object["rot"][0].asFloat(), object["rot"][1].asFloat(), object["rot"][2].asFloat()); + + //Scale + float scale = 1; + if (!object["scale"].isNull()) + scale = object["scale"].asFloat(); + + //Position + if (object["pos"].isNull()) + std::cout << "Invalid world file: objects pos - " << fileName << "\n"; + + //File + if (object["file"].isNull()) + std::cout << "Invalid world file: objects file - " << fileName << "\n"; + + //Create + Vec3f position(object["pos"][0].asFloat(), object["pos"][1].asFloat(), object["pos"][2].asFloat()); + position.y = getHeight(position.x, position.z); + + entities.push_back(new LevelObject(object["file"].asString(), position, rotation, scale, hasCollision)); + } + + if (!v["world"]["music"].isNull()) + { + sound_id = Racer::GetSoundSystem().LoadSound(v["world"]["music"].asString().c_str(), true); + music = Racer::GetSoundSystem().GetSound(sound_id); + } + + star_sound_id = Racer::GetSoundSystem().LoadSound("resources/sounds/Crystal.wav", false); + starPickup = Racer::GetSoundSystem().GetSound(star_sound_id); +} + +World::~World() +{ + delete heightmap; + music->Stop(); + starPickup->Stop(); + Racer::GetSoundSystem().UnloadSound(sound_id); + Racer::GetSoundSystem().UnloadSound(star_sound_id); + delete skybox; +} + +ObjectTemplate World::getObjectFromValue(int val) +{ + for (auto i : objecttemplates) + { + if (i.color == val) + return i; + } + + return objecttemplates[0]; +} + +float World::getHeight(float x, float y) +{ + return heightmap->GetHeight(x, y); +} + +void World::draw() +{ + player->setCamera(); + + float lightPosition[4] = { 0, 2, 1, 0 }; + glLightfv(GL_LIGHT0, GL_POSITION, lightPosition); + + GLfloat lightAmbient[] = { 0.05, 0.05, 0.05, 0 }; + GLfloat light_diffuse[] = { 0.9, 0.9, 0.9, 0 }; + glLightfv(GL_LIGHT0, GL_DIFFUSE, light_diffuse); + glLightfv(GL_LIGHT0, GL_AMBIENT, lightAmbient); + + GLfloat mat_specular[] = { 0.15, 0.15, 0.15, 0 }; + glMaterialfv(GL_FRONT, GL_SPECULAR, mat_specular); + + skybox->draw(); + player->draw(); + + heightmap->Draw(); + + for (auto &entity : entities) + entity->draw(); + + for (auto &star : stars) + star->draw(); + + interface->draw(); +} + +void World::update(float elapsedTime) +{ + if (nextworld) + { + WorldHandler::getInstance()->NextWorld(); + return; + } + + music->SetPos(player->position, Vec3f()); + + if (music->IsPlaying() == false) + { + music->Play(); + } + + for (auto &entity : entities) + entity->update(elapsedTime); + + bool remove = false; + int removeindex = 0; + + for (auto &star : stars) + { + star->update(elapsedTime); + + if (star->inObject(player->position)) + { + remove = true; + starPickup->Stop(); + starPickup->SetPos(Vec3f(), star->position); + starPickup->Play(); + player->stars++; + continue; + } + + if (!remove) + removeindex++; + } + + if (remove) + { + delete stars[removeindex]; + stars.erase(stars.begin() + removeindex); + } + + if (player->stars == starsCount) + nextworld = true; + + interface->update(elapsedTime); + +} + +void World::addLevelObject(LevelObject* obj) +{ + entities.push_back(obj); +} + +void World::addStar(Star * star) +{ + stars.push_back(star); +} + +bool World::isPlayerPositionValid() +{ + for (auto &e : entities) + { + if (e->canCollide && e->inObject(player->position)) + { + e->collide(); + return false; + } + } + return true; +} + diff --git a/Racer/World.h b/Racer/World.h new file mode 100644 index 0000000..5dd039a --- /dev/null +++ b/Racer/World.h @@ -0,0 +1,48 @@ +#pragma once + +#include +#include "HeightMap.h" +#include "Player.h" +#include "LevelObject.h" +#include "Interface.h" +#include "Skybox.h" +#include "Racer.h" +#include "ObjectTemplate.h" +#include "Star.h" + +class Entity; + +class World +{ +private: + std::vector objecttemplates; + Sound* music; + Sound* starPickup; + + Player* player; + HeightMap* heightmap; + Interface* interface; + Skybox* skybox; + + bool nextworld; + + int sound_id; + int star_sound_id; + int starsCount; + + std::vector entities; + std::vector stars; +public: + World(const std::string &fileName); + ~World(); + + void draw(); + void update(float elapsedTime); + bool isPlayerPositionValid(); + float getHeight(float x, float y); + void addLevelObject(LevelObject* obj); + void addStar(Star* star); + ObjectTemplate getObjectFromValue(int i); + +}; + diff --git a/Racer/WorldHandler.cpp b/Racer/WorldHandler.cpp new file mode 100644 index 0000000..fe968bc --- /dev/null +++ b/Racer/WorldHandler.cpp @@ -0,0 +1,140 @@ +#include "WorldHandler.h" +#include "World.h" + +#include "json.h" +#include +#include +#include + +WorldHandler* WorldHandler::instance = nullptr; + +void WorldHandler::ChangeWorld(int i) +{ + if (i < 0) + i = worldfiles.size() - 1; + + else if (i >= worldfiles.size()) + i = 0; + + if (i != worldIndex) + { + loadingWorld = true; + + if(worldIndex != -1) + delete world; + + world = new World(worldfiles[i]); + worldIndex = i; + loadingWorld = false; + } +} + +WorldHandler::WorldHandler() +{ + loadingWorld = true; + worldIndex = -1; + + //Find worlds.json + std::ifstream file("resources/worlds/worlds.json"); + if (!file.is_open()) + std::cout << "Error, can't open worlds overview file\n"; + + json::Value v = json::readJson(file); + file.close(); + + //Load file names into vector + if (v["worlds"].isNull() || !v["worlds"].isArray()) + std::cout << "Error, no content in worlds overview file\n"; + + for (auto line : v["worlds"]) + { + std::cout << "Found world: " << line << "\n"; + worldfiles.push_back(line); + } + + if (worldfiles.size() > 0) + { + ChangeWorld(0); + } +} + +WorldHandler::~WorldHandler() +{ + worldIndex = -1; + delete world; +} + +WorldHandler* WorldHandler::getInstance() +{ + if (instance == nullptr) + instance = new WorldHandler(); + + return instance; +} + +void WorldHandler::init() +{ + instance = new WorldHandler(); +} + +void WorldHandler::draw(void) +{ + if(!loadingWorld) + world->draw(); + else + { + //Draw Loading screen + } +} + +void WorldHandler::update(float deltaTime) +{ + if(!loadingWorld) + world->update(deltaTime); +} + +bool WorldHandler::isPlayerPositionValid(void) +{ + if(!loadingWorld) + return world->isPlayerPositionValid(); + return false; +} + +float WorldHandler::getHeight(float x, float y) +{ + if (!loadingWorld) + return world->getHeight(x, y); + else + return 0.0f; +} + + +void WorldHandler::Navigate(const std::string &fileName) +{ + if (!loadingWorld) + { + for (int i = 0; i < worldfiles.size(); i++) + { + if (worldfiles[i] == fileName) + ChangeWorld(i); + } + } +} + +void WorldHandler::NextWorld() +{ + if (!loadingWorld) + { + Player::getInstance()->stars = 0; + ChangeWorld(worldIndex + 1); + } +} + +void WorldHandler::PreviousWorld() +{ + if (!loadingWorld) + { + Player::getInstance()->stars = 0; + ChangeWorld(worldIndex - 1); + } +} \ No newline at end of file diff --git a/Racer/WorldHandler.h b/Racer/WorldHandler.h new file mode 100644 index 0000000..0cde251 --- /dev/null +++ b/Racer/WorldHandler.h @@ -0,0 +1,36 @@ +#pragma once +#include +#include + +class World; + +class WorldHandler +{ +private: + WorldHandler(); + static WorldHandler* instance; + + bool loadingWorld; + World* world; + int worldIndex; + void ChangeWorld(int i); +public: + + ~WorldHandler(); + + static WorldHandler* getInstance(void); + static void init(); + + void draw(void); + void update(float deltaTime); + + bool isPlayerPositionValid(void); + float getHeight(float x, float y); + + void Navigate(const std::string &fileName); + void NextWorld(); + void PreviousWorld(); + + std::vector worldfiles; +}; + diff --git a/Meinkraft/freeglut.dll b/Racer/freeglut.dll similarity index 100% rename from Meinkraft/freeglut.dll rename to Racer/freeglut.dll diff --git a/Racer/freeglut/Copying.txt b/Racer/freeglut/Copying.txt new file mode 100644 index 0000000..fc36ad9 --- /dev/null +++ b/Racer/freeglut/Copying.txt @@ -0,0 +1,27 @@ + + Freeglut Copyright + ------------------ + + Freeglut code without an explicit copyright is covered by the following + copyright: + + Copyright (c) 1999-2000 Pawel W. Olszta. All Rights Reserved. + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies or substantial portions of the Software. + + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + PAWEL W. OLSZTA BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + + Except as contained in this notice, the name of Pawel W. Olszta shall not be + used in advertising or otherwise to promote the sale, use or other dealings + in this Software without prior written authorization from Pawel W. Olszta. diff --git a/Meinkraft/freeglut/Readme.txt b/Racer/freeglut/Readme.txt similarity index 100% rename from Meinkraft/freeglut/Readme.txt rename to Racer/freeglut/Readme.txt diff --git a/Meinkraft/freeglut/include/GL/freeglut.h b/Racer/freeglut/include/GL/freeglut.h similarity index 100% rename from Meinkraft/freeglut/include/GL/freeglut.h rename to Racer/freeglut/include/GL/freeglut.h diff --git a/Meinkraft/freeglut/include/GL/freeglut_ext.h b/Racer/freeglut/include/GL/freeglut_ext.h similarity index 100% rename from Meinkraft/freeglut/include/GL/freeglut_ext.h rename to Racer/freeglut/include/GL/freeglut_ext.h diff --git a/Meinkraft/freeglut/include/GL/freeglut_std.h b/Racer/freeglut/include/GL/freeglut_std.h similarity index 100% rename from Meinkraft/freeglut/include/GL/freeglut_std.h rename to Racer/freeglut/include/GL/freeglut_std.h diff --git a/Meinkraft/freeglut/include/GL/glut.h b/Racer/freeglut/include/GL/glut.h similarity index 100% rename from Meinkraft/freeglut/include/GL/glut.h rename to Racer/freeglut/include/GL/glut.h diff --git a/Meinkraft/freeglut/lib/freeglut.lib b/Racer/freeglut/lib/freeglut.lib similarity index 100% rename from Meinkraft/freeglut/lib/freeglut.lib rename to Racer/freeglut/lib/freeglut.lib diff --git a/Meinkraft/json.cpp b/Racer/json.cpp similarity index 100% rename from Meinkraft/json.cpp rename to Racer/json.cpp diff --git a/Meinkraft/json.h b/Racer/json.h similarity index 100% rename from Meinkraft/json.h rename to Racer/json.h diff --git a/Racer/lib/serial/include/impl/unix.h b/Racer/lib/serial/include/impl/unix.h new file mode 100644 index 0000000..2d70fc4 --- /dev/null +++ b/Racer/lib/serial/include/impl/unix.h @@ -0,0 +1,221 @@ +/*! + * \file serial/impl/unix.h + * \author William Woodall + * \author John Harrison + * \version 0.1 + * + * \section LICENSE + * + * The MIT License + * + * Copyright (c) 2012 William Woodall, John Harrison + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + * + * \section DESCRIPTION + * + * This provides a unix based pimpl for the Serial class. This implementation is + * based off termios.h and uses select for multiplexing the IO ports. + * + */ + +#if !defined(_WIN32) + +#ifndef SERIAL_IMPL_UNIX_H +#define SERIAL_IMPL_UNIX_H + + +#include +#include "../serial.h" + +namespace serial { + +using std::size_t; +using std::string; +using std::invalid_argument; + +using serial::SerialException; +using serial::IOException; + +class MillisecondTimer { +public: + MillisecondTimer(const uint32_t millis); + int64_t remaining(); + +private: + static timespec timespec_now(); + timespec expiry; +}; + +class serial::Serial::SerialImpl { +public: + SerialImpl (const string &port, + unsigned long baudrate, + bytesize_t bytesize, + parity_t parity, + stopbits_t stopbits, + flowcontrol_t flowcontrol); + + virtual ~SerialImpl (); + + void + open (); + + void + close (); + + bool + isOpen () const; + + size_t + available (); + + bool + waitReadable (uint32_t timeout); + + void + waitByteTimes (size_t count); + + size_t + read (uint8_t *buf, size_t size = 1); + + size_t + write (const uint8_t *data, size_t length); + + void + flush (); + + void + flushInput (); + + void + flushOutput (); + + void + sendBreak (int duration); + + void + setBreak (bool level); + + void + setRTS (bool level); + + void + setDTR (bool level); + + bool + waitForChange (); + + bool + getCTS (); + + bool + getDSR (); + + bool + getRI (); + + bool + getCD (); + + void + setPort (const string &port); + + string + getPort () const; + + void + setTimeout (Timeout &timeout); + + Timeout + getTimeout () const; + + void + setBaudrate (unsigned long baudrate); + + unsigned long + getBaudrate () const; + + void + setBytesize (bytesize_t bytesize); + + bytesize_t + getBytesize () const; + + void + setParity (parity_t parity); + + parity_t + getParity () const; + + void + setStopbits (stopbits_t stopbits); + + stopbits_t + getStopbits () const; + + void + setFlowcontrol (flowcontrol_t flowcontrol); + + flowcontrol_t + getFlowcontrol () const; + + void + readLock (); + + void + readUnlock (); + + void + writeLock (); + + void + writeUnlock (); + +protected: + void reconfigurePort (); + +private: + string port_; // Path to the file descriptor + int fd_; // The current file descriptor + + bool is_open_; + bool xonxoff_; + bool rtscts_; + + Timeout timeout_; // Timeout for read operations + unsigned long baudrate_; // Baudrate + uint32_t byte_time_ns_; // Nanoseconds to transmit/receive a single byte + + parity_t parity_; // Parity + bytesize_t bytesize_; // Size of the bytes + stopbits_t stopbits_; // Stop Bits + flowcontrol_t flowcontrol_; // Flow Control + + // Mutex used to lock the read functions + pthread_mutex_t read_mutex; + // Mutex used to lock the write functions + pthread_mutex_t write_mutex; +}; + +} + +#endif // SERIAL_IMPL_UNIX_H + +#endif // !defined(_WIN32) diff --git a/Racer/lib/serial/include/impl/win.h b/Racer/lib/serial/include/impl/win.h new file mode 100644 index 0000000..f2e6db4 --- /dev/null +++ b/Racer/lib/serial/include/impl/win.h @@ -0,0 +1,207 @@ +/*! + * \file serial/impl/windows.h + * \author William Woodall + * \author John Harrison + * \version 0.1 + * + * \section LICENSE + * + * The MIT License + * + * Copyright (c) 2012 William Woodall, John Harrison + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + * + * \section DESCRIPTION + * + * This provides a windows implementation of the Serial class interface. + * + */ + +#if defined(_WIN32) + +#ifndef SERIAL_IMPL_WINDOWS_H +#define SERIAL_IMPL_WINDOWS_H + +#include "include/serial.h" + +#include "windows.h" + +namespace serial { + +using std::string; +using std::wstring; +using std::invalid_argument; + +using serial::SerialException; +using serial::IOException; + +class serial::Serial::SerialImpl { +public: + SerialImpl (const string &port, + unsigned long baudrate, + bytesize_t bytesize, + parity_t parity, + stopbits_t stopbits, + flowcontrol_t flowcontrol); + + virtual ~SerialImpl (); + + void + open (); + + void + close (); + + bool + isOpen () const; + + size_t + available (); + + bool + waitReadable (uint32_t timeout); + + void + waitByteTimes (size_t count); + + size_t + read (uint8_t *buf, size_t size = 1); + + size_t + write (const uint8_t *data, size_t length); + + void + flush (); + + void + flushInput (); + + void + flushOutput (); + + void + sendBreak (int duration); + + void + setBreak (bool level); + + void + setRTS (bool level); + + void + setDTR (bool level); + + bool + waitForChange (); + + bool + getCTS (); + + bool + getDSR (); + + bool + getRI (); + + bool + getCD (); + + void + setPort (const string &port); + + string + getPort () const; + + void + setTimeout (Timeout &timeout); + + Timeout + getTimeout () const; + + void + setBaudrate (unsigned long baudrate); + + unsigned long + getBaudrate () const; + + void + setBytesize (bytesize_t bytesize); + + bytesize_t + getBytesize () const; + + void + setParity (parity_t parity); + + parity_t + getParity () const; + + void + setStopbits (stopbits_t stopbits); + + stopbits_t + getStopbits () const; + + void + setFlowcontrol (flowcontrol_t flowcontrol); + + flowcontrol_t + getFlowcontrol () const; + + void + readLock (); + + void + readUnlock (); + + void + writeLock (); + + void + writeUnlock (); + +protected: + void reconfigurePort (); + +private: + wstring port_; // Path to the file descriptor + HANDLE fd_; + + bool is_open_; + + Timeout timeout_; // Timeout for read operations + unsigned long baudrate_; // Baudrate + + parity_t parity_; // Parity + bytesize_t bytesize_; // Size of the bytes + stopbits_t stopbits_; // Stop Bits + flowcontrol_t flowcontrol_; // Flow Control + + // Mutex used to lock the read functions + HANDLE read_mutex; + // Mutex used to lock the write functions + HANDLE write_mutex; +}; + +} + +#endif // SERIAL_IMPL_WINDOWS_H + +#endif // if defined(_WIN32) diff --git a/Racer/lib/serial/include/serial.h b/Racer/lib/serial/include/serial.h new file mode 100644 index 0000000..c777a13 --- /dev/null +++ b/Racer/lib/serial/include/serial.h @@ -0,0 +1,772 @@ +/*! + * \file serial/serial.h + * \author William Woodall + * \author John Harrison + * \version 0.1 + * + * \section LICENSE + * + * The MIT License + * + * Copyright (c) 2012 William Woodall + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + * + * \section DESCRIPTION + * + * This provides a cross platform interface for interacting with Serial Ports. + */ + +#ifndef SERIAL_H +#define SERIAL_H + +#include +#include +#include +#include +#include +#include +#include + +#define THROW(exceptionClass, message) throw exceptionClass(__FILE__, \ +__LINE__, (message) ) + +namespace serial { + +/*! + * Enumeration defines the possible bytesizes for the serial port. + */ + typedef enum { + fivebits = 5, + sixbits = 6, + sevenbits = 7, + eightbits = 8 + } bytesize_t; + +/*! + * Enumeration defines the possible parity types for the serial port. + */ + typedef enum { + parity_none = 0, + parity_odd = 1, + parity_even = 2, + parity_mark = 3, + parity_space = 4 + } parity_t; + +/*! + * Enumeration defines the possible stopbit types for the serial port. + */ + typedef enum { + stopbits_one = 1, + stopbits_two = 2, + stopbits_one_point_five + } stopbits_t; + +/*! + * Enumeration defines the possible flowcontrol types for the serial port. + */ + typedef enum { + flowcontrol_none = 0, + flowcontrol_software, + flowcontrol_hardware + } flowcontrol_t; + +/*! + * Structure for setting the timeout of the serial port, times are + * in milliseconds. + * + * In order to disable the interbyte timeout, set it to Timeout::max(). + */ + struct Timeout { +#ifdef max +# undef max +#endif + static uint32_t max() {return std::numeric_limits::max();} + /*! + * Convenience function to generate Timeout structs using a + * single absolute timeout. + * + * \param timeout A long that defines the time in milliseconds until a + * timeout occurs after a call to read or write is made. + * + * \return Timeout struct that represents this simple timeout provided. + */ + static Timeout simpleTimeout(uint32_t timeout) { + return Timeout(max(), timeout, 0, timeout, 0); + } + + /*! Number of milliseconds between bytes received to timeout on. */ + uint32_t inter_byte_timeout; + /*! A constant number of milliseconds to wait after calling read. */ + uint32_t read_timeout_constant; + /*! A multiplier against the number of requested bytes to wait after + * calling read. + */ + uint32_t read_timeout_multiplier; + /*! A constant number of milliseconds to wait after calling write. */ + uint32_t write_timeout_constant; + /*! A multiplier against the number of requested bytes to wait after + * calling write. + */ + uint32_t write_timeout_multiplier; + + explicit Timeout (uint32_t inter_byte_timeout_=0, + uint32_t read_timeout_constant_=0, + uint32_t read_timeout_multiplier_=0, + uint32_t write_timeout_constant_=0, + uint32_t write_timeout_multiplier_=0) + : inter_byte_timeout(inter_byte_timeout_), + read_timeout_constant(read_timeout_constant_), + read_timeout_multiplier(read_timeout_multiplier_), + write_timeout_constant(write_timeout_constant_), + write_timeout_multiplier(write_timeout_multiplier_) + {} + }; + +/*! + * Class that provides a portable serial port interface. + */ + class Serial { + public: + /*! + * Creates a Serial object and opens the port if a port is specified, + * otherwise it remains closed until serial::Serial::open is called. + * + * \param port A std::string containing the address of the serial port, + * which would be something like 'COM1' on Windows and '/dev/ttyS0' + * on Linux. + * + * \param baudrate An unsigned 32-bit integer that represents the baudrate + * + * \param timeout A serial::Timeout struct that defines the timeout + * conditions for the serial port. \see serial::Timeout + * + * \param bytesize Size of each byte in the serial transmission of data, + * default is eightbits, possible values are: fivebits, sixbits, sevenbits, + * eightbits + * + * \param parity Method of parity, default is parity_none, possible values + * are: parity_none, parity_odd, parity_even + * + * \param stopbits Number of stop bits used, default is stopbits_one, + * possible values are: stopbits_one, stopbits_one_point_five, stopbits_two + * + * \param flowcontrol Type of flowcontrol used, default is + * flowcontrol_none, possible values are: flowcontrol_none, + * flowcontrol_software, flowcontrol_hardware + * + * \throw serial::PortNotOpenedException + * \throw serial::IOException + * \throw std::invalid_argument + */ + Serial (const std::string &port = "", + uint32_t baudrate = 9600, + Timeout timeout = Timeout(), + bytesize_t bytesize = eightbits, + parity_t parity = parity_none, + stopbits_t stopbits = stopbits_one, + flowcontrol_t flowcontrol = flowcontrol_none); + + /*! Destructor */ + virtual ~Serial (); + + /*! + * Opens the serial port as long as the port is set and the port isn't + * already open. + * + * If the port is provided to the constructor then an explicit call to open + * is not needed. + * + * \see Serial::Serial + * + * \throw std::invalid_argument + * \throw serial::SerialException + * \throw serial::IOException + */ + void + open (); + + /*! Gets the open status of the serial port. + * + * \return Returns true if the port is open, false otherwise. + */ + bool + isOpen () const; + + /*! Closes the serial port. */ + void + close (); + + /*! Return the number of characters in the buffer. */ + size_t + available (); + + /*! Block until there is serial data to read or read_timeout_constant + * number of milliseconds have elapsed. The return value is true when + * the function exits with the port in a readable state, false otherwise + * (due to timeout or select interruption). */ + bool + waitReadable (); + + /*! Block for a period of time corresponding to the transmission time of + * count characters at present serial settings. This may be used in con- + * junction with waitReadable to read larger blocks of data from the + * port. */ + void + waitByteTimes (size_t count); + + /*! Read a given amount of bytes from the serial port into a given buffer. + * + * The read function will return in one of three cases: + * * The number of requested bytes was read. + * * In this case the number of bytes requested will match the size_t + * returned by read. + * * A timeout occurred, in this case the number of bytes read will not + * match the amount requested, but no exception will be thrown. One of + * two possible timeouts occurred: + * * The inter byte timeout expired, this means that number of + * milliseconds elapsed between receiving bytes from the serial port + * exceeded the inter byte timeout. + * * The total timeout expired, which is calculated by multiplying the + * read timeout multiplier by the number of requested bytes and then + * added to the read timeout constant. If that total number of + * milliseconds elapses after the initial call to read a timeout will + * occur. + * * An exception occurred, in this case an actual exception will be thrown. + * + * \param buffer An uint8_t array of at least the requested size. + * \param size A size_t defining how many bytes to be read. + * + * \return A size_t representing the number of bytes read as a result of the + * call to read. + * + * \throw serial::PortNotOpenedException + * \throw serial::SerialException + */ + size_t + read (uint8_t *buffer, size_t size); + + /*! Read a given amount of bytes from the serial port into a give buffer. + * + * \param buffer A reference to a std::vector of uint8_t. + * \param size A size_t defining how many bytes to be read. + * + * \return A size_t representing the number of bytes read as a result of the + * call to read. + * + * \throw serial::PortNotOpenedException + * \throw serial::SerialException + */ + size_t + read (std::vector &buffer, size_t size = 1); + + /*! Read a given amount of bytes from the serial port into a give buffer. + * + * \param buffer A reference to a std::string. + * \param size A size_t defining how many bytes to be read. + * + * \return A size_t representing the number of bytes read as a result of the + * call to read. + * + * \throw serial::PortNotOpenedException + * \throw serial::SerialException + */ + size_t + read (std::string &buffer, size_t size = 1); + + /*! Read a given amount of bytes from the serial port and return a string + * containing the data. + * + * \param size A size_t defining how many bytes to be read. + * + * \return A std::string containing the data read from the port. + * + * \throw serial::PortNotOpenedException + * \throw serial::SerialException + */ + std::string + read (size_t size = 1); + + /*! Reads in a line or until a given delimiter has been processed. + * + * Reads from the serial port until a single line has been read. + * + * \param buffer A std::string reference used to store the data. + * \param size A maximum length of a line, defaults to 65536 (2^16) + * \param eol A string to match against for the EOL. + * + * \return A size_t representing the number of bytes read. + * + * \throw serial::PortNotOpenedException + * \throw serial::SerialException + */ + size_t + readline (std::string &buffer, size_t size = 65536, std::string eol = "\n"); + + /*! Reads in a line or until a given delimiter has been processed. + * + * Reads from the serial port until a single line has been read. + * + * \param size A maximum length of a line, defaults to 65536 (2^16) + * \param eol A string to match against for the EOL. + * + * \return A std::string containing the line. + * + * \throw serial::PortNotOpenedException + * \throw serial::SerialException + */ + std::string + readline (size_t size = 65536, std::string eol = "\n"); + + /*! Reads in multiple lines until the serial port times out. + * + * This requires a timeout > 0 before it can be run. It will read until a + * timeout occurs and return a list of strings. + * + * \param size A maximum length of combined lines, defaults to 65536 (2^16) + * + * \param eol A string to match against for the EOL. + * + * \return A vector containing the lines. + * + * \throw serial::PortNotOpenedException + * \throw serial::SerialException + */ + std::vector + readlines (size_t size = 65536, std::string eol = "\n"); + + /*! Write a string to the serial port. + * + * \param data A const reference containing the data to be written + * to the serial port. + * + * \param size A size_t that indicates how many bytes should be written from + * the given data buffer. + * + * \return A size_t representing the number of bytes actually written to + * the serial port. + * + * \throw serial::PortNotOpenedException + * \throw serial::SerialException + * \throw serial::IOException + */ + size_t + write (const uint8_t *data, size_t size); + + /*! Write a string to the serial port. + * + * \param data A const reference containing the data to be written + * to the serial port. + * + * \return A size_t representing the number of bytes actually written to + * the serial port. + * + * \throw serial::PortNotOpenedException + * \throw serial::SerialException + * \throw serial::IOException + */ + size_t + write (const std::vector &data); + + /*! Write a string to the serial port. + * + * \param data A const reference containing the data to be written + * to the serial port. + * + * \return A size_t representing the number of bytes actually written to + * the serial port. + * + * \throw serial::PortNotOpenedException + * \throw serial::SerialException + * \throw serial::IOException + */ + size_t + write (const std::string &data); + + /*! Sets the serial port identifier. + * + * \param port A const std::string reference containing the address of the + * serial port, which would be something like 'COM1' on Windows and + * '/dev/ttyS0' on Linux. + * + * \throw std::invalid_argument + */ + void + setPort (const std::string &port); + + /*! Gets the serial port identifier. + * + * \see Serial::setPort + * + * \throw std::invalid_argument + */ + std::string + getPort () const; + + /*! Sets the timeout for reads and writes using the Timeout struct. + * + * There are two timeout conditions described here: + * * The inter byte timeout: + * * The inter_byte_timeout component of serial::Timeout defines the + * maximum amount of time, in milliseconds, between receiving bytes on + * the serial port that can pass before a timeout occurs. Setting this + * to zero will prevent inter byte timeouts from occurring. + * * Total time timeout: + * * The constant and multiplier component of this timeout condition, + * for both read and write, are defined in serial::Timeout. This + * timeout occurs if the total time since the read or write call was + * made exceeds the specified time in milliseconds. + * * The limit is defined by multiplying the multiplier component by the + * number of requested bytes and adding that product to the constant + * component. In this way if you want a read call, for example, to + * timeout after exactly one second regardless of the number of bytes + * you asked for then set the read_timeout_constant component of + * serial::Timeout to 1000 and the read_timeout_multiplier to zero. + * This timeout condition can be used in conjunction with the inter + * byte timeout condition with out any problems, timeout will simply + * occur when one of the two timeout conditions is met. This allows + * users to have maximum control over the trade-off between + * responsiveness and efficiency. + * + * Read and write functions will return in one of three cases. When the + * reading or writing is complete, when a timeout occurs, or when an + * exception occurs. + * + * \param timeout A serial::Timeout struct containing the inter byte + * timeout, and the read and write timeout constants and multipliers. + * + * \see serial::Timeout + */ + void + setTimeout (Timeout &timeout); + + /*! Sets the timeout for reads and writes. */ + void + setTimeout (uint32_t inter_byte_timeout, uint32_t read_timeout_constant, + uint32_t read_timeout_multiplier, uint32_t write_timeout_constant, + uint32_t write_timeout_multiplier) + { + Timeout timeout(inter_byte_timeout, read_timeout_constant, + read_timeout_multiplier, write_timeout_constant, + write_timeout_multiplier); + return setTimeout(timeout); + } + + /*! Gets the timeout for reads in seconds. + * + * \return A Timeout struct containing the inter_byte_timeout, and read + * and write timeout constants and multipliers. + * + * \see Serial::setTimeout + */ + Timeout + getTimeout () const; + + /*! Sets the baudrate for the serial port. + * + * Possible baudrates depends on the system but some safe baudrates include: + * 110, 300, 600, 1200, 2400, 4800, 9600, 14400, 19200, 28800, 38400, 56000, + * 57600, 115200 + * Some other baudrates that are supported by some comports: + * 128000, 153600, 230400, 256000, 460800, 921600 + * + * \param baudrate An integer that sets the baud rate for the serial port. + * + * \throw std::invalid_argument + */ + void + setBaudrate (uint32_t baudrate); + + /*! Gets the baudrate for the serial port. + * + * \return An integer that sets the baud rate for the serial port. + * + * \see Serial::setBaudrate + * + * \throw std::invalid_argument + */ + uint32_t + getBaudrate () const; + + /*! Sets the bytesize for the serial port. + * + * \param bytesize Size of each byte in the serial transmission of data, + * default is eightbits, possible values are: fivebits, sixbits, sevenbits, + * eightbits + * + * \throw std::invalid_argument + */ + void + setBytesize (bytesize_t bytesize); + + /*! Gets the bytesize for the serial port. + * + * \see Serial::setBytesize + * + * \throw std::invalid_argument + */ + bytesize_t + getBytesize () const; + + /*! Sets the parity for the serial port. + * + * \param parity Method of parity, default is parity_none, possible values + * are: parity_none, parity_odd, parity_even + * + * \throw std::invalid_argument + */ + void + setParity (parity_t parity); + + /*! Gets the parity for the serial port. + * + * \see Serial::setParity + * + * \throw std::invalid_argument + */ + parity_t + getParity () const; + + /*! Sets the stopbits for the serial port. + * + * \param stopbits Number of stop bits used, default is stopbits_one, + * possible values are: stopbits_one, stopbits_one_point_five, stopbits_two + * + * \throw std::invalid_argument + */ + void + setStopbits (stopbits_t stopbits); + + /*! Gets the stopbits for the serial port. + * + * \see Serial::setStopbits + * + * \throw std::invalid_argument + */ + stopbits_t + getStopbits () const; + + /*! Sets the flow control for the serial port. + * + * \param flowcontrol Type of flowcontrol used, default is flowcontrol_none, + * possible values are: flowcontrol_none, flowcontrol_software, + * flowcontrol_hardware + * + * \throw std::invalid_argument + */ + void + setFlowcontrol (flowcontrol_t flowcontrol); + + /*! Gets the flow control for the serial port. + * + * \see Serial::setFlowcontrol + * + * \throw std::invalid_argument + */ + flowcontrol_t + getFlowcontrol () const; + + /*! Flush the input and output buffers */ + void + flush (); + + /*! Flush only the input buffer */ + void + flushInput (); + + /*! Flush only the output buffer */ + void + flushOutput (); + + /*! Sends the RS-232 break signal. See tcsendbreak(3). */ + void + sendBreak (int duration); + + /*! Set the break condition to a given level. Defaults to true. */ + void + setBreak (bool level = true); + + /*! Set the RTS handshaking line to the given level. Defaults to true. */ + void + setRTS (bool level = true); + + /*! Set the DTR handshaking line to the given level. Defaults to true. */ + void + setDTR (bool level = true); + + /*! + * Blocks until CTS, DSR, RI, CD changes or something interrupts it. + * + * Can throw an exception if an error occurs while waiting. + * You can check the status of CTS, DSR, RI, and CD once this returns. + * Uses TIOCMIWAIT via ioctl if available (mostly only on Linux) with a + * resolution of less than +-1ms and as good as +-0.2ms. Otherwise a + * polling method is used which can give +-2ms. + * + * \return Returns true if one of the lines changed, false if something else + * occurred. + * + * \throw SerialException + */ + bool + waitForChange (); + + /*! Returns the current status of the CTS line. */ + bool + getCTS (); + + /*! Returns the current status of the DSR line. */ + bool + getDSR (); + + /*! Returns the current status of the RI line. */ + bool + getRI (); + + /*! Returns the current status of the CD line. */ + bool + getCD (); + + private: + // Disable copy constructors + Serial(const Serial&); + Serial& operator=(const Serial&); + + // Pimpl idiom, d_pointer + class SerialImpl; + SerialImpl *pimpl_; + + // Scoped Lock Classes + class ScopedReadLock; + class ScopedWriteLock; + + // Read common function + size_t + read_ (uint8_t *buffer, size_t size); + // Write common function + size_t + write_ (const uint8_t *data, size_t length); + + }; + + class SerialException : public std::exception + { + // Disable copy constructors + SerialException& operator=(const SerialException&); + std::string e_what_; + public: + SerialException (const char *description) { + std::stringstream ss; + ss << "SerialException " << description << " failed."; + e_what_ = ss.str(); + } + SerialException (const SerialException& other) : e_what_(other.e_what_) {} + virtual ~SerialException() throw() {} + virtual const char* what () const throw () { + return e_what_.c_str(); + } + }; + + class IOException : public std::exception + { + // Disable copy constructors + IOException& operator=(const IOException&); + std::string file_; + int line_; + std::string e_what_; + int errno_; + public: + explicit IOException (std::string file, int line, int errnum) + : file_(file), line_(line), errno_(errnum) { + std::stringstream ss; +#if defined(_WIN32) && !defined(__MINGW32__) + char error_str [1024]; + strerror_s(error_str, 1024, errnum); +#else + char * error_str = strerror(errnum); +#endif + ss << "IO Exception (" << errno_ << "): " << error_str; + ss << ", file " << file_ << ", line " << line_ << "."; + e_what_ = ss.str(); + } + explicit IOException (std::string file, int line, const char * description) + : file_(file), line_(line), errno_(0) { + std::stringstream ss; + ss << "IO Exception: " << description; + ss << ", file " << file_ << ", line " << line_ << "."; + e_what_ = ss.str(); + } + virtual ~IOException() throw() {} + IOException (const IOException& other) : line_(other.line_), e_what_(other.e_what_), errno_(other.errno_) {} + + int getErrorNumber () { return errno_; } + + virtual const char* what () const throw () { + return e_what_.c_str(); + } + }; + + class PortNotOpenedException : public std::exception + { + // Disable copy constructors + const PortNotOpenedException& operator=(PortNotOpenedException); + std::string e_what_; + public: + PortNotOpenedException (const char * description) { + std::stringstream ss; + ss << "PortNotOpenedException " << description << " failed."; + e_what_ = ss.str(); + } + PortNotOpenedException (const PortNotOpenedException& other) : e_what_(other.e_what_) {} + virtual ~PortNotOpenedException() throw() {} + virtual const char* what () const throw () { + return e_what_.c_str(); + } + }; + +/*! + * Structure that describes a serial device. + */ + struct PortInfo { + + /*! Address of the serial port (this can be passed to the constructor of Serial). */ + std::string port; + + /*! Human readable description of serial device if available. */ + std::string description; + + /*! Hardware ID (e.g. VID:PID of USB serial devices) or "n/a" if not available. */ + std::string hardware_id; + + }; + +/* Lists the serial ports available on the system + * + * Returns a vector of available serial ports, each represented + * by a serial::PortInfo data structure: + * + * \return vector of serial::PortInfo. + */ + std::vector + list_ports(); + +} // namespace serial + +#endif \ No newline at end of file diff --git a/Racer/lib/serial/include/v8stdint.h b/Racer/lib/serial/include/v8stdint.h new file mode 100644 index 0000000..f3be96b --- /dev/null +++ b/Racer/lib/serial/include/v8stdint.h @@ -0,0 +1,57 @@ +// This header is from the v8 google project: +// http://code.google.com/p/v8/source/browse/trunk/include/v8stdint.h + +// Copyright 2012 the V8 project authors. All rights reserved. +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following +// disclaimer in the documentation and/or other materials provided +// with the distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived +// from this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +// Load definitions of standard types. + +#ifndef V8STDINT_H_ +#define V8STDINT_H_ + +#include +#include + +#if defined(_WIN32) && !defined(__MINGW32__) + +typedef signed char int8_t; +typedef unsigned char uint8_t; +typedef short int16_t; // NOLINT +typedef unsigned short uint16_t; // NOLINT +typedef int int32_t; +typedef unsigned int uint32_t; +typedef __int64 int64_t; +typedef unsigned __int64 uint64_t; +// intptr_t and friends are defined in crtdefs.h through stdio.h. + +#else + +#include + +#endif + +#endif // V8STDINT_H_ diff --git a/Racer/lib/serial/src/impl/list_ports/list_ports_linux.cc b/Racer/lib/serial/src/impl/list_ports/list_ports_linux.cc new file mode 100644 index 0000000..917bf2a --- /dev/null +++ b/Racer/lib/serial/src/impl/list_ports/list_ports_linux.cc @@ -0,0 +1,335 @@ +#if defined(__linux__) + +/* + * Copyright (c) 2014 Craig Lilley + * This software is made available under the terms of the MIT licence. + * A copy of the licence can be obtained from: + * http://opensource.org/licenses/MIT + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include "../../../include/serial.h" + + +using serial::PortInfo; +using std::istringstream; +using std::ifstream; +using std::getline; +using std::vector; +using std::string; +using std::cout; +using std::endl; + +static vector glob(const vector& patterns); +static string basename(const string& path); +static string dirname(const string& path); +static bool path_exists(const string& path); +static string realpath(const string& path); +static string usb_sysfs_friendly_name(const string& sys_usb_path); +static vector get_sysfs_info(const string& device_path); +static string read_line(const string& file); +static string usb_sysfs_hw_string(const string& sysfs_path); +static string format(const char* format, ...); + +vector +glob(const vector& patterns) +{ + vector paths_found; + + if(patterns.size() == 0) + return paths_found; + + glob_t glob_results; + + int glob_retval = glob(patterns[0].c_str(), 0, NULL, &glob_results); + + vector::const_iterator iter = patterns.begin(); + + while(++iter != patterns.end()) + { + glob_retval = glob(iter->c_str(), GLOB_APPEND, NULL, &glob_results); + } + + for(int path_index = 0; path_index < glob_results.gl_pathc; path_index++) + { + paths_found.push_back(glob_results.gl_pathv[path_index]); + } + + globfree(&glob_results); + + return paths_found; +} + +string +basename(const string& path) +{ + size_t pos = path.rfind("/"); + + if(pos == std::string::npos) + return path; + + return string(path, pos+1, string::npos); +} + +string +dirname(const string& path) +{ + size_t pos = path.rfind("/"); + + if(pos == std::string::npos) + return path; + else if(pos == 0) + return "/"; + + return string(path, 0, pos); +} + +bool +path_exists(const string& path) +{ + struct stat sb; + + if( stat(path.c_str(), &sb ) == 0 ) + return true; + + return false; +} + +string +realpath(const string& path) +{ + char* real_path = realpath(path.c_str(), NULL); + + string result; + + if(real_path != NULL) + { + result = real_path; + + free(real_path); + } + + return result; +} + +string +usb_sysfs_friendly_name(const string& sys_usb_path) +{ + unsigned int device_number = 0; + + istringstream( read_line(sys_usb_path + "/devnum") ) >> device_number; + + string manufacturer = read_line( sys_usb_path + "/manufacturer" ); + + string product = read_line( sys_usb_path + "/product" ); + + string serial = read_line( sys_usb_path + "/serial" ); + + if( manufacturer.empty() && product.empty() && serial.empty() ) + return ""; + + return format("%s %s %s", manufacturer.c_str(), product.c_str(), serial.c_str() ); +} + +vector +get_sysfs_info(const string& device_path) +{ + string device_name = basename( device_path ); + + string friendly_name; + + string hardware_id; + + string sys_device_path = format( "/sys/class/tty/%s/device", device_name.c_str() ); + + if( device_name.compare(0,6,"ttyUSB") == 0 ) + { + sys_device_path = dirname( dirname( realpath( sys_device_path ) ) ); + + if( path_exists( sys_device_path ) ) + { + friendly_name = usb_sysfs_friendly_name( sys_device_path ); + + hardware_id = usb_sysfs_hw_string( sys_device_path ); + } + } + else if( device_name.compare(0,6,"ttyACM") == 0 ) + { + sys_device_path = dirname( realpath( sys_device_path ) ); + + if( path_exists( sys_device_path ) ) + { + friendly_name = usb_sysfs_friendly_name( sys_device_path ); + + hardware_id = usb_sysfs_hw_string( sys_device_path ); + } + } + else + { + // Try to read ID string of PCI device + + string sys_id_path = sys_device_path + "/id"; + + if( path_exists( sys_id_path ) ) + hardware_id = read_line( sys_id_path ); + } + + if( friendly_name.empty() ) + friendly_name = device_name; + + if( hardware_id.empty() ) + hardware_id = "n/a"; + + vector result; + result.push_back(friendly_name); + result.push_back(hardware_id); + + return result; +} + +string +read_line(const string& file) +{ + ifstream ifs(file.c_str(), ifstream::in); + + string line; + + if(ifs) + { + getline(ifs, line); + } + + return line; +} + +string +format(const char* format, ...) +{ + va_list ap; + + size_t buffer_size_bytes = 256; + + string result; + + char* buffer = (char*)malloc(buffer_size_bytes); + + if( buffer == NULL ) + return result; + + bool done = false; + + unsigned int loop_count = 0; + + while(!done) + { + va_start(ap, format); + + int return_value = vsnprintf(buffer, buffer_size_bytes, format, ap); + + if( return_value < 0 ) + { + done = true; + } + else if( return_value >= buffer_size_bytes ) + { + // Realloc and try again. + + buffer_size_bytes = return_value + 1; + + char* new_buffer_ptr = (char*)realloc(buffer, buffer_size_bytes); + + if( new_buffer_ptr == NULL ) + { + done = true; + } + else + { + buffer = new_buffer_ptr; + } + } + else + { + result = buffer; + done = true; + } + + va_end(ap); + + if( ++loop_count > 5 ) + done = true; + } + + free(buffer); + + return result; +} + +string +usb_sysfs_hw_string(const string& sysfs_path) +{ + string serial_number = read_line( sysfs_path + "/serial" ); + + if( serial_number.length() > 0 ) + { + serial_number = format( "SNR=%s", serial_number.c_str() ); + } + + string vid = read_line( sysfs_path + "/idVendor" ); + + string pid = read_line( sysfs_path + "/idProduct" ); + + return format("USB VID:PID=%s:%s %s", vid.c_str(), pid.c_str(), serial_number.c_str() ); +} + +vector +serial::list_ports() +{ + vector results; + + vector search_globs; + search_globs.push_back("/dev/ttyACM*"); + search_globs.push_back("/dev/ttyS*"); + search_globs.push_back("/dev/ttyUSB*"); + search_globs.push_back("/dev/tty.*"); + search_globs.push_back("/dev/cu.*"); + + vector devices_found = glob( search_globs ); + + vector::iterator iter = devices_found.begin(); + + while( iter != devices_found.end() ) + { + string device = *iter++; + + vector sysfs_info = get_sysfs_info( device ); + + string friendly_name = sysfs_info[0]; + + string hardware_id = sysfs_info[1]; + + PortInfo device_entry; + device_entry.port = device; + device_entry.description = friendly_name; + device_entry.hardware_id = hardware_id; + + results.push_back( device_entry ); + + } + + return results; +} + +#endif // defined(__linux__) diff --git a/Racer/lib/serial/src/impl/list_ports/list_ports_osx.cc b/Racer/lib/serial/src/impl/list_ports/list_ports_osx.cc new file mode 100644 index 0000000..333c55c --- /dev/null +++ b/Racer/lib/serial/src/impl/list_ports/list_ports_osx.cc @@ -0,0 +1,286 @@ +#if defined(__APPLE__) + +#include +#include + +#include +#include +#include +#include + +#include +#include +#include + +#include "serial/serial.h" + +using serial::PortInfo; +using std::string; +using std::vector; + +#define HARDWARE_ID_STRING_LENGTH 128 + +string cfstring_to_string( CFStringRef cfstring ); +string get_device_path( io_object_t& serial_port ); +string get_class_name( io_object_t& obj ); +io_registry_entry_t get_parent_iousb_device( io_object_t& serial_port ); +string get_string_property( io_object_t& device, const char* property ); +uint16_t get_int_property( io_object_t& device, const char* property ); +string rtrim(const string& str); + +string +cfstring_to_string( CFStringRef cfstring ) +{ + char cstring[MAXPATHLEN]; + string result; + + if( cfstring ) + { + Boolean success = CFStringGetCString( cfstring, + cstring, + sizeof(cstring), + kCFStringEncodingASCII ); + + if( success ) + result = cstring; + } + + return result; +} + +string +get_device_path( io_object_t& serial_port ) +{ + CFTypeRef callout_path; + string device_path; + + callout_path = IORegistryEntryCreateCFProperty( serial_port, + CFSTR(kIOCalloutDeviceKey), + kCFAllocatorDefault, + 0 ); + + if (callout_path) + { + if( CFGetTypeID(callout_path) == CFStringGetTypeID() ) + device_path = cfstring_to_string( static_cast(callout_path) ); + + CFRelease(callout_path); + } + + return device_path; +} + +string +get_class_name( io_object_t& obj ) +{ + string result; + io_name_t class_name; + kern_return_t kern_result; + + kern_result = IOObjectGetClass( obj, class_name ); + + if( kern_result == KERN_SUCCESS ) + result = class_name; + + return result; +} + +io_registry_entry_t +get_parent_iousb_device( io_object_t& serial_port ) +{ + io_object_t device = serial_port; + io_registry_entry_t parent = 0; + io_registry_entry_t result = 0; + kern_return_t kern_result = KERN_FAILURE; + string name = get_class_name(device); + + // Walk the IO Registry tree looking for this devices parent IOUSBDevice. + while( name != "IOUSBDevice" ) + { + kern_result = IORegistryEntryGetParentEntry( device, + kIOServicePlane, + &parent ); + + if(kern_result != KERN_SUCCESS) + { + result = 0; + break; + } + + device = parent; + + name = get_class_name(device); + } + + if(kern_result == KERN_SUCCESS) + result = device; + + return result; +} + +string +get_string_property( io_object_t& device, const char* property ) +{ + string property_name; + + if( device ) + { + CFStringRef property_as_cfstring = CFStringCreateWithCString ( + kCFAllocatorDefault, + property, + kCFStringEncodingASCII ); + + CFTypeRef name_as_cfstring = IORegistryEntryCreateCFProperty( + device, + property_as_cfstring, + kCFAllocatorDefault, + 0 ); + + if( name_as_cfstring ) + { + if( CFGetTypeID(name_as_cfstring) == CFStringGetTypeID() ) + property_name = cfstring_to_string( static_cast(name_as_cfstring) ); + + CFRelease(name_as_cfstring); + } + + if(property_as_cfstring) + CFRelease(property_as_cfstring); + } + + return property_name; +} + +uint16_t +get_int_property( io_object_t& device, const char* property ) +{ + uint16_t result = 0; + + if( device ) + { + CFStringRef property_as_cfstring = CFStringCreateWithCString ( + kCFAllocatorDefault, + property, + kCFStringEncodingASCII ); + + CFTypeRef number = IORegistryEntryCreateCFProperty( device, + property_as_cfstring, + kCFAllocatorDefault, + 0 ); + + if(property_as_cfstring) + CFRelease(property_as_cfstring); + + if( number ) + { + if( CFGetTypeID(number) == CFNumberGetTypeID() ) + { + bool success = CFNumberGetValue( static_cast(number), + kCFNumberSInt16Type, + &result ); + + if( !success ) + result = 0; + } + + CFRelease(number); + } + + } + + return result; +} + +string rtrim(const string& str) +{ + string result = str; + + string whitespace = " \t\f\v\n\r"; + + std::size_t found = result.find_last_not_of(whitespace); + + if (found != std::string::npos) + result.erase(found+1); + else + result.clear(); + + return result; +} + +vector +serial::list_ports(void) +{ + vector devices_found; + CFMutableDictionaryRef classes_to_match; + io_iterator_t serial_port_iterator; + io_object_t serial_port; + mach_port_t master_port; + kern_return_t kern_result; + + kern_result = IOMasterPort(MACH_PORT_NULL, &master_port); + + if(kern_result != KERN_SUCCESS) + return devices_found; + + classes_to_match = IOServiceMatching(kIOSerialBSDServiceValue); + + if (classes_to_match == NULL) + return devices_found; + + CFDictionarySetValue( classes_to_match, + CFSTR(kIOSerialBSDTypeKey), + CFSTR(kIOSerialBSDAllTypes) ); + + kern_result = IOServiceGetMatchingServices(master_port, classes_to_match, &serial_port_iterator); + + if (KERN_SUCCESS != kern_result) + return devices_found; + + while ( (serial_port = IOIteratorNext(serial_port_iterator)) ) + { + string device_path = get_device_path( serial_port ); + io_registry_entry_t parent = get_parent_iousb_device( serial_port ); + IOObjectRelease(serial_port); + + if( device_path.empty() ) + continue; + + PortInfo port_info; + port_info.port = device_path; + port_info.description = "n/a"; + port_info.hardware_id = "n/a"; + + string device_name = rtrim( get_string_property( parent, "USB Product Name" ) ); + string vendor_name = rtrim( get_string_property( parent, "USB Vendor Name") ); + string description = rtrim( vendor_name + " " + device_name ); + if( !description.empty() ) + port_info.description = description; + + string serial_number = rtrim(get_string_property( parent, "USB Serial Number" ) ); + uint16_t vendor_id = get_int_property( parent, "idVendor" ); + uint16_t product_id = get_int_property( parent, "idProduct" ); + + if( vendor_id && product_id ) + { + char cstring[HARDWARE_ID_STRING_LENGTH]; + + if(serial_number.empty()) + serial_number = "None"; + + int ret = snprintf( cstring, HARDWARE_ID_STRING_LENGTH, "USB VID:PID=%04x:%04x SNR=%s", + vendor_id, + product_id, + serial_number.c_str() ); + + if( (ret >= 0) && (ret < HARDWARE_ID_STRING_LENGTH) ) + port_info.hardware_id = cstring; + } + + devices_found.push_back(port_info); + } + + IOObjectRelease(serial_port_iterator); + return devices_found; +} + +#endif // defined(__APPLE__) diff --git a/Racer/lib/serial/src/impl/list_ports/list_ports_win.cc b/Racer/lib/serial/src/impl/list_ports/list_ports_win.cc new file mode 100644 index 0000000..e763338 --- /dev/null +++ b/Racer/lib/serial/src/impl/list_ports/list_ports_win.cc @@ -0,0 +1,152 @@ +#if defined(_WIN32) + +/* + * Copyright (c) 2014 Craig Lilley + * This software is made available under the terms of the MIT licence. + * A copy of the licence can be obtained from: + * http://opensource.org/licenses/MIT + */ + +#include "include/serial.h" +#include +#include +#include +#include +#include +#include + +using serial::PortInfo; +using std::vector; +using std::string; + +static const DWORD port_name_max_length = 256; +static const DWORD friendly_name_max_length = 256; +static const DWORD hardware_id_max_length = 256; + +// Convert a wide Unicode string to an UTF8 string +std::string utf8_encode(const std::wstring &wstr) +{ + int size_needed = WideCharToMultiByte(CP_UTF8, 0, &wstr[0], (int)wstr.size(), NULL, 0, NULL, NULL); + std::string strTo( size_needed, 0 ); + WideCharToMultiByte (CP_UTF8, 0, &wstr[0], (int)wstr.size(), &strTo[0], size_needed, NULL, NULL); + return strTo; +} + +vector +serial::list_ports() +{ + vector devices_found; + + HDEVINFO device_info_set = SetupDiGetClassDevs( + (const GUID *) &GUID_DEVCLASS_PORTS, + NULL, + NULL, + DIGCF_PRESENT); + + unsigned int device_info_set_index = 0; + SP_DEVINFO_DATA device_info_data; + + device_info_data.cbSize = sizeof(SP_DEVINFO_DATA); + + while(SetupDiEnumDeviceInfo(device_info_set, device_info_set_index, &device_info_data)) + { + device_info_set_index++; + + // Get port name + + HKEY hkey = SetupDiOpenDevRegKey( + device_info_set, + &device_info_data, + DICS_FLAG_GLOBAL, + 0, + DIREG_DEV, + KEY_READ); + + TCHAR port_name[port_name_max_length]; + DWORD port_name_length = port_name_max_length; + + LONG return_code = RegQueryValueEx( + hkey, + _T("PortName"), + NULL, + NULL, + (LPBYTE)port_name, + &port_name_length); + + RegCloseKey(hkey); + + if(return_code != EXIT_SUCCESS) + continue; + + if(port_name_length > 0 && port_name_length <= port_name_max_length) + port_name[port_name_length-1] = '\0'; + else + port_name[0] = '\0'; + + // Ignore parallel ports + + if(_tcsstr(port_name, _T("LPT")) != NULL) + continue; + + // Get port friendly name + + TCHAR friendly_name[friendly_name_max_length]; + DWORD friendly_name_actual_length = 0; + + BOOL got_friendly_name = SetupDiGetDeviceRegistryProperty( + device_info_set, + &device_info_data, + SPDRP_FRIENDLYNAME, + NULL, + (PBYTE)friendly_name, + friendly_name_max_length, + &friendly_name_actual_length); + + if(got_friendly_name == TRUE && friendly_name_actual_length > 0) + friendly_name[friendly_name_actual_length-1] = '\0'; + else + friendly_name[0] = '\0'; + + // Get hardware ID + + TCHAR hardware_id[hardware_id_max_length]; + DWORD hardware_id_actual_length = 0; + + BOOL got_hardware_id = SetupDiGetDeviceRegistryProperty( + device_info_set, + &device_info_data, + SPDRP_HARDWAREID, + NULL, + (PBYTE)hardware_id, + hardware_id_max_length, + &hardware_id_actual_length); + + if(got_hardware_id == TRUE && hardware_id_actual_length > 0) + hardware_id[hardware_id_actual_length-1] = '\0'; + else + hardware_id[0] = '\0'; + + #ifdef UNICODE + std::string portName = utf8_encode(port_name); + std::string friendlyName = utf8_encode(friendly_name); + std::string hardwareId = utf8_encode(hardware_id); + #else + std::string portName = port_name; + std::string friendlyName = friendly_name; + std::string hardwareId = hardware_id; + #endif + + PortInfo port_entry; + port_entry.port = portName; + port_entry.description = friendlyName; + port_entry.hardware_id = hardwareId; + + devices_found.push_back(port_entry); + } + + SetupDiDestroyDeviceInfoList(device_info_set); + + return devices_found; +} + +#endif // #if defined(_WIN32) diff --git a/Racer/lib/serial/src/impl/unix.cc b/Racer/lib/serial/src/impl/unix.cc new file mode 100644 index 0000000..dd29c11 --- /dev/null +++ b/Racer/lib/serial/src/impl/unix.cc @@ -0,0 +1,1058 @@ +/* Copyright 2012 William Woodall and John Harrison + * + * Additional Contributors: Christopher Baker @bakercp + */ + +#if !defined(_WIN32) + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#if defined(__linux__) +# include +#endif + +#include +#include +#include +#ifdef __MACH__ +#include +#include +#include +#endif + +#include "../../include/impl/unix.h" + +#ifndef TIOCINQ +#ifdef FIONREAD +#define TIOCINQ FIONREAD +#else +#define TIOCINQ 0x541B +#endif +#endif + +#if defined(MAC_OS_X_VERSION_10_3) && (MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_3) +#include +#endif + +using std::string; +using std::stringstream; +using std::invalid_argument; +using serial::MillisecondTimer; +using serial::Serial; +using serial::SerialException; +using serial::PortNotOpenedException; +using serial::IOException; + + +MillisecondTimer::MillisecondTimer (const uint32_t millis) + : expiry(timespec_now()) +{ + int64_t tv_nsec = expiry.tv_nsec + (millis * 1e6); + if (tv_nsec >= 1e9) { + int64_t sec_diff = tv_nsec / static_cast (1e9); + expiry.tv_nsec = tv_nsec - static_cast (1e9 * sec_diff); + expiry.tv_sec += sec_diff; + } else { + expiry.tv_nsec = tv_nsec; + } +} + +int64_t +MillisecondTimer::remaining () +{ + timespec now(timespec_now()); + int64_t millis = (expiry.tv_sec - now.tv_sec) * 1e3; + millis += (expiry.tv_nsec - now.tv_nsec) / 1e6; + return millis; +} + +timespec +MillisecondTimer::timespec_now () +{ + timespec time; +# ifdef __MACH__ // OS X does not have clock_gettime, use clock_get_time + clock_serv_t cclock; + mach_timespec_t mts; + host_get_clock_service(mach_host_self(), SYSTEM_CLOCK, &cclock); + clock_get_time(cclock, &mts); + mach_port_deallocate(mach_task_self(), cclock); + time.tv_sec = mts.tv_sec; + time.tv_nsec = mts.tv_nsec; +# else + clock_gettime(CLOCK_MONOTONIC, &time); +# endif + return time; +} + +timespec +timespec_from_ms (const uint32_t millis) +{ + timespec time; + time.tv_sec = millis / 1e3; + time.tv_nsec = (millis - (time.tv_sec * 1e3)) * 1e6; + return time; +} + +Serial::SerialImpl::SerialImpl (const string &port, unsigned long baudrate, + bytesize_t bytesize, + parity_t parity, stopbits_t stopbits, + flowcontrol_t flowcontrol) + : port_ (port), fd_ (-1), is_open_ (false), xonxoff_ (false), rtscts_ (false), + baudrate_ (baudrate), parity_ (parity), + bytesize_ (bytesize), stopbits_ (stopbits), flowcontrol_ (flowcontrol) +{ + pthread_mutex_init(&this->read_mutex, NULL); + pthread_mutex_init(&this->write_mutex, NULL); + if (port_.empty () == false) + open (); +} + +Serial::SerialImpl::~SerialImpl () +{ + close(); + pthread_mutex_destroy(&this->read_mutex); + pthread_mutex_destroy(&this->write_mutex); +} + +void +Serial::SerialImpl::open () +{ + if (port_.empty ()) { + throw invalid_argument ("Empty port is invalid."); + } + if (is_open_ == true) { + throw SerialException ("Serial port already open."); + } + + fd_ = ::open (port_.c_str(), O_RDWR | O_NOCTTY | O_NONBLOCK); + + if (fd_ == -1) { + switch (errno) { + case EINTR: + // Recurse because this is a recoverable error. + open (); + return; + case ENFILE: + case EMFILE: + THROW (IOException, "Too many file handles open."); + default: + THROW (IOException, errno); + } + } + + reconfigurePort(); + is_open_ = true; +} + +void +Serial::SerialImpl::reconfigurePort () +{ + if (fd_ == -1) { + // Can only operate on a valid file descriptor + THROW (IOException, "Invalid file descriptor, is the serial port open?"); + } + + struct termios options; // The options for the file descriptor + + if (tcgetattr(fd_, &options) == -1) { + THROW (IOException, "::tcgetattr"); + } + + // set up raw mode / no echo / binary + options.c_cflag |= (tcflag_t) (CLOCAL | CREAD); + options.c_lflag &= (tcflag_t) ~(ICANON | ECHO | ECHOE | ECHOK | ECHONL | + ISIG | IEXTEN); //|ECHOPRT + + options.c_oflag &= (tcflag_t) ~(OPOST); + options.c_iflag &= (tcflag_t) ~(INLCR | IGNCR | ICRNL | IGNBRK); +#ifdef IUCLC + options.c_iflag &= (tcflag_t) ~IUCLC; +#endif +#ifdef PARMRK + options.c_iflag &= (tcflag_t) ~PARMRK; +#endif + + // setup baud rate + bool custom_baud = false; + speed_t baud; + switch (baudrate_) { +#ifdef B0 + case 0: baud = B0; break; +#endif +#ifdef B50 + case 50: baud = B50; break; +#endif +#ifdef B75 + case 75: baud = B75; break; +#endif +#ifdef B110 + case 110: baud = B110; break; +#endif +#ifdef B134 + case 134: baud = B134; break; +#endif +#ifdef B150 + case 150: baud = B150; break; +#endif +#ifdef B200 + case 200: baud = B200; break; +#endif +#ifdef B300 + case 300: baud = B300; break; +#endif +#ifdef B600 + case 600: baud = B600; break; +#endif +#ifdef B1200 + case 1200: baud = B1200; break; +#endif +#ifdef B1800 + case 1800: baud = B1800; break; +#endif +#ifdef B2400 + case 2400: baud = B2400; break; +#endif +#ifdef B4800 + case 4800: baud = B4800; break; +#endif +#ifdef B7200 + case 7200: baud = B7200; break; +#endif +#ifdef B9600 + case 9600: baud = B9600; break; +#endif +#ifdef B14400 + case 14400: baud = B14400; break; +#endif +#ifdef B19200 + case 19200: baud = B19200; break; +#endif +#ifdef B28800 + case 28800: baud = B28800; break; +#endif +#ifdef B57600 + case 57600: baud = B57600; break; +#endif +#ifdef B76800 + case 76800: baud = B76800; break; +#endif +#ifdef B38400 + case 38400: baud = B38400; break; +#endif +#ifdef B115200 + case 115200: baud = B115200; break; +#endif +#ifdef B128000 + case 128000: baud = B128000; break; +#endif +#ifdef B153600 + case 153600: baud = B153600; break; +#endif +#ifdef B230400 + case 230400: baud = B230400; break; +#endif +#ifdef B256000 + case 256000: baud = B256000; break; +#endif +#ifdef B460800 + case 460800: baud = B460800; break; +#endif +#ifdef B576000 + case 576000: baud = B576000; break; +#endif +#ifdef B921600 + case 921600: baud = B921600; break; +#endif +#ifdef B1000000 + case 1000000: baud = B1000000; break; +#endif +#ifdef B1152000 + case 1152000: baud = B1152000; break; +#endif +#ifdef B1500000 + case 1500000: baud = B1500000; break; +#endif +#ifdef B2000000 + case 2000000: baud = B2000000; break; +#endif +#ifdef B2500000 + case 2500000: baud = B2500000; break; +#endif +#ifdef B3000000 + case 3000000: baud = B3000000; break; +#endif +#ifdef B3500000 + case 3500000: baud = B3500000; break; +#endif +#ifdef B4000000 + case 4000000: baud = B4000000; break; +#endif + default: + custom_baud = true; + // OS X support +#if defined(MAC_OS_X_VERSION_10_4) && (MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_4) + // Starting with Tiger, the IOSSIOSPEED ioctl can be used to set arbitrary baud rates + // other than those specified by POSIX. The driver for the underlying serial hardware + // ultimately determines which baud rates can be used. This ioctl sets both the input + // and output speed. + speed_t new_baud = static_cast (baudrate_); + if (-1 == ioctl (fd_, IOSSIOSPEED, &new_baud, 1)) { + THROW (IOException, errno); + } + // Linux Support +#elif defined(__linux__) && defined (TIOCSSERIAL) + struct serial_struct ser; + + if (-1 == ioctl (fd_, TIOCGSERIAL, &ser)) { + THROW (IOException, errno); + } + + // set custom divisor + ser.custom_divisor = ser.baud_base / static_cast (baudrate_); + // update flags + ser.flags &= ~ASYNC_SPD_MASK; + ser.flags |= ASYNC_SPD_CUST; + + if (-1 == ioctl (fd_, TIOCSSERIAL, &ser)) { + THROW (IOException, errno); + } +#else + throw invalid_argument ("OS does not currently support custom bauds"); +#endif + } + if (custom_baud == false) { +#ifdef _BSD_SOURCE + ::cfsetspeed(&options, baud); +#else + ::cfsetispeed(&options, baud); + ::cfsetospeed(&options, baud); +#endif + } + + // setup char len + options.c_cflag &= (tcflag_t) ~CSIZE; + if (bytesize_ == eightbits) + options.c_cflag |= CS8; + else if (bytesize_ == sevenbits) + options.c_cflag |= CS7; + else if (bytesize_ == sixbits) + options.c_cflag |= CS6; + else if (bytesize_ == fivebits) + options.c_cflag |= CS5; + else + throw invalid_argument ("invalid char len"); + // setup stopbits + if (stopbits_ == stopbits_one) + options.c_cflag &= (tcflag_t) ~(CSTOPB); + else if (stopbits_ == stopbits_one_point_five) + // ONE POINT FIVE same as TWO.. there is no POSIX support for 1.5 + options.c_cflag |= (CSTOPB); + else if (stopbits_ == stopbits_two) + options.c_cflag |= (CSTOPB); + else + throw invalid_argument ("invalid stop bit"); + // setup parity + options.c_iflag &= (tcflag_t) ~(INPCK | ISTRIP); + if (parity_ == parity_none) { + options.c_cflag &= (tcflag_t) ~(PARENB | PARODD); + } else if (parity_ == parity_even) { + options.c_cflag &= (tcflag_t) ~(PARODD); + options.c_cflag |= (PARENB); + } else if (parity_ == parity_odd) { + options.c_cflag |= (PARENB | PARODD); + } +#ifdef CMSPAR + else if (parity_ == parity_mark) { + options.c_cflag |= (PARENB | CMSPAR | PARODD); + } + else if (parity_ == parity_space) { + options.c_cflag |= (PARENB | CMSPAR); + options.c_cflag &= (tcflag_t) ~(PARODD); + } +#else + // CMSPAR is not defined on OSX. So do not support mark or space parity. + else if (parity_ == parity_mark || parity_ == parity_space) { + throw invalid_argument ("OS does not support mark or space parity"); + } +#endif // ifdef CMSPAR + else { + throw invalid_argument ("invalid parity"); + } + // setup flow control + if (flowcontrol_ == flowcontrol_none) { + xonxoff_ = false; + rtscts_ = false; + } + if (flowcontrol_ == flowcontrol_software) { + xonxoff_ = true; + rtscts_ = false; + } + if (flowcontrol_ == flowcontrol_hardware) { + xonxoff_ = false; + rtscts_ = true; + } + // xonxoff +#ifdef IXANY + if (xonxoff_) + options.c_iflag |= (IXON | IXOFF); //|IXANY) + else + options.c_iflag &= (tcflag_t) ~(IXON | IXOFF | IXANY); +#else + if (xonxoff_) + options.c_iflag |= (IXON | IXOFF); + else + options.c_iflag &= (tcflag_t) ~(IXON | IXOFF); +#endif + // rtscts +#ifdef CRTSCTS + if (rtscts_) + options.c_cflag |= (CRTSCTS); + else + options.c_cflag &= (unsigned long) ~(CRTSCTS); +#elif defined CNEW_RTSCTS + if (rtscts_) + options.c_cflag |= (CNEW_RTSCTS); + else + options.c_cflag &= (unsigned long) ~(CNEW_RTSCTS); +#else +#error "OS Support seems wrong." +#endif + + // http://www.unixwiz.net/techtips/termios-vmin-vtime.html + // this basically sets the read call up to be a polling read, + // but we are using select to ensure there is data available + // to read before each call, so we should never needlessly poll + options.c_cc[VMIN] = 0; + options.c_cc[VTIME] = 0; + + // activate settings + ::tcsetattr (fd_, TCSANOW, &options); + + // Update byte_time_ based on the new settings. + uint32_t bit_time_ns = 1e9 / baudrate_; + byte_time_ns_ = bit_time_ns * (1 + bytesize_ + parity_ + stopbits_); + + // Compensate for the stopbits_one_point_five enum being equal to int 3, + // and not 1.5. + if (stopbits_ == stopbits_one_point_five) { + byte_time_ns_ += ((1.5 - stopbits_one_point_five) * bit_time_ns); + } +} + +void +Serial::SerialImpl::close () +{ + if (is_open_ == true) { + if (fd_ != -1) { + int ret; + ret = ::close (fd_); + if (ret == 0) { + fd_ = -1; + } else { + THROW (IOException, errno); + } + } + is_open_ = false; + } +} + +bool +Serial::SerialImpl::isOpen () const +{ + return is_open_; +} + +size_t +Serial::SerialImpl::available () +{ + if (!is_open_) { + return 0; + } + int count = 0; + if (-1 == ioctl (fd_, TIOCINQ, &count)) { + THROW (IOException, errno); + } else { + return static_cast (count); + } +} + +bool +Serial::SerialImpl::waitReadable (uint32_t timeout) +{ + // Setup a select call to block for serial data or a timeout + fd_set readfds; + FD_ZERO (&readfds); + FD_SET (fd_, &readfds); + timespec timeout_ts (timespec_from_ms (timeout)); + int r = pselect (fd_ + 1, &readfds, NULL, NULL, &timeout_ts, NULL); + + if (r < 0) { + // Select was interrupted + if (errno == EINTR) { + return false; + } + // Otherwise there was some error + THROW (IOException, errno); + } + // Timeout occurred + if (r == 0) { + return false; + } + // This shouldn't happen, if r > 0 our fd has to be in the list! + if (!FD_ISSET (fd_, &readfds)) { + THROW (IOException, "select reports ready to read, but our fd isn't" + " in the list, this shouldn't happen!"); + } + // Data available to read. + return true; +} + +void +Serial::SerialImpl::waitByteTimes (size_t count) +{ + timespec wait_time = { 0, static_cast(byte_time_ns_ * count)}; + pselect (0, NULL, NULL, NULL, &wait_time, NULL); +} + +size_t +Serial::SerialImpl::read (uint8_t *buf, size_t size) +{ + // If the port is not open, throw + if (!is_open_) { + throw PortNotOpenedException ("Serial::read"); + } + size_t bytes_read = 0; + + // Calculate total timeout in milliseconds t_c + (t_m * N) + long total_timeout_ms = timeout_.read_timeout_constant; + total_timeout_ms += timeout_.read_timeout_multiplier * static_cast (size); + MillisecondTimer total_timeout(total_timeout_ms); + + // Pre-fill buffer with available bytes + { + ssize_t bytes_read_now = ::read (fd_, buf, size); + if (bytes_read_now > 0) { + bytes_read = bytes_read_now; + } + } + + while (bytes_read < size) { + int64_t timeout_remaining_ms = total_timeout.remaining(); + if (timeout_remaining_ms <= 0) { + // Timed out + break; + } + // Timeout for the next select is whichever is less of the remaining + // total read timeout and the inter-byte timeout. + uint32_t timeout = std::min(static_cast (timeout_remaining_ms), + timeout_.inter_byte_timeout); + // Wait for the device to be readable, and then attempt to read. + if (waitReadable(timeout)) { + // If it's a fixed-length multi-byte read, insert a wait here so that + // we can attempt to grab the whole thing in a single IO call. Skip + // this wait if a non-max inter_byte_timeout is specified. + if (size > 1 && timeout_.inter_byte_timeout == Timeout::max()) { + size_t bytes_available = available(); + if (bytes_available + bytes_read < size) { + waitByteTimes(size - (bytes_available + bytes_read)); + } + } + // This should be non-blocking returning only what is available now + // Then returning so that select can block again. + ssize_t bytes_read_now = + ::read (fd_, buf + bytes_read, size - bytes_read); + // read should always return some data as select reported it was + // ready to read when we get to this point. + if (bytes_read_now < 1) { + // Disconnected devices, at least on Linux, show the + // behavior that they are always ready to read immediately + // but reading returns nothing. + throw SerialException ("device reports readiness to read but " + "returned no data (device disconnected?)"); + } + // Update bytes_read + bytes_read += static_cast (bytes_read_now); + // If bytes_read == size then we have read everything we need + if (bytes_read == size) { + break; + } + // If bytes_read < size then we have more to read + if (bytes_read < size) { + continue; + } + // If bytes_read > size then we have over read, which shouldn't happen + if (bytes_read > size) { + throw SerialException ("read over read, too many bytes where " + "read, this shouldn't happen, might be " + "a logical error!"); + } + } + } + return bytes_read; +} + +size_t +Serial::SerialImpl::write (const uint8_t *data, size_t length) +{ + if (is_open_ == false) { + throw PortNotOpenedException ("Serial::write"); + } + fd_set writefds; + size_t bytes_written = 0; + + // Calculate total timeout in milliseconds t_c + (t_m * N) + long total_timeout_ms = timeout_.write_timeout_constant; + total_timeout_ms += timeout_.write_timeout_multiplier * static_cast (length); + MillisecondTimer total_timeout(total_timeout_ms); + + while (bytes_written < length) { + int64_t timeout_remaining_ms = total_timeout.remaining(); + if (timeout_remaining_ms <= 0) { + // Timed out + break; + } + timespec timeout(timespec_from_ms(timeout_remaining_ms)); + + FD_ZERO (&writefds); + FD_SET (fd_, &writefds); + + // Do the select + int r = pselect (fd_ + 1, NULL, &writefds, NULL, &timeout, NULL); + + // Figure out what happened by looking at select's response 'r' + /** Error **/ + if (r < 0) { + // Select was interrupted, try again + if (errno == EINTR) { + continue; + } + // Otherwise there was some error + THROW (IOException, errno); + } + /** Timeout **/ + if (r == 0) { + break; + } + /** Port ready to write **/ + if (r > 0) { + // Make sure our file descriptor is in the ready to write list + if (FD_ISSET (fd_, &writefds)) { + // This will write some + ssize_t bytes_written_now = + ::write (fd_, data + bytes_written, length - bytes_written); + // write should always return some data as select reported it was + // ready to write when we get to this point. + if (bytes_written_now < 1) { + // Disconnected devices, at least on Linux, show the + // behavior that they are always ready to write immediately + // but writing returns nothing. + throw SerialException ("device reports readiness to write but " + "returned no data (device disconnected?)"); + } + // Update bytes_written + bytes_written += static_cast (bytes_written_now); + // If bytes_written == size then we have written everything we need to + if (bytes_written == length) { + break; + } + // If bytes_written < size then we have more to write + if (bytes_written < length) { + continue; + } + // If bytes_written > size then we have over written, which shouldn't happen + if (bytes_written > length) { + throw SerialException ("write over wrote, too many bytes where " + "written, this shouldn't happen, might be " + "a logical error!"); + } + } + // This shouldn't happen, if r > 0 our fd has to be in the list! + THROW (IOException, "select reports ready to write, but our fd isn't" + " in the list, this shouldn't happen!"); + } + } + return bytes_written; +} + +void +Serial::SerialImpl::setPort (const string &port) +{ + port_ = port; +} + +string +Serial::SerialImpl::getPort () const +{ + return port_; +} + +void +Serial::SerialImpl::setTimeout (serial::Timeout &timeout) +{ + timeout_ = timeout; +} + +serial::Timeout +Serial::SerialImpl::getTimeout () const +{ + return timeout_; +} + +void +Serial::SerialImpl::setBaudrate (unsigned long baudrate) +{ + baudrate_ = baudrate; + if (is_open_) + reconfigurePort (); +} + +unsigned long +Serial::SerialImpl::getBaudrate () const +{ + return baudrate_; +} + +void +Serial::SerialImpl::setBytesize (serial::bytesize_t bytesize) +{ + bytesize_ = bytesize; + if (is_open_) + reconfigurePort (); +} + +serial::bytesize_t +Serial::SerialImpl::getBytesize () const +{ + return bytesize_; +} + +void +Serial::SerialImpl::setParity (serial::parity_t parity) +{ + parity_ = parity; + if (is_open_) + reconfigurePort (); +} + +serial::parity_t +Serial::SerialImpl::getParity () const +{ + return parity_; +} + +void +Serial::SerialImpl::setStopbits (serial::stopbits_t stopbits) +{ + stopbits_ = stopbits; + if (is_open_) + reconfigurePort (); +} + +serial::stopbits_t +Serial::SerialImpl::getStopbits () const +{ + return stopbits_; +} + +void +Serial::SerialImpl::setFlowcontrol (serial::flowcontrol_t flowcontrol) +{ + flowcontrol_ = flowcontrol; + if (is_open_) + reconfigurePort (); +} + +serial::flowcontrol_t +Serial::SerialImpl::getFlowcontrol () const +{ + return flowcontrol_; +} + +void +Serial::SerialImpl::flush () +{ + if (is_open_ == false) { + throw PortNotOpenedException ("Serial::flush"); + } + tcdrain (fd_); +} + +void +Serial::SerialImpl::flushInput () +{ + if (is_open_ == false) { + throw PortNotOpenedException ("Serial::flushInput"); + } + tcflush (fd_, TCIFLUSH); +} + +void +Serial::SerialImpl::flushOutput () +{ + if (is_open_ == false) { + throw PortNotOpenedException ("Serial::flushOutput"); + } + tcflush (fd_, TCOFLUSH); +} + +void +Serial::SerialImpl::sendBreak (int duration) +{ + if (is_open_ == false) { + throw PortNotOpenedException ("Serial::sendBreak"); + } + tcsendbreak (fd_, static_cast (duration / 4)); +} + +void +Serial::SerialImpl::setBreak (bool level) +{ + if (is_open_ == false) { + throw PortNotOpenedException ("Serial::setBreak"); + } + + if (level) { + if (-1 == ioctl (fd_, TIOCSBRK)) + { + stringstream ss; + ss << "setBreak failed on a call to ioctl(TIOCSBRK): " << errno << " " << strerror(errno); + throw(SerialException(ss.str().c_str())); + } + } else { + if (-1 == ioctl (fd_, TIOCCBRK)) + { + stringstream ss; + ss << "setBreak failed on a call to ioctl(TIOCCBRK): " << errno << " " << strerror(errno); + throw(SerialException(ss.str().c_str())); + } + } +} + +void +Serial::SerialImpl::setRTS (bool level) +{ + if (is_open_ == false) { + throw PortNotOpenedException ("Serial::setRTS"); + } + + int command = TIOCM_RTS; + + if (level) { + if (-1 == ioctl (fd_, TIOCMBIS, &command)) + { + stringstream ss; + ss << "setRTS failed on a call to ioctl(TIOCMBIS): " << errno << " " << strerror(errno); + throw(SerialException(ss.str().c_str())); + } + } else { + if (-1 == ioctl (fd_, TIOCMBIC, &command)) + { + stringstream ss; + ss << "setRTS failed on a call to ioctl(TIOCMBIC): " << errno << " " << strerror(errno); + throw(SerialException(ss.str().c_str())); + } + } +} + +void +Serial::SerialImpl::setDTR (bool level) +{ + if (is_open_ == false) { + throw PortNotOpenedException ("Serial::setDTR"); + } + + int command = TIOCM_DTR; + + if (level) { + if (-1 == ioctl (fd_, TIOCMBIS, &command)) + { + stringstream ss; + ss << "setDTR failed on a call to ioctl(TIOCMBIS): " << errno << " " << strerror(errno); + throw(SerialException(ss.str().c_str())); + } + } else { + if (-1 == ioctl (fd_, TIOCMBIC, &command)) + { + stringstream ss; + ss << "setDTR failed on a call to ioctl(TIOCMBIC): " << errno << " " << strerror(errno); + throw(SerialException(ss.str().c_str())); + } + } +} + +bool +Serial::SerialImpl::waitForChange () +{ +#ifndef TIOCMIWAIT + +while (is_open_ == true) { + + int status; + + if (-1 == ioctl (fd_, TIOCMGET, &status)) + { + stringstream ss; + ss << "waitForChange failed on a call to ioctl(TIOCMGET): " << errno << " " << strerror(errno); + throw(SerialException(ss.str().c_str())); + } + else + { + if (0 != (status & TIOCM_CTS) + || 0 != (status & TIOCM_DSR) + || 0 != (status & TIOCM_RI) + || 0 != (status & TIOCM_CD)) + { + return true; + } + } + + usleep(1000); + } + + return false; +#else + int command = (TIOCM_CD|TIOCM_DSR|TIOCM_RI|TIOCM_CTS); + + if (-1 == ioctl (fd_, TIOCMIWAIT, &command)) { + stringstream ss; + ss << "waitForDSR failed on a call to ioctl(TIOCMIWAIT): " + << errno << " " << strerror(errno); + throw(SerialException(ss.str().c_str())); + } + return true; +#endif +} + +bool +Serial::SerialImpl::getCTS () +{ + if (is_open_ == false) { + throw PortNotOpenedException ("Serial::getCTS"); + } + + int status; + + if (-1 == ioctl (fd_, TIOCMGET, &status)) + { + stringstream ss; + ss << "getCTS failed on a call to ioctl(TIOCMGET): " << errno << " " << strerror(errno); + throw(SerialException(ss.str().c_str())); + } + else + { + return 0 != (status & TIOCM_CTS); + } +} + +bool +Serial::SerialImpl::getDSR () +{ + if (is_open_ == false) { + throw PortNotOpenedException ("Serial::getDSR"); + } + + int status; + + if (-1 == ioctl (fd_, TIOCMGET, &status)) + { + stringstream ss; + ss << "getDSR failed on a call to ioctl(TIOCMGET): " << errno << " " << strerror(errno); + throw(SerialException(ss.str().c_str())); + } + else + { + return 0 != (status & TIOCM_DSR); + } +} + +bool +Serial::SerialImpl::getRI () +{ + if (is_open_ == false) { + throw PortNotOpenedException ("Serial::getRI"); + } + + int status; + + if (-1 == ioctl (fd_, TIOCMGET, &status)) + { + stringstream ss; + ss << "getRI failed on a call to ioctl(TIOCMGET): " << errno << " " << strerror(errno); + throw(SerialException(ss.str().c_str())); + } + else + { + return 0 != (status & TIOCM_RI); + } +} + +bool +Serial::SerialImpl::getCD () +{ + if (is_open_ == false) { + throw PortNotOpenedException ("Serial::getCD"); + } + + int status; + + if (-1 == ioctl (fd_, TIOCMGET, &status)) + { + stringstream ss; + ss << "getCD failed on a call to ioctl(TIOCMGET): " << errno << " " << strerror(errno); + throw(SerialException(ss.str().c_str())); + } + else + { + return 0 != (status & TIOCM_CD); + } +} + +void +Serial::SerialImpl::readLock () +{ + int result = pthread_mutex_lock(&this->read_mutex); + if (result) { + THROW (IOException, result); + } +} + +void +Serial::SerialImpl::readUnlock () +{ + int result = pthread_mutex_unlock(&this->read_mutex); + if (result) { + THROW (IOException, result); + } +} + +void +Serial::SerialImpl::writeLock () +{ + int result = pthread_mutex_lock(&this->write_mutex); + if (result) { + THROW (IOException, result); + } +} + +void +Serial::SerialImpl::writeUnlock () +{ + int result = pthread_mutex_unlock(&this->write_mutex); + if (result) { + THROW (IOException, result); + } +} + +#endif // !defined(_WIN32) diff --git a/Racer/lib/serial/src/impl/win.cc b/Racer/lib/serial/src/impl/win.cc new file mode 100644 index 0000000..dc72028 --- /dev/null +++ b/Racer/lib/serial/src/impl/win.cc @@ -0,0 +1,640 @@ +#if defined(_WIN32) + +/* Copyright 2012 William Woodall and John Harrison */ + +#include + +#include "include/impl/win.h" + +using std::string; +using std::wstring; +using std::stringstream; +using std::invalid_argument; +using serial::Serial; +using serial::Timeout; +using serial::bytesize_t; +using serial::parity_t; +using serial::stopbits_t; +using serial::flowcontrol_t; +using serial::SerialException; +using serial::PortNotOpenedException; +using serial::IOException; + +inline wstring +_prefix_port_if_needed(const wstring &input) +{ + static wstring windows_com_port_prefix = L"\\\\.\\"; + if (input.compare(windows_com_port_prefix) != 0) + { + return windows_com_port_prefix + input; + } + return input; +} + +Serial::SerialImpl::SerialImpl (const string &port, unsigned long baudrate, + bytesize_t bytesize, + parity_t parity, stopbits_t stopbits, + flowcontrol_t flowcontrol) + : port_ (port.begin(), port.end()), fd_ (INVALID_HANDLE_VALUE), is_open_ (false), + baudrate_ (baudrate), parity_ (parity), + bytesize_ (bytesize), stopbits_ (stopbits), flowcontrol_ (flowcontrol) +{ + read_mutex = CreateMutex(NULL, false, NULL); + write_mutex = CreateMutex(NULL, false, NULL); + if (port_.empty () == false) + open (); +} + +Serial::SerialImpl::~SerialImpl () +{ + this->close(); + CloseHandle(read_mutex); + CloseHandle(write_mutex); +} + +void +Serial::SerialImpl::open () +{ + if (port_.empty ()) { + throw invalid_argument ("Empty port is invalid."); + } + if (is_open_ == true) { + throw SerialException ("Serial port already open."); + } + + // See: https://github.com/wjwwood/serial/issues/84 + wstring port_with_prefix = _prefix_port_if_needed(port_); + LPCWSTR lp_port = port_with_prefix.c_str(); + fd_ = CreateFileW(lp_port, + GENERIC_READ | GENERIC_WRITE, + 0, + 0, + OPEN_EXISTING, + FILE_ATTRIBUTE_NORMAL, + 0); + + if (fd_ == INVALID_HANDLE_VALUE) { + DWORD errno_ = GetLastError(); + stringstream ss; + switch (errno_) { + case ERROR_FILE_NOT_FOUND: + // Use this->getPort to convert to a std::string + ss << "Specified port, " << this->getPort() << ", does not exist."; + THROW (IOException, ss.str().c_str()); + default: + ss << "Unknown error opening the serial port: " << errno; + THROW (IOException, ss.str().c_str()); + } + } + + reconfigurePort(); + is_open_ = true; +} + +void +Serial::SerialImpl::reconfigurePort () +{ + if (fd_ == INVALID_HANDLE_VALUE) { + // Can only operate on a valid file descriptor + THROW (IOException, "Invalid file descriptor, is the serial port open?"); + } + + DCB dcbSerialParams = {0}; + + dcbSerialParams.DCBlength=sizeof(dcbSerialParams); + + if (!GetCommState(fd_, &dcbSerialParams)) { + //error getting state + THROW (IOException, "Error getting the serial port state."); + } + + // setup baud rate + switch (baudrate_) { +#ifdef CBR_0 + case 0: dcbSerialParams.BaudRate = CBR_0; break; +#endif +#ifdef CBR_50 + case 50: dcbSerialParams.BaudRate = CBR_50; break; +#endif +#ifdef CBR_75 + case 75: dcbSerialParams.BaudRate = CBR_75; break; +#endif +#ifdef CBR_110 + case 110: dcbSerialParams.BaudRate = CBR_110; break; +#endif +#ifdef CBR_134 + case 134: dcbSerialParams.BaudRate = CBR_134; break; +#endif +#ifdef CBR_150 + case 150: dcbSerialParams.BaudRate = CBR_150; break; +#endif +#ifdef CBR_200 + case 200: dcbSerialParams.BaudRate = CBR_200; break; +#endif +#ifdef CBR_300 + case 300: dcbSerialParams.BaudRate = CBR_300; break; +#endif +#ifdef CBR_600 + case 600: dcbSerialParams.BaudRate = CBR_600; break; +#endif +#ifdef CBR_1200 + case 1200: dcbSerialParams.BaudRate = CBR_1200; break; +#endif +#ifdef CBR_1800 + case 1800: dcbSerialParams.BaudRate = CBR_1800; break; +#endif +#ifdef CBR_2400 + case 2400: dcbSerialParams.BaudRate = CBR_2400; break; +#endif +#ifdef CBR_4800 + case 4800: dcbSerialParams.BaudRate = CBR_4800; break; +#endif +#ifdef CBR_7200 + case 7200: dcbSerialParams.BaudRate = CBR_7200; break; +#endif +#ifdef CBR_9600 + case 9600: dcbSerialParams.BaudRate = CBR_9600; break; +#endif +#ifdef CBR_14400 + case 14400: dcbSerialParams.BaudRate = CBR_14400; break; +#endif +#ifdef CBR_19200 + case 19200: dcbSerialParams.BaudRate = CBR_19200; break; +#endif +#ifdef CBR_28800 + case 28800: dcbSerialParams.BaudRate = CBR_28800; break; +#endif +#ifdef CBR_57600 + case 57600: dcbSerialParams.BaudRate = CBR_57600; break; +#endif +#ifdef CBR_76800 + case 76800: dcbSerialParams.BaudRate = CBR_76800; break; +#endif +#ifdef CBR_38400 + case 38400: dcbSerialParams.BaudRate = CBR_38400; break; +#endif +#ifdef CBR_115200 + case 115200: dcbSerialParams.BaudRate = CBR_115200; break; +#endif +#ifdef CBR_128000 + case 128000: dcbSerialParams.BaudRate = CBR_128000; break; +#endif +#ifdef CBR_153600 + case 153600: dcbSerialParams.BaudRate = CBR_153600; break; +#endif +#ifdef CBR_230400 + case 230400: dcbSerialParams.BaudRate = CBR_230400; break; +#endif +#ifdef CBR_256000 + case 256000: dcbSerialParams.BaudRate = CBR_256000; break; +#endif +#ifdef CBR_460800 + case 460800: dcbSerialParams.BaudRate = CBR_460800; break; +#endif +#ifdef CBR_921600 + case 921600: dcbSerialParams.BaudRate = CBR_921600; break; +#endif + default: + // Try to blindly assign it + dcbSerialParams.BaudRate = baudrate_; + } + + // setup char len + if (bytesize_ == eightbits) + dcbSerialParams.ByteSize = 8; + else if (bytesize_ == sevenbits) + dcbSerialParams.ByteSize = 7; + else if (bytesize_ == sixbits) + dcbSerialParams.ByteSize = 6; + else if (bytesize_ == fivebits) + dcbSerialParams.ByteSize = 5; + else + throw invalid_argument ("invalid char len"); + + // setup stopbits + if (stopbits_ == stopbits_one) + dcbSerialParams.StopBits = ONESTOPBIT; + else if (stopbits_ == stopbits_one_point_five) + dcbSerialParams.StopBits = ONE5STOPBITS; + else if (stopbits_ == stopbits_two) + dcbSerialParams.StopBits = TWOSTOPBITS; + else + throw invalid_argument ("invalid stop bit"); + + // setup parity + if (parity_ == parity_none) { + dcbSerialParams.Parity = NOPARITY; + } else if (parity_ == parity_even) { + dcbSerialParams.Parity = EVENPARITY; + } else if (parity_ == parity_odd) { + dcbSerialParams.Parity = ODDPARITY; + } else if (parity_ == parity_mark) { + dcbSerialParams.Parity = MARKPARITY; + } else if (parity_ == parity_space) { + dcbSerialParams.Parity = SPACEPARITY; + } else { + throw invalid_argument ("invalid parity"); + } + + // setup flowcontrol + if (flowcontrol_ == flowcontrol_none) { + dcbSerialParams.fOutxCtsFlow = false; + dcbSerialParams.fRtsControl = 0x00; + dcbSerialParams.fOutX = false; + dcbSerialParams.fInX = false; + } + if (flowcontrol_ == flowcontrol_software) { + dcbSerialParams.fOutxCtsFlow = false; + dcbSerialParams.fRtsControl = 0x00; + dcbSerialParams.fOutX = true; + dcbSerialParams.fInX = true; + } + if (flowcontrol_ == flowcontrol_hardware) { + dcbSerialParams.fOutxCtsFlow = true; + dcbSerialParams.fRtsControl = 0x03; + dcbSerialParams.fOutX = false; + dcbSerialParams.fInX = false; + } + + // activate settings + if (!SetCommState(fd_, &dcbSerialParams)){ + CloseHandle(fd_); + THROW (IOException, "Error setting serial port settings."); + } + + // Setup timeouts + COMMTIMEOUTS timeouts = {0}; + timeouts.ReadIntervalTimeout = timeout_.inter_byte_timeout; + timeouts.ReadTotalTimeoutConstant = timeout_.read_timeout_constant; + timeouts.ReadTotalTimeoutMultiplier = timeout_.read_timeout_multiplier; + timeouts.WriteTotalTimeoutConstant = timeout_.write_timeout_constant; + timeouts.WriteTotalTimeoutMultiplier = timeout_.write_timeout_multiplier; + if (!SetCommTimeouts(fd_, &timeouts)) { + THROW (IOException, "Error setting timeouts."); + } +} + +void +Serial::SerialImpl::close () +{ + if (is_open_ == true) { + if (fd_ != INVALID_HANDLE_VALUE) { + int ret; + ret = CloseHandle(fd_); + if (ret == 0) { + stringstream ss; + ss << "Error while closing serial port: " << GetLastError(); + THROW (IOException, ss.str().c_str()); + } else { + fd_ = INVALID_HANDLE_VALUE; + } + } + is_open_ = false; + } +} + +bool +Serial::SerialImpl::isOpen () const +{ + return is_open_; +} + +size_t +Serial::SerialImpl::available () +{ + if (!is_open_) { + return 0; + } + COMSTAT cs; + if (!ClearCommError(fd_, NULL, &cs)) { + stringstream ss; + ss << "Error while checking status of the serial port: " << GetLastError(); + THROW (IOException, ss.str().c_str()); + } + return static_cast(cs.cbInQue); +} + +bool +Serial::SerialImpl::waitReadable (uint32_t /*timeout*/) +{ + THROW (IOException, "waitReadable is not implemented on Windows."); + return false; +} + +void +Serial::SerialImpl::waitByteTimes (size_t /*count*/) +{ + THROW (IOException, "waitByteTimes is not implemented on Windows."); +} + +size_t +Serial::SerialImpl::read (uint8_t *buf, size_t size) +{ + if (!is_open_) { + throw PortNotOpenedException ("Serial::read"); + } + DWORD bytes_read; + if (!ReadFile(fd_, buf, static_cast(size), &bytes_read, NULL)) { + stringstream ss; + ss << "Error while reading from the serial port: " << GetLastError(); + THROW (IOException, ss.str().c_str()); + } + return (size_t) (bytes_read); +} + +size_t +Serial::SerialImpl::write (const uint8_t *data, size_t length) +{ + if (is_open_ == false) { + throw PortNotOpenedException ("Serial::write"); + } + DWORD bytes_written; + if (!WriteFile(fd_, data, static_cast(length), &bytes_written, NULL)) { + stringstream ss; + ss << "Error while writing to the serial port: " << GetLastError(); + THROW (IOException, ss.str().c_str()); + } + return (size_t) (bytes_written); +} + +void +Serial::SerialImpl::setPort (const string &port) +{ + port_ = wstring(port.begin(), port.end()); +} + +string +Serial::SerialImpl::getPort () const +{ + return string(port_.begin(), port_.end()); +} + +void +Serial::SerialImpl::setTimeout (serial::Timeout &timeout) +{ + timeout_ = timeout; + if (is_open_) { + reconfigurePort (); + } +} + +serial::Timeout +Serial::SerialImpl::getTimeout () const +{ + return timeout_; +} + +void +Serial::SerialImpl::setBaudrate (unsigned long baudrate) +{ + baudrate_ = baudrate; + if (is_open_) { + reconfigurePort (); + } +} + +unsigned long +Serial::SerialImpl::getBaudrate () const +{ + return baudrate_; +} + +void +Serial::SerialImpl::setBytesize (serial::bytesize_t bytesize) +{ + bytesize_ = bytesize; + if (is_open_) { + reconfigurePort (); + } +} + +serial::bytesize_t +Serial::SerialImpl::getBytesize () const +{ + return bytesize_; +} + +void +Serial::SerialImpl::setParity (serial::parity_t parity) +{ + parity_ = parity; + if (is_open_) { + reconfigurePort (); + } +} + +serial::parity_t +Serial::SerialImpl::getParity () const +{ + return parity_; +} + +void +Serial::SerialImpl::setStopbits (serial::stopbits_t stopbits) +{ + stopbits_ = stopbits; + if (is_open_) { + reconfigurePort (); + } +} + +serial::stopbits_t +Serial::SerialImpl::getStopbits () const +{ + return stopbits_; +} + +void +Serial::SerialImpl::setFlowcontrol (serial::flowcontrol_t flowcontrol) +{ + flowcontrol_ = flowcontrol; + if (is_open_) { + reconfigurePort (); + } +} + +serial::flowcontrol_t +Serial::SerialImpl::getFlowcontrol () const +{ + return flowcontrol_; +} + +void +Serial::SerialImpl::flush () +{ + if (is_open_ == false) { + throw PortNotOpenedException ("Serial::flush"); + } + FlushFileBuffers (fd_); +} + +void +Serial::SerialImpl::flushInput () +{ + THROW (IOException, "flushInput is not supported on Windows."); +} + +void +Serial::SerialImpl::flushOutput () +{ + THROW (IOException, "flushOutput is not supported on Windows."); +} + +void +Serial::SerialImpl::sendBreak (int /*duration*/) +{ + THROW (IOException, "sendBreak is not supported on Windows."); +} + +void +Serial::SerialImpl::setBreak (bool level) +{ + if (is_open_ == false) { + throw PortNotOpenedException ("Serial::setBreak"); + } + if (level) { + EscapeCommFunction (fd_, SETBREAK); + } else { + EscapeCommFunction (fd_, CLRBREAK); + } +} + +void +Serial::SerialImpl::setRTS (bool level) +{ + if (is_open_ == false) { + throw PortNotOpenedException ("Serial::setRTS"); + } + if (level) { + EscapeCommFunction (fd_, SETRTS); + } else { + EscapeCommFunction (fd_, CLRRTS); + } +} + +void +Serial::SerialImpl::setDTR (bool level) +{ + if (is_open_ == false) { + throw PortNotOpenedException ("Serial::setDTR"); + } + if (level) { + EscapeCommFunction (fd_, SETDTR); + } else { + EscapeCommFunction (fd_, CLRDTR); + } +} + +bool +Serial::SerialImpl::waitForChange () +{ + if (is_open_ == false) { + throw PortNotOpenedException ("Serial::waitForChange"); + } + DWORD dwCommEvent; + + if (!SetCommMask(fd_, EV_CTS | EV_DSR | EV_RING | EV_RLSD)) { + // Error setting communications mask + return false; + } + + if (!WaitCommEvent(fd_, &dwCommEvent, NULL)) { + // An error occurred waiting for the event. + return false; + } else { + // Event has occurred. + return true; + } +} + +bool +Serial::SerialImpl::getCTS () +{ + if (is_open_ == false) { + throw PortNotOpenedException ("Serial::getCTS"); + } + DWORD dwModemStatus; + if (!GetCommModemStatus(fd_, &dwModemStatus)) { + THROW (IOException, "Error getting the status of the CTS line."); + } + + return (MS_CTS_ON & dwModemStatus) != 0; +} + +bool +Serial::SerialImpl::getDSR () +{ + if (is_open_ == false) { + throw PortNotOpenedException ("Serial::getDSR"); + } + DWORD dwModemStatus; + if (!GetCommModemStatus(fd_, &dwModemStatus)) { + THROW (IOException, "Error getting the status of the DSR line."); + } + + return (MS_DSR_ON & dwModemStatus) != 0; +} + +bool +Serial::SerialImpl::getRI() +{ + if (is_open_ == false) { + throw PortNotOpenedException ("Serial::getRI"); + } + DWORD dwModemStatus; + if (!GetCommModemStatus(fd_, &dwModemStatus)) { + THROW (IOException, "Error getting the status of the RI line."); + } + + return (MS_RING_ON & dwModemStatus) != 0; +} + +bool +Serial::SerialImpl::getCD() +{ + if (is_open_ == false) { + throw PortNotOpenedException ("Serial::getCD"); + } + DWORD dwModemStatus; + if (!GetCommModemStatus(fd_, &dwModemStatus)) { + // Error in GetCommModemStatus; + THROW (IOException, "Error getting the status of the CD line."); + } + + return (MS_RLSD_ON & dwModemStatus) != 0; +} + +void +Serial::SerialImpl::readLock() +{ + if (WaitForSingleObject(read_mutex, INFINITE) != WAIT_OBJECT_0) { + THROW (IOException, "Error claiming read mutex."); + } +} + +void +Serial::SerialImpl::readUnlock() +{ + if (!ReleaseMutex(read_mutex)) { + THROW (IOException, "Error releasing read mutex."); + } +} + +void +Serial::SerialImpl::writeLock() +{ + if (WaitForSingleObject(write_mutex, INFINITE) != WAIT_OBJECT_0) { + THROW (IOException, "Error claiming write mutex."); + } +} + +void +Serial::SerialImpl::writeUnlock() +{ + if (!ReleaseMutex(write_mutex)) { + THROW (IOException, "Error releasing write mutex."); + } +} + +#endif // #if defined(_WIN32) + diff --git a/Racer/lib/serial/src/serial.cc b/Racer/lib/serial/src/serial.cc new file mode 100644 index 0000000..2a7a108 --- /dev/null +++ b/Racer/lib/serial/src/serial.cc @@ -0,0 +1,415 @@ +/* Copyright 2012 William Woodall and John Harrison */ +#include + +#if !defined(_WIN32) && !defined(__OpenBSD__) && !defined(__FreeBSD__) +# include +#endif + +#if defined (__MINGW32__) +# define alloca __builtin_alloca +#endif + + +#ifdef _WIN32 +#include "include/serial.h" +#include "include/impl/win.h" +#else +#include "../include/serial.h" +#include "../include/impl/unix.h" +#endif + +using std::invalid_argument; +using std::min; +using std::numeric_limits; +using std::vector; +using std::size_t; +using std::string; + +using serial::Serial; +using serial::SerialException; +using serial::IOException; +using serial::bytesize_t; +using serial::parity_t; +using serial::stopbits_t; +using serial::flowcontrol_t; + +class Serial::ScopedReadLock { +public: + ScopedReadLock(SerialImpl *pimpl) : pimpl_(pimpl) { + this->pimpl_->readLock(); + } + ~ScopedReadLock() { + this->pimpl_->readUnlock(); + } +private: + // Disable copy constructors + ScopedReadLock(const ScopedReadLock&); + const ScopedReadLock& operator=(ScopedReadLock); + + SerialImpl *pimpl_; +}; + +class Serial::ScopedWriteLock { +public: + ScopedWriteLock(SerialImpl *pimpl) : pimpl_(pimpl) { + this->pimpl_->writeLock(); + } + ~ScopedWriteLock() { + this->pimpl_->writeUnlock(); + } +private: + // Disable copy constructors + ScopedWriteLock(const ScopedWriteLock&); + const ScopedWriteLock& operator=(ScopedWriteLock); + SerialImpl *pimpl_; +}; + +Serial::Serial (const string &port, uint32_t baudrate, serial::Timeout timeout, + bytesize_t bytesize, parity_t parity, stopbits_t stopbits, + flowcontrol_t flowcontrol) + : pimpl_(new SerialImpl (port, baudrate, bytesize, parity, + stopbits, flowcontrol)) +{ + pimpl_->setTimeout(timeout); +} + +Serial::~Serial () +{ + delete pimpl_; +} + +void +Serial::open () +{ + pimpl_->open (); +} + +void +Serial::close () +{ + pimpl_->close (); +} + +bool +Serial::isOpen () const +{ + return pimpl_->isOpen (); +} + +size_t +Serial::available () +{ + return pimpl_->available (); +} + +bool +Serial::waitReadable () +{ + serial::Timeout timeout(pimpl_->getTimeout ()); + return pimpl_->waitReadable(timeout.read_timeout_constant); +} + +void +Serial::waitByteTimes (size_t count) +{ + pimpl_->waitByteTimes(count); +} + +size_t +Serial::read_ (uint8_t *buffer, size_t size) +{ + return this->pimpl_->read (buffer, size); +} + +size_t +Serial::read (uint8_t *buffer, size_t size) +{ + ScopedReadLock lock(this->pimpl_); + return this->pimpl_->read (buffer, size); +} + +size_t +Serial::read (std::vector &buffer, size_t size) +{ + ScopedReadLock lock(this->pimpl_); + uint8_t *buffer_ = new uint8_t[size]; + size_t bytes_read = this->pimpl_->read (buffer_, size); + buffer.insert (buffer.end (), buffer_, buffer_+bytes_read); + delete[] buffer_; + return bytes_read; +} + +size_t +Serial::read (std::string &buffer, size_t size) +{ + ScopedReadLock lock(this->pimpl_); + uint8_t *buffer_ = new uint8_t[size]; + size_t bytes_read = this->pimpl_->read (buffer_, size); + buffer.append (reinterpret_cast(buffer_), bytes_read); + delete[] buffer_; + return bytes_read; +} + +string +Serial::read (size_t size) +{ + std::string buffer; + this->read (buffer, size); + return buffer; +} + +size_t +Serial::readline (string &buffer, size_t size, string eol) +{ + ScopedReadLock lock(this->pimpl_); + size_t eol_len = eol.length (); + uint8_t *buffer_ = static_cast + (alloca (size * sizeof (uint8_t))); + size_t read_so_far = 0; + while (true) + { + size_t bytes_read = this->read_ (buffer_ + read_so_far, 1); + read_so_far += bytes_read; + if (bytes_read == 0) { + break; // Timeout occured on reading 1 byte + } + if (string (reinterpret_cast + (buffer_ + read_so_far - eol_len), eol_len) == eol) { + break; // EOL found + } + if (read_so_far == size) { + break; // Reached the maximum read length + } + } + buffer.append(reinterpret_cast (buffer_), read_so_far); + return read_so_far; +} + +string +Serial::readline (size_t size, string eol) +{ + std::string buffer; + this->readline (buffer, size, eol); + return buffer; +} + +vector +Serial::readlines (size_t size, string eol) +{ + ScopedReadLock lock(this->pimpl_); + std::vector lines; + size_t eol_len = eol.length (); + uint8_t *buffer_ = static_cast + (alloca (size * sizeof (uint8_t))); + size_t read_so_far = 0; + size_t start_of_line = 0; + while (read_so_far < size) { + size_t bytes_read = this->read_ (buffer_+read_so_far, 1); + read_so_far += bytes_read; + if (bytes_read == 0) { + if (start_of_line != read_so_far) { + lines.push_back ( + string (reinterpret_cast (buffer_ + start_of_line), + read_so_far - start_of_line)); + } + break; // Timeout occured on reading 1 byte + } + if (string (reinterpret_cast + (buffer_ + read_so_far - eol_len), eol_len) == eol) { + // EOL found + lines.push_back( + string(reinterpret_cast (buffer_ + start_of_line), + read_so_far - start_of_line)); + start_of_line = read_so_far; + } + if (read_so_far == size) { + if (start_of_line != read_so_far) { + lines.push_back( + string(reinterpret_cast (buffer_ + start_of_line), + read_so_far - start_of_line)); + } + break; // Reached the maximum read length + } + } + return lines; +} + +size_t +Serial::write (const string &data) +{ + ScopedWriteLock lock(this->pimpl_); + return this->write_ (reinterpret_cast(data.c_str()), + data.length()); +} + +size_t +Serial::write (const std::vector &data) +{ + ScopedWriteLock lock(this->pimpl_); + return this->write_ (&data[0], data.size()); +} + +size_t +Serial::write (const uint8_t *data, size_t size) +{ + ScopedWriteLock lock(this->pimpl_); + return this->write_(data, size); +} + +size_t +Serial::write_ (const uint8_t *data, size_t length) +{ + return pimpl_->write (data, length); +} + +void +Serial::setPort (const string &port) +{ + ScopedReadLock rlock(this->pimpl_); + ScopedWriteLock wlock(this->pimpl_); + bool was_open = pimpl_->isOpen (); + if (was_open) close(); + pimpl_->setPort (port); + if (was_open) open (); +} + +string +Serial::getPort () const +{ + return pimpl_->getPort (); +} + +void +Serial::setTimeout (serial::Timeout &timeout) +{ + pimpl_->setTimeout (timeout); +} + +serial::Timeout +Serial::getTimeout () const { + return pimpl_->getTimeout (); +} + +void +Serial::setBaudrate (uint32_t baudrate) +{ + pimpl_->setBaudrate (baudrate); +} + +uint32_t +Serial::getBaudrate () const +{ + return uint32_t(pimpl_->getBaudrate ()); +} + +void +Serial::setBytesize (bytesize_t bytesize) +{ + pimpl_->setBytesize (bytesize); +} + +bytesize_t +Serial::getBytesize () const +{ + return pimpl_->getBytesize (); +} + +void +Serial::setParity (parity_t parity) +{ + pimpl_->setParity (parity); +} + +parity_t +Serial::getParity () const +{ + return pimpl_->getParity (); +} + +void +Serial::setStopbits (stopbits_t stopbits) +{ + pimpl_->setStopbits (stopbits); +} + +stopbits_t +Serial::getStopbits () const +{ + return pimpl_->getStopbits (); +} + +void +Serial::setFlowcontrol (flowcontrol_t flowcontrol) +{ + pimpl_->setFlowcontrol (flowcontrol); +} + +flowcontrol_t +Serial::getFlowcontrol () const +{ + return pimpl_->getFlowcontrol (); +} + +void Serial::flush () +{ + ScopedReadLock rlock(this->pimpl_); + ScopedWriteLock wlock(this->pimpl_); + pimpl_->flush (); +} + +void Serial::flushInput () +{ + ScopedReadLock lock(this->pimpl_); + pimpl_->flushInput (); +} + +void Serial::flushOutput () +{ + ScopedWriteLock lock(this->pimpl_); + pimpl_->flushOutput (); +} + +void Serial::sendBreak (int duration) +{ + pimpl_->sendBreak (duration); +} + +void Serial::setBreak (bool level) +{ + pimpl_->setBreak (level); +} + +void Serial::setRTS (bool level) +{ + pimpl_->setRTS (level); +} + +void Serial::setDTR (bool level) +{ + pimpl_->setDTR (level); +} + +bool Serial::waitForChange() +{ + return pimpl_->waitForChange(); +} + +bool Serial::getCTS () +{ + return pimpl_->getCTS (); +} + +bool Serial::getDSR () +{ + return pimpl_->getDSR (); +} + +bool Serial::getRI () +{ + return pimpl_->getRI (); +} + +bool Serial::getCD () +{ + return pimpl_->getCD (); +} \ No newline at end of file diff --git a/Racer/openAL/include/EFX-Util.h b/Racer/openAL/include/EFX-Util.h new file mode 100644 index 0000000..2042a58 --- /dev/null +++ b/Racer/openAL/include/EFX-Util.h @@ -0,0 +1,446 @@ +/*******************************************************************\ +* * +* EFX-UTIL.H - EFX Utilities functions and Reverb Presets * +* * +* File revision 1.0 * +* * +\*******************************************************************/ + +#ifndef EFX_UTIL_H_INCLUDED +#define EFX_UTIL_H_INCLUDED + +#ifdef __cplusplus +extern "C" { +#endif // __cplusplus + +#pragma pack(push, 4) + +#ifndef EAXVECTOR_DEFINED +#define EAXVECTOR_DEFINED +typedef struct _EAXVECTOR { + float x; + float y; + float z; +} EAXVECTOR; +#endif + +#ifndef EAXREVERBPROPERTIES_DEFINED +#define EAXREVERBPROPERTIES_DEFINED +typedef struct _EAXREVERBPROPERTIES +{ + unsigned long ulEnvironment; + float flEnvironmentSize; + float flEnvironmentDiffusion; + long lRoom; + long lRoomHF; + long lRoomLF; + float flDecayTime; + float flDecayHFRatio; + float flDecayLFRatio; + long lReflections; + float flReflectionsDelay; + EAXVECTOR vReflectionsPan; + long lReverb; + float flReverbDelay; + EAXVECTOR vReverbPan; + float flEchoTime; + float flEchoDepth; + float flModulationTime; + float flModulationDepth; + float flAirAbsorptionHF; + float flHFReference; + float flLFReference; + float flRoomRolloffFactor; + unsigned long ulFlags; +} EAXREVERBPROPERTIES, *LPEAXREVERBPROPERTIES; +#endif + +#ifndef EFXEAXREVERBPROPERTIES_DEFINED +#define EFXEAXREVERBPROPERTIES_DEFINED +typedef struct +{ + float flDensity; + float flDiffusion; + float flGain; + float flGainHF; + float flGainLF; + float flDecayTime; + float flDecayHFRatio; + float flDecayLFRatio; + float flReflectionsGain; + float flReflectionsDelay; + float flReflectionsPan[3]; + float flLateReverbGain; + float flLateReverbDelay; + float flLateReverbPan[3]; + float flEchoTime; + float flEchoDepth; + float flModulationTime; + float flModulationDepth; + float flAirAbsorptionGainHF; + float flHFReference; + float flLFReference; + float flRoomRolloffFactor; + int iDecayHFLimit; +} EFXEAXREVERBPROPERTIES, *LPEFXEAXREVERBPROPERTIES; +#endif + +#ifndef EAXOBSTRUCTIONPROPERTIES_DEFINED +#define EAXOBSTRUCTIONPROPERTIES_DEFINED +typedef struct _EAXOBSTRUCTIONPROPERTIES +{ + long lObstruction; + float flObstructionLFRatio; +} EAXOBSTRUCTIONPROPERTIES, *LPEAXOBSTRUCTIONPROPERTIES; +#endif + +#ifndef EAXOCCLUSIONPROPERTIES_DEFINED +#define EAXOCCLUSIONPROPERTIES_DEFINED +typedef struct _EAXOCCLUSIONPROPERTIES +{ + long lOcclusion; + float flOcclusionLFRatio; + float flOcclusionRoomRatio; + float flOcclusionDirectRatio; +} EAXOCCLUSIONPROPERTIES, *LPEAXOCCLUSIONPROPERTIES; +#endif + +#ifndef EAXEXCLUSIONPROPERTIES_DEFINED +#define EAXEXCLUSIONPROPERTIES_DEFINED +typedef struct _EAXEXCLUSIONPROPERTIES +{ + long lExclusion; + float flExclusionLFRatio; +} EAXEXCLUSIONPROPERTIES, *LPEAXEXCLUSIONPROPERTIES; +#endif + +#ifndef EFXLOWPASSFILTER_DEFINED +#define EFXLOWPASSFILTER_DEFINED +typedef struct _EFXLOWPASSFILTER +{ + float flGain; + float flGainHF; +} EFXLOWPASSFILTER, *LPEFXLOWPASSFILTER; +#endif + +#ifdef EFXUTILDLL_EXPORTS + #define EFX_API __declspec(dllexport) +#else + #define EFX_API +#endif + +EFX_API void __cdecl ConvertReverbParameters(EAXREVERBPROPERTIES *pEAXProp, EFXEAXREVERBPROPERTIES *pEFXEAXReverb); +EFX_API void __cdecl ConvertObstructionParameters(EAXOBSTRUCTIONPROPERTIES *pObProp, EFXLOWPASSFILTER *pDirectLowPassFilter); +EFX_API void __cdecl ConvertExclusionParameters(EAXEXCLUSIONPROPERTIES *pExProp, EFXLOWPASSFILTER *pSendLowPassFilter); +EFX_API void __cdecl ConvertOcclusionParameters(EAXOCCLUSIONPROPERTIES *pOcProp, EFXLOWPASSFILTER *pDirectLowPassFilter, EFXLOWPASSFILTER *pSendLowPassFilter); +EFX_API void __cdecl AdjustEnvironmentSize(EAXREVERBPROPERTIES *pEAXProp, float flEnvironmentSize); + +/***********************************************************************************************\ +* +* EAX Reverb Presets in legacy format - use ConvertReverbParameters() to convert to +* EFX EAX Reverb Presets for use with the OpenAL Effects Extension. +* +************************************************************************************************/ + +// Env Size Diffus Room RoomHF RoomLF DecTm DcHF DcLF Refl RefDel Ref Pan Revb RevDel Rev Pan EchTm EchDp ModTm ModDp AirAbs HFRef LFRef RRlOff FLAGS +#define REVERB_PRESET_GENERIC \ + {0, 7.5f, 1.000f, -1000, -100, 0, 1.49f, 0.83f, 1.00f, -2602, 0.007f, 0.00f,0.00f,0.00f, 200, 0.011f, 0.00f,0.00f,0.00f, 0.250f, 0.000f, 0.250f, 0.000f, -5.0f, 5000.0f, 250.0f, 0.00f, 0x3f } +#define REVERB_PRESET_PADDEDCELL \ + {1, 1.4f, 1.000f, -1000, -6000, 0, 0.17f, 0.10f, 1.00f, -1204, 0.001f, 0.00f,0.00f,0.00f, 207, 0.002f, 0.00f,0.00f,0.00f, 0.250f, 0.000f, 0.250f, 0.000f, -5.0f, 5000.0f, 250.0f, 0.00f, 0x3f } +#define REVERB_PRESET_ROOM \ + {2, 1.9f, 1.000f, -1000, -454, 0, 0.40f, 0.83f, 1.00f, -1646, 0.002f, 0.00f,0.00f,0.00f, 53, 0.003f, 0.00f,0.00f,0.00f, 0.250f, 0.000f, 0.250f, 0.000f, -5.0f, 5000.0f, 250.0f, 0.00f, 0x3f } +#define REVERB_PRESET_BATHROOM \ + {3, 1.4f, 1.000f, -1000, -1200, 0, 1.49f, 0.54f, 1.00f, -370, 0.007f, 0.00f,0.00f,0.00f, 1030, 0.011f, 0.00f,0.00f,0.00f, 0.250f, 0.000f, 0.250f, 0.000f, -5.0f, 5000.0f, 250.0f, 0.00f, 0x3f } +#define REVERB_PRESET_LIVINGROOM \ + {4, 2.5f, 1.000f, -1000, -6000, 0, 0.50f, 0.10f, 1.00f, -1376, 0.003f, 0.00f,0.00f,0.00f, -1104, 0.004f, 0.00f,0.00f,0.00f, 0.250f, 0.000f, 0.250f, 0.000f, -5.0f, 5000.0f, 250.0f, 0.00f, 0x3f } +#define REVERB_PRESET_STONEROOM \ + {5, 11.6f, 1.000f, -1000, -300, 0, 2.31f, 0.64f, 1.00f, -711, 0.012f, 0.00f,0.00f,0.00f, 83, 0.017f, 0.00f,0.00f,0.00f, 0.250f, 0.000f, 0.250f, 0.000f, -5.0f, 5000.0f, 250.0f, 0.00f, 0x3f } +#define REVERB_PRESET_AUDITORIUM \ + {6, 21.6f, 1.000f, -1000, -476, 0, 4.32f, 0.59f, 1.00f, -789, 0.020f, 0.00f,0.00f,0.00f, -289, 0.030f, 0.00f,0.00f,0.00f, 0.250f, 0.000f, 0.250f, 0.000f, -5.0f, 5000.0f, 250.0f, 0.00f, 0x3f } +#define REVERB_PRESET_CONCERTHALL \ + {7, 19.6f, 1.000f, -1000, -500, 0, 3.92f, 0.70f, 1.00f, -1230, 0.020f, 0.00f,0.00f,0.00f, -02, 0.029f, 0.00f,0.00f,0.00f, 0.250f, 0.000f, 0.250f, 0.000f, -5.0f, 5000.0f, 250.0f, 0.00f, 0x3f } +#define REVERB_PRESET_CAVE \ + {8, 14.6f, 1.000f, -1000, 0, 0, 2.91f, 1.30f, 1.00f, -602, 0.015f, 0.00f,0.00f,0.00f, -302, 0.022f, 0.00f,0.00f,0.00f, 0.250f, 0.000f, 0.250f, 0.000f, -5.0f, 5000.0f, 250.0f, 0.00f, 0x1f } +#define REVERB_PRESET_ARENA \ + {9, 36.2f, 1.000f, -1000, -698, 0, 7.24f, 0.33f, 1.00f, -1166, 0.020f, 0.00f,0.00f,0.00f, 16, 0.030f, 0.00f,0.00f,0.00f, 0.250f, 0.000f, 0.250f, 0.000f, -5.0f, 5000.0f, 250.0f, 0.00f, 0x3f } +#define REVERB_PRESET_HANGAR \ + {10, 50.3f, 1.000f, -1000, -1000, 0, 10.05f, 0.23f, 1.00f, -602, 0.020f, 0.00f,0.00f,0.00f, 198, 0.030f, 0.00f,0.00f,0.00f, 0.250f, 0.000f, 0.250f, 0.000f, -5.0f, 5000.0f, 250.0f, 0.00f, 0x3f } +#define REVERB_PRESET_CARPETTEDHALLWAY \ + {11, 1.9f, 1.000f, -1000, -4000, 0, 0.30f, 0.10f, 1.00f, -1831, 0.002f, 0.00f,0.00f,0.00f, -1630, 0.030f, 0.00f,0.00f,0.00f, 0.250f, 0.000f, 0.250f, 0.000f, -5.0f, 5000.0f, 250.0f, 0.00f, 0x3f } +#define REVERB_PRESET_HALLWAY \ + {12, 1.8f, 1.000f, -1000, -300, 0, 1.49f, 0.59f, 1.00f, -1219, 0.007f, 0.00f,0.00f,0.00f, 441, 0.011f, 0.00f,0.00f,0.00f, 0.250f, 0.000f, 0.250f, 0.000f, -5.0f, 5000.0f, 250.0f, 0.00f, 0x3f } +#define REVERB_PRESET_STONECORRIDOR \ + {13, 13.5f, 1.000f, -1000, -237, 0, 2.70f, 0.79f, 1.00f, -1214, 0.013f, 0.00f,0.00f,0.00f, 395, 0.020f, 0.00f,0.00f,0.00f, 0.250f, 0.000f, 0.250f, 0.000f, -5.0f, 5000.0f, 250.0f, 0.00f, 0x3f } +#define REVERB_PRESET_ALLEY \ + {14, 7.5f, 0.300f, -1000, -270, 0, 1.49f, 0.86f, 1.00f, -1204, 0.007f, 0.00f,0.00f,0.00f, -4, 0.011f, 0.00f,0.00f,0.00f, 0.125f, 0.950f, 0.250f, 0.000f, -5.0f, 5000.0f, 250.0f, 0.00f, 0x3f } +#define REVERB_PRESET_FOREST \ + {15, 38.0f, 0.300f, -1000, -3300, 0, 1.49f, 0.54f, 1.00f, -2560, 0.162f, 0.00f,0.00f,0.00f, -229, 0.088f, 0.00f,0.00f,0.00f, 0.125f, 1.000f, 0.250f, 0.000f, -5.0f, 5000.0f, 250.0f, 0.00f, 0x3f } +#define REVERB_PRESET_CITY \ + {16, 7.5f, 0.500f, -1000, -800, 0, 1.49f, 0.67f, 1.00f, -2273, 0.007f, 0.00f,0.00f,0.00f, -1691, 0.011f, 0.00f,0.00f,0.00f, 0.250f, 0.000f, 0.250f, 0.000f, -5.0f, 5000.0f, 250.0f, 0.00f, 0x3f } +#define REVERB_PRESET_MOUNTAINS \ + {17, 100.0f, 0.270f, -1000, -2500, 0, 1.49f, 0.21f, 1.00f, -2780, 0.300f, 0.00f,0.00f,0.00f, -1434, 0.100f, 0.00f,0.00f,0.00f, 0.250f, 1.000f, 0.250f, 0.000f, -5.0f, 5000.0f, 250.0f, 0.00f, 0x1f } +#define REVERB_PRESET_QUARRY \ + {18, 17.5f, 1.000f, -1000, -1000, 0, 1.49f, 0.83f, 1.00f, -10000, 0.061f, 0.00f,0.00f,0.00f, 500, 0.025f, 0.00f,0.00f,0.00f, 0.125f, 0.700f, 0.250f, 0.000f, -5.0f, 5000.0f, 250.0f, 0.00f, 0x3f } +#define REVERB_PRESET_PLAIN \ + {19, 42.5f, 0.210f, -1000, -2000, 0, 1.49f, 0.50f, 1.00f, -2466, 0.179f, 0.00f,0.00f,0.00f, -1926, 0.100f, 0.00f,0.00f,0.00f, 0.250f, 1.000f, 0.250f, 0.000f, -5.0f, 5000.0f, 250.0f, 0.00f, 0x3f } +#define REVERB_PRESET_PARKINGLOT \ + {20, 8.3f, 1.000f, -1000, 0, 0, 1.65f, 1.50f, 1.00f, -1363, 0.008f, 0.00f,0.00f,0.00f, -1153, 0.012f, 0.00f,0.00f,0.00f, 0.250f, 0.000f, 0.250f, 0.000f, -5.0f, 5000.0f, 250.0f, 0.00f, 0x1f } +#define REVERB_PRESET_SEWERPIPE \ + {21, 1.7f, 0.800f, -1000, -1000, 0, 2.81f, 0.14f, 1.00f, 429, 0.014f, 0.00f,0.00f,0.00f, 1023, 0.021f, 0.00f,0.00f,0.00f, 0.250f, 0.000f, 0.250f, 0.000f, -5.0f, 5000.0f, 250.0f, 0.00f, 0x3f } +#define REVERB_PRESET_UNDERWATER \ + {22, 1.8f, 1.000f, -1000, -4000, 0, 1.49f, 0.10f, 1.00f, -449, 0.007f, 0.00f,0.00f,0.00f, 1700, 0.011f, 0.00f,0.00f,0.00f, 0.250f, 0.000f, 1.180f, 0.348f, -5.0f, 5000.0f, 250.0f, 0.00f, 0x3f } +#define REVERB_PRESET_DRUGGED \ + {23, 1.9f, 0.500f, -1000, 0, 0, 8.39f, 1.39f, 1.00f, -115, 0.002f, 0.00f,0.00f,0.00f, 985, 0.030f, 0.00f,0.00f,0.00f, 0.250f, 0.000f, 0.250f, 1.000f, -5.0f, 5000.0f, 250.0f, 0.00f, 0x1f } +#define REVERB_PRESET_DIZZY \ + {24, 1.8f, 0.600f, -1000, -400, 0, 17.23f, 0.56f, 1.00f, -1713, 0.020f, 0.00f,0.00f,0.00f, -613, 0.030f, 0.00f,0.00f,0.00f, 0.250f, 1.000f, 0.810f, 0.310f, -5.0f, 5000.0f, 250.0f, 0.00f, 0x1f } +#define REVERB_PRESET_PSYCHOTIC \ + {25, 1.0f, 0.500f, -1000, -151, 0, 7.56f, 0.91f, 1.00f, -626, 0.020f, 0.00f,0.00f,0.00f, 774, 0.030f, 0.00f,0.00f,0.00f, 0.250f, 0.000f, 4.000f, 1.000f, -5.0f, 5000.0f, 250.0f, 0.00f, 0x1f } + + +// CASTLE PRESETS + +// Env Size Diffus Room RoomHF RoomLF DecTm DcHF DcLF Refl RefDel Ref Pan Revb RevDel Rev Pan EchTm EchDp ModTm ModDp AirAbs HFRef LFRef RRlOff FLAGS +#define REVERB_PRESET_CASTLE_SMALLROOM \ + { 26, 8.3f, 0.890f, -1000, -800, -2000, 1.22f, 0.83f, 0.31f, -100, 0.022f, 0.00f,0.00f,0.00f, 600, 0.011f, 0.00f,0.00f,0.00f, 0.138f, 0.080f, 0.250f, 0.000f, -5.0f, 5168.6f, 139.5f, 0.00f, 0x20 } +#define REVERB_PRESET_CASTLE_SHORTPASSAGE \ + { 26, 8.3f, 0.890f, -1000, -1000, -2000, 2.32f, 0.83f, 0.31f, -100, 0.007f, 0.00f,0.00f,0.00f, 200, 0.023f, 0.00f,0.00f,0.00f, 0.138f, 0.080f, 0.250f, 0.000f, -5.0f, 5168.6f, 139.5f, 0.00f, 0x20 } +#define REVERB_PRESET_CASTLE_MEDIUMROOM \ + { 26, 8.3f, 0.930f, -1000, -1100, -2000, 2.04f, 0.83f, 0.46f, -400, 0.022f, 0.00f,0.00f,0.00f, 400, 0.011f, 0.00f,0.00f,0.00f, 0.155f, 0.030f, 0.250f, 0.000f, -5.0f, 5168.6f, 139.5f, 0.00f, 0x20 } +#define REVERB_PRESET_CASTLE_LONGPASSAGE \ + { 26, 8.3f, 0.890f, -1000, -800, -2000, 3.42f, 0.83f, 0.31f, -100, 0.007f, 0.00f,0.00f,0.00f, 300, 0.023f, 0.00f,0.00f,0.00f, 0.138f, 0.080f, 0.250f, 0.000f, -5.0f, 5168.6f, 139.5f, 0.00f, 0x20 } +#define REVERB_PRESET_CASTLE_LARGEROOM \ + { 26, 8.3f, 0.820f, -1000, -1100, -1800, 2.53f, 0.83f, 0.50f, -700, 0.034f, 0.00f,0.00f,0.00f, 200, 0.016f, 0.00f,0.00f,0.00f, 0.185f, 0.070f, 0.250f, 0.000f, -5.0f, 5168.6f, 139.5f, 0.00f, 0x20 } +#define REVERB_PRESET_CASTLE_HALL \ + { 26, 8.3f, 0.810f, -1000, -1100, -1500, 3.14f, 0.79f, 0.62f, -1500, 0.056f, 0.00f,0.00f,0.00f, 100, 0.024f, 0.00f,0.00f,0.00f, 0.250f, 0.000f, 0.250f, 0.000f, -5.0f, 5168.6f, 139.5f, 0.00f, 0x20 } +#define REVERB_PRESET_CASTLE_CUPBOARD \ + { 26, 8.3f, 0.890f, -1000, -1100, -2000, 0.67f, 0.87f, 0.31f, 300, 0.010f, 0.00f,0.00f,0.00f, 1100, 0.007f, 0.00f,0.00f,0.00f, 0.138f, 0.080f, 0.250f, 0.000f, -5.0f, 5168.6f, 139.5f, 0.00f, 0x20 } +#define REVERB_PRESET_CASTLE_COURTYARD \ + { 26, 8.3f, 0.420f, -1000, -700, -1400, 2.13f, 0.61f, 0.23f, -1300, 0.160f, 0.00f,0.00f,0.00f, -300, 0.036f, 0.00f,0.00f,0.00f, 0.250f, 0.370f, 0.250f, 0.000f, -5.0f, 5000.0f, 250.0f, 0.00f, 0x1f } +#define REVERB_PRESET_CASTLE_ALCOVE \ + { 26, 8.3f, 0.890f, -1000, -600, -2000, 1.64f, 0.87f, 0.31f, 00, 0.007f, 0.00f,0.00f,0.00f, 300, 0.034f, 0.00f,0.00f,0.00f, 0.138f, 0.080f, 0.250f, 0.000f, -5.0f, 5168.6f, 139.5f, 0.00f, 0x20 } + + +// FACTORY PRESETS + +// Env Size Diffus Room RoomHF RoomLF DecTm DcHF DcLF Refl RefDel Ref Pan Revb RevDel Rev Pan EchTm EchDp ModTm ModDp AirAbs HFRef LFRef RRlOff FLAGS +#define REVERB_PRESET_FACTORY_ALCOVE \ + { 26, 1.8f, 0.590f, -1200, -200, -600, 3.14f, 0.65f, 1.31f, 300, 0.010f, 0.00f,0.00f,0.00f, 000, 0.038f, 0.00f,0.00f,0.00f, 0.114f, 0.100f, 0.250f, 0.000f, -5.0f, 3762.6f, 362.5f, 0.00f, 0x20 } +#define REVERB_PRESET_FACTORY_SHORTPASSAGE \ + { 26, 1.8f, 0.640f, -1200, -200, -600, 2.53f, 0.65f, 1.31f, 0, 0.010f, 0.00f,0.00f,0.00f, 200, 0.038f, 0.00f,0.00f,0.00f, 0.135f, 0.230f, 0.250f, 0.000f, -5.0f, 3762.6f, 362.5f, 0.00f, 0x20 } +#define REVERB_PRESET_FACTORY_MEDIUMROOM \ + { 26, 1.9f, 0.820f, -1200, -200, -600, 2.76f, 0.65f, 1.31f, -1100, 0.022f, 0.00f,0.00f,0.00f, 300, 0.023f, 0.00f,0.00f,0.00f, 0.174f, 0.070f, 0.250f, 0.000f, -5.0f, 3762.6f, 362.5f, 0.00f, 0x20 } +#define REVERB_PRESET_FACTORY_LONGPASSAGE \ + { 26, 1.8f, 0.640f, -1200, -200, -600, 4.06f, 0.65f, 1.31f, 0, 0.020f, 0.00f,0.00f,0.00f, 200, 0.037f, 0.00f,0.00f,0.00f, 0.135f, 0.230f, 0.250f, 0.000f, -5.0f, 3762.6f, 362.5f, 0.00f, 0x20 } +#define REVERB_PRESET_FACTORY_LARGEROOM \ + { 26, 1.9f, 0.750f, -1200, -300, -400, 4.24f, 0.51f, 1.31f, -1500, 0.039f, 0.00f,0.00f,0.00f, 100, 0.023f, 0.00f,0.00f,0.00f, 0.231f, 0.070f, 0.250f, 0.000f, -5.0f, 3762.6f, 362.5f, 0.00f, 0x20 } +#define REVERB_PRESET_FACTORY_HALL \ + { 26, 1.9f, 0.750f, -1000, -300, -400, 7.43f, 0.51f, 1.31f, -2400, 0.073f, 0.00f,0.00f,0.00f, -100, 0.027f, 0.00f,0.00f,0.00f, 0.250f, 0.070f, 0.250f, 0.000f, -5.0f, 3762.6f, 362.5f, 0.00f, 0x20 } +#define REVERB_PRESET_FACTORY_CUPBOARD \ + { 26, 1.7f, 0.630f, -1200, -200, -600, 0.49f, 0.65f, 1.31f, 200, 0.010f, 0.00f,0.00f,0.00f, 600, 0.032f, 0.00f,0.00f,0.00f, 0.107f, 0.070f, 0.250f, 0.000f, -5.0f, 3762.6f, 362.5f, 0.00f, 0x20 } +#define REVERB_PRESET_FACTORY_COURTYARD \ + { 26, 1.7f, 0.570f, -1000, -1000, -400, 2.32f, 0.29f, 0.56f, -1300, 0.140f, 0.00f,0.00f,0.00f, -800, 0.039f, 0.00f,0.00f,0.00f, 0.250f, 0.290f, 0.250f, 0.000f, -5.0f, 3762.6f, 362.5f, 0.00f, 0x20 } +#define REVERB_PRESET_FACTORY_SMALLROOM \ + { 26, 1.8f, 0.820f, -1000, -200, -600, 1.72f, 0.65f, 1.31f, -300, 0.010f, 0.00f,0.00f,0.00f, 500, 0.024f, 0.00f,0.00f,0.00f, 0.119f, 0.070f, 0.250f, 0.000f, -5.0f, 3762.6f, 362.5f, 0.00f, 0x20 } + + +// ICE PALACE PRESETS + +// Env Size Diffus Room RoomHF RoomLF DecTm DcHF DcLF Refl RefDel Ref Pan Revb RevDel Rev Pan EchTm EchDp ModTm ModDp AirAbs HFRef LFRef RRlOff FLAGS +#define REVERB_PRESET_ICEPALACE_ALCOVE \ + { 26, 2.7f, 0.840f, -1000, -500, -1100, 2.76f, 1.46f, 0.28f, 100, 0.010f, 0.00f,0.00f,0.00f, -100, 0.030f, 0.00f,0.00f,0.00f, 0.161f, 0.090f, 0.250f, 0.000f, -5.0f, 12428.5f, 99.6f, 0.00f, 0x20 } +#define REVERB_PRESET_ICEPALACE_SHORTPASSAGE \ + { 26, 2.7f, 0.750f, -1000, -500, -1100, 1.79f, 1.46f, 0.28f, -600, 0.010f, 0.00f,0.00f,0.00f, 100, 0.019f, 0.00f,0.00f,0.00f, 0.177f, 0.090f, 0.250f, 0.000f, -5.0f, 12428.5f, 99.6f, 0.00f, 0x20 } +#define REVERB_PRESET_ICEPALACE_MEDIUMROOM \ + { 26, 2.7f, 0.870f, -1000, -500, -700, 2.22f, 1.53f, 0.32f, -800, 0.039f, 0.00f,0.00f,0.00f, 100, 0.027f, 0.00f,0.00f,0.00f, 0.186f, 0.120f, 0.250f, 0.000f, -5.0f, 12428.5f, 99.6f, 0.00f, 0x20 } +#define REVERB_PRESET_ICEPALACE_LONGPASSAGE \ + { 26, 2.7f, 0.770f, -1000, -500, -800, 3.01f, 1.46f, 0.28f, -200, 0.012f, 0.00f,0.00f,0.00f, 200, 0.025f, 0.00f,0.00f,0.00f, 0.186f, 0.040f, 0.250f, 0.000f, -5.0f, 12428.5f, 99.6f, 0.00f, 0x20 } +#define REVERB_PRESET_ICEPALACE_LARGEROOM \ + { 26, 2.9f, 0.810f, -1000, -500, -700, 3.14f, 1.53f, 0.32f, -1200, 0.039f, 0.00f,0.00f,0.00f, 000, 0.027f, 0.00f,0.00f,0.00f, 0.214f, 0.110f, 0.250f, 0.000f, -5.0f, 12428.5f, 99.6f, 0.00f, 0x20 } +#define REVERB_PRESET_ICEPALACE_HALL \ + { 26, 2.9f, 0.760f, -1000, -700, -500, 5.49f, 1.53f, 0.38f, -1900, 0.054f, 0.00f,0.00f,0.00f, -400, 0.052f, 0.00f,0.00f,0.00f, 0.226f, 0.110f, 0.250f, 0.000f, -5.0f, 12428.5f, 99.6f, 0.00f, 0x20 } +#define REVERB_PRESET_ICEPALACE_CUPBOARD \ + { 26, 2.7f, 0.830f, -1000, -600, -1300, 0.76f, 1.53f, 0.26f, 100, 0.012f, 0.00f,0.00f,0.00f, 600, 0.016f, 0.00f,0.00f,0.00f, 0.143f, 0.080f, 0.250f, 0.000f, -5.0f, 12428.5f, 99.6f, 0.00f, 0x20 } +#define REVERB_PRESET_ICEPALACE_COURTYARD \ + { 26, 2.9f, 0.590f, -1000, -1100, -1000, 2.04f, 1.20f, 0.38f, -1000, 0.173f, 0.00f,0.00f,0.00f, -1000, 0.043f, 0.00f,0.00f,0.00f, 0.235f, 0.480f, 0.250f, 0.000f, -5.0f, 12428.5f, 99.6f, 0.00f, 0x20 } +#define REVERB_PRESET_ICEPALACE_SMALLROOM \ + { 26, 2.7f, 0.840f, -1000, -500, -1100, 1.51f, 1.53f, 0.27f, -100, 0.010f, 0.00f,0.00f,0.00f, 300, 0.011f, 0.00f,0.00f,0.00f, 0.164f, 0.140f, 0.250f, 0.000f, -5.0f, 12428.5f, 99.6f, 0.00f, 0x20 } + + +// SPACE STATION PRESETS + +// Env Size Diffus Room RoomHF RoomLF DecTm DcHF DcLF Refl RefDel Ref Pan Revb RevDel Rev Pan EchTm EchDp ModTm ModDp AirAbs HFRef LFRef RRlOff FLAGS +#define REVERB_PRESET_SPACESTATION_ALCOVE \ + { 26, 1.5f, 0.780f, -1000, -300, -100, 1.16f, 0.81f, 0.55f, 300, 0.007f, 0.00f,0.00f,0.00f, 000, 0.018f, 0.00f,0.00f,0.00f, 0.192f, 0.210f, 0.250f, 0.000f, -5.0f, 3316.1f, 458.2f, 0.00f, 0x20 } +#define REVERB_PRESET_SPACESTATION_MEDIUMROOM \ + { 26, 1.5f, 0.750f, -1000, -400, -100, 3.01f, 0.50f, 0.55f, -800, 0.034f, 0.00f,0.00f,0.00f, 100, 0.035f, 0.00f,0.00f,0.00f, 0.209f, 0.310f, 0.250f, 0.000f, -5.0f, 3316.1f, 458.2f, 0.00f, 0x20 } +#define REVERB_PRESET_SPACESTATION_SHORTPASSAGE \ + { 26, 1.5f, 0.870f, -1000, -400, -100, 3.57f, 0.50f, 0.55f, 0, 0.012f, 0.00f,0.00f,0.00f, 100, 0.016f, 0.00f,0.00f,0.00f, 0.172f, 0.200f, 0.250f, 0.000f, -5.0f, 3316.1f, 458.2f, 0.00f, 0x20 } +#define REVERB_PRESET_SPACESTATION_LONGPASSAGE \ + { 26, 1.9f, 0.820f, -1000, -400, -100, 4.62f, 0.62f, 0.55f, 0, 0.012f, 0.00f,0.00f,0.00f, 200, 0.031f, 0.00f,0.00f,0.00f, 0.250f, 0.230f, 0.250f, 0.000f, -5.0f, 3316.1f, 458.2f, 0.00f, 0x20 } +#define REVERB_PRESET_SPACESTATION_LARGEROOM \ + { 26, 1.8f, 0.810f, -1000, -400, -100, 3.89f, 0.38f, 0.61f, -1000, 0.056f, 0.00f,0.00f,0.00f, -100, 0.035f, 0.00f,0.00f,0.00f, 0.233f, 0.280f, 0.250f, 0.000f, -5.0f, 3316.1f, 458.2f, 0.00f, 0x20 } +#define REVERB_PRESET_SPACESTATION_HALL \ + { 26, 1.9f, 0.870f, -1000, -400, -100, 7.11f, 0.38f, 0.61f, -1500, 0.100f, 0.00f,0.00f,0.00f, -400, 0.047f, 0.00f,0.00f,0.00f, 0.250f, 0.250f, 0.250f, 0.000f, -5.0f, 3316.1f, 458.2f, 0.00f, 0x20 } +#define REVERB_PRESET_SPACESTATION_CUPBOARD \ + { 26, 1.4f, 0.560f, -1000, -300, -100, 0.79f, 0.81f, 0.55f, 300, 0.007f, 0.00f,0.00f,0.00f, 500, 0.018f, 0.00f,0.00f,0.00f, 0.181f, 0.310f, 0.250f, 0.000f, -5.0f, 3316.1f, 458.2f, 0.00f, 0x20 } +#define REVERB_PRESET_SPACESTATION_SMALLROOM \ + { 26, 1.5f, 0.700f, -1000, -300, -100, 1.72f, 0.82f, 0.55f, -200, 0.007f, 0.00f,0.00f,0.00f, 300, 0.013f, 0.00f,0.00f,0.00f, 0.188f, 0.260f, 0.250f, 0.000f, -5.0f, 3316.1f, 458.2f, 0.00f, 0x20 } + + +// WOODEN GALLEON PRESETS + +// Env Size Diffus Room RoomHF RoomLF DecTm DcHF DcLF Refl RefDel Ref Pan Revb RevDel Rev Pan EchTm EchDp ModTm ModDp AirAbs HFRef LFRef RRlOff FLAGS +#define REVERB_PRESET_WOODEN_ALCOVE \ + { 26, 7.5f, 1.000f, -1000, -1800, -1000, 1.22f, 0.62f, 0.91f, 100, 0.012f, 0.00f,0.00f,0.00f, -300, 0.024f, 0.00f,0.00f,0.00f, 0.250f, 0.000f, 0.250f, 0.000f, -5.0f, 4705.0f, 99.6f, 0.00f, 0x3f } +#define REVERB_PRESET_WOODEN_SHORTPASSAGE \ + { 26, 7.5f, 1.000f, -1000, -1800, -1000, 1.75f, 0.50f, 0.87f, -100, 0.012f, 0.00f,0.00f,0.00f, -400, 0.024f, 0.00f,0.00f,0.00f, 0.250f, 0.000f, 0.250f, 0.000f, -5.0f, 4705.0f, 99.6f, 0.00f, 0x3f } +#define REVERB_PRESET_WOODEN_MEDIUMROOM \ + { 26, 7.5f, 1.000f, -1000, -2000, -1100, 1.47f, 0.42f, 0.82f, -100, 0.049f, 0.00f,0.00f,0.00f, -100, 0.029f, 0.00f,0.00f,0.00f, 0.250f, 0.000f, 0.250f, 0.000f, -5.0f, 4705.0f, 99.6f, 0.00f, 0x3f } +#define REVERB_PRESET_WOODEN_LONGPASSAGE \ + { 26, 7.5f, 1.000f, -1000, -2000, -1000, 1.99f, 0.40f, 0.79f, 000, 0.020f, 0.00f,0.00f,0.00f, -700, 0.036f, 0.00f,0.00f,0.00f, 0.250f, 0.000f, 0.250f, 0.000f, -5.0f, 4705.0f, 99.6f, 0.00f, 0x3f } +#define REVERB_PRESET_WOODEN_LARGEROOM \ + { 26, 7.5f, 1.000f, -1000, -2100, -1100, 2.65f, 0.33f, 0.82f, -100, 0.066f, 0.00f,0.00f,0.00f, -200, 0.049f, 0.00f,0.00f,0.00f, 0.250f, 0.000f, 0.250f, 0.000f, -5.0f, 4705.0f, 99.6f, 0.00f, 0x3f } +#define REVERB_PRESET_WOODEN_HALL \ + { 26, 7.5f, 1.000f, -1000, -2200, -1100, 3.45f, 0.30f, 0.82f, -100, 0.088f, 0.00f,0.00f,0.00f, -200, 0.063f, 0.00f,0.00f,0.00f, 0.250f, 0.000f, 0.250f, 0.000f, -5.0f, 4705.0f, 99.6f, 0.00f, 0x3f } +#define REVERB_PRESET_WOODEN_CUPBOARD \ + { 26, 7.5f, 1.000f, -1000, -1700, -1000, 0.56f, 0.46f, 0.91f, 100, 0.012f, 0.00f,0.00f,0.00f, 100, 0.028f, 0.00f,0.00f,0.00f, 0.250f, 0.000f, 0.250f, 0.000f, -5.0f, 4705.0f, 99.6f, 0.00f, 0x3f } +#define REVERB_PRESET_WOODEN_SMALLROOM \ + { 26, 7.5f, 1.000f, -1000, -1900, -1000, 0.79f, 0.32f, 0.87f, 00, 0.032f, 0.00f,0.00f,0.00f, -100, 0.029f, 0.00f,0.00f,0.00f, 0.250f, 0.000f, 0.250f, 0.000f, -5.0f, 4705.0f, 99.6f, 0.00f, 0x3f } +#define REVERB_PRESET_WOODEN_COURTYARD \ + { 26, 7.5f, 0.650f, -1000, -2200, -1000, 1.79f, 0.35f, 0.79f, -500, 0.123f, 0.00f,0.00f,0.00f, -2000, 0.032f, 0.00f,0.00f,0.00f, 0.250f, 0.000f, 0.250f, 0.000f, -5.0f, 4705.0f, 99.6f, 0.00f, 0x3f } + + +// SPORTS PRESETS + +// Env Size Diffus Room RoomHF RoomLF DecTm DcHF DcLF Refl RefDel Ref Pan Revb RevDel Rev Pan EchTm EchDp ModTm ModDp AirAbs HFRef LFRef RRlOff FLAGS +#define REVERB_PRESET_SPORT_EMPTYSTADIUM \ + { 26, 7.2f, 1.000f, -1000, -700, -200, 6.26f, 0.51f, 1.10f, -2400, 0.183f, 0.00f,0.00f,0.00f, -800, 0.038f, 0.00f,0.00f,0.00f, 0.250f, 0.000f, 0.250f, 0.000f, -5.0f, 5000.0f, 250.0f, 0.00f, 0x20 } +#define REVERB_PRESET_SPORT_SQUASHCOURT \ + { 26, 7.5f, 0.750f, -1000, -1000, -200, 2.22f, 0.91f, 1.16f, -700, 0.007f, 0.00f,0.00f,0.00f, -200, 0.011f, 0.00f,0.00f,0.00f, 0.126f, 0.190f, 0.250f, 0.000f, -5.0f, 7176.9f, 211.2f, 0.00f, 0x20 } +#define REVERB_PRESET_SPORT_SMALLSWIMMINGPOOL \ + { 26, 36.2f, 0.700f, -1000, -200, -100, 2.76f, 1.25f, 1.14f, -400, 0.020f, 0.00f,0.00f,0.00f, -200, 0.030f, 0.00f,0.00f,0.00f, 0.179f, 0.150f, 0.895f, 0.190f, -5.0f, 5000.0f, 250.0f, 0.00f, 0x0 } +#define REVERB_PRESET_SPORT_LARGESWIMMINGPOOL\ + { 26, 36.2f, 0.820f, -1000, -200, 0, 5.49f, 1.31f, 1.14f, -700, 0.039f, 0.00f,0.00f,0.00f, -600, 0.049f, 0.00f,0.00f,0.00f, 0.222f, 0.550f, 1.159f, 0.210f, -5.0f, 5000.0f, 250.0f, 0.00f, 0x0 } +#define REVERB_PRESET_SPORT_GYMNASIUM \ + { 26, 7.5f, 0.810f, -1000, -700, -100, 3.14f, 1.06f, 1.35f, -800, 0.029f, 0.00f,0.00f,0.00f, -500, 0.045f, 0.00f,0.00f,0.00f, 0.146f, 0.140f, 0.250f, 0.000f, -5.0f, 7176.9f, 211.2f, 0.00f, 0x20 } +#define REVERB_PRESET_SPORT_FULLSTADIUM \ + { 26, 7.2f, 1.000f, -1000, -2300, -200, 5.25f, 0.17f, 0.80f, -2000, 0.188f, 0.00f,0.00f,0.00f, -1100, 0.038f, 0.00f,0.00f,0.00f, 0.250f, 0.000f, 0.250f, 0.000f, -5.0f, 5000.0f, 250.0f, 0.00f, 0x20 } +#define REVERB_PRESET_SPORT_STADIUMTANNOY \ + { 26, 3.0f, 0.780f, -1000, -500, -600, 2.53f, 0.88f, 0.68f, -1100, 0.230f, 0.00f,0.00f,0.00f, -600, 0.063f, 0.00f,0.00f,0.00f, 0.250f, 0.200f, 0.250f, 0.000f, -5.0f, 5000.0f, 250.0f, 0.00f, 0x20 } + + +// PREFAB PRESETS + +// Env Size Diffus Room RoomHF RoomLF DecTm DcHF DcLF Refl RefDel Ref Pan Revb RevDel Rev Pan EchTm EchDp ModTm ModDp AirAbs HFRef LFRef RRlOff FLAGS +#define REVERB_PRESET_PREFAB_WORKSHOP \ + { 26, 1.9f, 1.000f, -1000, -1700, -800, 0.76f, 1.00f, 1.00f, 0, 0.012f, 0.00f,0.00f,0.00f, 100, 0.012f, 0.00f,0.00f,0.00f, 0.250f, 0.000f, 0.250f, 0.000f, -5.0f, 5000.0f, 250.0f, 0.00f, 0x0 } +#define REVERB_PRESET_PREFAB_SCHOOLROOM \ + { 26, 1.86f, 0.690f, -1000, -400, -600, 0.98f, 0.45f, 0.18f, 300, 0.017f, 0.00f,0.00f,0.00f, 300, 0.015f, 0.00f,0.00f,0.00f, 0.095f, 0.140f, 0.250f, 0.000f, -5.0f, 7176.9f, 211.2f, 0.00f, 0x20 } +#define REVERB_PRESET_PREFAB_PRACTISEROOM \ + { 26, 1.86f, 0.870f, -1000, -800, -600, 1.12f, 0.56f, 0.18f, 200, 0.010f, 0.00f,0.00f,0.00f, 300, 0.011f, 0.00f,0.00f,0.00f, 0.095f, 0.140f, 0.250f, 0.000f, -5.0f, 7176.9f, 211.2f, 0.00f, 0x20 } +#define REVERB_PRESET_PREFAB_OUTHOUSE \ + { 26, 80.3f, 0.820f, -1000, -1900, -1600, 1.38f, 0.38f, 0.35f, -100, 0.024f, 0.00f,0.00f,-0.00f, -400, 0.044f, 0.00f,0.00f,0.00f, 0.121f, 0.170f, 0.250f, 0.000f, -5.0f, 2854.4f, 107.5f, 0.00f, 0x0 } +#define REVERB_PRESET_PREFAB_CARAVAN \ + { 26, 8.3f, 1.000f, -1000, -2100, -1800, 0.43f, 1.50f, 1.00f, 0, 0.012f, 0.00f,0.00f,0.00f, 600, 0.012f, 0.00f,0.00f,0.00f, 0.250f, 0.000f, 0.250f, 0.000f, -5.0f, 5000.0f, 250.0f, 0.00f, 0x1f } + // for US developers, a caravan is the same as a trailer =o) + + +// DOME AND PIPE PRESETS + +// Env Size Diffus Room RoomHF RoomLF DecTm DcHF DcLF Refl RefDel Ref Pan Revb RevDel Rev Pan EchTm EchDp ModTm ModDp AirAbs HFRef LFRef RRlOff FLAGS +#define REVERB_PRESET_DOME_TOMB \ + { 26, 51.8f, 0.790f, -1000, -900, -1300, 4.18f, 0.21f, 0.10f, -825, 0.030f, 0.00f,0.00f,0.00f, 450, 0.022f, 0.00f,0.00f,0.00f, 0.177f, 0.190f, 0.250f, 0.000f, -5.0f, 2854.4f, 20.0f, 0.00f, 0x0 } +#define REVERB_PRESET_PIPE_SMALL \ + { 26, 50.3f, 1.000f, -1000, -900, -1300, 5.04f, 0.10f, 0.10f, -600, 0.032f, 0.00f,0.00f,0.00f, 800, 0.015f, 0.00f,0.00f,0.00f, 0.250f, 0.000f, 0.250f, 0.000f, -5.0f, 2854.4f, 20.0f, 0.00f, 0x3f } +#define REVERB_PRESET_DOME_SAINTPAULS \ + { 26, 50.3f, 0.870f, -1000, -900, -1300, 10.48f, 0.19f, 0.10f, -1500, 0.090f, 0.00f,0.00f,0.00f, 200, 0.042f, 0.00f,0.00f,0.00f, 0.250f, 0.120f, 0.250f, 0.000f, -5.0f, 2854.4f, 20.0f, 0.00f, 0x3f } +#define REVERB_PRESET_PIPE_LONGTHIN \ + { 26, 1.6f, 0.910f, -1000, -700, -1100, 9.21f, 0.18f, 0.10f, -300, 0.010f, 0.00f,0.00f,0.00f, -300, 0.022f, 0.00f,0.00f,0.00f, 0.250f, 0.000f, 0.250f, 0.000f, -5.0f, 2854.4f, 20.0f, 0.00f, 0x0 } +#define REVERB_PRESET_PIPE_LARGE \ + { 26, 50.3f, 1.000f, -1000, -900, -1300, 8.45f, 0.10f, 0.10f, -800, 0.046f, 0.00f,0.00f,0.00f, 400, 0.032f, 0.00f,0.00f,0.00f, 0.250f, 0.000f, 0.250f, 0.000f, -5.0f, 2854.4f, 20.0f, 0.00f, 0x3f } +#define REVERB_PRESET_PIPE_RESONANT \ + { 26, 1.3f, 0.910f, -1000, -700, -1100, 6.81f, 0.18f, 0.10f, -300, 0.010f, 0.00f,0.00f,0.00f, 00, 0.022f, 0.00f,0.00f,0.00f, 0.250f, 0.000f, 0.250f, 0.000f, -5.0f, 2854.4f, 20.0f, 0.00f, 0x0 } + + +// OUTDOORS PRESETS + +// Env Size Diffus Room RoomHF RoomLF DecTm DcHF DcLF Refl RefDel Ref Pan Revb RevDel Rev Pan EchTm EchDp ModTm ModDp AirAbs HFRef LFRef RRlOff FLAGS +#define REVERB_PRESET_OUTDOORS_BACKYARD \ + { 26, 80.3f, 0.450f, -1000, -1200, -600, 1.12f, 0.34f, 0.46f, -700, 0.069f, 0.00f,0.00f,-0.00f, -300, 0.023f, 0.00f,0.00f,0.00f, 0.218f, 0.340f, 0.250f, 0.000f, -5.0f, 4399.1f, 242.9f, 0.00f, 0x0 } +#define REVERB_PRESET_OUTDOORS_ROLLINGPLAINS \ + { 26, 80.3f, 0.000f, -1000, -3900, -400, 2.13f, 0.21f, 0.46f, -1500, 0.300f, 0.00f,0.00f,-0.00f, -700, 0.019f, 0.00f,0.00f,0.00f, 0.250f, 1.000f, 0.250f, 0.000f, -5.0f, 4399.1f, 242.9f, 0.00f, 0x0 } +#define REVERB_PRESET_OUTDOORS_DEEPCANYON \ + { 26, 80.3f, 0.740f, -1000, -1500, -400, 3.89f, 0.21f, 0.46f, -1000, 0.223f, 0.00f,0.00f,-0.00f, -900, 0.019f, 0.00f,0.00f,0.00f, 0.250f, 1.000f, 0.250f, 0.000f, -5.0f, 4399.1f, 242.9f, 0.00f, 0x0 } +#define REVERB_PRESET_OUTDOORS_CREEK \ + { 26, 80.3f, 0.350f, -1000, -1500, -600, 2.13f, 0.21f, 0.46f, -800, 0.115f, 0.00f,0.00f,-0.00f, -1400, 0.031f, 0.00f,0.00f,0.00f, 0.218f, 0.340f, 0.250f, 0.000f, -5.0f, 4399.1f, 242.9f, 0.00f, 0x0 } +#define REVERB_PRESET_OUTDOORS_VALLEY \ + { 26, 80.3f, 0.280f, -1000, -3100, -1600, 2.88f, 0.26f, 0.35f, -1700, 0.263f, 0.00f,0.00f,-0.00f, -800, 0.100f, 0.00f,0.00f,0.00f, 0.250f, 0.340f, 0.250f, 0.000f, -5.0f, 2854.4f, 107.5f, 0.00f, 0x0 } + + +// MOOD PRESETS + +// Env Size Diffus Room RoomHF RoomLF DecTm DcHF DcLF Refl RefDel Ref Pan Revb RevDel Rev Pan EchTm EchDp ModTm ModDp AirAbs HFRef LFRef RRlOff FLAGS +#define REVERB_PRESET_MOOD_HEAVEN \ + { 26, 19.6f, 0.940f, -1000, -200, -700, 5.04f, 1.12f, 0.56f, -1230, 0.020f, 0.00f,0.00f,0.00f, 200, 0.029f, 0.00f,0.00f,0.00f, 0.250f, 0.080f, 2.742f, 0.050f, -2.0f, 5000.0f, 250.0f, 0.00f, 0x3f } +#define REVERB_PRESET_MOOD_HELL \ + { 26, 100.0f, 0.570f, -1000, -900, -700, 3.57f, 0.49f, 2.00f, -10000, 0.020f, 0.00f,0.00f,0.00f, 300, 0.030f, 0.00f,0.00f,0.00f, 0.110f, 0.040f, 2.109f, 0.520f, -5.0f, 5000.0f, 139.5f, 0.00f, 0x40 } +#define REVERB_PRESET_MOOD_MEMORY \ + { 26, 8.0f, 0.850f, -1000, -400, -900, 4.06f, 0.82f, 0.56f, -2800, 0.000f, 0.00f,0.00f,0.00f, 100, 0.000f, 0.00f,0.00f,0.00f, 0.250f, 0.000f, 0.474f, 0.450f, -10.0f, 5000.0f, 250.0f, 0.00f, 0x0 } + + +// DRIVING SIMULATION PRESETS + +// Env Size Diffus Room RoomHF RoomLF DecTm DcHF DcLF Refl RefDel Ref Pan Revb RevDel Rev Pan EchTm EchDp ModTm ModDp AirAbs HFRef LFRef RRlOff FLAGS +#define REVERB_PRESET_DRIVING_COMMENTATOR \ + { 26, 3.0f, 0.000f, -1000, -500, -600, 2.42f, 0.88f, 0.68f, -1400, 0.093f, 0.00f,0.00f,0.00f, -1200, 0.017f, 0.00f,0.00f,0.00f, 0.250f, 1.000f, 0.250f, 0.000f, -10.0f, 5000.0f, 250.0f, 0.00f, 0x20 } +#define REVERB_PRESET_DRIVING_PITGARAGE \ + { 26, 1.9f, 0.590f, -1000, -300, -500, 1.72f, 0.93f, 0.87f, -500, 0.000f, 0.00f,0.00f,0.00f, 200, 0.016f, 0.00f,0.00f,0.00f, 0.250f, 0.110f, 0.250f, 0.000f, -5.0f, 5000.0f, 250.0f, 0.00f, 0x0 } +#define REVERB_PRESET_DRIVING_INCAR_RACER \ + { 26, 1.1f, 0.800f, -1000, 0, -200, 0.17f, 2.00f, 0.41f, 500, 0.007f, 0.00f,0.00f,0.00f, -300, 0.015f, 0.00f,0.00f,0.00f, 0.250f, 0.000f, 0.250f, 0.000f, -5.0f, 10268.2f, 251.0f, 0.00f, 0x20 } +#define REVERB_PRESET_DRIVING_INCAR_SPORTS \ + { 26, 1.1f, 0.800f, -1000, -400, 0, 0.17f, 0.75f, 0.41f, 0, 0.010f, 0.00f,0.00f,0.00f, -500, 0.000f, 0.00f,0.00f,0.00f, 0.250f, 0.000f, 0.250f, 0.000f, -5.0f, 10268.2f, 251.0f, 0.00f, 0x20 } +#define REVERB_PRESET_DRIVING_INCAR_LUXURY \ + { 26, 1.6f, 1.000f, -1000, -2000, -600, 0.13f, 0.41f, 0.46f, -200, 0.010f, 0.00f,0.00f,0.00f, 400, 0.010f, 0.00f,0.00f,0.00f, 0.250f, 0.000f, 0.250f, 0.000f, -5.0f, 10268.2f, 251.0f, 0.00f, 0x20 } +#define REVERB_PRESET_DRIVING_FULLGRANDSTAND \ + { 26, 8.3f, 1.000f, -1000, -1100, -400, 3.01f, 1.37f, 1.28f, -900, 0.090f, 0.00f,0.00f,0.00f, -1500, 0.049f, 0.00f,0.00f,0.00f, 0.250f, 0.000f, 0.250f, 0.000f, -5.0f, 10420.2f, 250.0f, 0.00f, 0x1f } +#define REVERB_PRESET_DRIVING_EMPTYGRANDSTAND \ + { 26, 8.3f, 1.000f, -1000, 0, -200, 4.62f, 1.75f, 1.40f, -1363, 0.090f, 0.00f,0.00f,0.00f, -1200, 0.049f, 0.00f,0.00f,0.00f, 0.250f, 0.000f, 0.250f, 0.000f, -5.0f, 10420.2f, 250.0f, 0.00f, 0x1f } +#define REVERB_PRESET_DRIVING_TUNNEL \ + { 26, 3.1f, 0.810f, -1000, -800, -100, 3.42f, 0.94f, 1.31f, -300, 0.051f, 0.00f,0.00f,0.00f, -300, 0.047f, 0.00f,0.00f,0.00f, 0.214f, 0.050f, 0.250f, 0.000f, -5.0f, 5000.0f, 155.3f, 0.00f, 0x20 } + + +// CITY PRESETS + +// Env Size Diffus Room RoomHF RoomLF DecTm DcHF DcLF Refl RefDel Ref Pan Revb RevDel Rev Pan EchTm EchDp ModTm ModDp AirAbs HFRef LFRef RRlOff FLAGS +#define REVERB_PRESET_CITY_STREETS \ + { 26, 3.0f, 0.780f, -1000, -300, -100, 1.79f, 1.12f, 0.91f, -1100, 0.046f, 0.00f,0.00f,0.00f, -1400, 0.028f, 0.00f,0.00f,0.00f, 0.250f, 0.200f, 0.250f, 0.000f, -5.0f, 5000.0f, 250.0f, 0.00f, 0x20 } +#define REVERB_PRESET_CITY_SUBWAY \ + { 26, 3.0f, 0.740f, -1000, -300, -100, 3.01f, 1.23f, 0.91f, -300, 0.046f, 0.00f,0.00f,0.00f, 200, 0.028f, 0.00f,0.00f,0.00f, 0.125f, 0.210f, 0.250f, 0.000f, -5.0f, 5000.0f, 250.0f, 0.00f, 0x20 } +#define REVERB_PRESET_CITY_MUSEUM \ + { 26, 80.3f, 0.820f, -1000, -1500, -1500, 3.28f, 1.40f, 0.57f, -1200, 0.039f, 0.00f,0.00f,-0.00f, -100, 0.034f, 0.00f,0.00f,0.00f, 0.130f, 0.170f, 0.250f, 0.000f, -5.0f, 2854.4f, 107.5f, 0.00f, 0x0 } +#define REVERB_PRESET_CITY_LIBRARY \ + { 26, 80.3f, 0.820f, -1000, -1100, -2100, 2.76f, 0.89f, 0.41f, -900, 0.029f, 0.00f,0.00f,-0.00f, -100, 0.020f, 0.00f,0.00f,0.00f, 0.130f, 0.170f, 0.250f, 0.000f, -5.0f, 2854.4f, 107.5f, 0.00f, 0x0 } +#define REVERB_PRESET_CITY_UNDERPASS \ + { 26, 3.0f, 0.820f, -1000, -700, -100, 3.57f, 1.12f, 0.91f, -800, 0.059f, 0.00f,0.00f,0.00f, -100, 0.037f, 0.00f,0.00f,0.00f, 0.250f, 0.140f, 0.250f, 0.000f, -7.0f, 5000.0f, 250.0f, 0.00f, 0x20 } +#define REVERB_PRESET_CITY_ABANDONED \ + { 26, 3.0f, 0.690f, -1000, -200, -100, 3.28f, 1.17f, 0.91f, -700, 0.044f, 0.00f,0.00f,0.00f, -1100, 0.024f, 0.00f,0.00f,0.00f, 0.250f, 0.200f, 0.250f, 0.000f, -3.0f, 5000.0f, 250.0f, 0.00f, 0x20 } + + +// MISC ROOMS + +// Env Size Diffus Room RoomHF RoomLF DecTm DcHF DcLF Refl RefDel Ref Pan Revb RevDel Rev Pan EchTm EchDp ModTm ModDp AirAbs HFRef LFRef RRlOff FLAGS +#define REVERB_PRESET_DUSTYROOM \ + { 26, 1.8f, 0.560f, -1000, -200, -300, 1.79f, 0.38f, 0.21f, -600, 0.002f, 0.00f,0.00f,0.00f, 200, 0.006f, 0.00f,0.00f,0.00f, 0.202f, 0.050f, 0.250f, 0.000f, -10.0f, 13046.0f, 163.3f, 0.00f, 0x20 } +#define REVERB_PRESET_CHAPEL \ + { 26, 19.6f, 0.840f, -1000, -500, 0, 4.62f, 0.64f, 1.23f, -700, 0.032f, 0.00f,0.00f,0.00f, -200, 0.049f, 0.00f,0.00f,0.00f, 0.250f, 0.000f, 0.250f, 0.110f, -5.0f, 5000.0f, 250.0f, 0.00f, 0x3f } +#define REVERB_PRESET_SMALLWATERROOM \ + { 26, 36.2f, 0.700f, -1000, -698, 0, 1.51f, 1.25f, 1.14f, -100, 0.020f, 0.00f,0.00f,0.00f, 300, 0.030f, 0.00f,0.00f,0.00f, 0.179f, 0.150f, 0.895f, 0.190f, -7.0f, 5000.0f, 250.0f, 0.00f, 0x0 } + + +#pragma pack(pop) + +#ifdef __cplusplus +} +#endif // __cplusplus + +#endif // EFX-UTIL_H_INCLUDED \ No newline at end of file diff --git a/Racer/openAL/include/al.h b/Racer/openAL/include/al.h new file mode 100644 index 0000000..1c2f95b --- /dev/null +++ b/Racer/openAL/include/al.h @@ -0,0 +1,732 @@ +#ifndef AL_AL_H +#define AL_AL_H + + + +#if defined(__cplusplus) +extern "C" { +#endif + +#if defined(_WIN32) && !defined(_XBOX) + /* _OPENAL32LIB is deprecated */ + #if defined(AL_BUILD_LIBRARY) || defined (_OPENAL32LIB) + #define AL_API __declspec(dllexport) + #else + #define AL_API __declspec(dllimport) + #endif +#else + #define AL_API extern +#endif + +#if defined(_WIN32) + #define AL_APIENTRY __cdecl +#else + #define AL_APIENTRY +#endif + +#if TARGET_OS_MAC + #pragma export on +#endif + +/* The OPENAL, ALAPI, and ALAPIENTRY macros are deprecated, but are included for applications porting code + from AL 1.0 */ +#define OPENAL +#define ALAPI AL_API +#define ALAPIENTRY AL_APIENTRY + +#define AL_VERSION_1_0 +#define AL_VERSION_1_1 + + +/** 8-bit boolean */ +typedef char ALboolean; + +/** character */ +typedef char ALchar; + +/** signed 8-bit 2's complement integer */ +typedef char ALbyte; + +/** unsigned 8-bit integer */ +typedef unsigned char ALubyte; + +/** signed 16-bit 2's complement integer */ +typedef short ALshort; + +/** unsigned 16-bit integer */ +typedef unsigned short ALushort; + +/** signed 32-bit 2's complement integer */ +typedef int ALint; + +/** unsigned 32-bit integer */ +typedef unsigned int ALuint; + +/** non-negative 32-bit binary integer size */ +typedef int ALsizei; + +/** enumerated 32-bit value */ +typedef int ALenum; + +/** 32-bit IEEE754 floating-point */ +typedef float ALfloat; + +/** 64-bit IEEE754 floating-point */ +typedef double ALdouble; + +/** void type (for opaque pointers only) */ +typedef void ALvoid; + + +/* Enumerant values begin at column 50. No tabs. */ + +/* bad value */ +#define AL_INVALID -1 + +#define AL_NONE 0 + +/* Boolean False. */ +#define AL_FALSE 0 + +/** Boolean True. */ +#define AL_TRUE 1 + +/** Indicate Source has relative coordinates. */ +#define AL_SOURCE_RELATIVE 0x202 + + + +/** + * Directional source, inner cone angle, in degrees. + * Range: [0-360] + * Default: 360 + */ +#define AL_CONE_INNER_ANGLE 0x1001 + +/** + * Directional source, outer cone angle, in degrees. + * Range: [0-360] + * Default: 360 + */ +#define AL_CONE_OUTER_ANGLE 0x1002 + +/** + * Specify the pitch to be applied, either at source, + * or on mixer results, at listener. + * Range: [0.5-2.0] + * Default: 1.0 + */ +#define AL_PITCH 0x1003 + +/** + * Specify the current location in three dimensional space. + * OpenAL, like OpenGL, uses a right handed coordinate system, + * where in a frontal default view X (thumb) points right, + * Y points up (index finger), and Z points towards the + * viewer/camera (middle finger). + * To switch from a left handed coordinate system, flip the + * sign on the Z coordinate. + * Listener position is always in the world coordinate system. + */ +#define AL_POSITION 0x1004 + +/** Specify the current direction. */ +#define AL_DIRECTION 0x1005 + +/** Specify the current velocity in three dimensional space. */ +#define AL_VELOCITY 0x1006 + +/** + * Indicate whether source is looping. + * Type: ALboolean? + * Range: [AL_TRUE, AL_FALSE] + * Default: FALSE. + */ +#define AL_LOOPING 0x1007 + +/** + * Indicate the buffer to provide sound samples. + * Type: ALuint. + * Range: any valid Buffer id. + */ +#define AL_BUFFER 0x1009 + +/** + * Indicate the gain (volume amplification) applied. + * Type: ALfloat. + * Range: ]0.0- ] + * A value of 1.0 means un-attenuated/unchanged. + * Each division by 2 equals an attenuation of -6dB. + * Each multiplicaton with 2 equals an amplification of +6dB. + * A value of 0.0 is meaningless with respect to a logarithmic + * scale; it is interpreted as zero volume - the channel + * is effectively disabled. + */ +#define AL_GAIN 0x100A + +/* + * Indicate minimum source attenuation + * Type: ALfloat + * Range: [0.0 - 1.0] + * + * Logarthmic + */ +#define AL_MIN_GAIN 0x100D + +/** + * Indicate maximum source attenuation + * Type: ALfloat + * Range: [0.0 - 1.0] + * + * Logarthmic + */ +#define AL_MAX_GAIN 0x100E + +/** + * Indicate listener orientation. + * + * at/up + */ +#define AL_ORIENTATION 0x100F + +/** + * Specify the channel mask. (Creative) + * Type: ALuint + * Range: [0 - 255] + */ +#define AL_CHANNEL_MASK 0x3000 + + +/** + * Source state information. + */ +#define AL_SOURCE_STATE 0x1010 +#define AL_INITIAL 0x1011 +#define AL_PLAYING 0x1012 +#define AL_PAUSED 0x1013 +#define AL_STOPPED 0x1014 + +/** + * Buffer Queue params + */ +#define AL_BUFFERS_QUEUED 0x1015 +#define AL_BUFFERS_PROCESSED 0x1016 + +/** + * Source buffer position information + */ +#define AL_SEC_OFFSET 0x1024 +#define AL_SAMPLE_OFFSET 0x1025 +#define AL_BYTE_OFFSET 0x1026 + +/* + * Source type (Static, Streaming or undetermined) + * Source is Static if a Buffer has been attached using AL_BUFFER + * Source is Streaming if one or more Buffers have been attached using alSourceQueueBuffers + * Source is undetermined when it has the NULL buffer attached + */ +#define AL_SOURCE_TYPE 0x1027 +#define AL_STATIC 0x1028 +#define AL_STREAMING 0x1029 +#define AL_UNDETERMINED 0x1030 + +/** Sound samples: format specifier. */ +#define AL_FORMAT_MONO8 0x1100 +#define AL_FORMAT_MONO16 0x1101 +#define AL_FORMAT_STEREO8 0x1102 +#define AL_FORMAT_STEREO16 0x1103 + +/** + * source specific reference distance + * Type: ALfloat + * Range: 0.0 - +inf + * + * At 0.0, no distance attenuation occurs. Default is + * 1.0. + */ +#define AL_REFERENCE_DISTANCE 0x1020 + +/** + * source specific rolloff factor + * Type: ALfloat + * Range: 0.0 - +inf + * + */ +#define AL_ROLLOFF_FACTOR 0x1021 + +/** + * Directional source, outer cone gain. + * + * Default: 0.0 + * Range: [0.0 - 1.0] + * Logarithmic + */ +#define AL_CONE_OUTER_GAIN 0x1022 + +/** + * Indicate distance above which sources are not + * attenuated using the inverse clamped distance model. + * + * Default: +inf + * Type: ALfloat + * Range: 0.0 - +inf + */ +#define AL_MAX_DISTANCE 0x1023 + +/** + * Sound samples: frequency, in units of Hertz [Hz]. + * This is the number of samples per second. Half of the + * sample frequency marks the maximum significant + * frequency component. + */ +#define AL_FREQUENCY 0x2001 +#define AL_BITS 0x2002 +#define AL_CHANNELS 0x2003 +#define AL_SIZE 0x2004 + +/** + * Buffer state. + * + * Not supported for public use (yet). + */ +#define AL_UNUSED 0x2010 +#define AL_PENDING 0x2011 +#define AL_PROCESSED 0x2012 + + +/** Errors: No Error. */ +#define AL_NO_ERROR AL_FALSE + +/** + * Invalid Name paramater passed to AL call. + */ +#define AL_INVALID_NAME 0xA001 + +/** + * Invalid parameter passed to AL call. + */ +#define AL_ILLEGAL_ENUM 0xA002 +#define AL_INVALID_ENUM 0xA002 + +/** + * Invalid enum parameter value. + */ +#define AL_INVALID_VALUE 0xA003 + +/** + * Illegal call. + */ +#define AL_ILLEGAL_COMMAND 0xA004 +#define AL_INVALID_OPERATION 0xA004 + + +/** + * No mojo. + */ +#define AL_OUT_OF_MEMORY 0xA005 + + +/** Context strings: Vendor Name. */ +#define AL_VENDOR 0xB001 +#define AL_VERSION 0xB002 +#define AL_RENDERER 0xB003 +#define AL_EXTENSIONS 0xB004 + +/** Global tweakage. */ + +/** + * Doppler scale. Default 1.0 + */ +#define AL_DOPPLER_FACTOR 0xC000 + +/** + * Tweaks speed of propagation. + */ +#define AL_DOPPLER_VELOCITY 0xC001 + +/** + * Speed of Sound in units per second + */ +#define AL_SPEED_OF_SOUND 0xC003 + +/** + * Distance models + * + * used in conjunction with DistanceModel + * + * implicit: NONE, which disances distance attenuation. + */ +#define AL_DISTANCE_MODEL 0xD000 +#define AL_INVERSE_DISTANCE 0xD001 +#define AL_INVERSE_DISTANCE_CLAMPED 0xD002 +#define AL_LINEAR_DISTANCE 0xD003 +#define AL_LINEAR_DISTANCE_CLAMPED 0xD004 +#define AL_EXPONENT_DISTANCE 0xD005 +#define AL_EXPONENT_DISTANCE_CLAMPED 0xD006 + + +#if !defined(AL_NO_PROTOTYPES) + +/* + * Renderer State management + */ +AL_API void AL_APIENTRY alEnable( ALenum capability ); + +AL_API void AL_APIENTRY alDisable( ALenum capability ); + +AL_API ALboolean AL_APIENTRY alIsEnabled( ALenum capability ); + + +/* + * State retrieval + */ +AL_API const ALchar* AL_APIENTRY alGetString( ALenum param ); + +AL_API void AL_APIENTRY alGetBooleanv( ALenum param, ALboolean* data ); + +AL_API void AL_APIENTRY alGetIntegerv( ALenum param, ALint* data ); + +AL_API void AL_APIENTRY alGetFloatv( ALenum param, ALfloat* data ); + +AL_API void AL_APIENTRY alGetDoublev( ALenum param, ALdouble* data ); + +AL_API ALboolean AL_APIENTRY alGetBoolean( ALenum param ); + +AL_API ALint AL_APIENTRY alGetInteger( ALenum param ); + +AL_API ALfloat AL_APIENTRY alGetFloat( ALenum param ); + +AL_API ALdouble AL_APIENTRY alGetDouble( ALenum param ); + + +/* + * Error support. + * Obtain the most recent error generated in the AL state machine. + */ +AL_API ALenum AL_APIENTRY alGetError( void ); + + +/* + * Extension support. + * Query for the presence of an extension, and obtain any appropriate + * function pointers and enum values. + */ +AL_API ALboolean AL_APIENTRY alIsExtensionPresent( const ALchar* extname ); + +AL_API void* AL_APIENTRY alGetProcAddress( const ALchar* fname ); + +AL_API ALenum AL_APIENTRY alGetEnumValue( const ALchar* ename ); + + +/* + * LISTENER + * Listener represents the location and orientation of the + * 'user' in 3D-space. + * + * Properties include: - + * + * Gain AL_GAIN ALfloat + * Position AL_POSITION ALfloat[3] + * Velocity AL_VELOCITY ALfloat[3] + * Orientation AL_ORIENTATION ALfloat[6] (Forward then Up vectors) +*/ + +/* + * Set Listener parameters + */ +AL_API void AL_APIENTRY alListenerf( ALenum param, ALfloat value ); + +AL_API void AL_APIENTRY alListener3f( ALenum param, ALfloat value1, ALfloat value2, ALfloat value3 ); + +AL_API void AL_APIENTRY alListenerfv( ALenum param, const ALfloat* values ); + +AL_API void AL_APIENTRY alListeneri( ALenum param, ALint value ); + +AL_API void AL_APIENTRY alListener3i( ALenum param, ALint value1, ALint value2, ALint value3 ); + +AL_API void AL_APIENTRY alListeneriv( ALenum param, const ALint* values ); + +/* + * Get Listener parameters + */ +AL_API void AL_APIENTRY alGetListenerf( ALenum param, ALfloat* value ); + +AL_API void AL_APIENTRY alGetListener3f( ALenum param, ALfloat *value1, ALfloat *value2, ALfloat *value3 ); + +AL_API void AL_APIENTRY alGetListenerfv( ALenum param, ALfloat* values ); + +AL_API void AL_APIENTRY alGetListeneri( ALenum param, ALint* value ); + +AL_API void AL_APIENTRY alGetListener3i( ALenum param, ALint *value1, ALint *value2, ALint *value3 ); + +AL_API void AL_APIENTRY alGetListeneriv( ALenum param, ALint* values ); + + +/** + * SOURCE + * Sources represent individual sound objects in 3D-space. + * Sources take the PCM data provided in the specified Buffer, + * apply Source-specific modifications, and then + * submit them to be mixed according to spatial arrangement etc. + * + * Properties include: - + * + * Gain AL_GAIN ALfloat + * Min Gain AL_MIN_GAIN ALfloat + * Max Gain AL_MAX_GAIN ALfloat + * Position AL_POSITION ALfloat[3] + * Velocity AL_VELOCITY ALfloat[3] + * Direction AL_DIRECTION ALfloat[3] + * Head Relative Mode AL_SOURCE_RELATIVE ALint (AL_TRUE or AL_FALSE) + * Reference Distance AL_REFERENCE_DISTANCE ALfloat + * Max Distance AL_MAX_DISTANCE ALfloat + * RollOff Factor AL_ROLLOFF_FACTOR ALfloat + * Inner Angle AL_CONE_INNER_ANGLE ALint or ALfloat + * Outer Angle AL_CONE_OUTER_ANGLE ALint or ALfloat + * Cone Outer Gain AL_CONE_OUTER_GAIN ALint or ALfloat + * Pitch AL_PITCH ALfloat + * Looping AL_LOOPING ALint (AL_TRUE or AL_FALSE) + * MS Offset AL_MSEC_OFFSET ALint or ALfloat + * Byte Offset AL_BYTE_OFFSET ALint or ALfloat + * Sample Offset AL_SAMPLE_OFFSET ALint or ALfloat + * Attached Buffer AL_BUFFER ALint + * State (Query only) AL_SOURCE_STATE ALint + * Buffers Queued (Query only) AL_BUFFERS_QUEUED ALint + * Buffers Processed (Query only) AL_BUFFERS_PROCESSED ALint + */ + +/* Create Source objects */ +AL_API void AL_APIENTRY alGenSources( ALsizei n, ALuint* sources ); + +/* Delete Source objects */ +AL_API void AL_APIENTRY alDeleteSources( ALsizei n, const ALuint* sources ); + +/* Verify a handle is a valid Source */ +AL_API ALboolean AL_APIENTRY alIsSource( ALuint sid ); + +/* + * Set Source parameters + */ +AL_API void AL_APIENTRY alSourcef( ALuint sid, ALenum param, ALfloat value ); + +AL_API void AL_APIENTRY alSource3f( ALuint sid, ALenum param, ALfloat value1, ALfloat value2, ALfloat value3 ); + +AL_API void AL_APIENTRY alSourcefv( ALuint sid, ALenum param, const ALfloat* values ); + +AL_API void AL_APIENTRY alSourcei( ALuint sid, ALenum param, ALint value ); + +AL_API void AL_APIENTRY alSource3i( ALuint sid, ALenum param, ALint value1, ALint value2, ALint value3 ); + +AL_API void AL_APIENTRY alSourceiv( ALuint sid, ALenum param, const ALint* values ); + +/* + * Get Source parameters + */ +AL_API void AL_APIENTRY alGetSourcef( ALuint sid, ALenum param, ALfloat* value ); + +AL_API void AL_APIENTRY alGetSource3f( ALuint sid, ALenum param, ALfloat* value1, ALfloat* value2, ALfloat* value3); + +AL_API void AL_APIENTRY alGetSourcefv( ALuint sid, ALenum param, ALfloat* values ); + +AL_API void AL_APIENTRY alGetSourcei( ALuint sid, ALenum param, ALint* value ); + +AL_API void AL_APIENTRY alGetSource3i( ALuint sid, ALenum param, ALint* value1, ALint* value2, ALint* value3); + +AL_API void AL_APIENTRY alGetSourceiv( ALuint sid, ALenum param, ALint* values ); + + +/* + * Source vector based playback calls + */ + +/* Play, replay, or resume (if paused) a list of Sources */ +AL_API void AL_APIENTRY alSourcePlayv( ALsizei ns, const ALuint *sids ); + +/* Stop a list of Sources */ +AL_API void AL_APIENTRY alSourceStopv( ALsizei ns, const ALuint *sids ); + +/* Rewind a list of Sources */ +AL_API void AL_APIENTRY alSourceRewindv( ALsizei ns, const ALuint *sids ); + +/* Pause a list of Sources */ +AL_API void AL_APIENTRY alSourcePausev( ALsizei ns, const ALuint *sids ); + +/* + * Source based playback calls + */ + +/* Play, replay, or resume a Source */ +AL_API void AL_APIENTRY alSourcePlay( ALuint sid ); + +/* Stop a Source */ +AL_API void AL_APIENTRY alSourceStop( ALuint sid ); + +/* Rewind a Source (set playback postiton to beginning) */ +AL_API void AL_APIENTRY alSourceRewind( ALuint sid ); + +/* Pause a Source */ +AL_API void AL_APIENTRY alSourcePause( ALuint sid ); + +/* + * Source Queuing + */ +AL_API void AL_APIENTRY alSourceQueueBuffers( ALuint sid, ALsizei numEntries, const ALuint *bids ); + +AL_API void AL_APIENTRY alSourceUnqueueBuffers( ALuint sid, ALsizei numEntries, ALuint *bids ); + + +/** + * BUFFER + * Buffer objects are storage space for sample data. + * Buffers are referred to by Sources. One Buffer can be used + * by multiple Sources. + * + * Properties include: - + * + * Frequency (Query only) AL_FREQUENCY ALint + * Size (Query only) AL_SIZE ALint + * Bits (Query only) AL_BITS ALint + * Channels (Query only) AL_CHANNELS ALint + */ + +/* Create Buffer objects */ +AL_API void AL_APIENTRY alGenBuffers( ALsizei n, ALuint* buffers ); + +/* Delete Buffer objects */ +AL_API void AL_APIENTRY alDeleteBuffers( ALsizei n, const ALuint* buffers ); + +/* Verify a handle is a valid Buffer */ +AL_API ALboolean AL_APIENTRY alIsBuffer( ALuint bid ); + +/* Specify the data to be copied into a buffer */ +AL_API void AL_APIENTRY alBufferData( ALuint bid, ALenum format, const ALvoid* data, ALsizei size, ALsizei freq ); + +/* + * Set Buffer parameters + */ +AL_API void AL_APIENTRY alBufferf( ALuint bid, ALenum param, ALfloat value ); + +AL_API void AL_APIENTRY alBuffer3f( ALuint bid, ALenum param, ALfloat value1, ALfloat value2, ALfloat value3 ); + +AL_API void AL_APIENTRY alBufferfv( ALuint bid, ALenum param, const ALfloat* values ); + +AL_API void AL_APIENTRY alBufferi( ALuint bid, ALenum param, ALint value ); + +AL_API void AL_APIENTRY alBuffer3i( ALuint bid, ALenum param, ALint value1, ALint value2, ALint value3 ); + +AL_API void AL_APIENTRY alBufferiv( ALuint bid, ALenum param, const ALint* values ); + +/* + * Get Buffer parameters + */ +AL_API void AL_APIENTRY alGetBufferf( ALuint bid, ALenum param, ALfloat* value ); + +AL_API void AL_APIENTRY alGetBuffer3f( ALuint bid, ALenum param, ALfloat* value1, ALfloat* value2, ALfloat* value3); + +AL_API void AL_APIENTRY alGetBufferfv( ALuint bid, ALenum param, ALfloat* values ); + +AL_API void AL_APIENTRY alGetBufferi( ALuint bid, ALenum param, ALint* value ); + +AL_API void AL_APIENTRY alGetBuffer3i( ALuint bid, ALenum param, ALint* value1, ALint* value2, ALint* value3); + +AL_API void AL_APIENTRY alGetBufferiv( ALuint bid, ALenum param, ALint* values ); + + +/* + * Global Parameters + */ +AL_API void AL_APIENTRY alDopplerFactor( ALfloat value ); + +AL_API void AL_APIENTRY alDopplerVelocity( ALfloat value ); + +AL_API void AL_APIENTRY alSpeedOfSound( ALfloat value ); + +AL_API void AL_APIENTRY alDistanceModel( ALenum distanceModel ); + +#else /* AL_NO_PROTOTYPES */ + +typedef void (AL_APIENTRY *LPALENABLE)( ALenum capability ); +typedef void (AL_APIENTRY *LPALDISABLE)( ALenum capability ); +typedef ALboolean (AL_APIENTRY *LPALISENABLED)( ALenum capability ); +typedef const ALchar* (AL_APIENTRY *LPALGETSTRING)( ALenum param ); +typedef void (AL_APIENTRY *LPALGETBOOLEANV)( ALenum param, ALboolean* data ); +typedef void (AL_APIENTRY *LPALGETINTEGERV)( ALenum param, ALint* data ); +typedef void (AL_APIENTRY *LPALGETFLOATV)( ALenum param, ALfloat* data ); +typedef void (AL_APIENTRY *LPALGETDOUBLEV)( ALenum param, ALdouble* data ); +typedef ALboolean (AL_APIENTRY *LPALGETBOOLEAN)( ALenum param ); +typedef ALint (AL_APIENTRY *LPALGETINTEGER)( ALenum param ); +typedef ALfloat (AL_APIENTRY *LPALGETFLOAT)( ALenum param ); +typedef ALdouble (AL_APIENTRY *LPALGETDOUBLE)( ALenum param ); +typedef ALenum (AL_APIENTRY *LPALGETERROR)( void ); +typedef ALboolean (AL_APIENTRY *LPALISEXTENSIONPRESENT)(const ALchar* extname ); +typedef void* (AL_APIENTRY *LPALGETPROCADDRESS)( const ALchar* fname ); +typedef ALenum (AL_APIENTRY *LPALGETENUMVALUE)( const ALchar* ename ); +typedef void (AL_APIENTRY *LPALLISTENERF)( ALenum param, ALfloat value ); +typedef void (AL_APIENTRY *LPALLISTENER3F)( ALenum param, ALfloat value1, ALfloat value2, ALfloat value3 ); +typedef void (AL_APIENTRY *LPALLISTENERFV)( ALenum param, const ALfloat* values ); +typedef void (AL_APIENTRY *LPALLISTENERI)( ALenum param, ALint value ); +typedef void (AL_APIENTRY *LPALLISTENER3I)( ALenum param, ALint value1, ALint value2, ALint value3 ); +typedef void (AL_APIENTRY *LPALLISTENERIV)( ALenum param, const ALint* values ); +typedef void (AL_APIENTRY *LPALGETLISTENERF)( ALenum param, ALfloat* value ); +typedef void (AL_APIENTRY *LPALGETLISTENER3F)( ALenum param, ALfloat *value1, ALfloat *value2, ALfloat *value3 ); +typedef void (AL_APIENTRY *LPALGETLISTENERFV)( ALenum param, ALfloat* values ); +typedef void (AL_APIENTRY *LPALGETLISTENERI)( ALenum param, ALint* value ); +typedef void (AL_APIENTRY *LPALGETLISTENER3I)( ALenum param, ALint *value1, ALint *value2, ALint *value3 ); +typedef void (AL_APIENTRY *LPALGETLISTENERIV)( ALenum param, ALint* values ); +typedef void (AL_APIENTRY *LPALGENSOURCES)( ALsizei n, ALuint* sources ); +typedef void (AL_APIENTRY *LPALDELETESOURCES)( ALsizei n, const ALuint* sources ); +typedef ALboolean (AL_APIENTRY *LPALISSOURCE)( ALuint sid ); +typedef void (AL_APIENTRY *LPALSOURCEF)( ALuint sid, ALenum param, ALfloat value); +typedef void (AL_APIENTRY *LPALSOURCE3F)( ALuint sid, ALenum param, ALfloat value1, ALfloat value2, ALfloat value3 ); +typedef void (AL_APIENTRY *LPALSOURCEFV)( ALuint sid, ALenum param, const ALfloat* values ); +typedef void (AL_APIENTRY *LPALSOURCEI)( ALuint sid, ALenum param, ALint value); +typedef void (AL_APIENTRY *LPALSOURCE3I)( ALuint sid, ALenum param, ALint value1, ALint value2, ALint value3 ); +typedef void (AL_APIENTRY *LPALSOURCEIV)( ALuint sid, ALenum param, const ALint* values ); +typedef void (AL_APIENTRY *LPALGETSOURCEF)( ALuint sid, ALenum param, ALfloat* value ); +typedef void (AL_APIENTRY *LPALGETSOURCE3F)( ALuint sid, ALenum param, ALfloat* value1, ALfloat* value2, ALfloat* value3); +typedef void (AL_APIENTRY *LPALGETSOURCEFV)( ALuint sid, ALenum param, ALfloat* values ); +typedef void (AL_APIENTRY *LPALGETSOURCEI)( ALuint sid, ALenum param, ALint* value ); +typedef void (AL_APIENTRY *LPALGETSOURCE3I)( ALuint sid, ALenum param, ALint* value1, ALint* value2, ALint* value3); +typedef void (AL_APIENTRY *LPALGETSOURCEIV)( ALuint sid, ALenum param, ALint* values ); +typedef void (AL_APIENTRY *LPALSOURCEPLAYV)( ALsizei ns, const ALuint *sids ); +typedef void (AL_APIENTRY *LPALSOURCESTOPV)( ALsizei ns, const ALuint *sids ); +typedef void (AL_APIENTRY *LPALSOURCEREWINDV)( ALsizei ns, const ALuint *sids ); +typedef void (AL_APIENTRY *LPALSOURCEPAUSEV)( ALsizei ns, const ALuint *sids ); +typedef void (AL_APIENTRY *LPALSOURCEPLAY)( ALuint sid ); +typedef void (AL_APIENTRY *LPALSOURCESTOP)( ALuint sid ); +typedef void (AL_APIENTRY *LPALSOURCEREWIND)( ALuint sid ); +typedef void (AL_APIENTRY *LPALSOURCEPAUSE)( ALuint sid ); +typedef void (AL_APIENTRY *LPALSOURCEQUEUEBUFFERS)(ALuint sid, ALsizei numEntries, const ALuint *bids ); +typedef void (AL_APIENTRY *LPALSOURCEUNQUEUEBUFFERS)(ALuint sid, ALsizei numEntries, ALuint *bids ); +typedef void (AL_APIENTRY *LPALGENBUFFERS)( ALsizei n, ALuint* buffers ); +typedef void (AL_APIENTRY *LPALDELETEBUFFERS)( ALsizei n, const ALuint* buffers ); +typedef ALboolean (AL_APIENTRY *LPALISBUFFER)( ALuint bid ); +typedef void (AL_APIENTRY *LPALBUFFERDATA)( ALuint bid, ALenum format, const ALvoid* data, ALsizei size, ALsizei freq ); +typedef void (AL_APIENTRY *LPALBUFFERF)( ALuint bid, ALenum param, ALfloat value); +typedef void (AL_APIENTRY *LPALBUFFER3F)( ALuint bid, ALenum param, ALfloat value1, ALfloat value2, ALfloat value3 ); +typedef void (AL_APIENTRY *LPALBUFFERFV)( ALuint bid, ALenum param, const ALfloat* values ); +typedef void (AL_APIENTRY *LPALBUFFERI)( ALuint bid, ALenum param, ALint value); +typedef void (AL_APIENTRY *LPALBUFFER3I)( ALuint bid, ALenum param, ALint value1, ALint value2, ALint value3 ); +typedef void (AL_APIENTRY *LPALBUFFERIV)( ALuint bid, ALenum param, const ALint* values ); +typedef void (AL_APIENTRY *LPALGETBUFFERF)( ALuint bid, ALenum param, ALfloat* value ); +typedef void (AL_APIENTRY *LPALGETBUFFER3F)( ALuint bid, ALenum param, ALfloat* value1, ALfloat* value2, ALfloat* value3); +typedef void (AL_APIENTRY *LPALGETBUFFERFV)( ALuint bid, ALenum param, ALfloat* values ); +typedef void (AL_APIENTRY *LPALGETBUFFERI)( ALuint bid, ALenum param, ALint* value ); +typedef void (AL_APIENTRY *LPALGETBUFFER3I)( ALuint bid, ALenum param, ALint* value1, ALint* value2, ALint* value3); +typedef void (AL_APIENTRY *LPALGETBUFFERIV)( ALuint bid, ALenum param, ALint* values ); +typedef void (AL_APIENTRY *LPALDOPPLERFACTOR)( ALfloat value ); +typedef void (AL_APIENTRY *LPALDOPPLERVELOCITY)( ALfloat value ); +typedef void (AL_APIENTRY *LPALSPEEDOFSOUND)( ALfloat value ); +typedef void (AL_APIENTRY *LPALDISTANCEMODEL)( ALenum distanceModel ); + +#endif /* AL_NO_PROTOTYPES */ + +#if TARGET_OS_MAC + #pragma export off +#endif + +#if defined(__cplusplus) +} /* extern "C" */ +#endif + +#endif /* AL_AL_H */ diff --git a/Racer/openAL/include/alc.h b/Racer/openAL/include/alc.h new file mode 100644 index 0000000..b0bbfbe --- /dev/null +++ b/Racer/openAL/include/alc.h @@ -0,0 +1,281 @@ +#ifndef AL_ALC_H +#define AL_ALC_H + +#if defined(__cplusplus) +extern "C" { +#endif + +#if defined(_WIN32) && !defined(_XBOX) + /* _OPENAL32LIB is deprecated */ + #if defined(AL_BUILD_LIBRARY) || defined (_OPENAL32LIB) + #define ALC_API __declspec(dllexport) + #else + #define ALC_API __declspec(dllimport) + #endif +#else + #if defined(AL_BUILD_LIBRARY) && defined(HAVE_GCC_VISIBILITY) + #define ALC_API __attribute__((visibility("default"))) + #else + #define ALC_API extern + #endif +#endif + +#if defined(_WIN32) + #define ALC_APIENTRY __cdecl +#else + #define ALC_APIENTRY +#endif + +#if defined(TARGET_OS_MAC) && TARGET_OS_MAC + #pragma export on +#endif + +/* + * The ALCAPI, ALCAPIENTRY, and ALC_INVALID macros are deprecated, but are + * included for applications porting code from AL 1.0 + */ +#define ALCAPI ALC_API +#define ALCAPIENTRY ALC_APIENTRY +#define ALC_INVALID 0 + + +#define ALC_VERSION_0_1 1 + +typedef struct ALCdevice_struct ALCdevice; +typedef struct ALCcontext_struct ALCcontext; + + +/** 8-bit boolean */ +typedef char ALCboolean; + +/** character */ +typedef char ALCchar; + +/** signed 8-bit 2's complement integer */ +typedef char ALCbyte; + +/** unsigned 8-bit integer */ +typedef unsigned char ALCubyte; + +/** signed 16-bit 2's complement integer */ +typedef short ALCshort; + +/** unsigned 16-bit integer */ +typedef unsigned short ALCushort; + +/** signed 32-bit 2's complement integer */ +typedef int ALCint; + +/** unsigned 32-bit integer */ +typedef unsigned int ALCuint; + +/** non-negative 32-bit binary integer size */ +typedef int ALCsizei; + +/** enumerated 32-bit value */ +typedef int ALCenum; + +/** 32-bit IEEE754 floating-point */ +typedef float ALCfloat; + +/** 64-bit IEEE754 floating-point */ +typedef double ALCdouble; + +/** void type (for opaque pointers only) */ +typedef void ALCvoid; + + +/* Enumerant values begin at column 50. No tabs. */ + +/* Boolean False. */ +#define ALC_FALSE 0 + +/* Boolean True. */ +#define ALC_TRUE 1 + +/** + * followed by Hz + */ +#define ALC_FREQUENCY 0x1007 + +/** + * followed by Hz + */ +#define ALC_REFRESH 0x1008 + +/** + * followed by AL_TRUE, AL_FALSE + */ +#define ALC_SYNC 0x1009 + +/** + * followed by Num of requested Mono (3D) Sources + */ +#define ALC_MONO_SOURCES 0x1010 + +/** + * followed by Num of requested Stereo Sources + */ +#define ALC_STEREO_SOURCES 0x1011 + +/** + * errors + */ + +/** + * No error + */ +#define ALC_NO_ERROR ALC_FALSE + +/** + * No device + */ +#define ALC_INVALID_DEVICE 0xA001 + +/** + * invalid context ID + */ +#define ALC_INVALID_CONTEXT 0xA002 + +/** + * bad enum + */ +#define ALC_INVALID_ENUM 0xA003 + +/** + * bad value + */ +#define ALC_INVALID_VALUE 0xA004 + +/** + * Out of memory. + */ +#define ALC_OUT_OF_MEMORY 0xA005 + + +/** + * The Specifier string for default device + */ +#define ALC_DEFAULT_DEVICE_SPECIFIER 0x1004 +#define ALC_DEVICE_SPECIFIER 0x1005 +#define ALC_EXTENSIONS 0x1006 + +#define ALC_MAJOR_VERSION 0x1000 +#define ALC_MINOR_VERSION 0x1001 + +#define ALC_ATTRIBUTES_SIZE 0x1002 +#define ALC_ALL_ATTRIBUTES 0x1003 + +/** + * ALC_ENUMERATE_ALL_EXT enums + */ +#define ALC_DEFAULT_ALL_DEVICES_SPECIFIER 0x1012 +#define ALC_ALL_DEVICES_SPECIFIER 0x1013 + +/** + * Capture extension + */ +#define ALC_CAPTURE_DEVICE_SPECIFIER 0x310 +#define ALC_CAPTURE_DEFAULT_DEVICE_SPECIFIER 0x311 +#define ALC_CAPTURE_SAMPLES 0x312 + + +/* + * Context Management + */ +ALC_API ALCcontext * ALC_APIENTRY alcCreateContext( ALCdevice *device, const ALCint* attrlist ); + +ALC_API ALCboolean ALC_APIENTRY alcMakeContextCurrent( ALCcontext *context ); + +ALC_API void ALC_APIENTRY alcProcessContext( ALCcontext *context ); + +ALC_API void ALC_APIENTRY alcSuspendContext( ALCcontext *context ); + +ALC_API void ALC_APIENTRY alcDestroyContext( ALCcontext *context ); + +ALC_API ALCcontext * ALC_APIENTRY alcGetCurrentContext( void ); + +ALC_API ALCdevice* ALC_APIENTRY alcGetContextsDevice( ALCcontext *context ); + + +/* + * Device Management + */ +ALC_API ALCdevice * ALC_APIENTRY alcOpenDevice( const ALCchar *devicename ); + +ALC_API ALCboolean ALC_APIENTRY alcCloseDevice( ALCdevice *device ); + + +/* + * Error support. + * Obtain the most recent Context error + */ +ALC_API ALCenum ALC_APIENTRY alcGetError( ALCdevice *device ); + + +/* + * Extension support. + * Query for the presence of an extension, and obtain any appropriate + * function pointers and enum values. + */ +ALC_API ALCboolean ALC_APIENTRY alcIsExtensionPresent( ALCdevice *device, const ALCchar *extname ); + +ALC_API void * ALC_APIENTRY alcGetProcAddress( ALCdevice *device, const ALCchar *funcname ); + +ALC_API ALCenum ALC_APIENTRY alcGetEnumValue( ALCdevice *device, const ALCchar *enumname ); + + +/* + * Query functions + */ +ALC_API const ALCchar * ALC_APIENTRY alcGetString( ALCdevice *device, ALCenum param ); + +ALC_API void ALC_APIENTRY alcGetIntegerv( ALCdevice *device, ALCenum param, ALCsizei size, ALCint *data ); + + +/* + * Capture functions + */ +ALC_API ALCdevice* ALC_APIENTRY alcCaptureOpenDevice( const ALCchar *devicename, ALCuint frequency, ALCenum format, ALCsizei buffersize ); + +ALC_API ALCboolean ALC_APIENTRY alcCaptureCloseDevice( ALCdevice *device ); + +ALC_API void ALC_APIENTRY alcCaptureStart( ALCdevice *device ); + +ALC_API void ALC_APIENTRY alcCaptureStop( ALCdevice *device ); + +ALC_API void ALC_APIENTRY alcCaptureSamples( ALCdevice *device, ALCvoid *buffer, ALCsizei samples ); + +/* + * Pointer-to-function types, useful for dynamically getting ALC entry points. + */ +typedef ALCcontext * (ALC_APIENTRY *LPALCCREATECONTEXT) (ALCdevice *device, const ALCint *attrlist); +typedef ALCboolean (ALC_APIENTRY *LPALCMAKECONTEXTCURRENT)( ALCcontext *context ); +typedef void (ALC_APIENTRY *LPALCPROCESSCONTEXT)( ALCcontext *context ); +typedef void (ALC_APIENTRY *LPALCSUSPENDCONTEXT)( ALCcontext *context ); +typedef void (ALC_APIENTRY *LPALCDESTROYCONTEXT)( ALCcontext *context ); +typedef ALCcontext * (ALC_APIENTRY *LPALCGETCURRENTCONTEXT)( void ); +typedef ALCdevice * (ALC_APIENTRY *LPALCGETCONTEXTSDEVICE)( ALCcontext *context ); +typedef ALCdevice * (ALC_APIENTRY *LPALCOPENDEVICE)( const ALCchar *devicename ); +typedef ALCboolean (ALC_APIENTRY *LPALCCLOSEDEVICE)( ALCdevice *device ); +typedef ALCenum (ALC_APIENTRY *LPALCGETERROR)( ALCdevice *device ); +typedef ALCboolean (ALC_APIENTRY *LPALCISEXTENSIONPRESENT)( ALCdevice *device, const ALCchar *extname ); +typedef void * (ALC_APIENTRY *LPALCGETPROCADDRESS)(ALCdevice *device, const ALCchar *funcname ); +typedef ALCenum (ALC_APIENTRY *LPALCGETENUMVALUE)(ALCdevice *device, const ALCchar *enumname ); +typedef const ALCchar* (ALC_APIENTRY *LPALCGETSTRING)( ALCdevice *device, ALCenum param ); +typedef void (ALC_APIENTRY *LPALCGETINTEGERV)( ALCdevice *device, ALCenum param, ALCsizei size, ALCint *dest ); +typedef ALCdevice * (ALC_APIENTRY *LPALCCAPTUREOPENDEVICE)( const ALCchar *devicename, ALCuint frequency, ALCenum format, ALCsizei buffersize ); +typedef ALCboolean (ALC_APIENTRY *LPALCCAPTURECLOSEDEVICE)( ALCdevice *device ); +typedef void (ALC_APIENTRY *LPALCCAPTURESTART)( ALCdevice *device ); +typedef void (ALC_APIENTRY *LPALCCAPTURESTOP)( ALCdevice *device ); +typedef void (ALC_APIENTRY *LPALCCAPTURESAMPLES)( ALCdevice *device, ALCvoid *buffer, ALCsizei samples ); + +#if defined(TARGET_OS_MAC) && TARGET_OS_MAC + #pragma export off +#endif + +#if defined(__cplusplus) +} +#endif + +#endif /* AL_ALC_H */ diff --git a/Racer/openAL/include/efx-creative.h b/Racer/openAL/include/efx-creative.h new file mode 100644 index 0000000..4ea9da6 --- /dev/null +++ b/Racer/openAL/include/efx-creative.h @@ -0,0 +1,151 @@ +#ifndef __efxcreative_h_ +#define __efxcreative_h_ + +/** + * efx-creative.h - Environmental Audio Extensions + * for OpenAL Effects Extension. + * + */ +#ifdef __cplusplus +extern "C" { +#endif + + +/** + * Effect object definitions to be used with alEffect functions. + * + * Effect parameter value definitions, ranges, and defaults + * appear farther down in this file. + */ + +/* AL EAXReverb effect parameters. */ +#define AL_EAXREVERB_DENSITY 0x0001 +#define AL_EAXREVERB_DIFFUSION 0x0002 +#define AL_EAXREVERB_GAIN 0x0003 +#define AL_EAXREVERB_GAINHF 0x0004 +#define AL_EAXREVERB_GAINLF 0x0005 +#define AL_EAXREVERB_DECAY_TIME 0x0006 +#define AL_EAXREVERB_DECAY_HFRATIO 0x0007 +#define AL_EAXREVERB_DECAY_LFRATIO 0x0008 +#define AL_EAXREVERB_REFLECTIONS_GAIN 0x0009 +#define AL_EAXREVERB_REFLECTIONS_DELAY 0x000A +#define AL_EAXREVERB_REFLECTIONS_PAN 0x000B +#define AL_EAXREVERB_LATE_REVERB_GAIN 0x000C +#define AL_EAXREVERB_LATE_REVERB_DELAY 0x000D +#define AL_EAXREVERB_LATE_REVERB_PAN 0x000E +#define AL_EAXREVERB_ECHO_TIME 0x000F +#define AL_EAXREVERB_ECHO_DEPTH 0x0010 +#define AL_EAXREVERB_MODULATION_TIME 0x0011 +#define AL_EAXREVERB_MODULATION_DEPTH 0x0012 +#define AL_EAXREVERB_AIR_ABSORPTION_GAINHF 0x0013 +#define AL_EAXREVERB_HFREFERENCE 0x0014 +#define AL_EAXREVERB_LFREFERENCE 0x0015 +#define AL_EAXREVERB_ROOM_ROLLOFF_FACTOR 0x0016 +#define AL_EAXREVERB_DECAY_HFLIMIT 0x0017 + +/* Effect type definitions to be used with AL_EFFECT_TYPE. */ +#define AL_EFFECT_EAXREVERB 0x8000 + + + + /********************************************************** + * Effect parameter structures, value definitions, ranges and defaults. + */ + +/** + * AL reverb effect parameter ranges and defaults + */ +#define AL_EAXREVERB_MIN_DENSITY 0.0f +#define AL_EAXREVERB_MAX_DENSITY 1.0f +#define AL_EAXREVERB_DEFAULT_DENSITY 1.0f + +#define AL_EAXREVERB_MIN_DIFFUSION 0.0f +#define AL_EAXREVERB_MAX_DIFFUSION 1.0f +#define AL_EAXREVERB_DEFAULT_DIFFUSION 1.0f + +#define AL_EAXREVERB_MIN_GAIN 0.0f +#define AL_EAXREVERB_MAX_GAIN 1.0f +#define AL_EAXREVERB_DEFAULT_GAIN 0.32f + +#define AL_EAXREVERB_MIN_GAINHF 0.0f +#define AL_EAXREVERB_MAX_GAINHF 1.0f +#define AL_EAXREVERB_DEFAULT_GAINHF 0.89f + +#define AL_EAXREVERB_MIN_GAINLF 0.0f +#define AL_EAXREVERB_MAX_GAINLF 1.0f +#define AL_EAXREVERB_DEFAULT_GAINLF 1.0f + +#define AL_EAXREVERB_MIN_DECAY_TIME 0.1f +#define AL_EAXREVERB_MAX_DECAY_TIME 20.0f +#define AL_EAXREVERB_DEFAULT_DECAY_TIME 1.49f + +#define AL_EAXREVERB_MIN_DECAY_HFRATIO 0.1f +#define AL_EAXREVERB_MAX_DECAY_HFRATIO 2.0f +#define AL_EAXREVERB_DEFAULT_DECAY_HFRATIO 0.83f + +#define AL_EAXREVERB_MIN_DECAY_LFRATIO 0.1f +#define AL_EAXREVERB_MAX_DECAY_LFRATIO 2.0f +#define AL_EAXREVERB_DEFAULT_DECAY_LFRATIO 1.0f + +#define AL_EAXREVERB_MIN_REFLECTIONS_GAIN 0.0f +#define AL_EAXREVERB_MAX_REFLECTIONS_GAIN 3.16f +#define AL_EAXREVERB_DEFAULT_REFLECTIONS_GAIN 0.05f + +#define AL_EAXREVERB_MIN_REFLECTIONS_DELAY 0.0f +#define AL_EAXREVERB_MAX_REFLECTIONS_DELAY 0.3f +#define AL_EAXREVERB_DEFAULT_REFLECTIONS_DELAY 0.007f + +#define AL_EAXREVERB_DEFAULT_REFLECTIONS_PAN {0.0f, 0.0f, 0.0f} + +#define AL_EAXREVERB_MIN_LATE_REVERB_GAIN 0.0f +#define AL_EAXREVERB_MAX_LATE_REVERB_GAIN 10.0f +#define AL_EAXREVERB_DEFAULT_LATE_REVERB_GAIN 1.26f + +#define AL_EAXREVERB_MIN_LATE_REVERB_DELAY 0.0f +#define AL_EAXREVERB_MAX_LATE_REVERB_DELAY 0.1f +#define AL_EAXREVERB_DEFAULT_LATE_REVERB_DELAY 0.011f + +#define AL_EAXREVERB_DEFAULT_LATE_REVERB_PAN {0.0f, 0.0f, 0.0f} + +#define AL_EAXREVERB_MIN_ECHO_TIME 0.075f +#define AL_EAXREVERB_MAX_ECHO_TIME 0.25f +#define AL_EAXREVERB_DEFAULT_ECHO_TIME 0.25f + +#define AL_EAXREVERB_MIN_ECHO_DEPTH 0.0f +#define AL_EAXREVERB_MAX_ECHO_DEPTH 1.0f +#define AL_EAXREVERB_DEFAULT_ECHO_DEPTH 0.0f + +#define AL_EAXREVERB_MIN_MODULATION_TIME 0.04f +#define AL_EAXREVERB_MAX_MODULATION_TIME 4.0f +#define AL_EAXREVERB_DEFAULT_MODULATION_TIME 0.25f + +#define AL_EAXREVERB_MIN_MODULATION_DEPTH 0.0f +#define AL_EAXREVERB_MAX_MODULATION_DEPTH 1.0f +#define AL_EAXREVERB_DEFAULT_MODULATION_DEPTH 0.0f + +#define AL_EAXREVERB_MIN_AIR_ABSORPTION_GAINHF 0.892f +#define AL_EAXREVERB_MAX_AIR_ABSORPTION_GAINHF 1.0f +#define AL_EAXREVERB_DEFAULT_AIR_ABSORPTION_GAINHF 0.994f + +#define AL_EAXREVERB_MIN_HFREFERENCE 1000.0f +#define AL_EAXREVERB_MAX_HFREFERENCE 20000.0f +#define AL_EAXREVERB_DEFAULT_HFREFERENCE 5000.0f + +#define AL_EAXREVERB_MIN_LFREFERENCE 20.0f +#define AL_EAXREVERB_MAX_LFREFERENCE 1000.0f +#define AL_EAXREVERB_DEFAULT_LFREFERENCE 250.0f + +#define AL_EAXREVERB_MIN_ROOM_ROLLOFF_FACTOR 0.0f +#define AL_EAXREVERB_MAX_ROOM_ROLLOFF_FACTOR 10.0f +#define AL_EAXREVERB_DEFAULT_ROOM_ROLLOFF_FACTOR 0.0f + +#define AL_EAXREVERB_MIN_DECAY_HFLIMIT AL_FALSE +#define AL_EAXREVERB_MAX_DECAY_HFLIMIT AL_TRUE +#define AL_EAXREVERB_DEFAULT_DECAY_HFLIMIT AL_TRUE + + +#ifdef __cplusplus +} /* extern "C" */ +#endif + +#endif /* __efxcreative_h_ */ diff --git a/Racer/openAL/include/efx.h b/Racer/openAL/include/efx.h new file mode 100644 index 0000000..fece160 --- /dev/null +++ b/Racer/openAL/include/efx.h @@ -0,0 +1,737 @@ +#ifndef __efx_h_ +#define __efx_h_ + + +#ifdef __cplusplus +extern "C" { +#endif + +#define ALC_EXT_EFX_NAME "ALC_EXT_EFX" + +/** + * Context definitions to be used with alcCreateContext. + * These values must be unique and not conflict with other + * al context values. + */ +#define ALC_EFX_MAJOR_VERSION 0x20001 +#define ALC_EFX_MINOR_VERSION 0x20002 +#define ALC_MAX_AUXILIARY_SENDS 0x20003 + + + + +/** + * Listener definitions to be used with alListener functions. + * These values must be unique and not conflict with other + * al listener values. + */ +#define AL_METERS_PER_UNIT 0x20004 + + + + +/** + * Source definitions to be used with alSource functions. + * These values must be unique and not conflict with other + * al source values. + */ +#define AL_DIRECT_FILTER 0x20005 +#define AL_AUXILIARY_SEND_FILTER 0x20006 +#define AL_AIR_ABSORPTION_FACTOR 0x20007 +#define AL_ROOM_ROLLOFF_FACTOR 0x20008 +#define AL_CONE_OUTER_GAINHF 0x20009 +#define AL_DIRECT_FILTER_GAINHF_AUTO 0x2000A +#define AL_AUXILIARY_SEND_FILTER_GAIN_AUTO 0x2000B +#define AL_AUXILIARY_SEND_FILTER_GAINHF_AUTO 0x2000C + + + + +/** + * Effect object definitions to be used with alEffect functions. + * + * Effect parameter value definitions, ranges, and defaults + * appear farther down in this file. + */ + +/* Reverb Parameters */ +#define AL_REVERB_DENSITY 0x0001 +#define AL_REVERB_DIFFUSION 0x0002 +#define AL_REVERB_GAIN 0x0003 +#define AL_REVERB_GAINHF 0x0004 +#define AL_REVERB_DECAY_TIME 0x0005 +#define AL_REVERB_DECAY_HFRATIO 0x0006 +#define AL_REVERB_REFLECTIONS_GAIN 0x0007 +#define AL_REVERB_REFLECTIONS_DELAY 0x0008 +#define AL_REVERB_LATE_REVERB_GAIN 0x0009 +#define AL_REVERB_LATE_REVERB_DELAY 0x000A +#define AL_REVERB_AIR_ABSORPTION_GAINHF 0x000B +#define AL_REVERB_ROOM_ROLLOFF_FACTOR 0x000C +#define AL_REVERB_DECAY_HFLIMIT 0x000D + +/* Chorus Parameters */ +#define AL_CHORUS_WAVEFORM 0x0001 +#define AL_CHORUS_PHASE 0x0002 +#define AL_CHORUS_RATE 0x0003 +#define AL_CHORUS_DEPTH 0x0004 +#define AL_CHORUS_FEEDBACK 0x0005 +#define AL_CHORUS_DELAY 0x0006 + +/* Distortion Parameters */ +#define AL_DISTORTION_EDGE 0x0001 +#define AL_DISTORTION_GAIN 0x0002 +#define AL_DISTORTION_LOWPASS_CUTOFF 0x0003 +#define AL_DISTORTION_EQCENTER 0x0004 +#define AL_DISTORTION_EQBANDWIDTH 0x0005 + +/* Echo Parameters */ +#define AL_ECHO_DELAY 0x0001 +#define AL_ECHO_LRDELAY 0x0002 +#define AL_ECHO_DAMPING 0x0003 +#define AL_ECHO_FEEDBACK 0x0004 +#define AL_ECHO_SPREAD 0x0005 + +/* Flanger Parameters */ +#define AL_FLANGER_WAVEFORM 0x0001 +#define AL_FLANGER_PHASE 0x0002 +#define AL_FLANGER_RATE 0x0003 +#define AL_FLANGER_DEPTH 0x0004 +#define AL_FLANGER_FEEDBACK 0x0005 +#define AL_FLANGER_DELAY 0x0006 + +/* Frequencyshifter Parameters */ +#define AL_FREQUENCY_SHIFTER_FREQUENCY 0x0001 +#define AL_FREQUENCY_SHIFTER_LEFT_DIRECTION 0x0002 +#define AL_FREQUENCY_SHIFTER_RIGHT_DIRECTION 0x0003 + +/* Vocalmorpher Parameters */ +#define AL_VOCAL_MORPHER_PHONEMEA 0x0001 +#define AL_VOCAL_MORPHER_PHONEMEA_COARSE_TUNING 0x0002 +#define AL_VOCAL_MORPHER_PHONEMEB 0x0003 +#define AL_VOCAL_MORPHER_PHONEMEB_COARSE_TUNING 0x0004 +#define AL_VOCAL_MORPHER_WAVEFORM 0x0005 +#define AL_VOCAL_MORPHER_RATE 0x0006 + +/* Pitchshifter Parameters */ +#define AL_PITCH_SHIFTER_COARSE_TUNE 0x0001 +#define AL_PITCH_SHIFTER_FINE_TUNE 0x0002 + +/* Ringmodulator Parameters */ +#define AL_RING_MODULATOR_FREQUENCY 0x0001 +#define AL_RING_MODULATOR_HIGHPASS_CUTOFF 0x0002 +#define AL_RING_MODULATOR_WAVEFORM 0x0003 + +/* Autowah Parameters */ +#define AL_AUTOWAH_ATTACK_TIME 0x0001 +#define AL_AUTOWAH_RELEASE_TIME 0x0002 +#define AL_AUTOWAH_RESONANCE 0x0003 +#define AL_AUTOWAH_PEAK_GAIN 0x0004 + +/* Compressor Parameters */ +#define AL_COMPRESSOR_ONOFF 0x0001 + +/* Equalizer Parameters */ +#define AL_EQUALIZER_LOW_GAIN 0x0001 +#define AL_EQUALIZER_LOW_CUTOFF 0x0002 +#define AL_EQUALIZER_MID1_GAIN 0x0003 +#define AL_EQUALIZER_MID1_CENTER 0x0004 +#define AL_EQUALIZER_MID1_WIDTH 0x0005 +#define AL_EQUALIZER_MID2_GAIN 0x0006 +#define AL_EQUALIZER_MID2_CENTER 0x0007 +#define AL_EQUALIZER_MID2_WIDTH 0x0008 +#define AL_EQUALIZER_HIGH_GAIN 0x0009 +#define AL_EQUALIZER_HIGH_CUTOFF 0x000A + +/* Effect type */ +#define AL_EFFECT_FIRST_PARAMETER 0x0000 +#define AL_EFFECT_LAST_PARAMETER 0x8000 +#define AL_EFFECT_TYPE 0x8001 + +/* Effect type definitions to be used with AL_EFFECT_TYPE. */ +#define AL_EFFECT_NULL 0x0000 /* Can also be used as an Effect Object ID */ +#define AL_EFFECT_REVERB 0x0001 +#define AL_EFFECT_CHORUS 0x0002 +#define AL_EFFECT_DISTORTION 0x0003 +#define AL_EFFECT_ECHO 0x0004 +#define AL_EFFECT_FLANGER 0x0005 +#define AL_EFFECT_FREQUENCY_SHIFTER 0x0006 +#define AL_EFFECT_VOCAL_MORPHER 0x0007 +#define AL_EFFECT_PITCH_SHIFTER 0x0008 +#define AL_EFFECT_RING_MODULATOR 0x0009 +#define AL_EFFECT_AUTOWAH 0x000A +#define AL_EFFECT_COMPRESSOR 0x000B +#define AL_EFFECT_EQUALIZER 0x000C + +/** + * Auxiliary Slot object definitions to be used with alAuxiliaryEffectSlot functions. + */ +#define AL_EFFECTSLOT_EFFECT 0x0001 +#define AL_EFFECTSLOT_GAIN 0x0002 +#define AL_EFFECTSLOT_AUXILIARY_SEND_AUTO 0x0003 + +/** + * Value to be used as an Auxiliary Slot ID to disable a source send.. + */ +#define AL_EFFECTSLOT_NULL 0x0000 + + + +/** + * Filter object definitions to be used with alFilter functions. + */ + +/* Lowpass parameters. */ +#define AL_LOWPASS_GAIN 0x0001 +#define AL_LOWPASS_GAINHF 0x0002 + +/* Highpass Parameters */ +#define AL_HIGHPASS_GAIN 0x0001 +#define AL_HIGHPASS_GAINLF 0x0002 + +/* Bandpass Parameters */ +#define AL_BANDPASS_GAIN 0x0001 +#define AL_BANDPASS_GAINLF 0x0002 +#define AL_BANDPASS_GAINHF 0x0003 + +/* Filter type */ +#define AL_FILTER_FIRST_PARAMETER 0x0000 +#define AL_FILTER_LAST_PARAMETER 0x8000 +#define AL_FILTER_TYPE 0x8001 + +/* Filter type definitions to be used with AL_FILTER_TYPE. */ +#define AL_FILTER_NULL 0x0000 /* Can also be used as a Filter Object ID */ +#define AL_FILTER_LOWPASS 0x0001 +#define AL_FILTER_HIGHPASS 0x0002 +#define AL_FILTER_BANDPASS 0x0003 + + +/** + * Effect object functions. + */ + +/* Create Effect objects. */ +typedef void (__cdecl *LPALGENEFFECTS)( ALsizei n, ALuint* effects ); + +/* Delete Effect objects. */ +typedef void (__cdecl *LPALDELETEEFFECTS)( ALsizei n, ALuint* effects ); + +/* Verify a handle is a valid Effect. */ +typedef ALboolean (__cdecl *LPALISEFFECT)( ALuint eid ); + +/* Set an integer parameter for an Effect object. */ +typedef void (__cdecl *LPALEFFECTI)( ALuint eid, ALenum param, ALint value); +typedef void (__cdecl *LPALEFFECTIV)( ALuint eid, ALenum param, ALint* values ); + +/* Set a floating point parameter for an Effect object. */ +typedef void (__cdecl *LPALEFFECTF)( ALuint eid, ALenum param, ALfloat value); +typedef void (__cdecl *LPALEFFECTFV)( ALuint eid, ALenum param, ALfloat* values ); + +/* Get an integer parameter for an Effect object. */ +typedef void (__cdecl *LPALGETEFFECTI)( ALuint eid, ALenum pname, ALint* value ); +typedef void (__cdecl *LPALGETEFFECTIV)( ALuint eid, ALenum pname, ALint* values ); + +/* Get a floating point parameter for an Effect object. */ +typedef void (__cdecl *LPALGETEFFECTF)( ALuint eid, ALenum pname, ALfloat* value ); +typedef void (__cdecl *LPALGETEFFECTFV)( ALuint eid, ALenum pname, ALfloat* values ); + + +/** + * Filter object functions + */ + +/* Create Filter objects. */ +typedef void (__cdecl *LPALGENFILTERS)( ALsizei n, ALuint* filters ); + +/* Delete Filter objects. */ +typedef void (__cdecl *LPALDELETEFILTERS)( ALsizei n, ALuint* filters ); + +/* Verify a handle is a valid Filter. */ +typedef ALboolean (__cdecl *LPALISFILTER)( ALuint fid ); + +/* Set an integer parameter for a Filter object. */ +typedef void (__cdecl *LPALFILTERI)( ALuint fid, ALenum param, ALint value ); +typedef void (__cdecl *LPALFILTERIV)( ALuint fid, ALenum param, ALint* values ); + +/* Set a floating point parameter for an Filter object. */ +typedef void (__cdecl *LPALFILTERF)( ALuint fid, ALenum param, ALfloat value); +typedef void (__cdecl *LPALFILTERFV)( ALuint fid, ALenum param, ALfloat* values ); + +/* Get an integer parameter for a Filter object. */ +typedef void (__cdecl *LPALGETFILTERI)( ALuint fid, ALenum pname, ALint* value ); +typedef void (__cdecl *LPALGETFILTERIV)( ALuint fid, ALenum pname, ALint* values ); + +/* Get a floating point parameter for a Filter object. */ +typedef void (__cdecl *LPALGETFILTERF)( ALuint fid, ALenum pname, ALfloat* value ); +typedef void (__cdecl *LPALGETFILTERFV)( ALuint fid, ALenum pname, ALfloat* values ); + + +/** + * Auxiliary Slot object functions + */ + +/* Create Auxiliary Slot objects. */ +typedef void (__cdecl *LPALGENAUXILIARYEFFECTSLOTS)( ALsizei n, ALuint* slots ); + +/* Delete Auxiliary Slot objects. */ +typedef void (__cdecl *LPALDELETEAUXILIARYEFFECTSLOTS)( ALsizei n, ALuint* slots ); + +/* Verify a handle is a valid Auxiliary Slot. */ +typedef ALboolean (__cdecl *LPALISAUXILIARYEFFECTSLOT)( ALuint slot ); + +/* Set an integer parameter for a Auxiliary Slot object. */ +typedef void (__cdecl *LPALAUXILIARYEFFECTSLOTI)( ALuint asid, ALenum param, ALint value ); +typedef void (__cdecl *LPALAUXILIARYEFFECTSLOTIV)( ALuint asid, ALenum param, ALint* values ); + +/* Set a floating point parameter for an Auxiliary Slot object. */ +typedef void (__cdecl *LPALAUXILIARYEFFECTSLOTF)( ALuint asid, ALenum param, ALfloat value ); +typedef void (__cdecl *LPALAUXILIARYEFFECTSLOTFV)( ALuint asid, ALenum param, ALfloat* values ); + +/* Get an integer parameter for a Auxiliary Slot object. */ +typedef void (__cdecl *LPALGETAUXILIARYEFFECTSLOTI)( ALuint asid, ALenum pname, ALint* value ); +typedef void (__cdecl *LPALGETAUXILIARYEFFECTSLOTIV)( ALuint asid, ALenum pname, ALint* values ); + +/* Get a floating point parameter for a Auxiliary Slot object. */ +typedef void (__cdecl *LPALGETAUXILIARYEFFECTSLOTF)( ALuint asid, ALenum pname, ALfloat* value ); +typedef void (__cdecl *LPALGETAUXILIARYEFFECTSLOTFV)( ALuint asid, ALenum pname, ALfloat* values ); + + + + +/********************************************************** + * Filter ranges and defaults. + */ + +/** + * Lowpass filter + */ + +#define LOWPASS_MIN_GAIN 0.0f +#define LOWPASS_MAX_GAIN 1.0f +#define LOWPASS_DEFAULT_GAIN 1.0f + +#define LOWPASS_MIN_GAINHF 0.0f +#define LOWPASS_MAX_GAINHF 1.0f +#define LOWPASS_DEFAULT_GAINHF 1.0f + +/** + * Highpass filter + */ + +#define HIGHPASS_MIN_GAIN 0.0f +#define HIGHPASS_MAX_GAIN 1.0f +#define HIGHPASS_DEFAULT_GAIN 1.0f + +#define HIGHPASS_MIN_GAINLF 0.0f +#define HIGHPASS_MAX_GAINLF 1.0f +#define HIGHPASS_DEFAULT_GAINLF 1.0f + +/** + * Bandpass filter + */ + +#define BANDPASS_MIN_GAIN 0.0f +#define BANDPASS_MAX_GAIN 1.0f +#define BANDPASS_DEFAULT_GAIN 1.0f + +#define BANDPASS_MIN_GAINHF 0.0f +#define BANDPASS_MAX_GAINHF 1.0f +#define BANDPASS_DEFAULT_GAINHF 1.0f + +#define BANDPASS_MIN_GAINLF 0.0f +#define BANDPASS_MAX_GAINLF 1.0f +#define BANDPASS_DEFAULT_GAINLF 1.0f + + + + + /********************************************************** + * Effect parameter structures, value definitions, ranges and defaults. + */ + +/** + * AL reverb effect parameter ranges and defaults + */ +#define AL_REVERB_MIN_DENSITY 0.0f +#define AL_REVERB_MAX_DENSITY 1.0f +#define AL_REVERB_DEFAULT_DENSITY 1.0f + +#define AL_REVERB_MIN_DIFFUSION 0.0f +#define AL_REVERB_MAX_DIFFUSION 1.0f +#define AL_REVERB_DEFAULT_DIFFUSION 1.0f + +#define AL_REVERB_MIN_GAIN 0.0f +#define AL_REVERB_MAX_GAIN 1.0f +#define AL_REVERB_DEFAULT_GAIN 0.32f + +#define AL_REVERB_MIN_GAINHF 0.0f +#define AL_REVERB_MAX_GAINHF 1.0f +#define AL_REVERB_DEFAULT_GAINHF 0.89f + +#define AL_REVERB_MIN_DECAY_TIME 0.1f +#define AL_REVERB_MAX_DECAY_TIME 20.0f +#define AL_REVERB_DEFAULT_DECAY_TIME 1.49f + +#define AL_REVERB_MIN_DECAY_HFRATIO 0.1f +#define AL_REVERB_MAX_DECAY_HFRATIO 2.0f +#define AL_REVERB_DEFAULT_DECAY_HFRATIO 0.83f + +#define AL_REVERB_MIN_REFLECTIONS_GAIN 0.0f +#define AL_REVERB_MAX_REFLECTIONS_GAIN 3.16f +#define AL_REVERB_DEFAULT_REFLECTIONS_GAIN 0.05f + +#define AL_REVERB_MIN_REFLECTIONS_DELAY 0.0f +#define AL_REVERB_MAX_REFLECTIONS_DELAY 0.3f +#define AL_REVERB_DEFAULT_REFLECTIONS_DELAY 0.007f + +#define AL_REVERB_MIN_LATE_REVERB_GAIN 0.0f +#define AL_REVERB_MAX_LATE_REVERB_GAIN 10.0f +#define AL_REVERB_DEFAULT_LATE_REVERB_GAIN 1.26f + +#define AL_REVERB_MIN_LATE_REVERB_DELAY 0.0f +#define AL_REVERB_MAX_LATE_REVERB_DELAY 0.1f +#define AL_REVERB_DEFAULT_LATE_REVERB_DELAY 0.011f + +#define AL_REVERB_MIN_AIR_ABSORPTION_GAINHF 0.892f +#define AL_REVERB_MAX_AIR_ABSORPTION_GAINHF 1.0f +#define AL_REVERB_DEFAULT_AIR_ABSORPTION_GAINHF 0.994f + +#define AL_REVERB_MIN_ROOM_ROLLOFF_FACTOR 0.0f +#define AL_REVERB_MAX_ROOM_ROLLOFF_FACTOR 10.0f +#define AL_REVERB_DEFAULT_ROOM_ROLLOFF_FACTOR 0.0f + +#define AL_REVERB_MIN_DECAY_HFLIMIT AL_FALSE +#define AL_REVERB_MAX_DECAY_HFLIMIT AL_TRUE +#define AL_REVERB_DEFAULT_DECAY_HFLIMIT AL_TRUE + +/** + * AL chorus effect parameter ranges and defaults + */ +#define AL_CHORUS_MIN_WAVEFORM 0 +#define AL_CHORUS_MAX_WAVEFORM 1 +#define AL_CHORUS_DEFAULT_WAVEFORM 1 + +#define AL_CHORUS_WAVEFORM_SINUSOID 0 +#define AL_CHORUS_WAVEFORM_TRIANGLE 1 + +#define AL_CHORUS_MIN_PHASE (-180) +#define AL_CHORUS_MAX_PHASE 180 +#define AL_CHORUS_DEFAULT_PHASE 90 + +#define AL_CHORUS_MIN_RATE 0.0f +#define AL_CHORUS_MAX_RATE 10.0f +#define AL_CHORUS_DEFAULT_RATE 1.1f + +#define AL_CHORUS_MIN_DEPTH 0.0f +#define AL_CHORUS_MAX_DEPTH 1.0f +#define AL_CHORUS_DEFAULT_DEPTH 0.1f + +#define AL_CHORUS_MIN_FEEDBACK (-1.0f) +#define AL_CHORUS_MAX_FEEDBACK 1.0f +#define AL_CHORUS_DEFAULT_FEEDBACK 0.25f + +#define AL_CHORUS_MIN_DELAY 0.0f +#define AL_CHORUS_MAX_DELAY 0.016f +#define AL_CHORUS_DEFAULT_DELAY 0.016f + +/** + * AL distortion effect parameter ranges and defaults + */ +#define AL_DISTORTION_MIN_EDGE 0.0f +#define AL_DISTORTION_MAX_EDGE 1.0f +#define AL_DISTORTION_DEFAULT_EDGE 0.2f + +#define AL_DISTORTION_MIN_GAIN 0.01f +#define AL_DISTORTION_MAX_GAIN 1.0f +#define AL_DISTORTION_DEFAULT_GAIN 0.05f + +#define AL_DISTORTION_MIN_LOWPASS_CUTOFF 80.0f +#define AL_DISTORTION_MAX_LOWPASS_CUTOFF 24000.0f +#define AL_DISTORTION_DEFAULT_LOWPASS_CUTOFF 8000.0f + +#define AL_DISTORTION_MIN_EQCENTER 80.0f +#define AL_DISTORTION_MAX_EQCENTER 24000.0f +#define AL_DISTORTION_DEFAULT_EQCENTER 3600.0f + +#define AL_DISTORTION_MIN_EQBANDWIDTH 80.0f +#define AL_DISTORTION_MAX_EQBANDWIDTH 24000.0f +#define AL_DISTORTION_DEFAULT_EQBANDWIDTH 3600.0f + +/** + * AL echo effect parameter ranges and defaults + */ +#define AL_ECHO_MIN_DELAY 0.0f +#define AL_ECHO_MAX_DELAY 0.207f +#define AL_ECHO_DEFAULT_DELAY 0.1f + +#define AL_ECHO_MIN_LRDELAY 0.0f +#define AL_ECHO_MAX_LRDELAY 0.404f +#define AL_ECHO_DEFAULT_LRDELAY 0.1f + +#define AL_ECHO_MIN_DAMPING 0.0f +#define AL_ECHO_MAX_DAMPING 0.99f +#define AL_ECHO_DEFAULT_DAMPING 0.5f + +#define AL_ECHO_MIN_FEEDBACK 0.0f +#define AL_ECHO_MAX_FEEDBACK 1.0f +#define AL_ECHO_DEFAULT_FEEDBACK 0.5f + +#define AL_ECHO_MIN_SPREAD (-1.0f) +#define AL_ECHO_MAX_SPREAD 1.0f +#define AL_ECHO_DEFAULT_SPREAD (-1.0f) + +/** + * AL flanger effect parameter ranges and defaults + */ +#define AL_FLANGER_MIN_WAVEFORM 0 +#define AL_FLANGER_MAX_WAVEFORM 1 +#define AL_FLANGER_DEFAULT_WAVEFORM 1 + +#define AL_FLANGER_WAVEFORM_SINUSOID 0 +#define AL_FLANGER_WAVEFORM_TRIANGLE 1 + +#define AL_FLANGER_MIN_PHASE (-180) +#define AL_FLANGER_MAX_PHASE 180 +#define AL_FLANGER_DEFAULT_PHASE 0 + +#define AL_FLANGER_MIN_RATE 0.0f +#define AL_FLANGER_MAX_RATE 10.0f +#define AL_FLANGER_DEFAULT_RATE 0.27f + +#define AL_FLANGER_MIN_DEPTH 0.0f +#define AL_FLANGER_MAX_DEPTH 1.0f +#define AL_FLANGER_DEFAULT_DEPTH 1.0f + +#define AL_FLANGER_MIN_FEEDBACK (-1.0f) +#define AL_FLANGER_MAX_FEEDBACK 1.0f +#define AL_FLANGER_DEFAULT_FEEDBACK (-0.5f) + +#define AL_FLANGER_MIN_DELAY 0.0f +#define AL_FLANGER_MAX_DELAY 0.004f +#define AL_FLANGER_DEFAULT_DELAY 0.002f + +/** + * AL frequency shifter effect parameter ranges and defaults + */ +#define AL_FREQUENCY_SHIFTER_MIN_FREQUENCY 0.0f +#define AL_FREQUENCY_SHIFTER_MAX_FREQUENCY 24000.0f +#define AL_FREQUENCY_SHIFTER_DEFAULT_FREQUENCY 0.0f + +#define AL_FREQUENCY_SHIFTER_MIN_LEFT_DIRECTION 0 +#define AL_FREQUENCY_SHIFTER_MAX_LEFT_DIRECTION 2 +#define AL_FREQUENCY_SHIFTER_DEFAULT_LEFT_DIRECTION 0 + +#define AL_FREQUENCY_SHIFTER_MIN_RIGHT_DIRECTION 0 +#define AL_FREQUENCY_SHIFTER_MAX_RIGHT_DIRECTION 2 +#define AL_FREQUENCY_SHIFTER_DEFAULT_RIGHT_DIRECTION 0 + +#define AL_FREQUENCY_SHIFTER_DIRECTION_DOWN 0 +#define AL_FREQUENCY_SHIFTER_DIRECTION_UP 1 +#define AL_FREQUENCY_SHIFTER_DIRECTION_OFF 2 + +/** + * AL vocal morpher effect parameter ranges and defaults + */ +#define AL_VOCAL_MORPHER_MIN_PHONEMEA 0 +#define AL_VOCAL_MORPHER_MAX_PHONEMEA 29 +#define AL_VOCAL_MORPHER_DEFAULT_PHONEMEA 0 + +#define AL_VOCAL_MORPHER_MIN_PHONEMEA_COARSE_TUNING (-24) +#define AL_VOCAL_MORPHER_MAX_PHONEMEA_COARSE_TUNING 24 +#define AL_VOCAL_MORPHER_DEFAULT_PHONEMEA_COARSE_TUNING 0 + +#define AL_VOCAL_MORPHER_MIN_PHONEMEB 0 +#define AL_VOCAL_MORPHER_MAX_PHONEMEB 29 +#define AL_VOCAL_MORPHER_DEFAULT_PHONEMEB 10 + +#define AL_VOCAL_MORPHER_PHONEME_A 0 +#define AL_VOCAL_MORPHER_PHONEME_E 1 +#define AL_VOCAL_MORPHER_PHONEME_I 2 +#define AL_VOCAL_MORPHER_PHONEME_O 3 +#define AL_VOCAL_MORPHER_PHONEME_U 4 +#define AL_VOCAL_MORPHER_PHONEME_AA 5 +#define AL_VOCAL_MORPHER_PHONEME_AE 6 +#define AL_VOCAL_MORPHER_PHONEME_AH 7 +#define AL_VOCAL_MORPHER_PHONEME_AO 8 +#define AL_VOCAL_MORPHER_PHONEME_EH 9 +#define AL_VOCAL_MORPHER_PHONEME_ER 10 +#define AL_VOCAL_MORPHER_PHONEME_IH 11 +#define AL_VOCAL_MORPHER_PHONEME_IY 12 +#define AL_VOCAL_MORPHER_PHONEME_UH 13 +#define AL_VOCAL_MORPHER_PHONEME_UW 14 +#define AL_VOCAL_MORPHER_PHONEME_B 15 +#define AL_VOCAL_MORPHER_PHONEME_D 16 +#define AL_VOCAL_MORPHER_PHONEME_F 17 +#define AL_VOCAL_MORPHER_PHONEME_G 18 +#define AL_VOCAL_MORPHER_PHONEME_J 19 +#define AL_VOCAL_MORPHER_PHONEME_K 20 +#define AL_VOCAL_MORPHER_PHONEME_L 21 +#define AL_VOCAL_MORPHER_PHONEME_M 22 +#define AL_VOCAL_MORPHER_PHONEME_N 23 +#define AL_VOCAL_MORPHER_PHONEME_P 24 +#define AL_VOCAL_MORPHER_PHONEME_R 25 +#define AL_VOCAL_MORPHER_PHONEME_S 26 +#define AL_VOCAL_MORPHER_PHONEME_T 27 +#define AL_VOCAL_MORPHER_PHONEME_V 28 +#define AL_VOCAL_MORPHER_PHONEME_Z 29 + +#define AL_VOCAL_MORPHER_MIN_PHONEMEB_COARSE_TUNING (-24) +#define AL_VOCAL_MORPHER_MAX_PHONEMEB_COARSE_TUNING 24 +#define AL_VOCAL_MORPHER_DEFAULT_PHONEMEB_COARSE_TUNING 0 + +#define AL_VOCAL_MORPHER_MIN_WAVEFORM 0 +#define AL_VOCAL_MORPHER_MAX_WAVEFORM 2 +#define AL_VOCAL_MORPHER_DEFAULT_WAVEFORM 0 + +#define AL_VOCAL_MORPHER_WAVEFORM_SINUSOID 0 +#define AL_VOCAL_MORPHER_WAVEFORM_TRIANGLE 1 +#define AL_VOCAL_MORPHER_WAVEFORM_SAWTOOTH 2 + +#define AL_VOCAL_MORPHER_MIN_RATE 0.0f +#define AL_VOCAL_MORPHER_MAX_RATE 10.0f +#define AL_VOCAL_MORPHER_DEFAULT_RATE 1.41f + +/** + * AL pitch shifter effect parameter ranges and defaults + */ +#define AL_PITCH_SHIFTER_MIN_COARSE_TUNE (-12) +#define AL_PITCH_SHIFTER_MAX_COARSE_TUNE 12 +#define AL_PITCH_SHIFTER_DEFAULT_COARSE_TUNE 12 + +#define AL_PITCH_SHIFTER_MIN_FINE_TUNE (-50) +#define AL_PITCH_SHIFTER_MAX_FINE_TUNE 50 +#define AL_PITCH_SHIFTER_DEFAULT_FINE_TUNE 0 + +/** + * AL ring modulator effect parameter ranges and defaults + */ +#define AL_RING_MODULATOR_MIN_FREQUENCY 0.0f +#define AL_RING_MODULATOR_MAX_FREQUENCY 8000.0f +#define AL_RING_MODULATOR_DEFAULT_FREQUENCY 440.0f + +#define AL_RING_MODULATOR_MIN_HIGHPASS_CUTOFF 0.0f +#define AL_RING_MODULATOR_MAX_HIGHPASS_CUTOFF 24000.0f +#define AL_RING_MODULATOR_DEFAULT_HIGHPASS_CUTOFF 800.0f + +#define AL_RING_MODULATOR_MIN_WAVEFORM 0 +#define AL_RING_MODULATOR_MAX_WAVEFORM 2 +#define AL_RING_MODULATOR_DEFAULT_WAVEFORM 0 + +#define AL_RING_MODULATOR_SINUSOID 0 +#define AL_RING_MODULATOR_SAWTOOTH 1 +#define AL_RING_MODULATOR_SQUARE 2 + +/** + * AL autowah effect parameter ranges and defaults + */ +#define AL_AUTOWAH_MIN_ATTACK_TIME 0.0001f +#define AL_AUTOWAH_MAX_ATTACK_TIME 1.0f +#define AL_AUTOWAH_DEFAULT_ATTACK_TIME 0.06f + +#define AL_AUTOWAH_MIN_RELEASE_TIME 0.0001f +#define AL_AUTOWAH_MAX_RELEASE_TIME 1.0f +#define AL_AUTOWAH_DEFAULT_RELEASE_TIME 0.06f + +#define AL_AUTOWAH_MIN_RESONANCE 2.0f +#define AL_AUTOWAH_MAX_RESONANCE 1000.0f +#define AL_AUTOWAH_DEFAULT_RESONANCE 1000.0f + +#define AL_AUTOWAH_MIN_PEAK_GAIN 0.00003f +#define AL_AUTOWAH_MAX_PEAK_GAIN 31621.0f +#define AL_AUTOWAH_DEFAULT_PEAK_GAIN 11.22f + +/** + * AL compressor effect parameter ranges and defaults + */ +#define AL_COMPRESSOR_MIN_ONOFF 0 +#define AL_COMPRESSOR_MAX_ONOFF 1 +#define AL_COMPRESSOR_DEFAULT_ONOFF 1 + +/** + * AL equalizer effect parameter ranges and defaults + */ +#define AL_EQUALIZER_MIN_LOW_GAIN 0.126f +#define AL_EQUALIZER_MAX_LOW_GAIN 7.943f +#define AL_EQUALIZER_DEFAULT_LOW_GAIN 1.0f + +#define AL_EQUALIZER_MIN_LOW_CUTOFF 50.0f +#define AL_EQUALIZER_MAX_LOW_CUTOFF 800.0f +#define AL_EQUALIZER_DEFAULT_LOW_CUTOFF 200.0f + +#define AL_EQUALIZER_MIN_MID1_GAIN 0.126f +#define AL_EQUALIZER_MAX_MID1_GAIN 7.943f +#define AL_EQUALIZER_DEFAULT_MID1_GAIN 1.0f + +#define AL_EQUALIZER_MIN_MID1_CENTER 200.0f +#define AL_EQUALIZER_MAX_MID1_CENTER 3000.0f +#define AL_EQUALIZER_DEFAULT_MID1_CENTER 500.0f + +#define AL_EQUALIZER_MIN_MID1_WIDTH 0.01f +#define AL_EQUALIZER_MAX_MID1_WIDTH 1.0f +#define AL_EQUALIZER_DEFAULT_MID1_WIDTH 1.0f + +#define AL_EQUALIZER_MIN_MID2_GAIN 0.126f +#define AL_EQUALIZER_MAX_MID2_GAIN 7.943f +#define AL_EQUALIZER_DEFAULT_MID2_GAIN 1.0f + +#define AL_EQUALIZER_MIN_MID2_CENTER 1000.0f +#define AL_EQUALIZER_MAX_MID2_CENTER 8000.0f +#define AL_EQUALIZER_DEFAULT_MID2_CENTER 3000.0f + +#define AL_EQUALIZER_MIN_MID2_WIDTH 0.01f +#define AL_EQUALIZER_MAX_MID2_WIDTH 1.0f +#define AL_EQUALIZER_DEFAULT_MID2_WIDTH 1.0f + +#define AL_EQUALIZER_MIN_HIGH_GAIN 0.126f +#define AL_EQUALIZER_MAX_HIGH_GAIN 7.943f +#define AL_EQUALIZER_DEFAULT_HIGH_GAIN 1.0f + +#define AL_EQUALIZER_MIN_HIGH_CUTOFF 4000.0f +#define AL_EQUALIZER_MAX_HIGH_CUTOFF 16000.0f +#define AL_EQUALIZER_DEFAULT_HIGH_CUTOFF 6000.0f + + + + +/********************************************************** + * Source parameter value definitions, ranges and defaults. + */ +#define AL_MIN_AIR_ABSORPTION_FACTOR 0.0f +#define AL_MAX_AIR_ABSORPTION_FACTOR 10.0f +#define AL_DEFAULT_AIR_ABSORPTION_FACTOR 0.0f + +#define AL_MIN_ROOM_ROLLOFF_FACTOR 0.0f +#define AL_MAX_ROOM_ROLLOFF_FACTOR 10.0f +#define AL_DEFAULT_ROOM_ROLLOFF_FACTOR 0.0f + +#define AL_MIN_CONE_OUTER_GAINHF 0.0f +#define AL_MAX_CONE_OUTER_GAINHF 1.0f +#define AL_DEFAULT_CONE_OUTER_GAINHF 1.0f + +#define AL_MIN_DIRECT_FILTER_GAINHF_AUTO AL_FALSE +#define AL_MAX_DIRECT_FILTER_GAINHF_AUTO AL_TRUE +#define AL_DEFAULT_DIRECT_FILTER_GAINHF_AUTO AL_TRUE + +#define AL_MIN_AUXILIARY_SEND_FILTER_GAIN_AUTO AL_FALSE +#define AL_MAX_AUXILIARY_SEND_FILTER_GAIN_AUTO AL_TRUE +#define AL_DEFAULT_AUXILIARY_SEND_FILTER_GAIN_AUTO AL_TRUE + +#define AL_MIN_AUXILIARY_SEND_FILTER_GAINHF_AUTO AL_FALSE +#define AL_MAX_AUXILIARY_SEND_FILTER_GAINHF_AUTO AL_TRUE +#define AL_DEFAULT_AUXILIARY_SEND_FILTER_GAINHF_AUTO AL_TRUE + + + + +/********************************************************** + * Listener parameter value definitions, ranges and defaults. + */ +#define AL_MIN_METERS_PER_UNIT FLT_MIN +#define AL_MAX_METERS_PER_UNIT FLT_MAX +#define AL_DEFAULT_METERS_PER_UNIT 1.0f + + +#ifdef __cplusplus +} /* extern "C" */ +#endif + +#endif /* __efx_h_ */ diff --git a/Racer/openAL/include/xram.h b/Racer/openAL/include/xram.h new file mode 100644 index 0000000..5d83662 --- /dev/null +++ b/Racer/openAL/include/xram.h @@ -0,0 +1,94 @@ +#include + +// X-RAM Function pointer definitions +typedef ALboolean (__cdecl *EAXSetBufferMode)(ALsizei n, ALuint *buffers, ALint value); +typedef ALenum (__cdecl *EAXGetBufferMode)(ALuint buffer, ALint *value); + +////////////////////////////////////////////////////////////////////////////// +// Query for X-RAM extension +// +// if (alIsExtensionPresent("EAX-RAM") == AL_TRUE) +// X-RAM Extension found +// +////////////////////////////////////////////////////////////////////////////// + + +////////////////////////////////////////////////////////////////////////////// +// X-RAM enum names +// +// "AL_EAX_RAM_SIZE" +// "AL_EAX_RAM_FREE" +// "AL_STORAGE_AUTOMATIC" +// "AL_STORAGE_HARDWARE" +// "AL_STORAGE_ACCESSIBLE" +// +// Query enum values using alGetEnumValue, for example +// +// long lRamSizeEnum = alGetEnumValue("AL_EAX_RAM_SIZE") +// +////////////////////////////////////////////////////////////////////////////// + + +////////////////////////////////////////////////////////////////////////////// +// Query total amount of X-RAM +// +// long lTotalSize = alGetInteger(alGetEnumValue("AL_EAX_RAM_SIZE") +// +////////////////////////////////////////////////////////////////////////////// + + +////////////////////////////////////////////////////////////////////////////// +// Query free X-RAM available +// +// long lFreeSize = alGetInteger(alGetEnumValue("AL_EAX_RAM_FREE") +// +////////////////////////////////////////////////////////////////////////////// + + +////////////////////////////////////////////////////////////////////////////// +// Query X-RAM Function pointers +// +// Use typedefs defined above to get the X-RAM function pointers using +// alGetProcAddress +// +// EAXSetBufferMode eaxSetBufferMode; +// EAXGetBufferMode eaxGetBufferMode; +// +// eaxSetBufferMode = (EAXSetBufferMode)alGetProcAddress("EAXSetBufferMode"); +// eaxGetBufferMode = (EAXGetBufferMode)alGetProcAddress("EAXGetBufferMode"); +// +////////////////////////////////////////////////////////////////////////////// + + +////////////////////////////////////////////////////////////////////////////// +// Force an Open AL Buffer into X-RAM (good for non-streaming buffers) +// +// ALuint uiBuffer; +// alGenBuffers(1, &uiBuffer); +// eaxSetBufferMode(1, &uiBuffer, alGetEnumValue("AL_STORAGE_HARDWARE")); +// alBufferData(...); +// +////////////////////////////////////////////////////////////////////////////// + + +////////////////////////////////////////////////////////////////////////////// +// Force an Open AL Buffer into 'accessible' (currently host) RAM (good for streaming buffers) +// +// ALuint uiBuffer; +// alGenBuffers(1, &uiBuffer); +// eaxSetBufferMode(1, &uiBuffer, alGetEnumValue("AL_STORAGE_ACCESSIBLE")); +// alBufferData(...); +// +////////////////////////////////////////////////////////////////////////////// + + +////////////////////////////////////////////////////////////////////////////// +// Put an Open AL Buffer into X-RAM if memory is available, otherwise use +// host RAM. This is the default mode. +// +// ALuint uiBuffer; +// alGenBuffers(1, &uiBuffer); +// eaxSetBufferMode(1, &uiBuffer, alGetEnumValue("AL_STORAGE_AUTOMATIC")); +// alBufferData(...); +// +////////////////////////////////////////////////////////////////////////////// \ No newline at end of file diff --git a/Racer/openAL/libs/Win32/EFX-Util_MT/EFX-Util.lib b/Racer/openAL/libs/Win32/EFX-Util_MT/EFX-Util.lib new file mode 100644 index 0000000..f984bc7 Binary files /dev/null and b/Racer/openAL/libs/Win32/EFX-Util_MT/EFX-Util.lib differ diff --git a/Racer/openAL/libs/Win32/EFX-Util_MTDLL/EFX-Util.lib b/Racer/openAL/libs/Win32/EFX-Util_MTDLL/EFX-Util.lib new file mode 100644 index 0000000..e2e22c3 Binary files /dev/null and b/Racer/openAL/libs/Win32/EFX-Util_MTDLL/EFX-Util.lib differ diff --git a/Racer/openAL/libs/Win32/OpenAL32.lib b/Racer/openAL/libs/Win32/OpenAL32.lib new file mode 100644 index 0000000..d635de9 Binary files /dev/null and b/Racer/openAL/libs/Win32/OpenAL32.lib differ diff --git a/Racer/openAL/libs/Win64/EFX-Util_MT/EFX-Util.lib b/Racer/openAL/libs/Win64/EFX-Util_MT/EFX-Util.lib new file mode 100644 index 0000000..d4fcc8a Binary files /dev/null and b/Racer/openAL/libs/Win64/EFX-Util_MT/EFX-Util.lib differ diff --git a/Racer/openAL/libs/Win64/EFX-Util_MTDLL/EFX-Util.lib b/Racer/openAL/libs/Win64/EFX-Util_MTDLL/EFX-Util.lib new file mode 100644 index 0000000..8a926e5 Binary files /dev/null and b/Racer/openAL/libs/Win64/EFX-Util_MTDLL/EFX-Util.lib differ diff --git a/Racer/openAL/libs/Win64/OpenAL32.lib b/Racer/openAL/libs/Win64/OpenAL32.lib new file mode 100644 index 0000000..17663e0 Binary files /dev/null and b/Racer/openAL/libs/Win64/OpenAL32.lib differ diff --git a/Racer/resources/models/Boom/Boom.mtl b/Racer/resources/models/Boom/Boom.mtl new file mode 100644 index 0000000..467688b --- /dev/null +++ b/Racer/resources/models/Boom/Boom.mtl @@ -0,0 +1,192 @@ +newmtl initialShadingGroup +illum 4 +Kd 0.21 0.09 0.00 +Ka 0.00 0.00 0.00 +Tf 1.00 1.00 1.00 +Ni 1.00 +newmtl lambert2SG +illum 4 +Kd 0.00 1.00 0.00 +Ka 0.00 0.00 0.00 +Tf 1.00 1.00 1.00 +Ni 1.00 +newmtl lambert3SG +illum 4 +Kd 0.50 0.21 0.00 +Ka 0.00 0.00 0.00 +Tf 1.00 1.00 1.00 +Ni 1.00 +newmtl lambert4SG +illum 4 +Kd 0.50 0.21 0.00 +Ka 0.00 0.00 0.00 +Tf 1.00 1.00 1.00 +Ni 1.00 +newmtl lambert5SG +illum 4 +Kd 0.00 0.16 0.00 +Ka 0.00 0.00 0.00 +Tf 1.00 1.00 1.00 +Ni 1.00 +newmtl lambert6SG +illum 4 +Kd 0.00 0.16 0.00 +Ka 0.00 0.00 0.00 +Tf 1.00 1.00 1.00 +Ni 1.00 +newmtl lambert8SG +illum 4 +Kd 0.00 0.16 0.00 +Ka 0.00 0.00 0.00 +Tf 1.00 1.00 1.00 +Ni 1.00 +newmtl lambert9SG +illum 4 +Kd 1.00 1.00 1.00 +Ka 0.00 0.00 0.00 +Tf 1.00 1.00 1.00 +Ni 1.00 +newmtl lambert10SG +illum 4 +Kd 0.12 0.28 0.00 +Ka 0.00 0.00 0.00 +Tf 1.00 1.00 1.00 +Ni 1.00 +newmtl lambert11SG +illum 4 +Kd 0.50 0.21 0.00 +Ka 0.00 0.00 0.00 +Tf 1.00 1.00 1.00 +Ni 1.00 +newmtl pasted__lambert2SG +illum 4 +Kd 0.00 1.00 0.00 +Ka 0.00 0.00 0.00 +Tf 1.00 1.00 1.00 +Ni 1.00 +newmtl pasted__lambert2SG1 +illum 4 +Kd 0.00 1.00 0.00 +Ka 0.00 0.00 0.00 +Tf 1.00 1.00 1.00 +Ni 1.00 +newmtl pasted__lambert2SG2 +illum 4 +Kd 0.00 1.00 0.00 +Ka 0.00 0.00 0.00 +Tf 1.00 1.00 1.00 +Ni 1.00 +newmtl pasted__lambert2SG3 +illum 4 +Kd 0.00 1.00 0.00 +Ka 0.00 0.00 0.00 +Tf 1.00 1.00 1.00 +Ni 1.00 +newmtl pasted__lambert2SG4 +illum 4 +Kd 0.00 1.00 0.00 +Ka 0.00 0.00 0.00 +Tf 1.00 1.00 1.00 +Ni 1.00 +newmtl pasted__lambert3SG +illum 4 +Kd 0.50 0.21 0.00 +Ka 0.00 0.00 0.00 +Tf 1.00 1.00 1.00 +Ni 1.00 +newmtl pasted__lambert3SG1 +illum 4 +Kd 0.50 0.21 0.00 +Ka 0.00 0.00 0.00 +Tf 1.00 1.00 1.00 +Ni 1.00 +newmtl pasted__lambert3SG2 +illum 4 +Kd 0.50 0.21 0.00 +Ka 0.00 0.00 0.00 +Tf 1.00 1.00 1.00 +Ni 1.00 +newmtl pasted__lambert3SG3 +illum 4 +Kd 0.50 0.21 0.00 +Ka 0.00 0.00 0.00 +Tf 1.00 1.00 1.00 +Ni 1.00 +newmtl pasted__lambert3SG4 +illum 4 +Kd 0.50 0.21 0.00 +Ka 0.00 0.00 0.00 +Tf 1.00 1.00 1.00 +Ni 1.00 +newmtl pasted__lambert4SG +illum 4 +Kd 0.50 0.21 0.00 +Ka 0.00 0.00 0.00 +Tf 1.00 1.00 1.00 +Ni 1.00 +newmtl pasted__lambert4SG1 +illum 4 +Kd 0.50 0.21 0.00 +Ka 0.00 0.00 0.00 +Tf 1.00 1.00 1.00 +Ni 1.00 +newmtl pasted__lambert4SG2 +illum 4 +Kd 0.50 0.21 0.00 +Ka 0.00 0.00 0.00 +Tf 1.00 1.00 1.00 +Ni 1.00 +newmtl pasted__lambert5SG +illum 4 +Kd 0.00 0.16 0.00 +Ka 0.00 0.00 0.00 +Tf 1.00 1.00 1.00 +Ni 1.00 +newmtl pasted__lambert5SG1 +illum 4 +Kd 0.00 0.16 0.00 +Ka 0.00 0.00 0.00 +Tf 1.00 1.00 1.00 +Ni 1.00 +newmtl pasted__lambert5SG2 +illum 4 +Kd 0.00 0.16 0.00 +Ka 0.00 0.00 0.00 +Tf 1.00 1.00 1.00 +Ni 1.00 +newmtl pasted__lambert6SG +illum 4 +Kd 0.00 0.16 0.00 +Ka 0.00 0.00 0.00 +Tf 1.00 1.00 1.00 +Ni 1.00 +newmtl pasted__lambert6SG1 +illum 4 +Kd 0.00 0.16 0.00 +Ka 0.00 0.00 0.00 +Tf 1.00 1.00 1.00 +Ni 1.00 +newmtl pasted__lambert6SG2 +illum 4 +Kd 0.00 0.16 0.00 +Ka 0.00 0.00 0.00 +Tf 1.00 1.00 1.00 +Ni 1.00 +newmtl pasted__lambert8SG +illum 4 +Kd 0.00 0.16 0.00 +Ka 0.00 0.00 0.00 +Tf 1.00 1.00 1.00 +Ni 1.00 +newmtl pasted__lambert8SG1 +illum 4 +Kd 0.00 0.16 0.00 +Ka 0.00 0.00 0.00 +Tf 1.00 1.00 1.00 +Ni 1.00 +newmtl pasted__lambert8SG2 +illum 4 +Kd 0.00 0.16 0.00 +Ka 0.00 0.00 0.00 +Tf 1.00 1.00 1.00 +Ni 1.00 diff --git a/Racer/resources/models/DarkGrass/Blauw.png b/Racer/resources/models/DarkGrass/Blauw.png new file mode 100644 index 0000000..5a1a9d9 Binary files /dev/null and b/Racer/resources/models/DarkGrass/Blauw.png differ diff --git a/Racer/resources/models/DarkGrass/grass.mtl b/Racer/resources/models/DarkGrass/grass.mtl new file mode 100644 index 0000000..bb458ff --- /dev/null +++ b/Racer/resources/models/DarkGrass/grass.mtl @@ -0,0 +1,9 @@ +# WaveFront *.mtl file (generated by CINEMA 4D) + +newmtl Mat +Kd 0.80000001192093 0.80000001192093 0.80000001192093 +map_Kd Blauw.png +Ks 1.00000000000000 1.00000000000000 1.00000000000000 +Ns 100 +illum 7 + diff --git a/Racer/resources/models/DarkTree/m64_tree.png b/Racer/resources/models/DarkTree/m64_tree.png new file mode 100644 index 0000000..f834cd0 Binary files /dev/null and b/Racer/resources/models/DarkTree/m64_tree.png differ diff --git a/Racer/resources/models/DarkTree/n64tree.mtl b/Racer/resources/models/DarkTree/n64tree.mtl new file mode 100644 index 0000000..84c201a --- /dev/null +++ b/Racer/resources/models/DarkTree/n64tree.mtl @@ -0,0 +1,11 @@ +# Material file for n64tree.obj + +newmtl tree + Ns 0 + d 1 + illum 2 + Kd 0.8 0.8 0.8 + Ks 0.0 0.0 0.0 + Ka 0.2 0.2 0.2 + map_Kd m64_tree.png + diff --git a/Racer/resources/models/Grass/Blauw.png b/Racer/resources/models/Grass/Blauw.png new file mode 100644 index 0000000..f5280a9 Binary files /dev/null and b/Racer/resources/models/Grass/Blauw.png differ diff --git a/Racer/resources/models/Grass/grass.mtl b/Racer/resources/models/Grass/grass.mtl new file mode 100644 index 0000000..bb458ff --- /dev/null +++ b/Racer/resources/models/Grass/grass.mtl @@ -0,0 +1,9 @@ +# WaveFront *.mtl file (generated by CINEMA 4D) + +newmtl Mat +Kd 0.80000001192093 0.80000001192093 0.80000001192093 +map_Kd Blauw.png +Ks 1.00000000000000 1.00000000000000 1.00000000000000 +Ns 100 +illum 7 + diff --git a/Racer/resources/models/Kart/Kart.mtl b/Racer/resources/models/Kart/Kart.mtl new file mode 100644 index 0000000..3f98487 --- /dev/null +++ b/Racer/resources/models/Kart/Kart.mtl @@ -0,0 +1,147 @@ +newmtl bob1:initialShadingGroup +illum 4 +Kd 0.50 0.50 0.50 +Ka 0.00 0.00 0.00 +Tf 1.00 1.00 1.00 +Ni 1.00 +newmtl initialShadingGroup +illum 4 +Kd 0.00 0.00 0.00 +Ka 0.00 0.00 0.00 +Tf 1.00 1.00 1.00 +Ni 1.00 +newmtl lambert2SG +illum 4 +Kd 0.20 0.32 0.50 +Ka 0.00 0.00 0.00 +Tf 1.00 1.00 1.00 +Ni 1.00 +newmtl lambert5SG +illum 4 +Kd 1.00 0.00 0.00 +Ka 0.00 0.00 0.00 +Tf 1.00 1.00 1.00 +Ni 1.00 +newmtl lambert6SG +illum 4 +Kd 0.00 0.00 0.00 +Ka 0.00 0.00 0.00 +Tf 1.00 1.00 1.00 +Ni 1.00 +newmtl lambert7SG +illum 4 +Kd 0.00 0.00 0.00 +Ka 0.00 0.00 0.00 +Tf 1.00 1.00 1.00 +map_Kd Screenshot_1.png +Ni 1.00 +newmtl lambert8SG +illum 4 +Kd 0.00 0.00 0.00 +Ka 0.00 0.00 0.00 +Tf 1.00 1.00 1.00 +map_Kd Screenshot_1.png +Ni 1.00 +newmtl lambert10SG +illum 4 +Kd 1.00 1.00 1.00 +Ka 0.00 0.00 0.00 +Tf 1.00 1.00 1.00 +Ni 1.00 +newmtl lambert12SG +illum 4 +Kd 0.58 0.00 1.00 +Ka 0.00 0.00 0.00 +Tf 1.00 1.00 1.00 +Ni 1.00 +newmtl lambert13SG +illum 4 +Kd 0.00 1.00 0.00 +Ka 0.00 0.00 0.00 +Tf 1.00 1.00 1.00 +Ni 1.00 +newmtl lambert14SG +illum 4 +Kd 1.00 1.00 0.00 +Ka 0.00 0.00 0.00 +Tf 1.00 1.00 1.00 +Ni 1.00 +newmtl lambert15SG +illum 4 +Kd 0.00 0.00 0.00 +Ka 0.00 0.00 0.00 +Tf 1.00 1.00 1.00 +map_Kd TheThing2.png +Ni 1.00 +newmtl lambert16SG +illum 4 +Kd 0.00 0.00 0.00 +Ka 0.00 0.00 0.00 +Tf 1.00 1.00 1.00 +map_Kd SkateboardwielThing.png +Ni 1.00 +newmtl lambert17SG +illum 4 +Kd 0.25 0.25 0.25 +Ka 0.00 0.00 0.00 +Tf 1.00 1.00 1.00 +Ni 1.00 +Ks 0.50 0.50 0.50 +newmtl lambert18SG +illum 4 +Kd 0.00 0.00 0.00 +Ka 0.00 0.00 0.00 +Tf 1.00 1.00 1.00 +map_Kd BobStoneTexture.png +Ni 1.00 +Ks 0.50 0.50 0.50 +newmtl lambert19SG +illum 4 +Kd 0.85 0.85 0.85 +Ka 0.00 0.00 0.00 +Tf 1.00 1.00 1.00 +Ni 1.00 +newmtl lambert20SG +illum 4 +Kd 0.00 0.00 0.00 +Ka 0.00 0.00 0.00 +Tf 0.64 0.64 0.64 +Ni 1.00 +newmtl lambert21SG +illum 4 +Kd 0.00 0.00 0.00 +Ka 0.00 0.00 0.00 +Tf 1.00 1.00 1.00 +Ni 1.00 +newmtl lambert22SG +illum 4 +Kd 0.50 0.50 0.50 +Ka 0.00 0.00 0.00 +Tf 1.00 1.00 1.00 +Ni 1.00 +newmtl lambert23SG +illum 4 +Kd 0.00 0.00 0.00 +Ka 0.00 0.00 0.00 +Tf 1.00 1.00 1.00 +map_Kd Kart.png +Ni 1.00 +newmtl pasted__lambert2SG +illum 4 +Kd 0.00 0.00 0.00 +Ka 0.00 0.00 0.00 +Tf 1.00 1.00 1.00 +map_Kd Screenshot_1.png +Ni 1.00 +newmtl pasted__lambert4SG +illum 4 +Kd 0.50 1.00 1.00 +Ka 0.00 0.00 0.00 +Tf 1.00 1.00 1.00 +Ni 1.00 +newmtl pasted__lambert5SG +illum 4 +Kd 0.00 1.00 1.00 +Ka 0.00 0.00 0.00 +Tf 1.00 1.00 1.00 +Ni 1.00 diff --git a/Racer/resources/models/Kart/Kart.png b/Racer/resources/models/Kart/Kart.png new file mode 100644 index 0000000..3475e14 Binary files /dev/null and b/Racer/resources/models/Kart/Kart.png differ diff --git a/Racer/resources/models/Tree/m64_tree.png b/Racer/resources/models/Tree/m64_tree.png new file mode 100644 index 0000000..c66d949 Binary files /dev/null and b/Racer/resources/models/Tree/m64_tree.png differ diff --git a/Racer/resources/models/Tree/n64tree.mtl b/Racer/resources/models/Tree/n64tree.mtl new file mode 100644 index 0000000..84c201a --- /dev/null +++ b/Racer/resources/models/Tree/n64tree.mtl @@ -0,0 +1,11 @@ +# Material file for n64tree.obj + +newmtl tree + Ns 0 + d 1 + illum 2 + Kd 0.8 0.8 0.8 + Ks 0.0 0.0 0.0 + Ka 0.2 0.2 0.2 + map_Kd m64_tree.png + diff --git a/Racer/resources/models/box/box.mtl b/Racer/resources/models/box/box.mtl new file mode 100644 index 0000000..d326259 --- /dev/null +++ b/Racer/resources/models/box/box.mtl @@ -0,0 +1,13 @@ +# Blender MTL File: 'yoshi_falls.blend' +# Material Count: 1 + +newmtl box_mat +Ns 96.078431 +Ka 0.000000 0.000000 0.000000 +Kd 0.778039 0.778039 0.778039 +Ks 0.000000 0.000000 0.000000 +Ni 1.000000 +d 0.000000 +illum 1 +map_Kd box_mat.png +map_d box_mat.png diff --git a/Racer/resources/models/box/box_mat.png b/Racer/resources/models/box/box_mat.png new file mode 100644 index 0000000..582961b Binary files /dev/null and b/Racer/resources/models/box/box_mat.png differ diff --git a/Racer/resources/models/redstar/I_star.mtl b/Racer/resources/models/redstar/I_star.mtl new file mode 100644 index 0000000..ea89fd7 --- /dev/null +++ b/Racer/resources/models/redstar/I_star.mtl @@ -0,0 +1,9 @@ +# Created by Every File Explorer + +newmtl mat_star +Ka 1 1 1 +Kd 1 1 1 +Ks 0.1490196 0.1490196 0 +d 1 +map_Kd Tex/I_star.png + diff --git a/Racer/resources/models/redstar/Tex/I_star.png b/Racer/resources/models/redstar/Tex/I_star.png new file mode 100644 index 0000000..87f37e3 Binary files /dev/null and b/Racer/resources/models/redstar/Tex/I_star.png differ diff --git a/Racer/resources/models/star/I_star.mtl b/Racer/resources/models/star/I_star.mtl new file mode 100644 index 0000000..ea89fd7 --- /dev/null +++ b/Racer/resources/models/star/I_star.mtl @@ -0,0 +1,9 @@ +# Created by Every File Explorer + +newmtl mat_star +Ka 1 1 1 +Kd 1 1 1 +Ks 0.1490196 0.1490196 0 +d 1 +map_Kd Tex/I_star.png + diff --git a/Racer/resources/models/star/Tex/I_star.png b/Racer/resources/models/star/Tex/I_star.png new file mode 100644 index 0000000..5d04bd1 Binary files /dev/null and b/Racer/resources/models/star/Tex/I_star.png differ diff --git a/Racer/resources/skyboxes/dark/back.png b/Racer/resources/skyboxes/dark/back.png new file mode 100644 index 0000000..d5f2c97 Binary files /dev/null and b/Racer/resources/skyboxes/dark/back.png differ diff --git a/Racer/resources/skyboxes/dark/bottom.png b/Racer/resources/skyboxes/dark/bottom.png new file mode 100644 index 0000000..3fe1d47 Binary files /dev/null and b/Racer/resources/skyboxes/dark/bottom.png differ diff --git a/Racer/resources/skyboxes/dark/front.png b/Racer/resources/skyboxes/dark/front.png new file mode 100644 index 0000000..87b29dd Binary files /dev/null and b/Racer/resources/skyboxes/dark/front.png differ diff --git a/Racer/resources/skyboxes/dark/left.png b/Racer/resources/skyboxes/dark/left.png new file mode 100644 index 0000000..9b04eb4 Binary files /dev/null and b/Racer/resources/skyboxes/dark/left.png differ diff --git a/Racer/resources/skyboxes/dark/right.png b/Racer/resources/skyboxes/dark/right.png new file mode 100644 index 0000000..0423971 Binary files /dev/null and b/Racer/resources/skyboxes/dark/right.png differ diff --git a/Racer/resources/skyboxes/dark/top.png b/Racer/resources/skyboxes/dark/top.png new file mode 100644 index 0000000..1d0d926 Binary files /dev/null and b/Racer/resources/skyboxes/dark/top.png differ diff --git a/Racer/resources/skyboxes/sky/back.png b/Racer/resources/skyboxes/sky/back.png new file mode 100644 index 0000000..db7d79a Binary files /dev/null and b/Racer/resources/skyboxes/sky/back.png differ diff --git a/Racer/resources/skyboxes/sky/bottom.png b/Racer/resources/skyboxes/sky/bottom.png new file mode 100644 index 0000000..000f9c9 Binary files /dev/null and b/Racer/resources/skyboxes/sky/bottom.png differ diff --git a/Racer/resources/skyboxes/sky/front.png b/Racer/resources/skyboxes/sky/front.png new file mode 100644 index 0000000..43c806b Binary files /dev/null and b/Racer/resources/skyboxes/sky/front.png differ diff --git a/Racer/resources/skyboxes/sky/left.png b/Racer/resources/skyboxes/sky/left.png new file mode 100644 index 0000000..d40a107 Binary files /dev/null and b/Racer/resources/skyboxes/sky/left.png differ diff --git a/Racer/resources/skyboxes/sky/right.png b/Racer/resources/skyboxes/sky/right.png new file mode 100644 index 0000000..5edaf99 Binary files /dev/null and b/Racer/resources/skyboxes/sky/right.png differ diff --git a/Racer/resources/skyboxes/sky/top.png b/Racer/resources/skyboxes/sky/top.png new file mode 100644 index 0000000..02b446f Binary files /dev/null and b/Racer/resources/skyboxes/sky/top.png differ diff --git a/Racer/resources/sounds/Crystal.wav b/Racer/resources/sounds/Crystal.wav new file mode 100644 index 0000000..2d13707 Binary files /dev/null and b/Racer/resources/sounds/Crystal.wav differ diff --git a/Meinkraft/resources/theme.wav b/Racer/resources/sounds/dark.wav similarity index 53% rename from Meinkraft/resources/theme.wav rename to Racer/resources/sounds/dark.wav index 5af30a7..d840b97 100644 Binary files a/Meinkraft/resources/theme.wav and b/Racer/resources/sounds/dark.wav differ diff --git a/Racer/resources/sounds/race.wav b/Racer/resources/sounds/race.wav new file mode 100644 index 0000000..0f928d3 Binary files /dev/null and b/Racer/resources/sounds/race.wav differ diff --git a/Racer/resources/worlds/dark.json b/Racer/resources/worlds/dark.json new file mode 100644 index 0000000..7a6adbc --- /dev/null +++ b/Racer/resources/worlds/dark.json @@ -0,0 +1,29 @@ +{ + "world": { + "heightmap": "resources/worlds/dark.png", + "texture": "resources/worlds/darktexture.png", + "skybox": "resources/skyboxes/dark/", + "music": "resources/sounds/dark.wav", + "object-templates": [ + { + "file": "resources/models/DarkTree/n64tree.obj", + "color": 100, + "scale": 0.3 + }, + { + "file": "resources/models/DarkGrass/grass.obj", + "color": 110, + "scale": 1, + "collision": false + }] + }, + "player": { + "startposition": [ 30, -1, 175], + "kart": + { + "file": "resources/models/Kart/Kart.obj", + "scale": 0.5 + } + }, + "objects": [ ] +} \ No newline at end of file diff --git a/Racer/resources/worlds/dark.pdn b/Racer/resources/worlds/dark.pdn new file mode 100644 index 0000000..ce28e01 Binary files /dev/null and b/Racer/resources/worlds/dark.pdn differ diff --git a/Racer/resources/worlds/dark.png b/Racer/resources/worlds/dark.png new file mode 100644 index 0000000..94837e0 Binary files /dev/null and b/Racer/resources/worlds/dark.png differ diff --git a/Racer/resources/worlds/darktexture.png b/Racer/resources/worlds/darktexture.png new file mode 100644 index 0000000..31f7af9 Binary files /dev/null and b/Racer/resources/worlds/darktexture.png differ diff --git a/Racer/resources/worlds/race.json b/Racer/resources/worlds/race.json new file mode 100644 index 0000000..f048d7a --- /dev/null +++ b/Racer/resources/worlds/race.json @@ -0,0 +1,29 @@ +{ + "world": { + "heightmap": "resources/worlds/race.png", + "texture": "resources/worlds/racetexture.png", + "skybox": "resources/skyboxes/sky/", + "music": "resources/sounds/race.wav", + "object-templates": [ + { + "file": "resources/models/Tree/n64tree.obj", + "color": 100, + "scale": 0.3 + }, + { + "file": "resources/models/Grass/grass.obj", + "color": 110, + "scale": 1, + "collision": false + }] + }, + "player": { + "startposition": [ 30, -1, 175], + "kart": + { + "file": "resources/models/Kart/Kart.obj", + "scale": 0.5 + } + }, + "objects": [ ] +} \ No newline at end of file diff --git a/Racer/resources/worlds/race.png b/Racer/resources/worlds/race.png new file mode 100644 index 0000000..830fb97 Binary files /dev/null and b/Racer/resources/worlds/race.png differ diff --git a/Racer/resources/worlds/racetexture.pdn b/Racer/resources/worlds/racetexture.pdn new file mode 100644 index 0000000..6da218b --- /dev/null +++ b/Racer/resources/worlds/racetexture.pdn @@ -0,0 +1,74 @@ +PDN3D NPaintDotNet.Data, Version=4.9.5848.30436, Culture=neutral, PublicKeyToken=nullPaintDotNet.Document +isDisposedlayerswidthheight savedWithuserMetadataItemsPaintDotNet.LayerListSystem.VersionSystem.Collections.Generic.KeyValuePair`2[[System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089],[System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]][]   PaintDotNet.LayerListparentArrayList+_itemsArrayList+_sizeArrayList+_versionPaintDotNet.Document   +System.Version_Major_Minor_Build _Revision vSystem.Collections.Generic.KeyValuePair`2[[System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089],[System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]]System.Collections.Generic.KeyValuePair`2[[System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089],[System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]]keyvalue +$exif.tag4 +D +$exif.tag5 / +$exif.tag67 +$exif.tag77    NPaintDotNet.Core, Version=4.9.5848.30436, Culture=neutral, PublicKeyToken=nullPaintDotNet.BitmapLayer +propertiessurfaceLayer+isDisposed Layer+width Layer+heightLayer+properties-PaintDotNet.BitmapLayer+BitmapLayerPropertiesPaintDotNet.Surface!PaintDotNet.Layer+LayerProperties      -PaintDotNet.BitmapLayer+BitmapLayerPropertiesblendOp&PaintDotNet.UserBlendOps+NormalBlendOp PaintDotNet.Surfacewidthheightstridescan0PaintDotNet.MemoryBlock !PaintDotNet.Layer+LayerPropertiesnameuserMetadataItemsvisible isBackgroundopacity blendModeSystem.Collections.Generic.KeyValuePair`2[[System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089],[System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]][]PaintDotNet.LayerBlendMode +Background PaintDotNet.LayerBlendModevalue__-PaintDotNet.BitmapLayer+BitmapLayerPropertiesblendOp)PaintDotNet.UserBlendOps+ColorBurnBlendOp " #$Layer 2 &PaintDotNet.UserBlendOps+NormalBlendOpPaintDotNet.MemoryBlocklength64 hasParentdeferred  System.Collections.Generic.KeyValuePair`2[[System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089],[System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]]")PaintDotNet.UserBlendOps+ColorBurnBlendOp# 2w\Wv$a +U( {Y)bf#ib{G1V;즃C$< @ H7{\^̗U I0P~Ǜ_a{WhcB~h<-VvV~'[+;j&]_~Fy[e=+͏;*͟uTZ>무|YiIWJۣJ=({+z+*U>t8P```JÕ@F*V1rw2rg2|doe證͉ #'+ק*oOU=]teھ$ՙț37g+o2Gry2sy2si2 rqbebe^yʂs9¯q_|9={q~Ks\1?ޠkM=U&@{-zO1Q1۰y +7{ z f|N30],*mVZTZl>=;sQ6Vjlg9G- s<ȅ%ad䬖ș|}{zb^XX0:a o>؇Ӹc<]Ot=Ҏz|Y0:೴hUl,#k~cߖ!Bޓm{'vca.@uޫ{Ifl,>Xg//Ⱥpd9G+ϭ8UeӡUVN'+V?ŸU J',>`0:aKG{}3ըF*=3쾟 |j|<{2tMJl1>'}bş/{dۻضwma{Ⱦml۳,7uY_/\X#Uqm^GY= +k5 +~]:b-V/xz! .N0I]0b>a ]l+_#su@ݙ:`Oާl} #mgپ|A.|A݋mf֯v]X_HΜ#˖U92~f ?GvʫG9#/~8%?QN'*9 ?Xuy'{?Jً#H^(|qqx^kO:}f?m !\]EXgΑe}r,fOwdOh>v_9T9}/ߩukt?; ,V'٘ ?0 F=0>קM\z 8/@A濱;yͼ;C{OʶWNclf} B^u mZs"7Nl6{Ǿy/,)UNηϴ}O0/k=>|b=)dFrcqX=Z9 yX +AV7vz'Z_a~Nx޷f\Lp; B 9A.Ђ.ym (epOgqy8H7HD u<ЊoSl͌j~=kl~UWsg0=ö{y̼,2yͶΙyǩ{sN5!|__y?#guñz'#"}`?X3*Ỳ`>y B0zYt6 u@VP낍?,';{m=F3w{澗m{fV^^erl{֭MOp3B+_<\,/??$E|p<{BN<9K泰z|v.//pA7>V:ۍ"@=Q.P F]m~b3c깅~[黃:l}&`ٟeXl XOؗ=mcrXGΙC/gq~ +q/ 6T +uۿAH胃P!]`o De=`>9x` ܞt @ r>p8@yyFKߑfCoU=h!G=Kqo-UxW53Wrt6/Ͼ|aޙl|/)Or|nni~X>z}_ (l'G\|2;m>oI3ظ{Na=f}{b>=Us?Ruϗ?ǾyVun8?l1m/:  +gj}6p:`:}lv h8Y>υf?\&o~y?m3vz`ۙS)άJW)臢|V'_ܺyV3t8Z!y 谹TP)`?k??&#S|oO!< ֟o۫c7F̆:@rtzu>r8`l+4{zߑ`b_v[߱b~V}{ܿK܏I5Ǽ1Uc¬k_hM9N:`΄K+5_<7/(0X_o3+Y?[_}}1O S,2.}t>P8P }yg_m(^GK w $[=/:-gwY|ep^Y%^%t.7QP>0q6M ̗~߅Q`f?yneq2o| w9*ok<^_㐬rFsgrQЅ}l}a|8'샿ql:s{`ahg/%y ^Z2ql>pXf1naub>@5kg*[߁0z1.z0͟`?66:v =zt6_>/=BqN h߭V%Eϲ<5{hl>?oGO>pyYk_ +ϱ0b.gl0yEguar})}G'?jmpq}Vٟ<g1P Q[\`>@6SmC_v +aC~'?7&ys%cM|<9=7OY6 +{96cVi&C q- U&|$J P;i-v?dai!76 g.ϭQ14~?t۫»3 +˩ I@u(OZŽ= ߑX׍/*KoƳ;|cLG[V;5E@13 PEzc~Ƈy~[17/+|g/ 72?`wxN@uoog^0c:Y"r+˄Z&MݔLӭ]{o7_&xOTLfѢ껦eSt Z|Q 7\c~@xy ]~AEO>v?ۘIo8oI|~f7G0~~5fuC ϰo\ٳi.v3dEng'F, IΊ~Qn{7}@|/p}s: |Nj}3>!U:@FamOM. ;Hޱ!賟d]uf|__ I2~iM #9O[m+ز<EB7[(,}Sr]@U"`fD?@V@jJIҦתl<(xPxfT/P?lq_C=:7~VkC-O0`qoWm>ǷPE +DjZ|';MEs-0=7{G;f1Oz@U)MԫΩ< x; P0P{m~e:ok|{žUu9G#5l-s`Pr=CO#p^o5c#įe|6":{n&}mˠ/ɐO{ts]|O~uͿ:(Nସq)p_(cy@ƽx{j7&COdWoW:]gzz߀ޞ2Wct9~zr|01 |b߭n}gra9gƧ2!o ӎqoN-CƑ cv98} P|+K(2yGb'l+0{3zfIp̐%tᗏWs<1\`F)qwgy>C/F9ɇ.t{f|}Gֳml–9O0N|3Iof#Xvm$qm1qx9ɇ$|CHORA't,sy"d?ӭ go/vd!6ݼ {z-P-9{&1F!}mdw>[{8&:=iDKɧ$͡|/z썈}D?0h:be)1&8a^G9@|.n ;}WӶC>C^9 yͼ].|bU>; 0a;}mgvs1P%٣q'ӭ$]^ImǙx} u`,cSi-&<[~b<|ZW |N_`5OF܍N~ow{=;O7g} i9omWkݳ!⯋-W#wi(ƖtEY3fs{˭V =e~V+؟/ZO{qWYs/c9\>𿈻U?9@$>7by'=~}&k@vxݢ]gzʲ~e_fur0{wk}=ϖܵc98efTnA>N13l#W4 =wzC |=ЦR]37p>wJlOry.9y% ۠,@|&m<ӾK_|,ѯϯQ涎1CO} m]ro{#[ù}E!soK2|tKҎ3 |jblo{-,\[$o/ b-۝l1&*+N?(_MuOz<>me$c-1*,/7 oRp6{;>b~W\Zruc]b |kϟ{`=S1ck]Zud[ks97gRߧl[ߙZg|ԯBΤ|۩jfKI'sx*Soa?/i@xG|W9P{_ {ǹ[yb-Aou +{>mj`|On=Nnj?Wgw{<)5|P@cg(@9jfz߹7Eg???=®>1|~o |/>Ǽǻ,=#&_k΋2;[ŜlގѲ=PH]|jwE?3ﵼl3?y1ÍN/b2l^W5>De΢Wq{gp>kf|W͓Fp^;v1A1?rds }PߌQ1G=@Į_3o W;5Ӹr^e*]-D=\4 YW<3|[yv>s'7aꇲ?13q|?}9ó +T^uV;󜂟כi{t8ώ1(3Kgy2>G= ³)@3*>*=/~*hkoN=u]ր&ſ? KKq? 8_1aVߏ_j}Kީv?u[AfI6)uop)g*2dGch/soI38O-0J-{?ΏNogN =v3Ú`f؟CSlps5ssM=s~Ot@69O?o>D:7欟;u?]:y ?jUc>KzuC=5qb$WrC({d03 b\xK_PS~xgy?y=,{ ѱ0A?ŵ7?So+vhؑ tWK EQ<&/sޛcgXع2{> =¸+X 'u.բͿN>clz6fzMZptGw8jqO-Z_~&3W.skx^{/-;qCVljӣߩl.żywag +}⽽zo;q wA瓽) 6Q^݇kΥxPߏƱKAAA.?87rN^,:ߟ~3v(QI~> ;F7[8޽z粫[gQ10yC$7+;FpF(JDV?_zߧyEG٬j>Ϳ06r7w/FHrSu̡:wI` omCy;1xW;tdՖڎ)G{_/}oɝ@^voM7L{n!-\4#GO GKU*ne-=u)קT?W07O7%7Ǧ"~v"yэi'Ըߙ}I7Yb;9vݘ^n1>gٻw׿ۇ~3˹x;WmTL^s/6rkW ?a~yy1GЇ,ysĬ/KU/_=~~1E%?3П>>e륶^yϾ73 3춻κǹwn7S8օ+3_W~8rCCK'zѶ_Ϧ垟ףYϊk࿈.9a?[:d:~l?Aؿ*~R>n >g{xށw<Ĝ`{,uy̷Z~.Nܿmܽ"717ۘ<YO͹0yk40I ,̊U>ca{{[Ax_:#vxrP71pML(.*q~/OMmsXv#vO+UmJ#z1'Y[[nG_(81=Ss߿."5Cٲ?kBsNCc0o2>#[1m|`ߑ}cfc4o +~U׈g:ɩuqlw;Ct#b_>?*9G}clf-^j_'gS'N.>Y{{<>eCƇxg֯:r~Q3^ڎ qn^w #QV90>Ej6Q/~?ÎAI1s?gxVW ^$~&䎼??gv6fwǷm~sJBŷ\x"󎬿NL17q뺒l kK_r~4ۏk__kdg1΀Z2ŵNojC-[~~OUf쫆U~>/=[o{g2?yOГ~*KxUx׬qZF;Uܝ=9=|~Krqw?RPMʮt l?L<#zk}Y,&ͽyA?&7g0ߟUO˱jWΟ*;__S\{}kIQ6?ɽI.=QYe׏l}eƓ/_X}}r>9:\o_}4}/إ([[ׯks39Ȟ_ǻ鮇z3m~wܻ)C{{5`o:[%goƯE/ais%|/y5Aϋ1_lY?i j}ٵ?ޭ 3׵Y];k_[ݷ#|'{]}|rbU7ז0/=Q +y~=w8.Mn}f%eg}WO+7qogg_H_;M,ulϘ/`gϯ|1;Y)I}YsC<%7f龴@}?/1k?.?IJv?scOr{EUzzZޟ\CGEk},߇܏+{].l=ܬ?m~jOhߟ1cs}#&.Ҏ}5hԩ_?/{?ߺ[;7%>UcO}?Y˾|ٛmg|]>_{Qly[_{/ =WqWYK{|sk36#¿>z콏ܫ(X_v?צܿiw?v͏|}oyܛg(>F%0;~3G߇ۡt[^To{vSmsr}?pיk4;{(Z]FW,z&?[-!MImOtwk{$x>'rFv|~xOg/W` Ic;N]A1g<嫲(ho?7]o{1C%{~&;W?_D'>jeߏ%7aK|Y!ܲ?&ށe'0 3(ku K'yمr?etaa1pOmrcޗ/~Iq [1M@{Ƙ)?43BV]v~'HߗnA +|-̾ND6|}݁R򡎷|n'}QށW>ʉ<Cv=~Y<}!Faƙs%!&_g簎 $`z=^z2"(n?ؼ}Af9;iy時2gvT+~}e?{#^VO'zߔ`)ty0EO}_зFrS4C}WSlS[>{a9usVc{:ow?زy{>1 Ai=PW>[vut3ς7W翾޿z}D1ok|@V@y"Cnz '_{Vo:0oY? +9~oٝ>ǎgiͶ0._u; "x{^g-l5ÍSͽ擿/6_}˿kz rCzOP/"˿T%d_hf "w}cs]o? ݐu@d7/.`akv=~-3c-´K [B7|G>QÓs|}?w6ޞZٯOO7??IFϔ%/y~b+M:]̧?qcNdy}w{$9Zvk= "oǢyߠ#7ma1GΈeZ={hkg_;O߷-5bG:EKMi9֟7샿a= ?uUyi*{7^1?w>w`S^WܦY7@Êq|v>i?n%g|oW~cدڙ,xJ|zG{O{p"?N.'1gt]i憠 bR<~FCw>D,kV4(c܉ePDQ-bSߧb})'_]+?4r_޿͘s[oz_>4e}Ⱦk&7[OBmsbRxZI<-;/n O!{|pz;;{6xo3^Ŀ|7OOj'Oj1=Q7OȾl0yzg:R+~;oe{lm(q9dЭR'>>aK?o۬o4%ow4h?w!mg{k?kq~U__O~5mOqm6;.~bw{%& mXYjy}Ce?f:l^KIH/>b~{g&OGTMG7?ٿfF g;G*߇s|G!KopkPOfi5<̶ +s#lc/͌ 9g[}uaA/3}6YUEt@fO +6;S7)/oު!۾ەɾ1P?oRo4mޱgml>>zg\2iօxd:8vnعMje!Yx)O:,#IX.xH,G Szc@g{פu~Pۛ!_Og?l~ݾ߯$U1T}?h?#|Y/OJM=y<ֿK T=\ۣl`w0۾ bۛ!?r+߱_c~If˾^]/Pds|F,=s/=[h%!u(OZߺNt7ђv_wS'Gt]Puy Oz5GT 4NvϘakt~_ 9?/2b~_\y#?qqݹ7'$z]Vsw*&zp?žϽM}VT@Ko`@ 'z>{szG0}5P?_?l0{__~Q=lO"aOusfyʲUzlIח.,<ڢ\W%ZhOw[I!3aݺG0Wzwי]Ngz~<(w4O)ٻ|c_G~I eSn?3Soi>eyۋouӧ7оվ~E0_S-}g&M>e("$#ެ'8f=w~(+X7z8Dvw?vv隆fA )zykG'}ޛ5aoOA|/w?=u {#Dmz/R[SXF̻uگ[[O6'ޡY_WD=s Jv®? Ao?sk[?)=cp`~Cb/:18f/1{w?NϗnsFS~#o}sNy"c5]+Cֿw;z@{mT{/IE]ʃ+-ڵ +=b\"_55c<ӄ8Ӥzn2`uAOg4o+ ԧjK?16nǾ wЇrcw/UYڥzr~/bf_9s=_|_nν3P*vG>ib^.1j5Ftk?yN[r;l=R} |/w= 6U=P4]r}R 2j: h[*?yMnާz|ճ4؏|:W>|O)}s.? wR[[2EGoHd[e#g?_?mfn +p~#PE}&xPԽҤ *?r}/^:! 9tRͻ$Ϟzs~K8?Iϱ>P߷wf ;3AQ<ޓ: cw;4m!r}{c<|4]ZĻ~Zuh\ |=:YnϦջa>vٜ|WnẢ 3{ w,?iU+{_ʰ8y`2ok_|mx3}zܛsz}jGwǴϿF$;nt7wb9LL,䡡V +# +iCos&g Psx_b! [ݤ9'PL 8U /.6V/ſMK/OE;}mqyJV)4Y̧"rYߗ8GPVwSpSV q Ww Pά>P~Y:%xAv;, Vzg# uuGlM OM *9Sh'gܿ֙hWqۿl\=sƷvs}k9'>X=GbKR~~ so#fN^Nܭp۷ἕJ;Jbb5.8ľ4ܥ$Ns-Zg]:@:dPMT㿓 iG=vv[/߮_oT?~W<Q˾{b4{;-=VI'1??qAouW<^?UWsG}{a ?<+Rr} 1o~G]yݛ*}5;i*vFk赘QfR^0/ۛ泝Ĝ&q@mkIHehWo*_z~U%fJd;(;^?.1f*7qqscZ?q}3E᭹抰}{}b},rSa/븶C9's^- *3p4ogIu1noa[w~^̏ƛ>9<žm~yC%.CN+b~>U]g_>kϠ;w9UExyd>0U,O,_?jOZ)UA<תEϕ` z adzwnÿ_HoM@σOZsy{$b{/1w<Dž.:\?t;6~]7dP;hOQiwlW=n>xDk~|Cf\ޯ%z'~?䇮λ}cfFq|mte+=?W qPrD:se\{X/VW&]E?_+7 ?ϻ?s華lω~WT[mr~?1 _FԄm?{}U=R@;w 7B;#?V?/^/T*OjAM_TacSq什2K"5~VT[ϗ)JHv{H$t@CoOb s ܫvTNlo"[9SBls~T߯}Y} !Q= +z0?}t~+7۩r:3h난 |dۂF?⿝W[~kSy?ףvGAco(%y~i?iU?KQWy[qaٯw#~yς-8Sq!O4_j~|JUiOawjp_mm?~{l={#%coݨj_r~4KH@ǒ{R3s#o<}`X=.0q_P>#Q}Pla}n NCNH  ~sz^|7"ee_TuWzߌ:aٿ#:jG^lVEo>=-nEa<{s/^=u@}K_q`?96[&y,܊ڞJx˛/>_9;#?N/C9Qxa5G~|/P9_U|\Dž8jۭ^_P\}f~s?41􀑟':~sW;~r真ZzvyUÂlt1^u+\@$%~VpނmJWm޿^ۏ?Is}R]w~ڢl:"(S`<pOF]&7^'g%8fԫޡ90WV> yq7tM)nHפ˥{~_{=܌؍)kɷ.]96Tޯ=7ɷ +eG3߽@6|/y_{t3xrv^2yG߿I`{y?$&/$ҭm=wW|0\~?aޢ^?.oϲ.Ot~(Q9?/1Kϓ͇}[^y`'OI!zw9:fC/jfo#?K~4ްnnQO|ࣸ]k<~[Iۯ)g9Wq>/.EN k9G7S"gF5Hc/p}o4JPzRυlt2H@R+';m==@xUn~Dnټ?«_$}xE~\ޏ>G㲗txע޾/}Q7`zNYw_wu*?3:zg}0'{EY]3q=2i dv~3c7[^ -wu?,u~qld߿'}r)_ͤ*92$*p] y=oѽo\~C().g|2: rll_Ļ5[,$Ζ(Z 60݄loɽpg5 sޟ|ن5Wql-ɿ**o4GPɝTG%N g ,xD7D^U(t@_u~ܸzaW@V=g$TZ\?/17h[v;cS/kQs+`Kol#+A9lޏqX/EOqOvPcU_^:ܻ`am >xnZ{. 7==/݊x:Qݎ  zaV$Fg|K/(twM^=a@DZbyu:bg7U&*@3Q~uy*\S~ +wIDNU 3{,~>>>ܝFGqflà_1᳛c3/FR!þьq/u@=ȿ׭Fy/VN*?_z8|+(Wzs؟|e'}Ep]Ew;NjɫyhJe{Pk|;R"'F ;|IzA }~"=wF0^ġ( >BbOR=A͌Bw!m,zp .H f?boFb;_Qr|L?s*FAggl~?[6w|RbĝmOM({wT?f_+fwz͝dKw|8uxq/~vcr*݄ }<@ >@T H>M?ntK? N0lu?zNӹzt?V#?-[T͟lޏmKSOL:Lrv]+{ݎr wǃ~n^۴x&~9+$w?S'Z}=@9uYiWicbgBSU?+)Zvw'o&kk>wSo~L5>Nz"i{$}V{ +:@?R9}dH݈P{c" Q }_7_ _ÿw xYC+!ǾuϹ?c쏵J!Uؿ93/~6N=u#KQIޯN/ok&#d :tCh~,I j{ ^PfGp3|@|;'O\@Y};`?iS{Gv{?OG?|_?a Ѿ>%%/֓Iۺ?*gmUow'rc?5iZCy՝iky>i=N؉IG$tu+Zt4`gt<௤Z+'sFBvFDw)nW!1n`_U?BA,[c)Br5|_=}?r{WBrRb]:vic۟ky?*RMy?\߯an ӼPf@g;ywk9}{!סܭr/&jm3oXgN?}rj?@O,&?' 1xg #@&UbxVoZhCsFό]OZ_WY,%Y-Mpy? +|ztӮq싽a+BqȎ[IY=A{9I 2>j#wG{?5LϙgOhދ+%94Y_^չW7w +~ 0}ۿ![[%濛a]`jmGRcT>q9O;$3gþJ`:/ZYv>JPbX8e<8)1.p/fX?fOPʳϾޝ?~g?>{[F;l#wPtwP?DcCu0ϼt~={$v%j=";`$;rO*/?"!w79;cV?o)O糦46?fD.?r;ӫbL3{Pw}ƾ]ܳ︇gߗ UO|-:nՃK^.` ܎} U d ] lgdI3La8w˫-mKi91S);j> G?": a(`/^3_全s[g~Ћ{{생'et?qp$Ѕ#Vs*R?R"XnV72b_lA1ˍfpcQ3fE.)wKB)P{J!&׍*N?5nDW5ywRw=9RF^0'9nyT~þyޥN~DyPq3P3by@vt =ݾ'[?,7@y˿5 kܟӀ=Š(G/?߁uU?//g]o֟Z>w/jb|];C꠹=Y>@cܙ"yϥU1@[)w+5s0 _Kקlb*F)ӫz‪/V W{C߅TB5~˾>_?>^dy?WK]Jq}ۯ~HBCJ$7Q.`ğ !SsI/.qnmk_;d@Qp/n{B=W_H$j _~Ibw5ۯn/lʹ}$񴟻,ۯZP?Mr>x_O(v_z2(Q?؛S7I{ s{?{ϻՑ\P=;G!}r3vuݪε}w7RP{T.̯~h\e硖uM$+x??-x `29v<Ζ[V2Ӆ=!s8 =dU{bb[^nu//92ߋ)4n@϶sْ>In{zyXzLWGw2b:$P#]L=I?f/ k _=p+Z?(4yn'w(?z3~U{\Ԍo9ki~s緷rmЩ=6~ b [ꢫvq{1@F/PV@tGs) 7?/?}{>[~=Nzyw?﷎݄yUgޯ(?6e{py1TZXU#a~TI7VN桪-,'OZ)o> <)qC9?qs|2?B^ݿ߷|TDb0ޗc^f0 sa!ߣ= {O7YOZGBo0e/¾_\ +oy~Dbu=/9sIwʹ.u7k%f\*y`H1ꀡS9; T[ ~_ 3 z0㳿=;7ZVW0ۖl>S^(w/_DT=q:NdDn^JH_@oFKǾˍfk6s'oo=!1?tGL7Pl{gmt3)w~YO6Dt?}Y;kJ9w_>=S}#NkÎ1aO^߀ߚ_vLVweȾ cNw`gzMr`%lͶuout@KpI`d{L?o*4ϕ?Q[<רݿjOo7d}}RoѼg;l:-:}RlČiQBJ33?yO,Qt5<٤go}I-Ӫ?+1i粶a&qQgJd/Μ͙S^@+1JR7'w.,w1`Gc\H0'rjXO/Q{w_@z} c~k3z /3m?ɾ(ލ'v.vۋ9> d.3X3=Ro]p'IߋUɽl9_5S?|MzMu|=CvWkIO~3?~>O^?wd_ ۟2RwG^ be;9ɜTfp8~Rw[>AL%"; oA0?'`!w[<ޙy=j|%ϯ$w}Qߜle~_ 5rem#&L92˭i#%L}Am j[BN2 uxNrJ|k@|V՛Q|CN<{vY3"C1Co1zZV}wF[i/]loݵ(su{}@6֤{.V55/5+jq p EU?K FLFrs} lEwb|{kR@t.:PB3C|`tcߏ-:E_{{~c~}#٫w3~ߏ9J{'ݳI\#m<@ bt 5/r?BOߋ7}gmj_|`(sH z>(}|nlK`u= G}nm>g峿ا/˿C7}A?-z^(s~R#Cl!pX\l 5@>Ro.ipgK1_d7vJ@֫ݪ4Y>Ե$unD.`yҊ&k?_som>R>(q>|ܺ9zIl?OghF@1D{{.7SJ]i=u,T[H ͆V! .?8D>@ke?C/{Xx@1Kz]`=G|@9>}f_g_۩߯z [-;X#s@aPyeWw=dЗĿoUe pj@9AVNrky;R; gns_ u.VQG<k4[}R+~Z~vg\*_TUr~_~oO ?gn<lϐ @qwvj4">ᗎaLwkVq;oV:=`} >yg;{}>U1.gu5_Hdr~zf4{ +/fキRftNߌw3g{3@Fw<`*P>|C/Zvf .0,)a7W`mǝoMWAKShH(F} > d=E{|xySv1-~aVzP?=z=H|S='Wչ/= qw2ߟ~kw^a.D2_h8p{6{'XkgT ߻ +fH .s 7:e~&̭X`rQ]@!.{@ ?xe{=o7"G7}l/;}\Wmzh?P_w/8]L}+'g2:YOA;`'ޙQ1%-\@܎2#? @{aثw-sZ"3~~=`.wxاRs@lJN?oߟv_T|H$OwKodj]:p{.؞Ψ &[1@= P@. .'> |fdO3NckMa@]wC|~>p?K|h?yI}l0jPL/{$Do0NV_P&&pM q?N9IOS歽1PJ:/t}fw+_@']l dϣq9X;ucc @~|,}7is4}nԼT?Oeo\wax}XΫwկ3XWOsw}⛝/(.潁@bkT gy` ~vԳ;O67}o.Poʂcw}X,߿9[_ÖŒmÃdx+ (}xGjT'yogt)_Z@6|7{e|]:@A^zNZ> @\ vO=6Q>?{=>Qbl)1˳|?շ 6'wSTr<KW%W;,4cb4#@U-H`m9k+1/z(}z5 e`ze$9t%}qS3W>R  5ǍpE yz=>@9rX'C s> ǘ1g{|}.8?`?Ϝ/pw31${3 ?LE?G똇sJ9Ǐ{1@ofZgHs%|Z?p4胔׀7={=_#wܼ3-uE;1[jesl{̛4W}}R?Ugѽ?}SSK<~-p{9zȞ3FngI?pVVyS̤==px&@_ 3xy`^Ez~soIoGA/;;MA_Z~UϾ?0u;hd%۽ +tvw^J_x5D9@x#Gw6TOg>pF ^.PC`vHta78z#'=>ya4.O>(c"g)W}?zށ^I={̾ۥÃ?Kek-jucBow|C?ޏ;Oͩft ڤZ0~#_#4ʎnj$?{{}wwO$=v1z}?d}ka?hV:_}HI*f+*.H;O9f{H>y>@*짽$ y@=+:lY,4zѼU^}}qp*{gՑqv!؅Ihg잗y90g|fLoYb6[,0f3`m02#f{VIݨTTߗ.Ǿ-͖}/m9N\f[U?MusPE8]w+;soEώ9RKyn|ύg5<П:({x~gó+`9Co&ɞ'O{|i컽͖}f{`_?Sq]fžRYsvWހ{XpcZ9ߊsck%IuOwܟgcj&_}=xԞ}p>{1ܱstrVr @>+_ݗ6x= )ʳc+p4qΉ:R?zij՚kv>wK- 9%k?&=a't`>s=\ijznge~o f q|YKCߡsɸ{$8w/>,`} +_ZϚMϓ}+'9;OgIڳ@ ;5:N<MlZ?RϿ=tbH{x&|bسh Dz_}>>=g&a\_ ?Q3]nui}6c7gQ99޳tFϔi~ :D{r.@-م26z {u[M߬>5]S}l2Wioheq(`O!a.GsEgI&|8+e!qs~G0Uq#3)^o*=B7?A0`r TPrj`|DO.Ng6n޵Їz&̫Jmܿ*8OZ`}7U?,Ĺފ5p=kcadzp\ܢZ-ľ'9ЛU/?7RpfVu?}pO8<{>?Z{<xgM̩kȟVϘbmo > +[wkۚ|߯ TwgtύmȐ=K}g9B{E(}9w~Uûԛc?q2ՖD% uf)>9j|;{ik>;Whj}7a_OkV޿:zkh/Bws3u@d^XpkTۢ[Žy{m1#}^ {n>@<y#z 'cg);(<^E?8 wa;8p>收~> ":j6#v Bf Ub~9!c{l]^l Zc_y=7oL$kڏW-8GZ;3˟L=`공Ez +@,wd~zn<`oa/ T >-v^kA[$_g>ġ~ +uo3z,' }p^8vQG9~ MqC;uf`]xRCk=܍3ؿAܯb^ݨ|3OJ;0|_v*~?_`cԛ ?kZ<u"z_?mfr^Ys?=#=io9w=GNgz'BLgtsOŕׁ<@yR" e +z8{ `f* wSniCkj\{I>5},mZWدYƵQᾊOy-Mg~-Jd1  LĿǓ>\cO3As?tZYR p(Oڷ_{oOg"`?Fi84I^g/(?!aQ^` }o% n@yBNJZ,?B t `:abwU`>J apG3l5_}Bkj~>uYY?k-\ur O  |`߿=ȳNWoYévj` |9n I/a%&Jq 8Oy@?d?g}y ,_9$=pb/8r}\x + 2~MBoݙAu۷D<EΑuO`f {i񙇵YǽKO>v;z`_^马v*Mh'z=Uk?xns&I-p󀿿BSN.H=b6/~{|jpk'9 8@Haw%cYs@{x=PV&Dʨ ykC:蝇ܛ*oc>櫽^8S2{&;>%7' S?p -0ԙ@}/V^{0u +.w} [ε71}կ//{|T83exNb4o<.@/>/1E_v/p5 7T&zҾ& gzfʬDut!Z``]bWkVǻ>&Iܿԍót/ybgx根k|w ;;ڇ^n^ 1xh'_aߌIoA9$\b.b,sxW֣\-y蚯UF?6׆E"I87uBX9VU=Hܯj~署ƿ 0"v?@Dח|ߏDF?kX>b].g՛p^X +_^M0v[xHJpfc\C? OEO@_xi#JD>O.{ߌ  .ZNĹ/*匟IοZYv?lk<g~ Vx_F=L/8#> p{e,p2qP4>0m&/.P.fD{y9uxd̏.sTAO+WA'U9VAjY*>jaZ`jpYz i U\!PΟs7B1\0q[Z5ޞmEǠQ!zߚs?>K%Go?y Z gsx,jYȞ}{~)'|@{HpHy(F{Ƕ/00pJ8 Gʡ30̿cI98F3P3ud}}Rw{:J+9?VTk+`~qsA/Z`￾|YKhB0 (m^~p@ BPZhKI&'7vo`?CQfgh(ߍ81~9lj]ghfzg/K{N|hk/* v} P;>ay=l 4Ԟ JvYs= }ȝ7? _^=׳=M0Ys=Ĝi_n_-<bJxzy<δ1]LWfi߻go)s|Z, +yg=AP8|VtT|ç}eOz֨g,=G9j>Y11@$-P x+x7m:55 +V4y^M7ʽ\/뾞f_Rψdóz`xzѭs:0㋱5Ĭ^m5\9wz*ֲjSZיN-@=K@ྐث1X@ֹ̪=S#O]|9*rWPꈰR'_?O̹>{[5A+`{0SMc쳽Tp#z¬Us3rB(5ߋΗd Z_|e1@9/3 g|6\wsOxtV==y~`\uf2sT=0{pӜ|+؛h3{N7Yݷʼn dYσ9ܛX_5ߋuz~&>Z}b?y}-w2= <9 pN3躠 \6u \PytZeys(ӹm&^soc}5?CLߏc shVb/lԻ:'>^-T\j+RBu=}M/y]x_]őYq`{ + h(d.Wб@LN`|Gz;@u:x<zNQKg/{'Wyg}/1s\ɨ~5'=@?{jnsdF(Ӹmbt>l~`}ٚLP%05^b>1gc=zc-~Ǘw8?8kX6K>\0shPu5*n;^q Ύ: AQ7WAi1Few<B;=C~W1 ȼvo~ߨN2M&&@yzL 9@/{`uj=z{cXFNPcLK,/+C~YQLH|Z'FӺ>`YȬ=;PO0߃#ge؛'G~Ɵ`?_ךXhmapT'̌ 8?y'̘LpAFF}! s6|_`qyMx~[!wk=WĹ^`_w@8'T} -&h+^2:Gxϔ}dYϩސt?|MiPzt1]r0}/%QG#09uݰ5v'&C/4%p/k:ri>g H9ܵe}x:λZ#đ3֌=yX׋ٹ~6k3b} $^`kL̗v= x.B֊g౺DqZQb}m͂%C akw]y8[c~}ܓ8 7.m.j}x?kձ_${9}@z z! t~ (G!nI7ϞΛy2<٘k}}5jRkkcOeUW&IӐuזu;TǓ^1_3߁qd+ٖ~1>[A[~5Jد7(budL%±z</3+CԼ?90C~GV'\3ۆk輹Y_岮wŻc̷群gX< p^ JU$&¨<^c.[n'``}ks|]y'ϥUj֚uZC|Z*eq}e}O¼pk=q/1~S={/<˝?ϯ5SybH T X? 6^ kȟXiMU[Iu@cu#l;mj"ϋu9cA·_\%>ُ5kU,rxʽ@j؀~x0Vnt+SKo/ϡu>"g~Jp'w\j:'bS~n&i=Z_@<['h@R;}76 x~k_/K׷5Ԓ:ǵ6KkRo X;;VfzWlt`:x@Ay/_L?'{FM /pcT|=E |oFKjN~TNKjU3i .m5>|bQ1sj[;s>3"~PdL=A0C%ZD>檵8jó/a'y;}(ޛ- yV+gzc0xB./hp 6V2|[TYҼ ?Y9\4ߜ;1XVGqgy ( @(Gͥq5ߣө<_ϚdECr/N2bPWSj,vLM|8+K͙J۔[!I\b<4>'z?=h|s) #QCBsVPk6)g?E𿠎(/!ZSLP&]+|?瓋*Wz?<~62˰^P ͜ϼvjާ//O 흉{K@ HBC dd2YQPQ@@AE:]z V9t0(Xnd' }Ob~ƈTl zú:kb4Nw3s.g;e`(jPM X @!Xދ,% 8㍏9y,q}5}Aw_g^Nw|Gũ̿˙/Q xJ|FZg{Է󃸟y}\\Z~ir皵k:zOp{Yשw_S^~}>RݝoJx[wqNHc{u5ɝ;yav_'j<]taqp fXk]}3_c;kvj9|;=Γ==h.՚yZxcD^p0Nfc_=sz|}p6T_#? HHgszKOFõ?ٝ VkH(Og@0d?I5@ĵsBNcߞ9kzK7u1a J}5|^]"A|boIO?qsjyxtF| zcH1cY<]|}c^_0הG_CSyAL}uAgue^71ftO3+o;\p?9mH\s"=x/ùb?FGGcX9t}7(^/1ص(gew9gMOG#%OGO0 /?{O{8?z8? /"A{A"^~^1?=_?ǵ|4&C$kGc4Ϝs9-|{ސ;x?4lЃޟj]Ӟ >s(5 ^X;S\9N{9!f~﷡S3"5u:j}lpSG\w-jӽBo=p>X7<:1! !3ĸУglc& ]U/>R#A<ǗcJog~M_O\^;1^3']2'EQIc澆籣~{;'siD I* toc?/?(y$`ҺH'wFǃ<~kpN5?V鎻Fǹw: ֳ ƥyTĿ| 6c3g9>\w|XHi'gGM{?.<}nqNBwL{,sp 0/[}{z{x AOq\ 49+U?.L\O<݄@VsBB `8'N74{x} %'>N?"h8O,p^.x=]~f559xṷa]y`& DbO ?~ @XVՠ22 fc@?|?y|>(oXV l@#.Ls1$C9M|^_ׂȩku=u^^A e,M]`/D3]/o~%t7jG/KEw=v^G?ا{"M um+C6%t͆ 땧Y#~nx^>pr;ڻ vev;_'E ,p5/DAݓ5Qql6 ^ /Z|C^:``A{];a Nȶ0Wp@_4kd̷LĀ 6{n+v*馽gmbF<9l;ml}.M{b՝vv;v1y@3rR!i m<2Yᚍeulc۠wځn{~cךVv6'vwCkWH#ǀ 96eV--UKzk6n;gG-vzKvv]A$kzKĀW7sֶ,?!Ys,{rC:Ț ou ToN{wK>8"jKx_ߢWP \zNVxy;q5:OhOP/D¸6k\[1k5.XeEvބ/?Bie.kr q.q}߶Ӯooo>5ǮD{H/?&C .[')h<4~܆[b?j|W޾^پ)ʎ^H#\9f7Vۑ{uvy7Utz1_mWaguN8e/A넔 F0'sն@ |Ӿ/ojE] ol#{[ Uvz{_~Bc<[2c5,,^aC_zQTgX#(k;ra;7}'U .0\I/Z<+:XCۻ-vjB+ڟ{Y }etc]ro;j `yeLB`R[`?G?zh +Cb}{U{ u@cn[cmҿe6nY;Xe;~y?Ky}8MG#. 8 /þx7֨ D +s - cu^pr_xj*헒F޿lV\g?`o#16~/Tl ݳ39ײoH- VX0m^-Gߍ$<wC>{q=}˪gbۯzyבC]Ri݌/18' :dq_z6{ s?[c}]Ze}?z\P=Wl),,ʹR} x/ +Sk:b(v=?ޏpQOx"XAL. }Jm "C.Ͽue}G/{wه;1Dlw߶yֈ)?Cb'@*x&ht/{t{@?j7ꄟ +k7#m {?~63sHKM.~>C}Il?{~/b/>E]@ +ߤIC7x=o}_:B_?!F֟m 4STgZ4=h:|~e~>?@_ &|}?n?Gym6N`}V[X6JB 5\y|tguNy/p~`/4OCv>_L#@~qu??8ߏq ++!Fp@q@o@yw3v]l.|z>ǫ|M)%,fނ'ēksnX_9xYpsWz~5Qq+m Bϯ+xߩZoC  Ā+6#fT/ēD=]^Ze]>;&ۂJ _(i-74|8k:$^;{7}YoĿI^? σ&n?[ Co+Ex+7ڢ pqDf;czjnTV"EΐͿ/ēK*l"4<_ CۻV5؀ߤ#bτ2?ƾCg7s1č ݶ}mڴ6vy "Z}&4~Aο?19"]mS8<b-ăK C5[C4FYKY|h-_y?AO-*n/nKR37T[1lY0>.B<8QwO;n6ApN^Qo˻6jy;xUPeWj]N"~\ol +=d{{K67p xym cukyO 4=k~sr~-k>:c/Dy?WkmV봵uv9Ps'u={gg9gQz{$De1=i_I`Ƕ#Fj]F = |:gI7 \)\g|Ϳ:v8Kx?QczBVz#Gun=dk?t{NlnD s^Q9g\5t[KBD+@9qZ.ƀu^E~j pNs]OHњjvhq>B?&~P +jS[ b@lÁm9h=65|gQ ᚞9Fp??os7IH-> ^ABN^6ā  \{ڞ^~hKv1=6N zu#wƹEҾ#x2P":^f]'Z{ۅZ`oz;Nw[s^[,y%|P jZFqE۲mvԶmk;}eYvޭkx^i_1B޿ T{9o ld_wmӮI +n<ʐoB'c˟c JBo=?'z?ŀڐ 8l8tZ|`G/[E&HB$}$yX-.h[-'@,h%[u[rG.EB2Vu =0|ͮh8O߰>B[7u|BCySW?\NT8ֆkajOY֐HzsAڿ=wr5r'!VD\|(vqeTf!D{:mׅ