mirror of
https://github.com/AquariaOSE/Aquaria.git
synced 2025-08-23 06:50:54 +00:00
Remove unused files
This commit is contained in:
parent
dff33b0530
commit
51baa76816
51 changed files with 13 additions and 4111 deletions
|
@ -1,59 +0,0 @@
|
|||
/*
|
||||
Copyright (C) 2007, 2010 - Bit-Blot
|
||||
|
||||
This file is part of Aquaria.
|
||||
|
||||
Aquaria is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU General Public License
|
||||
as published by the Free Software Foundation; either version 2
|
||||
of the License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
|
||||
See the GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
#include "Element.h"
|
||||
|
||||
#include "../BBGE/Core.h"
|
||||
|
||||
BoxElement::BoxElement(int width, int height) : Element(BOX)
|
||||
{
|
||||
blendEnabled = false;
|
||||
this->width = width;
|
||||
this->height = height;
|
||||
height+=2;
|
||||
|
||||
|
||||
ww = width/2 + 2;
|
||||
hh = height/2 + 10;
|
||||
this->color = 0;
|
||||
cull = true;
|
||||
//cull = false;
|
||||
}
|
||||
|
||||
/*
|
||||
bool BoxElement::isOnScreen()
|
||||
{
|
||||
// HACK: biased towards being fast for rows
|
||||
//if (alpha.x < 1.0f) return false;
|
||||
//if (!cull) return true;
|
||||
|
||||
if (this->position.y + hh >= core->screenCullY1
|
||||
&& this->position.y - hh <= core->screenCullY2)
|
||||
{
|
||||
if (this->position.x + ww >= core->screenCullX1
|
||||
&& this->position.x - ww <= core->screenCullX2)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
*/
|
|
@ -1,56 +0,0 @@
|
|||
/*
|
||||
Copyright (C) 2007, 2010 - Bit-Blot
|
||||
|
||||
This file is part of Aquaria.
|
||||
|
||||
Aquaria is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU General Public License
|
||||
as published by the Free Software Foundation; either version 2
|
||||
of the License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
|
||||
See the GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
#include "GridRender.h"
|
||||
|
||||
BubbleRender::BubbleRender() : RenderObject()
|
||||
{
|
||||
bubble.setTexture("particles/bubble");
|
||||
bubble.alpha = 0.5;
|
||||
bubble.scale = Vector(0.5,0.5);
|
||||
cull = false;
|
||||
}
|
||||
|
||||
void BubbleRender::rebuild()
|
||||
{
|
||||
bubbles.clear();
|
||||
for (int x = dsq->game->cameraMin.x; x < dsq->game->cameraMax.x; x+=64)
|
||||
{
|
||||
for (int y = dsq->game->cameraMin.y; y < dsq->game->cameraMax.y; y+=64)
|
||||
{
|
||||
bubbles.push_back(Vector(x,y) + Vector(rand()%16-32, rand()%16-32));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void BubbleRender::onRender()
|
||||
{
|
||||
for (int i = 0; i < bubbles.size(); i++)
|
||||
{
|
||||
if (bubbles[i].x > core->screenCullX1 && bubbles[i].x < core->screenCullX2)
|
||||
{
|
||||
if (bubbles[i].y > core->screenCullY1 && bubbles[i].y < core->screenCullY2)
|
||||
{
|
||||
bubble.position = bubbles[i];
|
||||
bubble.render();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -33,7 +33,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|||
#include "Shot.h"
|
||||
#include "GridRender.h"
|
||||
#include "AutoMap.h"
|
||||
#include "PackRead.h"
|
||||
|
||||
#include "RoundedRect.h"
|
||||
#include "TTFFont.h"
|
||||
|
|
|
@ -1,62 +0,0 @@
|
|||
/*
|
||||
Copyright (C) 2007, 2010 - Bit-Blot
|
||||
|
||||
This file is part of Aquaria.
|
||||
|
||||
Aquaria is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU General Public License
|
||||
as published by the Free Software Foundation; either version 2
|
||||
of the License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
|
||||
See the GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
#include "DSQ.h"
|
||||
|
||||
void FFTNotes::load()
|
||||
{
|
||||
data.clear();
|
||||
std::ifstream in("data/FFTNotes.txt");
|
||||
std::string read;
|
||||
while (std::getline(in, read))
|
||||
{
|
||||
std::istringstream is(read);
|
||||
int n=0, v=0;
|
||||
is >> n;
|
||||
while (is >> v)
|
||||
{
|
||||
data[v] = n+1;
|
||||
}
|
||||
}
|
||||
in.close();
|
||||
}
|
||||
|
||||
int FFTNotes::getNoteFromFFT(int fft, int octave)
|
||||
{
|
||||
if (fft == 0)
|
||||
return -1;
|
||||
int v = data[fft]-1;
|
||||
/*
|
||||
std::ostringstream os;
|
||||
os << "fftv: " << v;
|
||||
debugLog(os.str());
|
||||
*/
|
||||
if (v == (octave+1)*10)
|
||||
{
|
||||
v = 7;
|
||||
}
|
||||
if (v > (octave+1)*10 || v < octave*10)
|
||||
{
|
||||
v = -1;
|
||||
}
|
||||
if (v != -1)
|
||||
v -= octave*10; // : )
|
||||
return v;
|
||||
}
|
|
@ -2099,14 +2099,14 @@ void Game::clearDynamicGrid(unsigned char maskbyte /* = OT_MASK_BLACK */)
|
|||
{
|
||||
// just to be sure in case the grid/type sizes change,
|
||||
// otherwise there is a chance to write a few bytes over the end of the buffer -- FG
|
||||
compile_assert(sizeof(grid) % sizeof(uint32) == 0);
|
||||
compile_assert(sizeof(grid) % sizeof(unsigned) == 0);
|
||||
|
||||
unsigned char *gridstart = &grid[0][0];
|
||||
uint32 *gridend = (uint32*)(gridstart + sizeof(grid));
|
||||
uint32 *gridptr = (uint32*)gridstart;
|
||||
unsigned *gridend = (unsigned*)(gridstart + sizeof(grid));
|
||||
unsigned *gridptr = (unsigned*)gridstart;
|
||||
// mask out specific bytes
|
||||
// use full uint32 rounds instead of single-bytes to speed things up.
|
||||
const uint32 mask = maskbyte | (maskbyte << 8) | (maskbyte << 16) | (maskbyte << 24);
|
||||
const unsigned mask = maskbyte | (maskbyte << 8) | (maskbyte << 16) | (maskbyte << 24);
|
||||
do
|
||||
{
|
||||
*gridptr &= mask;
|
||||
|
|
|
@ -3517,8 +3517,8 @@ void SceneEditor::prevEntityType()
|
|||
void SceneEditor::dumpObs()
|
||||
{
|
||||
TileVector tv;
|
||||
unsigned char *data = new unsigned char[MAX_GRID * MAX_GRID * sizeof(uint32)];
|
||||
uint32 *ptr = (uint32*)data;
|
||||
unsigned char *data = new unsigned char[MAX_GRID * MAX_GRID * sizeof(unsigned)];
|
||||
unsigned *ptr = (unsigned*)data;
|
||||
for(tv.y = MAX_GRID - 1; ; --tv.y)
|
||||
{
|
||||
for(tv.x = 0; tv.x < MAX_GRID; ++tv.x)
|
||||
|
|
|
@ -1,70 +0,0 @@
|
|||
/*
|
||||
Copyright (C) 2007, 2010 - Bit-Blot
|
||||
|
||||
This file is part of Aquaria.
|
||||
|
||||
Aquaria is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU General Public License
|
||||
as published by the Free Software Foundation; either version 2
|
||||
of the License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
|
||||
See the GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
#include "States.h"
|
||||
|
||||
StarRenderer::StarRenderer(int num, int range) : RenderObject()
|
||||
{
|
||||
stars.resize(num);
|
||||
int rh = range/2;
|
||||
for (int i = 0; i < stars.size(); i++)
|
||||
{
|
||||
stars[i] = Vector((rand()%range)-rh, (rand()%range)-rh, (rand()%range)-rh);
|
||||
}
|
||||
//rotation.interpolateTo(Vector(0,360,0), 30, -1);
|
||||
//position.interpolateTo(Vector(0,0,-100), 10, -1);
|
||||
}
|
||||
|
||||
void StarRenderer::render()
|
||||
{
|
||||
#ifdef BBGE_BUILD_OPENGL
|
||||
core->enable3D();
|
||||
glLoadIdentity();
|
||||
glTranslatef(position.x, position.y, position.z);
|
||||
glRotatef(rotation.x, 1, 0, 0);
|
||||
glRotatef(rotation.y, 0, 1, 0);
|
||||
glRotatef(rotation.z, 0, 0, 1);
|
||||
glPointSize(1);
|
||||
glBindTexture(GL_TEXTURE_2D, 0);
|
||||
|
||||
glBegin(GL_POINTS);
|
||||
for (int i = 0; i < stars.size(); i++)
|
||||
{
|
||||
float c = 1.0f-fabsf(stars[i].z)/50.0f;
|
||||
glColor3f(c,c,c);
|
||||
glVertex3f(stars[i].x, stars[i].y, stars[i].z);
|
||||
}
|
||||
glEnd();
|
||||
|
||||
core->enable2D(core->getVirtualWidth());
|
||||
/*
|
||||
glMatrixMode(GL_PROJECTION);
|
||||
glPopMatrix();
|
||||
glMatrixMode(GL_MODELVIEW);
|
||||
glPopMatrix();
|
||||
*/
|
||||
#endif
|
||||
}
|
||||
|
||||
void StarRenderer::onRender()
|
||||
{
|
||||
|
||||
}
|
||||
|
|
@ -1,104 +0,0 @@
|
|||
/*
|
||||
Copyright (C) 2007, 2010 - Bit-Blot
|
||||
|
||||
This file is part of Aquaria.
|
||||
|
||||
Aquaria is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU General Public License
|
||||
as published by the Free Software Foundation; either version 2
|
||||
of the License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
|
||||
See the GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
#include "WaterFont.h"
|
||||
#include "DSQ.h"
|
||||
#include "Game.h"
|
||||
#include "Avatar.h"
|
||||
|
||||
#include "../BBGE/Particles.h"
|
||||
|
||||
WaterFont::WaterFont() : BitmapText(&dsq->font)
|
||||
{
|
||||
pTime = 0;
|
||||
setBitmapFontEffect(BFE_SHADOWBLUR);
|
||||
setFontSize(26);
|
||||
}
|
||||
|
||||
//const float interval = 0.015;
|
||||
void spawnWaterFontParticle(RenderObject *me, Vector position, int size, float life, int layer)
|
||||
{
|
||||
float t = life;
|
||||
int angle = rand()%360;
|
||||
int spd = 10;
|
||||
PauseQuad *q = new PauseQuad;
|
||||
q->setTexture("particles/spark");
|
||||
|
||||
q->setBlendType(RenderObject::BLEND_ADD);
|
||||
|
||||
q->color.ensureData();
|
||||
q->color.data->path.addPathNode(Vector(1,1,1),0);
|
||||
q->color.data->path.addPathNode(Vector(0.1,0.75,1),0.3);
|
||||
q->color.data->path.addPathNode(Vector(0.05,0.5,1),0.8);
|
||||
q->color.data->path.addPathNode(Vector(0,0,1),1.0);
|
||||
q->color.startPath(t);
|
||||
|
||||
//q->color = Vector(1, 0.5, 0);
|
||||
q->alpha.ensureData();
|
||||
q->alpha.data->path.addPathNode(0, 0);
|
||||
q->alpha.data->path.addPathNode(0.2, 0.5);
|
||||
q->alpha.data->path.addPathNode(0, 1.0);
|
||||
q->alpha.startPath(t);
|
||||
q->velocity = Vector(sinf(angle)*spd,cosf(angle)*spd);
|
||||
//q->velocity += vel;
|
||||
q->setLife(1.0);
|
||||
q->setDecayRate(1.0f/t);
|
||||
q->rotation.z = rand()%360;
|
||||
q->setWidthHeight(size, size);
|
||||
q->position = position;
|
||||
q->cull = false;
|
||||
//q->influenced = 16;
|
||||
|
||||
dsq->game->addRenderObject(q, layer);
|
||||
//me->addChild(q);
|
||||
//me->renderBeforeParent = false;
|
||||
//me->parentManagedPointer = true;
|
||||
//q->update(interval);
|
||||
}
|
||||
|
||||
|
||||
//const float interval = 0.012;
|
||||
const float interval = 0.08;
|
||||
void WaterFont::onUpdate(float dt)
|
||||
{
|
||||
BitmapText::onUpdate(dt);
|
||||
|
||||
Vector sp(position.x-alignWidth*0.5f-15, 5+position.y+5);
|
||||
Vector ep(position.x+alignWidth*0.5f+15, 5+position.y+10);
|
||||
pTime += dt;
|
||||
while (pTime > interval)
|
||||
{
|
||||
int dist = alignWidth / 40;
|
||||
for (int i = 0; i < dist; i++)
|
||||
{
|
||||
Vector p(rand()%(int(ep.x-sp.x))+sp.x, rand()%(int(ep.y-sp.y))+sp.y);
|
||||
/*
|
||||
std::ostringstream os;
|
||||
os << "p(" << p.x << ", " << p.y << ")";
|
||||
debugLog(os.str());
|
||||
*/
|
||||
Vector d(rand()%200-100,rand()%200-100);
|
||||
d *= 0.01f;
|
||||
spawnWaterFontParticle(this, p, 64, 1.2, LR_PARTICLES);
|
||||
}
|
||||
pTime -= interval;
|
||||
}
|
||||
}
|
||||
|
|
@ -1,35 +0,0 @@
|
|||
/*
|
||||
Copyright (C) 2007, 2010 - Bit-Blot
|
||||
|
||||
This file is part of Aquaria.
|
||||
|
||||
Aquaria is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU General Public License
|
||||
as published by the Free Software Foundation; either version 2
|
||||
of the License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
|
||||
See the GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
#ifndef WATERFONT_H
|
||||
#define WATERFONT_H
|
||||
|
||||
#include "../BBGE/BitmapFont.h"
|
||||
|
||||
class WaterFont : public BitmapText
|
||||
{
|
||||
public:
|
||||
WaterFont();
|
||||
protected:
|
||||
float pTime;
|
||||
void onUpdate(float dt);
|
||||
};
|
||||
|
||||
#endif
|
|
@ -1,79 +0,0 @@
|
|||
/*
|
||||
Copyright (C) 2007, 2010 - Bit-Blot
|
||||
|
||||
This file is part of Aquaria.
|
||||
|
||||
Aquaria is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU General Public License
|
||||
as published by the Free Software Foundation; either version 2
|
||||
of the License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
|
||||
See the GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
#include "AnimatedSprite.h"
|
||||
|
||||
AnimData::AnimData()
|
||||
{
|
||||
frameStart = frameEnd = 0;
|
||||
time = 0;
|
||||
loop = 0;
|
||||
pingPong = false;
|
||||
datafile = 0;
|
||||
}
|
||||
|
||||
AnimatedSprite::AnimatedSprite() : Quad()
|
||||
{
|
||||
//debugLog("AnimatedSprite::AnimatedSprite()");
|
||||
frame = 0;
|
||||
animator.setUpdatee(&frame);
|
||||
animationTime.setUpdatee (&animator.timePeriod);
|
||||
//debugLog("End AnimatedSprite::AnimatedSprite()");
|
||||
}
|
||||
|
||||
void AnimatedSprite::animate (AnimData &animData)
|
||||
{
|
||||
onAnimData(animData);
|
||||
animate (animData.name, animData.frameStart, animData.frameEnd, animData.time, animData.loop, animData.pingPong);
|
||||
}
|
||||
|
||||
void AnimatedSprite::onAnimData(AnimData &animData)
|
||||
{
|
||||
}
|
||||
|
||||
void AnimatedSprite::animate (const std::string &name, int from, int to, float time, int loopType, bool pingPong, float initialDelay)
|
||||
{
|
||||
if (from == to && to == 0)
|
||||
{
|
||||
debugLog ("null animation");
|
||||
animator.stop();
|
||||
return;
|
||||
}
|
||||
currentAnim = name;
|
||||
frame = from;
|
||||
animator.interpolateTo (to, time, loopType);
|
||||
animator.pingPong = pingPong;
|
||||
animator.initialDelay = initialDelay;
|
||||
}
|
||||
|
||||
void AnimatedSprite::onUpdate (float dt)
|
||||
{
|
||||
Quad::onUpdate (dt);
|
||||
animator.update (dt);
|
||||
animationTime.update (dt);
|
||||
if (!animator.interpolating && currentAnim != "")
|
||||
{
|
||||
animComplete(currentAnim);
|
||||
lastAnim = currentAnim;
|
||||
currentAnim = "";
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1,68 +0,0 @@
|
|||
/*
|
||||
Copyright (C) 2007, 2010 - Bit-Blot
|
||||
|
||||
This file is part of Aquaria.
|
||||
|
||||
Aquaria is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU General Public License
|
||||
as published by the Free Software Foundation; either version 2
|
||||
of the License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
|
||||
See the GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
#ifndef __animated_sprite__
|
||||
#define __animated_sprite__
|
||||
|
||||
#include "Quad.h"
|
||||
#include "Interpolator.h"
|
||||
|
||||
class AnimData
|
||||
{
|
||||
public:
|
||||
AnimData();
|
||||
std::string name;
|
||||
int frameStart, frameEnd, datafile;
|
||||
float time;
|
||||
int loop;
|
||||
bool pingPong;
|
||||
};
|
||||
|
||||
|
||||
class AnimatedSprite : public Quad
|
||||
{
|
||||
public:
|
||||
AnimatedSprite();
|
||||
|
||||
Interpolator animator, animationTime;
|
||||
float frame;
|
||||
std::string currentAnim, lastAnim;
|
||||
|
||||
virtual void animComplete(std::string name) {}
|
||||
|
||||
void animate (const std::string &name, int from, int to, float time, int loopType, bool pingPong = false, float initialDelay = 0.0f);
|
||||
void animate (AnimData &animData);
|
||||
|
||||
bool isAnimating()
|
||||
{
|
||||
return animator.interpolating;
|
||||
}
|
||||
|
||||
|
||||
|
||||
protected:
|
||||
virtual void onAnimData(AnimData &animData);
|
||||
virtual void onUpdate (float dt);
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
|
|
@ -1,139 +0,0 @@
|
|||
/*
|
||||
Copyright (C) 2007, 2010 - Bit-Blot
|
||||
|
||||
This file is part of Aquaria.
|
||||
|
||||
Aquaria is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU General Public License
|
||||
as published by the Free Software Foundation; either version 2
|
||||
of the License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
|
||||
See the GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
#include "BloomEffect.h"
|
||||
#include "Core.h"
|
||||
|
||||
BloomEffect::BloomEffect() : RenderObject()
|
||||
{
|
||||
active = false;
|
||||
followCamera = 1;
|
||||
cull = 0;
|
||||
stretch = 0;
|
||||
startLayer = endLayer = -1;
|
||||
|
||||
texID = 0;
|
||||
format = GL_LUMINANCE;
|
||||
|
||||
useFrameBuffer = true;
|
||||
}
|
||||
|
||||
void BloomEffect::init(int quality, int startLayer, int endLayer)
|
||||
{
|
||||
this->startLayer = startLayer;
|
||||
this->endLayer = endLayer;
|
||||
this->quality = quality;
|
||||
|
||||
if (useFrameBuffer)
|
||||
{
|
||||
if (frameBuffer.init(quality, quality))
|
||||
active = true;
|
||||
else
|
||||
{
|
||||
active = false;
|
||||
useFrameBuffer = false;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
texID = generateEmptyTexture(quality);
|
||||
}
|
||||
}
|
||||
|
||||
void BloomEffect::unloadDevice()
|
||||
{
|
||||
if (frameBuffer.isInited())
|
||||
frameBuffer.unloadDevice();
|
||||
}
|
||||
|
||||
void BloomEffect::reloadDevice()
|
||||
{
|
||||
if (frameBuffer.isInited())
|
||||
frameBuffer.reloadDevice();
|
||||
}
|
||||
|
||||
void BloomEffect::render()
|
||||
{
|
||||
if (active && frameBuffer.isInited())
|
||||
{
|
||||
// get
|
||||
glViewport(0,0,quality,quality);
|
||||
|
||||
frameBuffer.startCapture();
|
||||
|
||||
glClearColor(0,0,0,1);
|
||||
glClear(GL_COLOR_BUFFER_BIT);
|
||||
core->render(startLayer, endLayer, false);
|
||||
|
||||
if (useFrameBuffer)
|
||||
{
|
||||
frameBuffer.endCapture();
|
||||
}
|
||||
else
|
||||
{
|
||||
glBindTexture(GL_TEXTURE_2D,texID);
|
||||
glCopyTexImage2D(GL_TEXTURE_2D, 0, format, 0, 0, quality, quality, 0);
|
||||
}
|
||||
|
||||
core->setClearColor(core->getClearColor());
|
||||
glViewport(0, 0, core->width, core->height);
|
||||
|
||||
|
||||
// render
|
||||
glEnable(GL_TEXTURE_2D);
|
||||
if (useFrameBuffer)
|
||||
frameBuffer.bindTexture();
|
||||
else
|
||||
glBindTexture(GL_TEXTURE_2D,texID);
|
||||
|
||||
glPushMatrix();
|
||||
glLoadIdentity();
|
||||
|
||||
//glScalef(scale.x, scale.y, 0);
|
||||
|
||||
float spost = 0.0;
|
||||
|
||||
|
||||
int x=0,y=0;
|
||||
x = -core->getVirtualOffX()*2;
|
||||
y = -core->getVirtualOffY()*2;
|
||||
applyBlendType();
|
||||
glColor4f(color.x, color.y, color.z, alpha.x*alphaMod);
|
||||
glBegin(GL_QUADS); // Begin Drawing Quads
|
||||
|
||||
glTexCoord2f(0,1); // Texture Coordinate ( 0, 1 )
|
||||
glVertex2f(x-stretch,y-stretch); // First Vertex ( 0, 0 )
|
||||
glTexCoord2f(0,0); // Texture Coordinate ( 0, 0 )
|
||||
glVertex2f(x-stretch,core->height+stretch); // Second Vertex ( 0, 480 )
|
||||
|
||||
glTexCoord2f(1,0); // Texture Coordinate ( 1, 0 )
|
||||
glVertex2f(core->width+stretch,core->height+stretch); // Third Vertex ( 640, 480 )
|
||||
|
||||
glTexCoord2f(1,1); // Texture Coordinate ( 1, 1 )
|
||||
glVertex2f(core->width+stretch,y-stretch); // Fourth Vertex ( 640, 0 )
|
||||
glEnd();
|
||||
|
||||
glPopMatrix();
|
||||
|
||||
glBindTexture(GL_TEXTURE_2D, 0);
|
||||
RenderObject::lastTextureApplied = 0;
|
||||
}
|
||||
}
|
||||
|
|
@ -1,48 +0,0 @@
|
|||
/*
|
||||
Copyright (C) 2007, 2010 - Bit-Blot
|
||||
|
||||
This file is part of Aquaria.
|
||||
|
||||
Aquaria is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU General Public License
|
||||
as published by the Free Software Foundation; either version 2
|
||||
of the License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
|
||||
See the GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
#ifndef BLOOMEFFECT_H
|
||||
#define BLOOMEFFECT_H
|
||||
|
||||
#include "RenderObject.h"
|
||||
#include "FrameBuffer.h"
|
||||
|
||||
class BloomEffect : public RenderObject
|
||||
{
|
||||
public:
|
||||
BloomEffect();
|
||||
void init(int quality, int startLayer, int endLayer);
|
||||
FrameBuffer frameBuffer;
|
||||
void unloadDevice();
|
||||
void reloadDevice();
|
||||
void render();
|
||||
|
||||
GLuint format;
|
||||
int texID;
|
||||
|
||||
protected:
|
||||
int startLayer, endLayer;
|
||||
int quality;
|
||||
bool active;
|
||||
int stretch; // slightly adjust edges outward
|
||||
bool useFrameBuffer;
|
||||
};
|
||||
|
||||
#endif
|
|
@ -1,28 +0,0 @@
|
|||
/*
|
||||
Copyright (C) 2007, 2010 - Bit-Blot
|
||||
|
||||
This file is part of Aquaria.
|
||||
|
||||
Aquaria is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU General Public License
|
||||
as published by the Free Software Foundation; either version 2
|
||||
of the License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
|
||||
See the GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
//#ifdef BBGE_BUILD_MSVC8X
|
||||
|
||||
extern "C"
|
||||
{
|
||||
int errno;
|
||||
}
|
||||
|
||||
//#endif
|
|
@ -1,443 +0,0 @@
|
|||
/*
|
||||
Copyright (C) 2007, 2010 - Bit-Blot
|
||||
|
||||
This file is part of Aquaria.
|
||||
|
||||
Aquaria is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU General Public License
|
||||
as published by the Free Software Foundation; either version 2
|
||||
of the License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
|
||||
See the GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
#include "Collision.h"
|
||||
|
||||
CollisionShape::CollisionShape()
|
||||
{
|
||||
xw = yw = 0;
|
||||
setType(CIRCLE);
|
||||
active = true;
|
||||
project = true;
|
||||
radius = 32;
|
||||
corners.resize(4);
|
||||
layer = 0;
|
||||
}
|
||||
|
||||
void CollisionShape::setType(Type type)
|
||||
{
|
||||
this->type = type;
|
||||
}
|
||||
|
||||
CollisionShape::Type CollisionShape::getType()
|
||||
{
|
||||
return type;
|
||||
}
|
||||
|
||||
/*
|
||||
bool CollisionShape::compareMask(CollisionShape &c)
|
||||
{
|
||||
for (CollisionLayerMask::iterator i = c.colliderMask.begin(); i != c.colliderMask.end(); i++)
|
||||
{
|
||||
for (CollisionLayerMask::iterator j = c.collideeMask.begin(); j != c.collideeMask.end(); j++)
|
||||
{
|
||||
if ((*i)) && (*j))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
*/
|
||||
bool CollisionShape::compareLayer(CollisionShape &c)
|
||||
{
|
||||
return (this->layer <= c.layer);
|
||||
}
|
||||
|
||||
void CollisionShape::updatePosition(const Vector &position)
|
||||
{
|
||||
this->position = position + offsetPosition;
|
||||
/*
|
||||
switch (getType())
|
||||
{
|
||||
case AABB:
|
||||
{
|
||||
corners[0] = position + Vector( - xw, - yw);
|
||||
corners[1] = position + Vector(xw, - yw);
|
||||
corners[2] = position + Vector(xw, yw);
|
||||
corners[3] = position + Vector(-xw ,yw);
|
||||
}
|
||||
break;
|
||||
}
|
||||
*/
|
||||
|
||||
}
|
||||
|
||||
CollisionResult CollisionShape::findOverlap(CollisionShape &collisionShape)
|
||||
{
|
||||
CollisionResult c;
|
||||
|
||||
|
||||
switch (getType())
|
||||
{
|
||||
case CIRCLE:
|
||||
{
|
||||
switch(collisionShape.getType())
|
||||
{
|
||||
case CIRCLE:
|
||||
c = collideCircleWithCircle(collisionShape);
|
||||
break;
|
||||
case AABB:
|
||||
{
|
||||
|
||||
float txw = collisionShape.xw;
|
||||
float tyw = collisionShape.yw;
|
||||
|
||||
Vector d = position - collisionShape.position;//tile->obj delta
|
||||
int px = (txw + radius) - fabsf(d.x);//penetration depth in x
|
||||
|
||||
if(0 < px)
|
||||
{
|
||||
int py = (tyw + radius) - fabsf(d.y);//pen depth in y
|
||||
|
||||
if(0 < py)
|
||||
{
|
||||
//object may be colliding with tile
|
||||
|
||||
//determine grid/voronoi region of circle center
|
||||
float oH = 0;
|
||||
float oV = 0;
|
||||
if(d.x < -txw)
|
||||
{
|
||||
//circle is on left side of tile
|
||||
oH = -1;
|
||||
}
|
||||
else if(txw < d.x)
|
||||
{
|
||||
//circle is on right side of tile
|
||||
oH = 1;
|
||||
}
|
||||
|
||||
if(d.y < -tyw)
|
||||
{
|
||||
//circle is on top side of tile
|
||||
oV = -1;
|
||||
}
|
||||
else if(tyw < d.y)
|
||||
{
|
||||
//circle is on bottom side of tile
|
||||
oV = 1;
|
||||
}
|
||||
|
||||
c = collideCircleWithAABB(collisionShape, px, py, oH, oV);
|
||||
//ResolveCircleTile(px,py,oH,oV,this,c);
|
||||
|
||||
}
|
||||
}
|
||||
//return collideCircleWithAABB(collisionShape);
|
||||
}
|
||||
break;
|
||||
case TOP_HALF_CIRCLE:
|
||||
c = collideCircleWithTopHalfCircle(collisionShape);
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
return c;
|
||||
}
|
||||
|
||||
CollisionResult CollisionShape::collideCircleWithCircle(CollisionShape &collisionShape)
|
||||
{
|
||||
CollisionResult c;
|
||||
Vector dist = position - collisionShape.position;// - position;
|
||||
float fastLen = dist.getSquaredLength2D();
|
||||
float totalDist = (radius + collisionShape.radius);
|
||||
if (fastLen < (totalDist*totalDist))
|
||||
{
|
||||
/*
|
||||
std::ostringstream os;
|
||||
os << "len " << len << " totalDist " << totalDist;
|
||||
msg(os.str());
|
||||
*/
|
||||
float len = dist.getLength2D();
|
||||
c.collided = true;
|
||||
dist.setLength2D(totalDist - len);
|
||||
//dist |= totalDist;
|
||||
c.overlap = dist;
|
||||
}
|
||||
else
|
||||
{
|
||||
c.collided = false;
|
||||
}
|
||||
return c;
|
||||
}
|
||||
|
||||
float CollisionShape::getY1()
|
||||
{
|
||||
return position.y - yw;
|
||||
}
|
||||
|
||||
float CollisionShape::getY2()
|
||||
{
|
||||
return position.y + yw;
|
||||
}
|
||||
|
||||
float CollisionShape::getX1()
|
||||
{
|
||||
return position.x - xw;
|
||||
}
|
||||
|
||||
float CollisionShape::getX2()
|
||||
{
|
||||
return position.x + xw;
|
||||
}
|
||||
|
||||
void CollisionShape::render()
|
||||
{
|
||||
#ifdef BBGE_BUILD_OPENGL
|
||||
glTranslatef(offsetPosition.x, offsetPosition.y,0);
|
||||
switch(getType())
|
||||
{
|
||||
case CIRCLE:
|
||||
drawCircle(radius);
|
||||
break;
|
||||
case AABB:
|
||||
//case CIRCLE:
|
||||
//glColor3f(1,1,1);
|
||||
|
||||
//glLineWidth(2);
|
||||
|
||||
glBegin(GL_QUADS);
|
||||
{
|
||||
glVertex2f(-xw,yw);
|
||||
glVertex2f(xw,yw);
|
||||
glVertex2f(xw,-yw);
|
||||
glVertex2f(-xw,-yw);
|
||||
|
||||
/*
|
||||
glColor4f(0.0f, 1.0f, 0.0f, 1.0f);
|
||||
glVertex2f(topLeft.x, topLeft.y);
|
||||
glVertex2f(bottomRight.x, topLeft.y);
|
||||
|
||||
glVertex2f(bottomRight.x, topLeft.y);
|
||||
glVertex2f(bottomRight.x, bottomRight.y);
|
||||
|
||||
glVertex2f(bottomRight.x, bottomRight.y);
|
||||
glVertex2f(topLeft.x, bottomRight.y);
|
||||
|
||||
glVertex2f(topLeft.x, bottomRight.y);
|
||||
glVertex2f(topLeft.x, topLeft.y);
|
||||
|
||||
*/
|
||||
}
|
||||
glEnd();
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
glTranslatef(-offsetPosition.x, -offsetPosition.y,0);
|
||||
#endif
|
||||
//glDisable(GL_BLEND);
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
// FOR EDGES
|
||||
|
||||
if (position.y > collisionShape.getY1() - radius && position.y < collisionShape.getY2() + radius)
|
||||
{
|
||||
float dist = collisionShape.getX1() - position.x;
|
||||
if (dist > 0 && dist < radius)
|
||||
{
|
||||
c.collided = true;
|
||||
c.overlap = Vector(radius - dist,0);
|
||||
}
|
||||
else if (dist < 0 && -dist < radius)
|
||||
{
|
||||
c.collided = true;
|
||||
c.overlap = -Vector(radius - (-dist),0);
|
||||
}
|
||||
}
|
||||
|
||||
if (!c.collided)
|
||||
{
|
||||
if (position.y > collisionShape.getY1() - radius && position.y < collisionShape.getY2() + radius)
|
||||
{
|
||||
float dist = collisionShape.getX2() - position.x;
|
||||
if (dist > 0 && dist < radius)
|
||||
{
|
||||
c.collided = true;
|
||||
c.overlap += Vector(radius - dist,0);
|
||||
}
|
||||
else if (dist < 0 && -dist < radius)
|
||||
{
|
||||
c.collided = true;
|
||||
c.overlap += -Vector(radius - (-dist),0);
|
||||
}
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
CollisionResult CollisionShape::collideCircleWithAABB(CollisionShape &collisionShape, float x, float y, int oH, int oV)
|
||||
{
|
||||
CollisionResult c;
|
||||
if(oH == 0)
|
||||
{
|
||||
if(oV == 0)
|
||||
{
|
||||
|
||||
//collision with current cell
|
||||
if(x < y)
|
||||
{
|
||||
//penetration in x is smaller; project in x
|
||||
float dx = position.x - collisionShape.position.x;//get sign for projection along x-axis
|
||||
|
||||
|
||||
|
||||
// msg("oH==0, oV ==0, x <y");
|
||||
//NOTE: should we handle the delta == 0 case?! and how? (project towards oldpos?)
|
||||
if(dx < 0)
|
||||
{
|
||||
c.reportCollision(Vector(-x, 0));
|
||||
return c;
|
||||
}
|
||||
else
|
||||
{
|
||||
c.reportCollision(Vector(x,0));
|
||||
return c;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// msg("oH==0, oV ==0, x >= y");
|
||||
//penetration in y is smaller; project in y
|
||||
float dy = position.y - collisionShape.position.y;//get sign for projection along y-axis
|
||||
|
||||
//NOTE: should we handle the delta == 0 case?! and how? (project towards oldpos?)
|
||||
if(dy < 0)
|
||||
{
|
||||
c.reportCollision(Vector(0, -y));
|
||||
return c;
|
||||
}
|
||||
else
|
||||
{
|
||||
c.reportCollision(Vector(0, y));
|
||||
return c;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// msg ("oH == 0, oV != 0");
|
||||
c.reportCollision(Vector(0, y*oV));
|
||||
return c;
|
||||
}
|
||||
}
|
||||
else if(oV == 0)
|
||||
{
|
||||
// msg ("oV == 0");
|
||||
c.reportCollision(Vector(x*oH,0));
|
||||
return c;
|
||||
}
|
||||
else
|
||||
{
|
||||
//diagonal collision
|
||||
|
||||
//get diag vertex position
|
||||
float vx = collisionShape.position.x + (oH*collisionShape.xw);
|
||||
float vy = collisionShape.position.y + (oV*collisionShape.yw);
|
||||
|
||||
float dx = position.x - vx - 1;//calc vert->circle vector
|
||||
float dy = position.y - vy - 1;
|
||||
|
||||
float len = sqrtf(dx*dx + dy*dy);
|
||||
float pen = radius - len;
|
||||
if(0 < pen)
|
||||
{
|
||||
//vertex is in the circle; project outward
|
||||
if(len == 0)
|
||||
{
|
||||
//project out by 45deg
|
||||
dx = oH / SQRT2;
|
||||
dy = oV / SQRT2;
|
||||
}
|
||||
else
|
||||
{
|
||||
dx /= len;
|
||||
dy /= len;
|
||||
}
|
||||
|
||||
c.reportCollision(Vector(dx*pen, dy*pen));
|
||||
//obj.ReportCollisionVsWorld(dx*pen, dy*pen, dx, dy, t);
|
||||
|
||||
return c;
|
||||
}
|
||||
}
|
||||
|
||||
return c;
|
||||
|
||||
}
|
||||
|
||||
bool CollisionShape::isPointWithin(Vector point)
|
||||
{
|
||||
switch (this->getType())
|
||||
{
|
||||
case CIRCLE:
|
||||
{
|
||||
Vector dist = point - this->position;
|
||||
return (dist.getSquaredLength2D() < sqr(this->radius));
|
||||
}
|
||||
break;
|
||||
case AABB:
|
||||
{
|
||||
if (point.x < position.x + xw && point.y < position.y + yw)
|
||||
{
|
||||
if (point.x > position.x - xw && point.y > position.y - yw)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
CollisionResult CollisionShape::collideCircleWithTopHalfCircle(CollisionShape &collisionShape)
|
||||
{
|
||||
CollisionResult c;
|
||||
Vector dist = collisionShape.position - position;
|
||||
float len = dist.getLength2D();
|
||||
float totalDist = (radius + collisionShape.radius);
|
||||
|
||||
//which edge did we hit?
|
||||
if (collisionShape.position.y > (position.y - (radius/2)))
|
||||
{
|
||||
if (len < collisionShape.radius)
|
||||
{
|
||||
c.collided = true;
|
||||
c.overlap = Vector(0, position.y - (collisionShape.position.y - collisionShape.radius));
|
||||
}
|
||||
}
|
||||
else if (len < totalDist && dist.y > 0)
|
||||
{
|
||||
c.collided = true;
|
||||
dist.setLength2D(totalDist - len);
|
||||
c.overlap = dist;
|
||||
}
|
||||
else
|
||||
{
|
||||
c.collided = false;
|
||||
}
|
||||
return c;
|
||||
}
|
146
BBGE/Collision.h
146
BBGE/Collision.h
|
@ -1,146 +0,0 @@
|
|||
/*
|
||||
Copyright (C) 2007, 2010 - Bit-Blot
|
||||
|
||||
This file is part of Aquaria.
|
||||
|
||||
Aquaria is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU General Public License
|
||||
as published by the Free Software Foundation; either version 2
|
||||
of the License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
|
||||
See the GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
#ifndef COLLISION_H
|
||||
#define COLLISION_H
|
||||
|
||||
#include "Base.h"
|
||||
|
||||
class RenderObject;
|
||||
struct CollisionResult
|
||||
{
|
||||
CollisionResult()
|
||||
{
|
||||
collided = false;
|
||||
collider = 0;
|
||||
project = true;
|
||||
}
|
||||
bool project;
|
||||
bool collided;
|
||||
Vector overlap;
|
||||
RenderObject *collider;
|
||||
|
||||
void reportCollision(Vector overlap)
|
||||
{
|
||||
collided = true;
|
||||
this->overlap = overlap;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
class CollisionShape
|
||||
{
|
||||
public:
|
||||
CollisionShape();
|
||||
|
||||
/*
|
||||
void addCollisionGroup(int group);
|
||||
void removeCollisionGroup(int group);
|
||||
void canCollideWithGroup();
|
||||
*/
|
||||
|
||||
void updatePosition(const Vector &position);
|
||||
|
||||
void activate()
|
||||
{
|
||||
active = true;
|
||||
}
|
||||
void deactivate()
|
||||
{
|
||||
active = false;
|
||||
}
|
||||
|
||||
bool isActive()
|
||||
{
|
||||
return active;
|
||||
}
|
||||
|
||||
float getX1();
|
||||
float getX2();
|
||||
float getY1();
|
||||
float getY2();
|
||||
float xw, yw;
|
||||
float radius;
|
||||
|
||||
enum Type { NONE=0, AABB, CIRCLE, TOP_HALF_CIRCLE, TRIANGLE };
|
||||
|
||||
void setType(Type type);
|
||||
Type getType();
|
||||
|
||||
|
||||
|
||||
bool isPointWithin(Vector point);
|
||||
void render();
|
||||
|
||||
CollisionResult findOverlap(CollisionShape &collisionShape);
|
||||
Vector offsetPosition;
|
||||
|
||||
bool compareLayer(CollisionShape &c);
|
||||
//bool compareMask(CollisionShape &c);
|
||||
int getLayer() { return layer; }
|
||||
void setLayer(int layer) { this->layer = layer; }
|
||||
|
||||
bool project;
|
||||
protected:
|
||||
int layer;
|
||||
/*
|
||||
typedef std::vector<int> CollisionLayerMask;
|
||||
CollisionLayerMask colliderMask, collideeMask;
|
||||
*/
|
||||
std::vector<Vector> corners;
|
||||
Vector position;
|
||||
bool active;
|
||||
CollisionResult collideCircleWithCircle(CollisionShape &collisionShape);
|
||||
CollisionResult collideCircleWithTopHalfCircle(CollisionShape &collisionShape);
|
||||
CollisionResult collideCircleWithAABB(CollisionShape &collisionShape, float x, float y, int oH, int oV);
|
||||
|
||||
|
||||
|
||||
Type type;
|
||||
};
|
||||
|
||||
/*
|
||||
class CollisionObject
|
||||
{
|
||||
public:
|
||||
void onCollision();
|
||||
void collide()
|
||||
{
|
||||
CollisionResult c;
|
||||
for (int i = 0; i < collisionManager->colliders.size(); i++)
|
||||
{
|
||||
c = findOverlap(collisionManager->colliders[i]->collisionShape);
|
||||
if (c.collided)
|
||||
{
|
||||
position -= c.overlap;
|
||||
collisionShape.position =
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
class CollisionManager
|
||||
{
|
||||
public:
|
||||
void addCollider(
|
||||
};
|
||||
*/
|
||||
|
||||
#endif
|
|
@ -1,51 +0,0 @@
|
|||
/*
|
||||
Copyright (C) 2007, 2010 - Bit-Blot
|
||||
|
||||
This file is part of Aquaria.
|
||||
|
||||
Aquaria is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU General Public License
|
||||
as published by the Free Software Foundation; either version 2
|
||||
of the License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
|
||||
See the GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
#ifndef COMMONEVENTS_H
|
||||
#define COMMONEVENTS_H
|
||||
|
||||
#include "Event.h"
|
||||
|
||||
class SoundEvent : public Event
|
||||
{
|
||||
public:
|
||||
SoundEvent(const PlaySfx &p) : playSfx(p)
|
||||
{}
|
||||
void act()
|
||||
{
|
||||
core->sound->playSfx(playSfx);
|
||||
}
|
||||
private:
|
||||
PlaySfx playSfx;
|
||||
};
|
||||
|
||||
class JumpStateEvent : public Event
|
||||
{
|
||||
public:
|
||||
JumpStateEvent(const std::string &state) : state(state) {}
|
||||
void act()
|
||||
{
|
||||
core->enqueueJumpState(state, true);
|
||||
}
|
||||
private:
|
||||
std::string state;
|
||||
};
|
||||
|
||||
#endif
|
|
@ -1272,7 +1272,6 @@ void Core::init()
|
|||
{
|
||||
setupFileAccess();
|
||||
|
||||
flags.set(CF_CLEARBUFFERS);
|
||||
quitNestedMainFlag = false;
|
||||
#ifdef BBGE_BUILD_GLFW
|
||||
if (!glfwInit())
|
||||
|
@ -2805,7 +2804,7 @@ std::string getScreenshotFilename()
|
|||
}
|
||||
}
|
||||
|
||||
uint32 Core::getTicks()
|
||||
unsigned Core::getTicks()
|
||||
{
|
||||
#ifdef BBGE_BUILD_SDL
|
||||
return SDL_GetTicks();
|
||||
|
@ -3264,15 +3263,7 @@ void Core::sort()
|
|||
|
||||
void Core::clearBuffers()
|
||||
{
|
||||
if (flags.get(CF_CLEARBUFFERS))
|
||||
{
|
||||
#ifdef BBGE_BUILD_OPENGL
|
||||
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); // Clear The Screen And The Depth Buffer
|
||||
#endif
|
||||
#ifdef BBGE_BUILD_DIRECTX
|
||||
g_pd3dDevice->Clear( 0, NULL, D3DCLEAR_TARGET, D3DCOLOR_XRGB(int(clearColor.x*255),int(clearColor.y*255),int(clearColor.z*255)), 1.0f, 0 );
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
void Core::setupRenderPositionAndScale()
|
||||
|
|
|
@ -35,9 +35,6 @@ BUILD_LINUX
|
|||
#include "ActionMapper.h"
|
||||
#include "Event.h"
|
||||
#include "StateManager.h"
|
||||
#include "Light.h"
|
||||
#include "Flags.h"
|
||||
//#include "Scripting.h"
|
||||
#include "Effects.h"
|
||||
#include "Localization.h"
|
||||
|
||||
|
@ -1052,7 +1049,7 @@ public:
|
|||
|
||||
void updateCursorFromJoystick(float dt, int spd);
|
||||
|
||||
uint32 getTicks();
|
||||
unsigned getTicks();
|
||||
|
||||
float stopWatch(int d);
|
||||
|
||||
|
@ -1205,7 +1202,6 @@ public:
|
|||
|
||||
int currentLayerPass;
|
||||
int keys[KEY_MAXARRAY];
|
||||
Flags flags;
|
||||
virtual void debugLog(const std::string &s);
|
||||
virtual void errorLog(const std::string &s);
|
||||
void messageBox(const std::string &title, const std::string &msg);
|
||||
|
|
|
@ -1,37 +0,0 @@
|
|||
/*
|
||||
Copyright (C) 2007, 2010 - Bit-Blot
|
||||
|
||||
This file is part of Aquaria.
|
||||
|
||||
Aquaria is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU General Public License
|
||||
as published by the Free Software Foundation; either version 2
|
||||
of the License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
|
||||
See the GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
#include "Cube.h"
|
||||
|
||||
void Cube::onRender()
|
||||
{
|
||||
#if 0 // not used at the moment, and incompatible with OpenGL ES. --ryan.
|
||||
#ifdef BBGE_BUILD_OPENGL
|
||||
glBegin(GL_QUADS);
|
||||
{
|
||||
//auxSolidCube(1);
|
||||
//auxSolidTorus(1,2);
|
||||
//auxSolidIcosahedron(1);
|
||||
//auxSolidSphere(1);
|
||||
}
|
||||
glEnd();
|
||||
#endif
|
||||
#endif
|
||||
}
|
34
BBGE/Cube.h
34
BBGE/Cube.h
|
@ -1,34 +0,0 @@
|
|||
/*
|
||||
Copyright (C) 2007, 2010 - Bit-Blot
|
||||
|
||||
This file is part of Aquaria.
|
||||
|
||||
Aquaria is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU General Public License
|
||||
as published by the Free Software Foundation; either version 2
|
||||
of the License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
|
||||
See the GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
#ifndef __cube__
|
||||
#define __cube__
|
||||
|
||||
#include "RenderObject.h"
|
||||
|
||||
|
||||
class Cube : public RenderObject
|
||||
{
|
||||
public:
|
||||
protected:
|
||||
void onRender();
|
||||
};
|
||||
|
||||
#endif
|
|
@ -1,135 +0,0 @@
|
|||
/*
|
||||
Copyright (C) 2007, 2010 - Bit-Blot
|
||||
|
||||
This file is part of Aquaria.
|
||||
|
||||
Aquaria is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU General Public License
|
||||
as published by the Free Software Foundation; either version 2
|
||||
of the License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
|
||||
See the GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
#include "Cutscene.h"
|
||||
|
||||
Cutscene::Cutscene()
|
||||
{
|
||||
time = playing = 0;
|
||||
}
|
||||
|
||||
void Cutscene::play()
|
||||
{
|
||||
time = 0;
|
||||
playing = 1;
|
||||
}
|
||||
|
||||
void Cutscene::clear()
|
||||
{
|
||||
for (IDMap::iterator i = idMap.begin(); i != idMap.end(); ++i)
|
||||
{
|
||||
(*i).second->safeKill();
|
||||
}
|
||||
|
||||
idMap.clear();
|
||||
markers.clear();
|
||||
}
|
||||
|
||||
void Cutscene::load(const std::string &f)
|
||||
{
|
||||
clear();
|
||||
|
||||
doc.LoadFile(f.c_str());
|
||||
|
||||
XMLElement *e = doc.FirstChildElement("time");
|
||||
while (e)
|
||||
{
|
||||
CutsceneMarker m;
|
||||
m.e = e;
|
||||
|
||||
std::string s = e->Attribute("t");
|
||||
int p = 0, c1=0,c2=0;
|
||||
float t = 0;
|
||||
for (int c=0; c < s.size(); c++)
|
||||
{
|
||||
switch(c)
|
||||
{
|
||||
case 0:
|
||||
t += atoi(s[c]) * (600);
|
||||
break;
|
||||
case 1:
|
||||
t += atoi(s[c]) * 60;
|
||||
break;
|
||||
case 3:
|
||||
t += atoi(s[c]) * 10;
|
||||
break;
|
||||
case 4:
|
||||
t += atoi(s[c]);
|
||||
break;
|
||||
case 6:
|
||||
t += atoi(s[c]) * 0.1f;
|
||||
break;
|
||||
case 7:
|
||||
t += atoi(s[c]) * 0.01f;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
markers.push_back(m);
|
||||
}
|
||||
}
|
||||
|
||||
void Cutscene::save(const std::string &f)
|
||||
{
|
||||
}
|
||||
|
||||
void Cutscene::playMarker(CutsceneMarker *m)
|
||||
{
|
||||
if (m)
|
||||
{
|
||||
XMLElement *r=0;
|
||||
if (r = m->e->FirstChildElement("quad"))
|
||||
{
|
||||
id = r->Attribute("id");
|
||||
if (idMap[id])
|
||||
{
|
||||
errorLog("id [" + id + "] already exists");
|
||||
}
|
||||
|
||||
std::string gfx = m->e->Attribute("gfx");
|
||||
std::istringstream is(m->e->Attribute("pos"));
|
||||
Vector pos;
|
||||
is >> pos.x >> pos.y >> pos.z;
|
||||
int layer = atoi(m->e->Attribute("layer"));
|
||||
|
||||
Quad *q = new Quad(gfx, pos);
|
||||
addRenderObject(q, layer);
|
||||
}
|
||||
if (r = m->e->FirstChildElement(""))
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Cutscene::update(float dt)
|
||||
{
|
||||
if (playing)
|
||||
{
|
||||
time += dt;
|
||||
|
||||
while ((curMarker < markers.size()) && (time >= markers[curMarker].t))
|
||||
{
|
||||
playMarker(&markers[curMarker]);
|
||||
|
||||
curMarker ++;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,58 +0,0 @@
|
|||
/*
|
||||
Copyright (C) 2007, 2010 - Bit-Blot
|
||||
|
||||
This file is part of Aquaria.
|
||||
|
||||
Aquaria is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU General Public License
|
||||
as published by the Free Software Foundation; either version 2
|
||||
of the License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
|
||||
See the GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
#include "Core.h"
|
||||
#include "SkeletalSprite.h"
|
||||
#include "Particles.h"
|
||||
|
||||
struct CutsceneMarker
|
||||
{
|
||||
float t;
|
||||
XMLElement *e;
|
||||
};
|
||||
|
||||
class Cutscene
|
||||
{
|
||||
public:
|
||||
Cutscene();
|
||||
|
||||
void play();
|
||||
void playMarker(CutsceneMarker *m);
|
||||
void load(const std::string &f);
|
||||
void save(const std::string &f);
|
||||
|
||||
void update(float dt);
|
||||
|
||||
XMLDocument file;
|
||||
|
||||
std::vector <CutsceneMarker> markers;
|
||||
|
||||
float time;
|
||||
int playing;
|
||||
int curMarker;
|
||||
|
||||
typedef std::map<std::string, RenderObject*> IDMap;
|
||||
IDMap idMap;
|
||||
|
||||
|
||||
// readers
|
||||
std::string id;
|
||||
};
|
||||
|
|
@ -1,174 +0,0 @@
|
|||
/*
|
||||
Copyright (C) 2007, 2010 - Bit-Blot
|
||||
|
||||
This file is part of Aquaria.
|
||||
|
||||
Aquaria is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU General Public License
|
||||
as published by the Free Software Foundation; either version 2
|
||||
of the License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
|
||||
See the GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
#include "DFSprite.h"
|
||||
#include "MathFunctions.h"
|
||||
|
||||
DFSprite::DFSprite() : AnimatedSprite()
|
||||
{
|
||||
//debugLog("DFSprite::DFSprite()");
|
||||
currentDatafile = 0;
|
||||
//debugLog("End DFSprite::DFSprite()");
|
||||
}
|
||||
|
||||
/*
|
||||
DFSprite::~DFSprite()
|
||||
{
|
||||
destroy();
|
||||
}
|
||||
*/
|
||||
|
||||
void DFSprite::destroy()
|
||||
{
|
||||
//make sure that animatedSprite::destroy() doesn't
|
||||
// destroy our texture
|
||||
// since its just a pointer to a texture in the datafile
|
||||
texture = 0;
|
||||
for (int i = 0; i < datafiles.size(); i++)
|
||||
{
|
||||
datafiles[i]->destroy();
|
||||
delete datafiles[i];
|
||||
}
|
||||
datafiles.clear();
|
||||
AnimatedSprite::destroy();
|
||||
}
|
||||
|
||||
void DFSprite::onUpdate(float dt)
|
||||
{
|
||||
AnimatedSprite::onUpdate(dt);
|
||||
|
||||
if (currentDatafile)
|
||||
{
|
||||
setTexturePointer(currentDatafile->get(frame), NO_ADD_REF);
|
||||
}
|
||||
}
|
||||
|
||||
void DFSprite::onSetTexture()
|
||||
{
|
||||
Quad::onSetTexture();
|
||||
/*
|
||||
width = texture->width;
|
||||
height = texture->height;
|
||||
*/
|
||||
|
||||
//scale = Vector(texture->width, texture->height,0);
|
||||
}
|
||||
|
||||
// returns index of datafile with the specified name
|
||||
// returns -1 on failure
|
||||
int DFSprite::findDatafile(const std::string &name)
|
||||
{
|
||||
for (int i = 0; i < datafiles.size(); i++)
|
||||
{
|
||||
if (datafiles[i]->getName()==name)
|
||||
{
|
||||
return i;
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
// select datafile # index
|
||||
void DFSprite::selectDatafile(int index)
|
||||
{
|
||||
if (datafiles.empty())
|
||||
msg("Datafiles empty");
|
||||
if (index >= datafiles.size() || index <0)
|
||||
{
|
||||
std::ostringstream os;
|
||||
os << "Datafile selection index out of range [";
|
||||
os << index;
|
||||
os << "]";
|
||||
msg(os.str());
|
||||
errorLog(os.str());
|
||||
exit(0);
|
||||
}
|
||||
currentDatafile = datafiles[index];
|
||||
}
|
||||
|
||||
int DFSprite::addDatafile()
|
||||
{
|
||||
Datafile *d = new Datafile;
|
||||
datafiles.push_back(d);
|
||||
return datafiles.size()-1;
|
||||
}
|
||||
|
||||
void DFSprite::onAnimData(AnimData &animData)
|
||||
{
|
||||
selectDatafile(animData.datafile);
|
||||
}
|
||||
|
||||
Datafile *DFSprite::getDatafile(int index)
|
||||
{
|
||||
if (index < 0 || index >= datafiles.size())
|
||||
errorLog("Datafile index out of bounds");
|
||||
return datafiles[index];
|
||||
}
|
||||
|
||||
// shorctut code
|
||||
// select the datafile as specified by animData
|
||||
void DFSprite::selectDatafile(AnimData &animData)
|
||||
{
|
||||
selectDatafile(animData.datafile);
|
||||
}
|
||||
|
||||
// get the datafile specified in animData
|
||||
Datafile *DFSprite::getDatafile(AnimData &animData)
|
||||
{
|
||||
return getDatafile(animData.datafile);
|
||||
}
|
||||
|
||||
void DFSprite::setFrameBasedRotation(const Vector &p1, const Vector &p2)
|
||||
{
|
||||
if (currentDatafile)
|
||||
{
|
||||
float angle;
|
||||
MathFunctions::calculateAngleBetweenVectorsInDegrees(p1, p2, angle);
|
||||
angle += 90;
|
||||
int bframe = frame;
|
||||
bframe = int((angle*float(currentDatafile->getSize())) / 360.0f);
|
||||
if (bframe >= currentDatafile->getSize())
|
||||
bframe = currentDatafile->getSize()-1;
|
||||
else if (bframe < 0)
|
||||
bframe = 0;
|
||||
frame = bframe;
|
||||
}
|
||||
else
|
||||
{
|
||||
msg ("No datafile selected");
|
||||
}
|
||||
}
|
||||
|
||||
void DFSprite::selectDatafileBasedRotation(const Vector &p1, const Vector &p2, int datafileRange, int datafileIndexOffset, bool flipAngle, float angleOffset)
|
||||
{
|
||||
float angle;
|
||||
MathFunctions::calculateAngleBetweenVectorsInDegrees(p1, p2, angle);
|
||||
angle += 90;
|
||||
angle += angleOffset;
|
||||
if (flipAngle)
|
||||
angle = 360 - angle;
|
||||
int bframe = frame;
|
||||
bframe = int((angle*float(datafileRange)) / 360.0f);
|
||||
if (bframe >= datafileRange)
|
||||
bframe = datafileRange-1;
|
||||
else if (bframe < 0)
|
||||
bframe = 0;
|
||||
selectDatafile(bframe+datafileIndexOffset);
|
||||
}
|
|
@ -1,53 +0,0 @@
|
|||
/*
|
||||
Copyright (C) 2007, 2010 - Bit-Blot
|
||||
|
||||
This file is part of Aquaria.
|
||||
|
||||
Aquaria is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU General Public License
|
||||
as published by the Free Software Foundation; either version 2
|
||||
of the License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
|
||||
See the GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
#ifndef __dfsprite__
|
||||
#define __dfsprite__
|
||||
|
||||
#include "Quad.h"
|
||||
#include "Datafile.h"
|
||||
#include "AnimatedSprite.h"
|
||||
|
||||
class DFSprite : public AnimatedSprite
|
||||
{
|
||||
public:
|
||||
DFSprite();
|
||||
//~DFSprite();
|
||||
void destroy();
|
||||
|
||||
//void animate();
|
||||
|
||||
int findDatafile(const std::string &name);
|
||||
void selectDatafile(int index);
|
||||
void selectDatafile(AnimData &animData);
|
||||
Datafile *getDatafile(int index);
|
||||
Datafile *getDatafile(AnimData &animData);
|
||||
int addDatafile();
|
||||
void setFrameBasedRotation(const Vector &p1, const Vector &p2);
|
||||
void selectDatafileBasedRotation(const Vector &p1, const Vector &p2, int datafileRange, int datafileIndexOffset=0, bool flipAngle=false, float angleOffset=0);
|
||||
protected:
|
||||
void onAnimData(AnimData &animData);
|
||||
std::vector<Datafile*> datafiles;
|
||||
Datafile *currentDatafile;
|
||||
void onSetTexture();
|
||||
void onUpdate(float dt);
|
||||
};
|
||||
|
||||
#endif
|
|
@ -1,158 +0,0 @@
|
|||
/*
|
||||
Copyright (C) 2007, 2010 - Bit-Blot
|
||||
|
||||
This file is part of Aquaria.
|
||||
|
||||
Aquaria is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU General Public License
|
||||
as published by the Free Software Foundation; either version 2
|
||||
of the License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
|
||||
See the GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
#include "Datafile.h"
|
||||
#include "Texture.h"
|
||||
|
||||
Datafile::Datafile()
|
||||
{
|
||||
w = 0; h = 0;
|
||||
}
|
||||
|
||||
Datafile::~Datafile()
|
||||
{
|
||||
destroy();
|
||||
}
|
||||
|
||||
void Datafile::destroy()
|
||||
{
|
||||
for (int i = 0; i < textures.size(); i++)
|
||||
{
|
||||
textures[i]->removeRef();
|
||||
}
|
||||
textures.clear();
|
||||
}
|
||||
|
||||
//hacky... for now
|
||||
void Datafile::addTexture(Texture *t)
|
||||
{
|
||||
textures.push_back(t);
|
||||
w = t->width;
|
||||
h = t->height;
|
||||
}
|
||||
|
||||
Texture* Datafile::get(int idx)
|
||||
{
|
||||
if (idx < 0 || idx >= textures.size())
|
||||
{
|
||||
std::ostringstream os;
|
||||
os << "index [" << idx << "] out of range - textureName[" << this->name << "]";
|
||||
errorLog (os.str());
|
||||
}
|
||||
return textures[idx];
|
||||
}
|
||||
/*
|
||||
void Datafile::load(const std::string &name, int w, int h)
|
||||
{
|
||||
this->w = w;
|
||||
this->h = h;
|
||||
std::ifstream in;
|
||||
in.open(name);
|
||||
std::string read;
|
||||
while (std::getline(in,read))
|
||||
{
|
||||
Texture *t = new Texture;
|
||||
t->loadFromString(read);
|
||||
}
|
||||
}
|
||||
|
||||
void Datafile::save(const std::string &datafile)
|
||||
{
|
||||
std::ofstream out;
|
||||
}
|
||||
*/
|
||||
|
||||
|
||||
void Datafile::loadFromAVI(const std::string &aviFile)
|
||||
{
|
||||
/*
|
||||
AviRender a(aviFile);
|
||||
|
||||
bool done = false;
|
||||
float time = 0;
|
||||
int counter = 20;
|
||||
while (!done)
|
||||
{
|
||||
// GLuint id;
|
||||
//a.bindFrameToTexture(time, &id);
|
||||
//if (id)
|
||||
{
|
||||
Texture *texture = new Texture;
|
||||
//a.setCurrentFrameAsTexture();
|
||||
//texture->id = a.id;
|
||||
a.bindFrameToTexture(time, texture->id, texture->imageData);
|
||||
|
||||
//texture->setID(id);
|
||||
texture->width = 512;
|
||||
texture->height = 512;
|
||||
addTexture(texture);
|
||||
//texture->addRef();
|
||||
//frame ++;
|
||||
}
|
||||
|
||||
|
||||
counter --;
|
||||
if (counter <= 0)
|
||||
done = true;
|
||||
|
||||
time += 1;
|
||||
//frame++;
|
||||
|
||||
}
|
||||
|
||||
//a.getCurrentFrameAsTexture();
|
||||
|
||||
*/
|
||||
}
|
||||
|
||||
void Datafile::loadTextureRange(const std::string &file, const std::string &type, int start, int end)
|
||||
{
|
||||
for (int t = start; t < end; t++)
|
||||
{
|
||||
|
||||
std::ostringstream num_os;
|
||||
num_os << t;
|
||||
|
||||
std::ostringstream os;
|
||||
os << file;
|
||||
|
||||
for (int j = 0; j < 4 - num_os.str().size(); j++)
|
||||
{
|
||||
os << "0";
|
||||
}
|
||||
|
||||
os << t;
|
||||
|
||||
os << type;
|
||||
|
||||
addTexture(core->addTexture(os.str()));
|
||||
}
|
||||
}
|
||||
|
||||
const std::string &Datafile::getName()
|
||||
{
|
||||
return name;
|
||||
}
|
||||
|
||||
void Datafile::setName(const std::string &name)
|
||||
{
|
||||
this->name = name;
|
||||
}
|
||||
|
|
@ -1,55 +0,0 @@
|
|||
/*
|
||||
Copyright (C) 2007, 2010 - Bit-Blot
|
||||
|
||||
This file is part of Aquaria.
|
||||
|
||||
Aquaria is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU General Public License
|
||||
as published by the Free Software Foundation; either version 2
|
||||
of the License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
|
||||
See the GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
#ifndef __datafile__
|
||||
#define __datafile__
|
||||
|
||||
#include "Core.h"
|
||||
|
||||
class Datafile
|
||||
{
|
||||
public:
|
||||
Datafile();
|
||||
~Datafile();
|
||||
void destroy();
|
||||
|
||||
void addTexture(Texture *t);
|
||||
Texture* get(int idx);
|
||||
void loadTextureRange(const std::string &file, const std::string &type, int start, int end);
|
||||
void loadFromAVI(const std::string &aviFile);
|
||||
|
||||
const std::string &getName();
|
||||
|
||||
void setName(const std::string &name);
|
||||
int getSize()
|
||||
{
|
||||
return textures.size();
|
||||
}
|
||||
protected:
|
||||
//void load(const std::string &name);
|
||||
std::string name;
|
||||
|
||||
|
||||
int w, h;
|
||||
|
||||
std::vector <Texture*> textures;
|
||||
};
|
||||
|
||||
#endif
|
|
@ -1,57 +0,0 @@
|
|||
/*
|
||||
Copyright (C) 2007, 2010 - Bit-Blot
|
||||
|
||||
This file is part of Aquaria.
|
||||
|
||||
Aquaria is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU General Public License
|
||||
as published by the Free Software Foundation; either version 2
|
||||
of the License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
|
||||
See the GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
#include "FileVars.h"
|
||||
|
||||
FileVars::FileVars()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void FileVars::load(const std::string &absPath)
|
||||
{
|
||||
std::string vname;
|
||||
std::ifstream in(absPath.c_str());
|
||||
while (in >> vname)
|
||||
{
|
||||
std::string val;
|
||||
in >> val;
|
||||
if (val.find('.') != std::string::npos)
|
||||
{
|
||||
std::istringstream is(val);
|
||||
is >> floats[vname];
|
||||
}
|
||||
else
|
||||
{
|
||||
std::istringstream is(val);
|
||||
is >> ints[vname];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
float FileVars::f(const std::string &vname)
|
||||
{
|
||||
return floats[vname];
|
||||
}
|
||||
|
||||
int FileVars::i(const std::string &vname)
|
||||
{
|
||||
return ints[vname];
|
||||
}
|
|
@ -1,39 +0,0 @@
|
|||
/*
|
||||
Copyright (C) 2007, 2010 - Bit-Blot
|
||||
|
||||
This file is part of Aquaria.
|
||||
|
||||
Aquaria is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU General Public License
|
||||
as published by the Free Software Foundation; either version 2
|
||||
of the License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
|
||||
See the GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
#ifndef FILEVARS_H
|
||||
#define FILEVARS_H
|
||||
|
||||
#include "Base.h"
|
||||
|
||||
|
||||
class FileVars
|
||||
{
|
||||
public:
|
||||
FileVars();
|
||||
void load(const std::string &absPath);
|
||||
float f(const std::string &vname);
|
||||
int i(const std::string &vname);
|
||||
protected:
|
||||
std::map<std::string,float> floats;
|
||||
std::map<std::string, int> ints;
|
||||
};
|
||||
|
||||
#endif
|
|
@ -1,46 +0,0 @@
|
|||
/*
|
||||
Copyright (C) 2007, 2010 - Bit-Blot
|
||||
|
||||
This file is part of Aquaria.
|
||||
|
||||
Aquaria is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU General Public License
|
||||
as published by the Free Software Foundation; either version 2
|
||||
of the License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
|
||||
See the GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
#include "Core.h"
|
||||
|
||||
Flags::Flags()
|
||||
{
|
||||
flags = 0;
|
||||
}
|
||||
|
||||
void Flags::set(uint32 flag)
|
||||
{
|
||||
flags |= flag;
|
||||
}
|
||||
|
||||
void Flags::unset(uint32 flag)
|
||||
{
|
||||
flags &= ~flag;
|
||||
}
|
||||
|
||||
bool Flags::get(uint32 flag)
|
||||
{
|
||||
return (flags & flag);
|
||||
}
|
||||
|
||||
void Flags::toggle(uint32 flag)
|
||||
{
|
||||
flags ^= flag;
|
||||
}
|
48
BBGE/Flags.h
48
BBGE/Flags.h
|
@ -1,48 +0,0 @@
|
|||
/*
|
||||
Copyright (C) 2007, 2010 - Bit-Blot
|
||||
|
||||
This file is part of Aquaria.
|
||||
|
||||
Aquaria is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU General Public License
|
||||
as published by the Free Software Foundation; either version 2
|
||||
of the License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
|
||||
See the GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
#ifndef BBGE_FLAGS_H
|
||||
#define BBGE_FLAGS_H
|
||||
|
||||
#ifdef BBGE_BUILD_WINDOWS
|
||||
typedef unsigned __int32 uint32;
|
||||
#endif
|
||||
#ifdef BBGE_BUILD_UNIX
|
||||
#include <stdint.h>
|
||||
typedef uint32_t uint32;
|
||||
#endif
|
||||
#ifdef BBGE_BUILD_X360
|
||||
typedef unsigned int uint32;
|
||||
#endif
|
||||
|
||||
class Flags
|
||||
{
|
||||
public:
|
||||
Flags();
|
||||
void set(uint32 flag);
|
||||
void unset(uint32 flag);
|
||||
void toggle(uint32 flag);
|
||||
bool get(uint32 flag);
|
||||
uint32 getValue() { return flags; }
|
||||
|
||||
uint32 flags;
|
||||
};
|
||||
|
||||
#endif
|
|
@ -1,161 +0,0 @@
|
|||
/*
|
||||
Copyright (C) 2007, 2010 - Bit-Blot
|
||||
|
||||
This file is part of Aquaria.
|
||||
|
||||
Aquaria is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU General Public License
|
||||
as published by the Free Software Foundation; either version 2
|
||||
of the License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
|
||||
See the GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
#include "Interpolator.h"
|
||||
|
||||
void Interpolator::stop ()
|
||||
{
|
||||
interpolating = false;
|
||||
}
|
||||
|
||||
void Interpolator::setUpdatee (float *u)
|
||||
{
|
||||
updatee = u;
|
||||
}
|
||||
|
||||
void Interpolator::interpolateTo (float interTo, float time, int ltype)
|
||||
{
|
||||
if (!updatee)
|
||||
{
|
||||
errorLog ("No updatee set for interpolator!");
|
||||
return;
|
||||
}
|
||||
|
||||
loopType = ltype;
|
||||
to = interTo;
|
||||
timePeriod = time;
|
||||
from = *updatee;
|
||||
interpolating = true;
|
||||
timePassed = 0.0f;
|
||||
fakeTimePassed = 0.0f;
|
||||
useSpeed = false;
|
||||
}
|
||||
|
||||
void Interpolator::interpolateBySpeed (float interTo, float speed, int ltype)
|
||||
{
|
||||
this->speed = speed;
|
||||
loopType = ltype;
|
||||
to = interTo;
|
||||
from = *updatee;
|
||||
timePassed = 0.0f;
|
||||
useSpeed = false;
|
||||
timePeriod = fabsf(to-from) / speed;
|
||||
|
||||
interpolating = true;
|
||||
}
|
||||
|
||||
void Interpolator::setSpeed (float s)
|
||||
{
|
||||
useSpeed = true;
|
||||
interpolating = true;
|
||||
speed = s;
|
||||
}
|
||||
|
||||
void Interpolator::update (float dt)
|
||||
{
|
||||
|
||||
if (interpolating)
|
||||
{
|
||||
if (initialDelay > 0)
|
||||
{
|
||||
initialDelay -= dt;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!useSpeed)
|
||||
{
|
||||
timePassed += dt*timeMultiplier;
|
||||
if (timePassed >= timePeriod)
|
||||
{
|
||||
*updatee = to;
|
||||
interpolating = false;
|
||||
if (loopType != 0)
|
||||
{
|
||||
if (loopType > 0)
|
||||
loopType -= 1;
|
||||
if (pingPong)
|
||||
interpolateTo (from, timePeriod, loopType);
|
||||
else
|
||||
{
|
||||
*updatee = from;
|
||||
interpolateTo (to, timePeriod, loopType);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
*updatee = (to - from) * (timePassed / timePeriod);
|
||||
*updatee += from;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
*updatee += speed * dt;
|
||||
if(*updatee > 255) *updatee = 0;
|
||||
if(*updatee < 0) *updatee = 255;
|
||||
/*
|
||||
timePassed += speed *dt;
|
||||
|
||||
if (timePassed >= timePeriod)
|
||||
{
|
||||
*updatee = to;
|
||||
interpolating = false;
|
||||
if (loopType != 0)
|
||||
{
|
||||
if (loopType > 0)
|
||||
loopType -= 1;
|
||||
if (pingPong)
|
||||
interpolateTo (from, timePeriod, loopType);
|
||||
else
|
||||
{
|
||||
*updatee = from;
|
||||
interpolateTo (to, timePeriod, loopType);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
*updatee = (to - from) * (timePassed / timePeriod);
|
||||
*updatee += from;
|
||||
}
|
||||
*/
|
||||
/*
|
||||
if (updatee >= to)
|
||||
{
|
||||
if (pingPong)
|
||||
{
|
||||
interpolateTo (from, timePeriod, loopType);
|
||||
//if(*updatee > to) *updatee = 0;
|
||||
//if(*updatee < from) *updatee = 255;
|
||||
}
|
||||
else
|
||||
{
|
||||
*updatee = from;
|
||||
interpolateTo (to, timePeriod, loopType);
|
||||
}
|
||||
}
|
||||
*/
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -1,69 +0,0 @@
|
|||
/*
|
||||
Copyright (C) 2007, 2010 - Bit-Blot
|
||||
|
||||
This file is part of Aquaria.
|
||||
|
||||
Aquaria is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU General Public License
|
||||
as published by the Free Software Foundation; either version 2
|
||||
of the License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
|
||||
See the GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
#ifndef _interpolator_
|
||||
#define _interpolator_
|
||||
|
||||
#include "Base.h"
|
||||
|
||||
class Interpolator;
|
||||
|
||||
class Interpolator
|
||||
{
|
||||
public:
|
||||
Interpolator () : updatee (0), interpolating (false), loopType (0), useSpeed (false), pingPong (false)
|
||||
{
|
||||
initialDelay = 0.0f;
|
||||
timeMultiplier = 1;
|
||||
timePassed=to=speed=from=timePeriod=fakeTimePassed=0;
|
||||
}
|
||||
bool pingPong;
|
||||
void setUpdatee (float *u);
|
||||
void interpolateTo (float interTo, float time, int ltype);
|
||||
void interpolateBySpeed (float interTo, float speed, int ltype);
|
||||
void update (float dt);
|
||||
void setSpeed (float speed);
|
||||
void stop ();
|
||||
float getX2 ()
|
||||
{
|
||||
return (timePassed - timePeriod/2)*(timePassed - timePeriod/2);
|
||||
}
|
||||
|
||||
bool interpolating, useSpeed;
|
||||
int loopType;
|
||||
float timePeriod;
|
||||
float initialDelay;
|
||||
float to;
|
||||
float timeMultiplier;
|
||||
|
||||
EventPtr endOfInterpolationEvent;
|
||||
EventPtr startOfInterpolationEvent;
|
||||
|
||||
private:
|
||||
|
||||
float speed, from, timePassed, fakeTimePassed;
|
||||
float *updatee;
|
||||
};
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
|
|
@ -1,68 +0,0 @@
|
|||
/*
|
||||
Copyright (C) 2007, 2010 - Bit-Blot
|
||||
|
||||
This file is part of Aquaria.
|
||||
|
||||
Aquaria is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU General Public License
|
||||
as published by the Free Software Foundation; either version 2
|
||||
of the License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
|
||||
See the GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
#include "Light.h"
|
||||
|
||||
Light::Light()
|
||||
{
|
||||
num = 0;
|
||||
enabled = false;
|
||||
ambient = Vector(0.0f,0.0f,0.0f);
|
||||
diffuse = Vector(1,1,1);
|
||||
position = Vector(0,0,0);
|
||||
}
|
||||
|
||||
void Light::apply()
|
||||
{
|
||||
#ifdef BBGE_BUILD_OPENGL
|
||||
int t = GL_LIGHT0;
|
||||
switch (num)
|
||||
{
|
||||
case 0: t=GL_LIGHT0; break;
|
||||
case 1: t=GL_LIGHT1; break;
|
||||
case 2: t=GL_LIGHT2; break;
|
||||
case 3: t=GL_LIGHT3; break;
|
||||
case 4: t=GL_LIGHT4; break;
|
||||
case 5: t=GL_LIGHT5; break;
|
||||
case 6: t=GL_LIGHT6; break;
|
||||
case 7: t=GL_LIGHT7; break;
|
||||
}
|
||||
if (enabled)
|
||||
{
|
||||
glEnable(t);
|
||||
float v[4];
|
||||
glLightfv(t, GL_AMBIENT, ambient.getv4(v, 1));
|
||||
glLightfv(t, GL_DIFFUSE, diffuse.getv4(v, 1));
|
||||
glLightfv(t, GL_POSITION, position.getv4(v, 0));
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
glDisable(t);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void Light::update (float dt)
|
||||
{
|
||||
diffuse.update(dt);
|
||||
ambient.update(dt);
|
||||
position.update(dt);
|
||||
}
|
41
BBGE/Light.h
41
BBGE/Light.h
|
@ -1,41 +0,0 @@
|
|||
/*
|
||||
Copyright (C) 2007, 2010 - Bit-Blot
|
||||
|
||||
This file is part of Aquaria.
|
||||
|
||||
Aquaria is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU General Public License
|
||||
as published by the Free Software Foundation; either version 2
|
||||
of the License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
|
||||
See the GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
#ifndef __light__
|
||||
#define __light__
|
||||
|
||||
#include "Base.h"
|
||||
#include "Vector.h"
|
||||
|
||||
class Light
|
||||
{
|
||||
public:
|
||||
Light();
|
||||
InterpolatedVector ambient, diffuse, position;
|
||||
bool enabled;
|
||||
int num;
|
||||
void apply();
|
||||
void update(float dt);
|
||||
protected:
|
||||
|
||||
|
||||
};
|
||||
|
||||
#endif
|
|
@ -1,45 +0,0 @@
|
|||
/*
|
||||
Copyright (C) 2007, 2010 - Bit-Blot
|
||||
|
||||
This file is part of Aquaria.
|
||||
|
||||
Aquaria is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU General Public License
|
||||
as published by the Free Software Foundation; either version 2
|
||||
of the License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
|
||||
See the GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
#include "LightCone.h"
|
||||
|
||||
LightCone::LightCone() : RenderObject()
|
||||
{
|
||||
length = 64;
|
||||
spread = 32;
|
||||
}
|
||||
|
||||
void LightCone::onRender()
|
||||
{
|
||||
#ifdef BBGE_BUILD_OPENGL
|
||||
RenderObject::onRender();
|
||||
glBegin(GL_QUADS);
|
||||
//glNormal3f( 0.0f, 0, 1.0f);
|
||||
glColor4f(color.x, color.y, color.z, 1*alpha.x);
|
||||
glVertex3f(0, 0, 0);
|
||||
glColor4f(color.x, color.y, color.z,1*alpha.x);
|
||||
glVertex3f(0, 0, 0);
|
||||
glColor4f(color.x, color.y, color.z,0*alpha.x);
|
||||
glVertex3f(spread/2, length, 0);
|
||||
glColor4f(color.x, color.y, color.z,0*alpha.x);
|
||||
glVertex3f(-spread/2, length, 0);
|
||||
glEnd();
|
||||
#endif
|
||||
}
|
|
@ -1,36 +0,0 @@
|
|||
/*
|
||||
Copyright (C) 2007, 2010 - Bit-Blot
|
||||
|
||||
This file is part of Aquaria.
|
||||
|
||||
Aquaria is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU General Public License
|
||||
as published by the Free Software Foundation; either version 2
|
||||
of the License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
|
||||
See the GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
#ifndef __light_cone__
|
||||
#define __light_cone__
|
||||
|
||||
#include "RenderObject.h"
|
||||
|
||||
class LightCone : public RenderObject
|
||||
{
|
||||
public:
|
||||
LightCone();
|
||||
int length;
|
||||
int spread;
|
||||
protected:
|
||||
void onRender();
|
||||
};
|
||||
|
||||
#endif
|
460
BBGE/Model.cpp
460
BBGE/Model.cpp
|
@ -1,460 +0,0 @@
|
|||
/*
|
||||
Copyright (C) 2007, 2010 - Bit-Blot
|
||||
|
||||
This file is part of Aquaria.
|
||||
|
||||
Aquaria is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU General Public License
|
||||
as published by the Free Software Foundation; either version 2
|
||||
of the License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
|
||||
See the GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
#include "Model.h"
|
||||
#include "Core.h"
|
||||
|
||||
#include "cal3d/cal3d.h"
|
||||
|
||||
#include "../ExternalLibs/glpng.h"
|
||||
|
||||
const std::string modelPath = "models/";
|
||||
|
||||
Model::Model() : RenderObject()
|
||||
{
|
||||
m_calModel = 0;
|
||||
//, coreModel("poot")
|
||||
m_calCoreModel = new CalCoreModel("model");
|
||||
if (!m_calCoreModel)
|
||||
{
|
||||
errorLog("Model: failed: new CalCoreModel");
|
||||
}
|
||||
|
||||
m_motionBlend[0] = 0.6f;
|
||||
m_motionBlend[1] = 0.1f;
|
||||
m_motionBlend[2] = 0.3f;
|
||||
m_animationCount = 0;
|
||||
m_meshCount = 0;
|
||||
m_renderScale = 1.0f;
|
||||
m_lodLevel = 1.0f;
|
||||
|
||||
cull = false;
|
||||
}
|
||||
|
||||
void Model::destroy()
|
||||
{
|
||||
RenderObject::destroy();
|
||||
}
|
||||
|
||||
|
||||
bool Model::load(const std::string& _strFilename)
|
||||
{
|
||||
// open the model configuration file
|
||||
std::ifstream file;
|
||||
std::string strFilename(core->adjustFilenameCase(_strFilename));
|
||||
file.open(strFilename.c_str(), std::ios::in | std::ios::binary);
|
||||
if(!file)
|
||||
{
|
||||
std::ostringstream os;
|
||||
os << "Failed to open model configuration file '" << strFilename << "'." << std::endl;
|
||||
errorLog(os.str());
|
||||
return false;
|
||||
}
|
||||
|
||||
// initialize the data path
|
||||
std::string strPath = m_path;
|
||||
|
||||
// initialize the animation count
|
||||
int animationCount;
|
||||
animationCount = 0;
|
||||
|
||||
// parse all lines from the model configuration file
|
||||
int line;
|
||||
for(line = 1; ; line++)
|
||||
{
|
||||
// read the next model configuration line
|
||||
std::string strBuffer;
|
||||
std::getline(file, strBuffer);
|
||||
|
||||
// stop if we reached the end of file
|
||||
if(file.eof()) break;
|
||||
|
||||
// check if an error happend while reading from the file
|
||||
if(!file)
|
||||
{
|
||||
std::cerr << "Error while reading from the model configuration file '" << strFilename << "'." << std::endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
// find the first non-whitespace character
|
||||
std::string::size_type pos;
|
||||
pos = strBuffer.find_first_not_of(" \t");
|
||||
|
||||
// check for empty lines
|
||||
if((pos == std::string::npos) || (strBuffer[pos] == '\n') || (strBuffer[pos] == '\r') || (strBuffer[pos] == 0)) continue;
|
||||
|
||||
// check for comment lines
|
||||
if(strBuffer[pos] == '#') continue;
|
||||
|
||||
// get the key
|
||||
std::string strKey;
|
||||
strKey = strBuffer.substr(pos, strBuffer.find_first_of(" =\t\n\r", pos) - pos);
|
||||
pos += strKey.size();
|
||||
|
||||
// get the '=' character
|
||||
pos = strBuffer.find_first_not_of(" \t", pos);
|
||||
if((pos == std::string::npos) || (strBuffer[pos] != '='))
|
||||
{
|
||||
std::cerr << strFilename << "(" << line << "): Invalid syntax." << std::endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
// find the first non-whitespace character after the '=' character
|
||||
pos = strBuffer.find_first_not_of(" \t", pos + 1);
|
||||
|
||||
// get the data
|
||||
std::string strData;
|
||||
strData = strBuffer.substr(pos, strBuffer.find_first_of("\n\r", pos) - pos);
|
||||
|
||||
// handle the model creation
|
||||
if(strKey == "scale")
|
||||
{
|
||||
// set rendering scale factor
|
||||
m_renderScale = atof(strData.c_str());
|
||||
}
|
||||
else if(strKey == "path")
|
||||
{
|
||||
// set the new path for the data files if one hasn't been set already
|
||||
if (m_path == "") strPath = strData;
|
||||
}
|
||||
else if(strKey == "skeleton")
|
||||
{
|
||||
// load core skeleton
|
||||
std::cout << "Loading skeleton '" << strData << "'..." << std::endl;
|
||||
if(!m_calCoreModel->loadCoreSkeleton(strPath + strData))
|
||||
{
|
||||
CalError::printLastError();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else if(strKey == "animation")
|
||||
{
|
||||
// load core animation
|
||||
std::cout << "Loading animation '" << strData << "'..." << std::endl;
|
||||
m_animationId[animationCount] = m_calCoreModel->loadCoreAnimation(strPath + strData);
|
||||
if(m_animationId[animationCount] == -1)
|
||||
{
|
||||
CalError::printLastError();
|
||||
return false;
|
||||
}
|
||||
|
||||
animationCount++;
|
||||
}
|
||||
else if(strKey == "mesh")
|
||||
{
|
||||
// load core mesh
|
||||
std::cout << "Loading mesh '" << strData << "'..." << std::endl;
|
||||
if(m_calCoreModel->loadCoreMesh(strPath + strData) == -1)
|
||||
{
|
||||
CalError::printLastError();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else if(strKey == "material")
|
||||
{
|
||||
// load core material
|
||||
std::cout << "Loading material '" << strData << "'..." << std::endl;
|
||||
if(m_calCoreModel->loadCoreMaterial(strPath + strData) == -1)
|
||||
{
|
||||
CalError::printLastError();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
std::cerr << strFilename << "(" << line << "): Invalid syntax." << std::endl;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// explicitely close the file
|
||||
file.close();
|
||||
|
||||
// load all textures and store the opengl texture id in the corresponding map in the material
|
||||
int materialId;
|
||||
for(materialId = 0; materialId < m_calCoreModel->getCoreMaterialCount(); materialId++)
|
||||
{
|
||||
// get the core material
|
||||
CalCoreMaterial *pCoreMaterial;
|
||||
pCoreMaterial = m_calCoreModel->getCoreMaterial(materialId);
|
||||
|
||||
// loop through all maps of the core material
|
||||
int mapId;
|
||||
for(mapId = 0; mapId < pCoreMaterial->getMapCount(); mapId++)
|
||||
{
|
||||
// get the filename of the texture
|
||||
std::string strFilename;
|
||||
strFilename = pCoreMaterial->getMapFilename(mapId);
|
||||
|
||||
// load the texture from the file
|
||||
GLuint textureId;
|
||||
pngInfo info;
|
||||
textureId = pngBind((strPath + strFilename).c_str(), PNG_BUILDMIPMAPS, PNG_ALPHA, &info, GL_CLAMP, GL_LINEAR_MIPMAP_LINEAR, GL_LINEAR);
|
||||
//loadTexture(strPath + strFilename);
|
||||
|
||||
// store the opengl texture id in the user data of the map
|
||||
pCoreMaterial->setMapUserData(mapId, (Cal::UserData)textureId);
|
||||
}
|
||||
}
|
||||
|
||||
// make one material thread for each material
|
||||
// NOTE: this is not the right way to do it, but this viewer can't do the right
|
||||
// mapping without further information on the model etc.
|
||||
for(materialId = 0; materialId < m_calCoreModel->getCoreMaterialCount(); materialId++)
|
||||
{
|
||||
// create the a material thread
|
||||
m_calCoreModel->createCoreMaterialThread(materialId);
|
||||
|
||||
// initialize the material thread
|
||||
m_calCoreModel->setCoreMaterialId(materialId, 0, materialId);
|
||||
}
|
||||
|
||||
// Calculate Bounding Boxes
|
||||
|
||||
m_calCoreModel->getCoreSkeleton()->calculateBoundingBoxes(m_calCoreModel);
|
||||
|
||||
m_calModel = new CalModel(m_calCoreModel);
|
||||
|
||||
// attach all meshes to the model
|
||||
int meshId;
|
||||
for(meshId = 0; meshId < m_calCoreModel->getCoreMeshCount(); meshId++)
|
||||
{
|
||||
m_calModel->attachMesh(meshId);
|
||||
}
|
||||
|
||||
// set the material set of the whole model
|
||||
m_calModel->setMaterialSet(0);
|
||||
|
||||
// set initial animation state
|
||||
/*
|
||||
m_state = STATE_MOTION;
|
||||
m_calModel->getMixer()->blendCycle(m_animationId[STATE_MOTION], m_motionBlend[0], 0.0f);
|
||||
m_calModel->getMixer()->blendCycle(m_animationId[STATE_MOTION + 1], m_motionBlend[1], 0.0f);
|
||||
m_calModel->getMixer()->blendCycle(m_animationId[STATE_MOTION + 2], m_motionBlend[2], 0.0f);
|
||||
*/
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void Model::onUpdate(float dt)
|
||||
{
|
||||
RenderObject::onUpdate(dt);
|
||||
|
||||
if (m_calModel)
|
||||
m_calModel->update(dt);
|
||||
}
|
||||
|
||||
void Model::renderMesh(bool bWireframe, bool bLight)
|
||||
{
|
||||
// get the renderer of the model
|
||||
CalRenderer *pCalRenderer;
|
||||
pCalRenderer = m_calModel->getRenderer();
|
||||
|
||||
// begin the rendering loop
|
||||
if(!pCalRenderer->beginRendering()) return;
|
||||
|
||||
// set wireframe mode if necessary
|
||||
if(bWireframe)
|
||||
{
|
||||
glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
|
||||
}
|
||||
|
||||
// set the global OpenGL states
|
||||
glEnable(GL_DEPTH_TEST);
|
||||
glShadeModel(GL_SMOOTH);
|
||||
|
||||
// set the lighting mode if necessary
|
||||
if(bLight)
|
||||
{
|
||||
glEnable(GL_LIGHTING);
|
||||
glEnable(GL_LIGHT0);
|
||||
}
|
||||
|
||||
// we will use vertex arrays, so enable them
|
||||
glEnableClientState(GL_VERTEX_ARRAY);
|
||||
glEnableClientState(GL_NORMAL_ARRAY);
|
||||
|
||||
// get the number of meshes
|
||||
int meshCount;
|
||||
meshCount = pCalRenderer->getMeshCount();
|
||||
|
||||
// render all meshes of the model
|
||||
int meshId;
|
||||
for(meshId = 0; meshId < meshCount; meshId++)
|
||||
{
|
||||
// get the number of submeshes
|
||||
int submeshCount;
|
||||
submeshCount = pCalRenderer->getSubmeshCount(meshId);
|
||||
|
||||
// render all submeshes of the mesh
|
||||
int submeshId;
|
||||
for(submeshId = 0; submeshId < submeshCount; submeshId++)
|
||||
{
|
||||
// select mesh and submesh for further data access
|
||||
if(pCalRenderer->selectMeshSubmesh(meshId, submeshId))
|
||||
{
|
||||
unsigned char meshColor[4];
|
||||
GLfloat materialColor[4];
|
||||
|
||||
// set the material ambient color
|
||||
pCalRenderer->getAmbientColor(&meshColor[0]);
|
||||
materialColor[0] = meshColor[0] / 255.0f; materialColor[1] = meshColor[1] / 255.0f; materialColor[2] = meshColor[2] / 255.0f; materialColor[3] = meshColor[3] / 255.0f;
|
||||
glMaterialfv(GL_FRONT, GL_AMBIENT, materialColor);
|
||||
|
||||
// set the material diffuse color
|
||||
pCalRenderer->getDiffuseColor(&meshColor[0]);
|
||||
materialColor[0] = meshColor[0] / 255.0f; materialColor[1] = meshColor[1] / 255.0f; materialColor[2] = meshColor[2] / 255.0f; materialColor[3] = meshColor[3] / 255.0f;
|
||||
glMaterialfv(GL_FRONT, GL_DIFFUSE, materialColor);
|
||||
|
||||
// set the vertex color if we have no lights
|
||||
if(!bLight)
|
||||
{
|
||||
glColor4fv(materialColor);
|
||||
}
|
||||
|
||||
// set the material specular color
|
||||
pCalRenderer->getSpecularColor(&meshColor[0]);
|
||||
materialColor[0] = meshColor[0] / 255.0f; materialColor[1] = meshColor[1] / 255.0f; materialColor[2] = meshColor[2] / 255.0f; materialColor[3] = meshColor[3] / 255.0f;
|
||||
glMaterialfv(GL_FRONT, GL_SPECULAR, materialColor);
|
||||
|
||||
// set the material shininess factor
|
||||
float shininess;
|
||||
shininess = 50.0f; //TODO: pCalRenderer->getShininess();
|
||||
glMaterialfv(GL_FRONT, GL_SHININESS, &shininess);
|
||||
|
||||
// get the transformed vertices of the submesh
|
||||
static float meshVertices[30000][3];
|
||||
int vertexCount;
|
||||
vertexCount = pCalRenderer->getVertices(&meshVertices[0][0]);
|
||||
|
||||
// get the transformed normals of the submesh
|
||||
static float meshNormals[30000][3];
|
||||
pCalRenderer->getNormals(&meshNormals[0][0]);
|
||||
|
||||
// get the texture coordinates of the submesh
|
||||
static float meshTextureCoordinates[30000][2];
|
||||
int textureCoordinateCount;
|
||||
textureCoordinateCount = pCalRenderer->getTextureCoordinates(0, &meshTextureCoordinates[0][0]);
|
||||
|
||||
// get the faces of the submesh
|
||||
static CalIndex meshFaces[50000][3];
|
||||
int faceCount;
|
||||
faceCount = pCalRenderer->getFaces(&meshFaces[0][0]);
|
||||
|
||||
// set the vertex and normal buffers
|
||||
glVertexPointer(3, GL_FLOAT, 0, &meshVertices[0][0]);
|
||||
glNormalPointer(GL_FLOAT, 0, &meshNormals[0][0]);
|
||||
|
||||
// set the texture coordinate buffer and state if necessary
|
||||
if((pCalRenderer->getMapCount() > 0) && (textureCoordinateCount > 0))
|
||||
{
|
||||
glEnable(GL_TEXTURE_2D);
|
||||
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
|
||||
glEnable(GL_COLOR_MATERIAL);
|
||||
|
||||
// set the texture id we stored in the map user data
|
||||
glBindTexture(GL_TEXTURE_2D, (GLuint)pCalRenderer->getMapUserData(0));
|
||||
|
||||
// set the texture coordinate buffer
|
||||
glTexCoordPointer(2, GL_FLOAT, 0, &meshTextureCoordinates[0][0]);
|
||||
|
||||
glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
|
||||
}
|
||||
|
||||
// draw the submesh
|
||||
|
||||
if(sizeof(CalIndex)==2)
|
||||
glDrawElements(GL_TRIANGLES, faceCount * 3, GL_UNSIGNED_SHORT, &meshFaces[0][0]);
|
||||
else
|
||||
glDrawElements(GL_TRIANGLES, faceCount * 3, GL_UNSIGNED_INT, &meshFaces[0][0]);
|
||||
|
||||
// disable the texture coordinate state if necessary
|
||||
if((pCalRenderer->getMapCount() > 0) && (textureCoordinateCount > 0))
|
||||
{
|
||||
glDisable(GL_COLOR_MATERIAL);
|
||||
glDisableClientState(GL_TEXTURE_COORD_ARRAY);
|
||||
glDisable(GL_TEXTURE_2D);
|
||||
}
|
||||
|
||||
// DEBUG-CODE //////////////////////////////////////////////////////////////////
|
||||
/*
|
||||
glBegin(GL_LINES);
|
||||
glColor3f(1.0f, 1.0f, 1.0f);
|
||||
int vertexId;
|
||||
for(vertexId = 0; vertexId < vertexCount; vertexId++)
|
||||
{
|
||||
const float scale = 0.3f;
|
||||
glVertex3f(meshVertices[vertexId][0], meshVertices[vertexId][1], meshVertices[vertexId][2]);
|
||||
glVertex3f(meshVertices[vertexId][0] + meshNormals[vertexId][0] * scale, meshVertices[vertexId][1] + meshNormals[vertexId][1] * scale, meshVertices[vertexId][2] + meshNormals[vertexId][2] * scale);
|
||||
}
|
||||
glEnd();
|
||||
*/
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// clear vertex array state
|
||||
glDisableClientState(GL_NORMAL_ARRAY);
|
||||
glDisableClientState(GL_VERTEX_ARRAY);
|
||||
|
||||
// reset the lighting mode
|
||||
if(bLight)
|
||||
{
|
||||
glDisable(GL_LIGHTING);
|
||||
glDisable(GL_LIGHT0);
|
||||
}
|
||||
|
||||
// reset the global OpenGL states
|
||||
glDisable(GL_DEPTH_TEST);
|
||||
|
||||
// reset wireframe mode if necessary
|
||||
if(bWireframe)
|
||||
{
|
||||
glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
|
||||
}
|
||||
|
||||
// end the rendering
|
||||
pCalRenderer->endRendering();
|
||||
}
|
||||
|
||||
void Model::onRender()
|
||||
{
|
||||
/*
|
||||
glClearDepth(1.0f);
|
||||
core->resize3D();
|
||||
*/
|
||||
|
||||
glEnable(GL_DEPTH_TEST); // Enables Depth Testing
|
||||
glDepthFunc(GL_LEQUAL); // The Type Of Depth Testing To Do
|
||||
|
||||
glDisable(GL_TEXTURE_2D);
|
||||
glBindTexture(GL_TEXTURE_2D, 0);
|
||||
|
||||
glShadeModel(GL_SMOOTH);
|
||||
|
||||
// check if we need to render the mesh
|
||||
renderMesh(false, false);
|
||||
|
||||
glEnable(GL_TEXTURE_2D);
|
||||
|
||||
glDisable(GL_DEPTH_TEST);
|
||||
|
||||
}
|
62
BBGE/Model.h
62
BBGE/Model.h
|
@ -1,62 +0,0 @@
|
|||
/*
|
||||
Copyright (C) 2007, 2010 - Bit-Blot
|
||||
|
||||
This file is part of Aquaria.
|
||||
|
||||
Aquaria is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU General Public License
|
||||
as published by the Free Software Foundation; either version 2
|
||||
of the License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
|
||||
See the GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
#ifndef BBGE_MODEL_H
|
||||
#define BBGE_MODEL_H
|
||||
|
||||
#include "RenderObject.h"
|
||||
|
||||
|
||||
class CalCoreModel;
|
||||
class CalModel;
|
||||
|
||||
|
||||
class Model : public RenderObject
|
||||
{
|
||||
public:
|
||||
Model();
|
||||
void destroy();
|
||||
|
||||
bool load(const std::string &file);
|
||||
|
||||
|
||||
protected:
|
||||
void onUpdate(float dt);
|
||||
|
||||
void onRender();
|
||||
void renderMesh(bool bWireframe, bool bLight);
|
||||
|
||||
protected:
|
||||
//int m_state;
|
||||
CalCoreModel* m_calCoreModel;
|
||||
CalModel* m_calModel;
|
||||
int m_animationId[16];
|
||||
int m_animationCount;
|
||||
int m_meshId[32];
|
||||
int m_meshCount;
|
||||
GLuint m_textureId[32];
|
||||
int m_textureCount;
|
||||
float m_motionBlend[3];
|
||||
float m_renderScale;
|
||||
float m_lodLevel;
|
||||
std::string m_path;
|
||||
};
|
||||
|
||||
#endif
|
|
@ -1,302 +0,0 @@
|
|||
/*
|
||||
Copyright (C) 2007, 2010 - Bit-Blot
|
||||
|
||||
This file is part of Aquaria.
|
||||
|
||||
Aquaria is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU General Public License
|
||||
as published by the Free Software Foundation; either version 2
|
||||
of the License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
|
||||
See the GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
#include "OggStream.h"
|
||||
#include "SoundManager.h"
|
||||
#include "Base.h"
|
||||
|
||||
#define BUFFER_SIZE (4096 * 4)
|
||||
|
||||
OggStream::OggStream()
|
||||
{
|
||||
loop=false;
|
||||
source = 0;
|
||||
buffers[0] = 0;
|
||||
buffers[1] = 0;
|
||||
}
|
||||
|
||||
void OggStream::open(std::string path)
|
||||
{
|
||||
int result;
|
||||
|
||||
oggFile = fopen(core->adjustFilenameCase(path.c_str()), "rb");
|
||||
|
||||
if (!oggFile)
|
||||
{
|
||||
sound->error("Could not open Ogg file.");
|
||||
return;
|
||||
}
|
||||
|
||||
result = ov_open(oggFile, &oggStream, NULL, 0);
|
||||
|
||||
if (result < 0)
|
||||
{
|
||||
fclose(oggFile);
|
||||
|
||||
sound->error(std::string("Could not open Ogg stream. ") + errorString(result));
|
||||
return;
|
||||
}
|
||||
|
||||
vorbisInfo = ov_info(&oggStream, -1);
|
||||
vorbisComment = ov_comment(&oggStream, -1);
|
||||
|
||||
if(vorbisInfo->channels == 1)
|
||||
format = AL_FORMAT_MONO16;
|
||||
else
|
||||
format = AL_FORMAT_STEREO16;
|
||||
|
||||
|
||||
alGenBuffers(2, buffers);
|
||||
check();
|
||||
alGenSources(1, &source);
|
||||
check();
|
||||
|
||||
alSource3f(source, AL_POSITION, 0.0, 0.0, 0.0);
|
||||
alSource3f(source, AL_VELOCITY, 0.0, 0.0, 0.0);
|
||||
alSource3f(source, AL_DIRECTION, 0.0, 0.0, 0.0);
|
||||
alSourcef (source, AL_ROLLOFF_FACTOR, 0.0 );
|
||||
alSourcei (source, AL_SOURCE_RELATIVE, AL_TRUE );
|
||||
}
|
||||
|
||||
void OggStream::release()
|
||||
{
|
||||
BBGE_PROF(OggStream::release);
|
||||
if (source)
|
||||
{
|
||||
alSourceStop(source);
|
||||
empty();
|
||||
alDeleteSources(1, &source);
|
||||
check();
|
||||
}
|
||||
if (buffers && (buffers[0] || buffers[1]))
|
||||
{
|
||||
alDeleteBuffers(1, buffers);
|
||||
check();
|
||||
}
|
||||
|
||||
ov_clear(&oggStream);
|
||||
|
||||
source = 0;
|
||||
buffers[0] = 0;
|
||||
buffers[1] = 0;
|
||||
}
|
||||
|
||||
void OggStream::display()
|
||||
{
|
||||
std::cout
|
||||
<< "version " << vorbisInfo->version << "\n"
|
||||
<< "channels " << vorbisInfo->channels << "\n"
|
||||
<< "rate (hz) " << vorbisInfo->rate << "\n"
|
||||
<< "bitrate upper " << vorbisInfo->bitrate_upper << "\n"
|
||||
<< "bitrate nominal " << vorbisInfo->bitrate_nominal << "\n"
|
||||
<< "bitrate lower " << vorbisInfo->bitrate_lower << "\n"
|
||||
<< "bitrate window " << vorbisInfo->bitrate_window << "\n"
|
||||
<< "\n"
|
||||
<< "vendor " << vorbisComment->vendor << "\n";
|
||||
|
||||
for(int i = 0; i < vorbisComment->comments; i++)
|
||||
std::cout << " " << vorbisComment->user_comments[i] << "\n";
|
||||
|
||||
std::cout << std::endl;
|
||||
}
|
||||
|
||||
bool OggStream::play(bool l)
|
||||
{
|
||||
BBGE_PROF(OggStream::play);
|
||||
if(isPlaying())
|
||||
return true;
|
||||
|
||||
if(!stream(buffers[0]))
|
||||
return false;
|
||||
|
||||
if(!stream(buffers[1]))
|
||||
return false;
|
||||
|
||||
loop=l;
|
||||
|
||||
alSourceQueueBuffers(source, 2, buffers);
|
||||
alSourcePlay(source);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool OggStream::isPlaying()
|
||||
{
|
||||
ALenum state;
|
||||
|
||||
if (source)
|
||||
{
|
||||
alGetSourcei(source, AL_SOURCE_STATE, &state);
|
||||
|
||||
return (state == AL_PLAYING);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
void OggStream::setGain(float gain)
|
||||
{
|
||||
if (!source) return;
|
||||
|
||||
alSourcef(source, AL_GAIN, gain);
|
||||
ALenum error=alGetError();
|
||||
|
||||
if(error!=AL_FALSE)
|
||||
{
|
||||
switch(error)
|
||||
{
|
||||
case(AL_INVALID_VALUE):
|
||||
sound->error("Invalid value for gain");
|
||||
break;
|
||||
default:
|
||||
sound->error("Error trying to set gain!");
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool OggStream::update()
|
||||
{
|
||||
if (!source) return false;
|
||||
|
||||
int processed;
|
||||
bool active = true;
|
||||
|
||||
if (!isPlaying())
|
||||
{
|
||||
alSourcePlay(source);
|
||||
}
|
||||
|
||||
alGetSourcei(source, AL_BUFFERS_PROCESSED, &processed);
|
||||
|
||||
while(processed--)
|
||||
{
|
||||
ALuint buffer;
|
||||
|
||||
alSourceUnqueueBuffers(source, 1, &buffer);
|
||||
check();
|
||||
|
||||
active = stream(buffer);
|
||||
|
||||
alSourceQueueBuffers(source, 1, &buffer);
|
||||
check();
|
||||
}
|
||||
|
||||
if (!active)
|
||||
{
|
||||
release();
|
||||
}
|
||||
|
||||
return active;
|
||||
}
|
||||
|
||||
bool OggStream::stream(ALuint buffer)
|
||||
{
|
||||
char pcm[BUFFER_SIZE];
|
||||
int size = 0;
|
||||
int section;
|
||||
int result;
|
||||
|
||||
while(size < BUFFER_SIZE)
|
||||
{
|
||||
result = ov_read(&oggStream, pcm + size, BUFFER_SIZE - size, 0, 2, 1, §ion);
|
||||
|
||||
if(result > 0)
|
||||
size += result;
|
||||
else
|
||||
{ if(result < 0) {} else break; }
|
||||
}
|
||||
|
||||
if(size == 0)
|
||||
{
|
||||
if (loop)
|
||||
{
|
||||
std::cout << "looping\n";
|
||||
int r = ov_pcm_seek(&oggStream, 0);
|
||||
if (r != 0)
|
||||
{
|
||||
std::cout << "error\n";
|
||||
}
|
||||
|
||||
while(size < BUFFER_SIZE)
|
||||
{
|
||||
result = ov_read(&oggStream, pcm + size, BUFFER_SIZE - size, 0, 2, 1, §ion);
|
||||
|
||||
if(result > 0)
|
||||
size += result;
|
||||
else
|
||||
{ if(result < 0) {} else break; }
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
alBufferData(buffer, format, pcm, size, vorbisInfo->rate);
|
||||
//check();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void OggStream::empty()
|
||||
{
|
||||
if (!source) return;
|
||||
int queued;
|
||||
|
||||
alGetSourcei(source, AL_BUFFERS_QUEUED, &queued);
|
||||
|
||||
while(queued--)
|
||||
{
|
||||
ALuint buffer;
|
||||
|
||||
alSourceUnqueueBuffers(source, 1, &buffer);
|
||||
check();
|
||||
}
|
||||
}
|
||||
|
||||
void OggStream::check()
|
||||
{
|
||||
int error = alGetError();
|
||||
|
||||
if(error != AL_NO_ERROR)
|
||||
sound->error(std::string("OpenAL error was raised."));
|
||||
}
|
||||
|
||||
std::string OggStream::errorString(int code)
|
||||
{
|
||||
switch(code)
|
||||
{
|
||||
case OV_EREAD:
|
||||
return std::string("Read from media.");
|
||||
case OV_ENOTVORBIS:
|
||||
return std::string("Not Vorbis data.");
|
||||
case OV_EVERSION:
|
||||
return std::string("Vorbis version mismatch.");
|
||||
case OV_EBADHEADER:
|
||||
return std::string("Invalid Vorbis header.");
|
||||
case OV_EFAULT:
|
||||
return std::string("Internal logic fault (bug or heap/stack corruption.");
|
||||
default:
|
||||
return std::string("Unknown Ogg error.");
|
||||
}
|
||||
}
|
||||
|
|
@ -1,61 +0,0 @@
|
|||
/*
|
||||
Copyright (C) 2007, 2010 - Bit-Blot
|
||||
|
||||
This file is part of Aquaria.
|
||||
|
||||
Aquaria is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU General Public License
|
||||
as published by the Free Software Foundation; either version 2
|
||||
of the License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
|
||||
See the GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
#ifndef __ogg_h__
|
||||
#define __ogg_h__
|
||||
|
||||
#include <string>
|
||||
#include <iostream>
|
||||
|
||||
#include "al.h"
|
||||
#include "vorbis/vorbisfile.h"
|
||||
|
||||
class OggStream
|
||||
{
|
||||
public:
|
||||
OggStream();
|
||||
void open(std::string path);
|
||||
void release();
|
||||
void display();
|
||||
bool play(bool loop=false);
|
||||
bool isPlaying();
|
||||
bool update();
|
||||
void setGain(float g);
|
||||
protected:
|
||||
bool stream(ALuint buffer);
|
||||
void empty();
|
||||
void check();
|
||||
std::string errorString(int code);
|
||||
|
||||
private:
|
||||
FILE* oggFile;
|
||||
OggVorbis_File oggStream;
|
||||
vorbis_info* vorbisInfo;
|
||||
vorbis_comment* vorbisComment;
|
||||
|
||||
ALuint buffers[2];
|
||||
ALuint source;
|
||||
ALenum format;
|
||||
bool loop;
|
||||
};
|
||||
|
||||
|
||||
#endif // __ogg_h__
|
||||
|
|
@ -1,140 +0,0 @@
|
|||
/*
|
||||
Copyright (C) 2007, 2010 - Bit-Blot
|
||||
|
||||
This file is part of Aquaria.
|
||||
|
||||
Aquaria is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU General Public License
|
||||
as published by the Free Software Foundation; either version 2
|
||||
of the License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
|
||||
See the GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
#include "PackRead.h"
|
||||
#include <fcntl.h>
|
||||
|
||||
#if defined(BBGE_BUILD_UNIX)
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#define _open open
|
||||
#define _read read
|
||||
#define _lseek lseek
|
||||
#define _close close
|
||||
#else
|
||||
#include <io.h>
|
||||
#endif
|
||||
|
||||
#define LOC_UNIT long int
|
||||
|
||||
void packGetLoc(const std::string &pack, const std::string &file, long int *location, int *size)
|
||||
{
|
||||
*location = 0;
|
||||
*size = 0;
|
||||
|
||||
int fd = _open(pack.c_str(), O_RDONLY);
|
||||
int numFiles, nameSize, fileSize; LOC_UNIT loc;
|
||||
|
||||
_read(fd, &numFiles, sizeof(int));
|
||||
|
||||
for (int i = 0; i < numFiles; i++)
|
||||
{
|
||||
_lseek(fd, (i * sizeof(LOC_UNIT)) + sizeof(int), SEEK_SET);
|
||||
|
||||
_read(fd, &loc, sizeof(LOC_UNIT));
|
||||
|
||||
_lseek(fd, loc, SEEK_SET);
|
||||
|
||||
_read(fd, &fileSize, sizeof(int));
|
||||
|
||||
_read(fd, &nameSize, sizeof(int));
|
||||
|
||||
char *name = (char*)malloc(nameSize+1);
|
||||
_read(fd, name, nameSize);
|
||||
name[nameSize] = '\0';
|
||||
|
||||
/*
|
||||
sprintf(dbg, "fs: %d ns: %d n: %s", fileSize, nameSize, name);
|
||||
debugLog(dbg);
|
||||
*/
|
||||
|
||||
if (nocasecmp(file, std::string(name))==0)
|
||||
{
|
||||
char *buffer = (char*)malloc(fileSize);
|
||||
_read(fd, buffer, fileSize);
|
||||
|
||||
free(name);
|
||||
_close(fd);
|
||||
|
||||
*location = loc + sizeof(int) + sizeof(int) + nameSize;
|
||||
*size = fileSize;
|
||||
|
||||
return;
|
||||
//return buffer;
|
||||
}
|
||||
|
||||
free(name);
|
||||
}
|
||||
|
||||
_close(fd);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
void packReadInfo(const char *pack)
|
||||
{
|
||||
debugLog("pack read info");
|
||||
|
||||
//char dbg[256];
|
||||
|
||||
int fd = _open(pack, O_RDONLY);
|
||||
|
||||
int numFiles, nameSize, fileSize;
|
||||
LOC_UNIT loc;
|
||||
|
||||
_read(fd, &numFiles, sizeof(int));
|
||||
|
||||
/*
|
||||
sprintf(dbg, "numFiles: %d", numFiles);
|
||||
debugLog(dbg);
|
||||
*/
|
||||
|
||||
for (int i = 0; i < numFiles; i++)
|
||||
{
|
||||
_lseek(fd, (i * sizeof(LOC_UNIT)) + sizeof(int), SEEK_SET);
|
||||
|
||||
_read(fd, &loc, sizeof(LOC_UNIT));
|
||||
|
||||
/*
|
||||
sprintf(dbg, "loc[%d] = %d", i, loc);
|
||||
debugLog(dbg);
|
||||
*/
|
||||
|
||||
_lseek(fd, loc, SEEK_SET);
|
||||
|
||||
_read(fd, &fileSize, sizeof(int));
|
||||
|
||||
_read(fd, &nameSize, sizeof(int));
|
||||
|
||||
char *name = (char*)malloc(nameSize+1);
|
||||
_read(fd, name, nameSize);
|
||||
name[nameSize] = '\0';
|
||||
|
||||
|
||||
/*
|
||||
sprintf(dbg, "fs: %d ns: %d n: %s", fileSize, nameSize, name);
|
||||
debugLog(dbg);
|
||||
*/
|
||||
|
||||
free(name);
|
||||
}
|
||||
|
||||
_close(fd);
|
||||
}
|
|
@ -1,25 +0,0 @@
|
|||
/*
|
||||
Copyright (C) 2007, 2010 - Bit-Blot
|
||||
|
||||
This file is part of Aquaria.
|
||||
|
||||
Aquaria is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU General Public License
|
||||
as published by the Free Software Foundation; either version 2
|
||||
of the License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
|
||||
See the GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
#include "Base.h"
|
||||
|
||||
void packReadInfo(const char *pack);
|
||||
|
||||
void packGetLoc(const std::string &pack, const std::string &file, long int *location, int *size);
|
|
@ -1,60 +0,0 @@
|
|||
/*
|
||||
Copyright (C) 2007, 2010 - Bit-Blot
|
||||
|
||||
This file is part of Aquaria.
|
||||
|
||||
Aquaria is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU General Public License
|
||||
as published by the Free Software Foundation; either version 2
|
||||
of the License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
|
||||
See the GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
#include "PointSprites.h"
|
||||
|
||||
#ifdef BBGE_BUILD_WINDOWS
|
||||
|
||||
PointSprites::PointSprites()
|
||||
{
|
||||
glPointParameterfARB = NULL;
|
||||
glPointParameterfvARB = NULL;
|
||||
}
|
||||
|
||||
void PointSprites::init()
|
||||
{
|
||||
char *ext = (char*)glGetString( GL_EXTENSIONS );
|
||||
|
||||
if( strstr( ext, "GL_ARB_point_parameters" ) == NULL )
|
||||
{
|
||||
debugLog("PointSprites: GL_ARB_point_parameters extension was not found");
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
#ifdef BBGE_BUILD_GLFW
|
||||
glPointParameterfARB = (PFNGLPOINTPARAMETERFARBPROC)glfwGetProcAddress("glPointParameterfARB");
|
||||
glPointParameterfvARB = (PFNGLPOINTPARAMETERFVARBPROC)glfwGetProcAddress("glPointParameterfvARB");
|
||||
#endif
|
||||
|
||||
#ifdef BBGE_BUILD_SDL
|
||||
glPointParameterfARB = (PFNGLPOINTPARAMETERFARBPROC)SDL_GL_GetProcAddress("glPointParameterfARB");
|
||||
glPointParameterfvARB = (PFNGLPOINTPARAMETERFVARBPROC)SDL_GL_GetProcAddress("glPointParameterfvARB");
|
||||
#endif
|
||||
|
||||
if( !glPointParameterfARB || !glPointParameterfvARB )
|
||||
{
|
||||
debugLog("PointSprites: One or more GL_ARB_point_parameters functions were not found");
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
|
@ -1,39 +0,0 @@
|
|||
/*
|
||||
Copyright (C) 2007, 2010 - Bit-Blot
|
||||
|
||||
This file is part of Aquaria.
|
||||
|
||||
Aquaria is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU General Public License
|
||||
as published by the Free Software Foundation; either version 2
|
||||
of the License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
|
||||
See the GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
#ifndef POINTSPRITES_H
|
||||
#define POINTSPRITES_H
|
||||
|
||||
#include "Base.h"
|
||||
|
||||
#ifdef BBGE_BUILD_WINDOWS
|
||||
|
||||
class PointSprites
|
||||
{
|
||||
public:
|
||||
PointSprites();
|
||||
void init();
|
||||
|
||||
PFNGLPOINTPARAMETERFARBPROC glPointParameterfARB;
|
||||
PFNGLPOINTPARAMETERFVARBPROC glPointParameterfvARB;
|
||||
};
|
||||
|
||||
#endif
|
||||
#endif
|
|
@ -23,7 +23,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|||
|
||||
#include "Base.h"
|
||||
#include "Texture.h"
|
||||
#include "Flags.h"
|
||||
#include "ScriptObject.h"
|
||||
|
||||
class Core;
|
||||
|
|
|
@ -22,7 +22,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|||
#include "Core.h"
|
||||
#include "SoundManager.h"
|
||||
#include "Base.h"
|
||||
#include "PackRead.h"
|
||||
|
||||
#if defined(BBGE_BUILD_FMODEX)
|
||||
#ifdef BBGE_BUILD_FMOD_OPENAL_BRIDGE
|
||||
|
|
180
BBGE/flags.hpp
180
BBGE/flags.hpp
|
@ -1,180 +0,0 @@
|
|||
// flags.hpp
|
||||
//
|
||||
// Copyright (c) 2004 Eugene Gladyshev
|
||||
//
|
||||
// Permission to copy, use, modify, sell and distribute this software
|
||||
// is granted provided this copyright notice appears in all copies.
|
||||
// This software is provided "as is" without express or implied
|
||||
// warranty, and with no claim as to its suitability for any purpose.
|
||||
//
|
||||
|
||||
#ifndef __ttl_flg_flags__hpp
|
||||
#define __ttl_flg_flags__hpp
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
namespace ttl
|
||||
{
|
||||
namespace flg
|
||||
{
|
||||
namespace impl
|
||||
{
|
||||
template<
|
||||
int Bits,
|
||||
int type = Bits <= sizeof(char)*8?1:(Bits <= sizeof(short)*8?2:(Bits <= sizeof(int)*8?3:4))
|
||||
> struct bestfit;
|
||||
|
||||
template< int Bits >
|
||||
struct bestfit<Bits, 1>
|
||||
{
|
||||
typedef unsigned char type;
|
||||
};
|
||||
|
||||
template< int Bits >
|
||||
struct bestfit<Bits, 2>
|
||||
{
|
||||
typedef unsigned short type;
|
||||
};
|
||||
|
||||
template< int Bits >
|
||||
struct bestfit<Bits, 3>
|
||||
{
|
||||
typedef unsigned int type;
|
||||
};
|
||||
|
||||
template< int Bits >
|
||||
struct bestfit<Bits, 4>
|
||||
{
|
||||
typedef unsigned int type;
|
||||
};
|
||||
};
|
||||
|
||||
template< typename T, int Bits = sizeof(int)*8, typename Holder = typename impl::bestfit<Bits>::type >
|
||||
struct flags
|
||||
{
|
||||
typedef flags this_t;
|
||||
typedef T value_type;
|
||||
|
||||
Holder f_;
|
||||
|
||||
flags() : f_(0) {}
|
||||
flags( T f1 ) : f_(f1) {}
|
||||
flags( T f1, T f2 ) : f_(f1|f2) {}
|
||||
flags( T f1, T f2, T f3 ) : f_(f1|f2|f3) {}
|
||||
flags( T f1, T f2, T f3, T f4 ) : f_(f1|f2|f3|f4) {}
|
||||
flags( T f1, T f2, T f3, T f4, T f5 ) : f_(f1|f2|f3|f4|f5) {}
|
||||
flags( T f1, T f2, T f3, T f4, T f5, T f6 ) : f_(f1|f2|f3|f4|f5|f6) {}
|
||||
flags( T f1, T f2, T f3, T f4, T f5, T f6, T f7 ) : f_(f1|f2|f3|f4|f5|f6|f7) {}
|
||||
flags( T f1, T f2, T f3, T f4, T f5, T f6, T f7, T f8 ) : f_(f1|f2|f3|f4|f5|f6|f7|f8) {}
|
||||
flags( T f1, T f2, T f3, T f4, T f5, T f6, T f7, T f8, T f9 ) : f_(f1|f2|f3|f4|f5|f6|f7|f8|f9) {}
|
||||
flags( T f1, T f2, T f3, T f4, T f5, T f6, T f7, T f8, T f9, T f10 ) : f_(f1|f2|f3|f4|f5|f6|f7|f8|f9|f10) {}
|
||||
|
||||
this_t& operator |=( const this_t& f ) { f_ |= f.f_; return *this; }
|
||||
this_t& operator &=( const this_t& f ) { f_ &= f.f_; return *this; }
|
||||
|
||||
bool operator ==( const this_t& l ) const { return f_ == l.f_; }
|
||||
bool operator !=( const this_t& l ) const { return f_ != l.f_; }
|
||||
|
||||
bool operator !() { return f_ == 0; }
|
||||
|
||||
Holder get_holder() const { return f_; }
|
||||
|
||||
bool test( const this_t l ) const { return (f_ & l.f_)?true:false; }
|
||||
bool test() const { return f_!=0; }
|
||||
};
|
||||
|
||||
template< typename T, int Bits, typename Holder >
|
||||
flags<T, Bits, Holder> operator ~(const flags<T, Bits, Holder>& l)
|
||||
{
|
||||
flags<T, Bits, Holder> tmp;
|
||||
tmp.f_ = ~l.f_;
|
||||
return tmp;
|
||||
}
|
||||
|
||||
template< typename T, int Bits, typename Holder >
|
||||
flags<T, Bits, Holder> operator |(const flags<T, Bits, Holder>& l, const T& r)
|
||||
{
|
||||
flags<T, Bits, Holder> tmp( r );
|
||||
return l|tmp;
|
||||
}
|
||||
|
||||
template< typename T, int Bits, typename Holder >
|
||||
flags<T, Bits, Holder> operator |(const flags<T, Bits, Holder>& l, const flags<T, Bits, Holder>& r)
|
||||
{
|
||||
flags<T, Bits, Holder> tmp( l );
|
||||
tmp|=r;
|
||||
return tmp;
|
||||
}
|
||||
|
||||
template< typename T, int Bits, typename Holder >
|
||||
flags<T, Bits, Holder> operator &(const flags<T, Bits, Holder>& l, const T& r)
|
||||
{
|
||||
flags<T, Bits, Holder> tmp( r );
|
||||
return l&tmp;
|
||||
}
|
||||
|
||||
template< typename T, int Bits, typename Holder >
|
||||
flags<T, Bits, Holder> operator &(const flags<T, Bits, Holder>& l, const flags<T, Bits, Holder>& r)
|
||||
{
|
||||
flags<T, Bits, Holder> tmp( l );
|
||||
tmp&=r;
|
||||
return tmp;
|
||||
}
|
||||
|
||||
struct map_first2second {};
|
||||
struct map_second2first {};
|
||||
|
||||
template < typename Pair, typename MapDirection = map_first2second >
|
||||
struct flag_mapper;
|
||||
|
||||
template< typename Pair >
|
||||
struct flag_mapper<Pair, map_first2second>
|
||||
{
|
||||
typedef typename Pair::first_type type;
|
||||
typedef typename Pair::second_type result_type;
|
||||
|
||||
const type& d_;
|
||||
result_type& r_;
|
||||
|
||||
flag_mapper( const type& d, result_type& r ) : d_(d), r_(r) {}
|
||||
|
||||
void operator()( const Pair& p ) const
|
||||
{
|
||||
if( (p.first&d_) == true ) r_ |= p.second;
|
||||
}
|
||||
};
|
||||
|
||||
template< typename Pair >
|
||||
struct flag_mapper<Pair, map_second2first>
|
||||
{
|
||||
typedef typename Pair::second_type type;
|
||||
typedef typename Pair::first_type result_type;
|
||||
|
||||
const type& d_;
|
||||
result_type r_;
|
||||
|
||||
flag_mapper( const type& d ) : d_(d), r_() {}
|
||||
|
||||
void operator()( const Pair& p ) const
|
||||
{
|
||||
if( (p.second&d_) == true ) r_ |= p.first;
|
||||
}
|
||||
};
|
||||
|
||||
//It is a an iterator of elements like std::pair
|
||||
template< typename It >
|
||||
typename It::value_type::second_type map(
|
||||
const typename It::value_type::first_type f,
|
||||
It first, It end )
|
||||
{
|
||||
typename It::value_type::second_type r;
|
||||
flag_mapper<typename It::value_type> m(f, r);
|
||||
std::for_each( first, end, m );
|
||||
return r;
|
||||
}
|
||||
|
||||
}; //flg
|
||||
};
|
||||
|
||||
#endif //__flags__hpp
|
||||
|
|
@ -454,15 +454,6 @@ SET(AQUARIA_SRCS
|
|||
${SRCDIR}/WorldMapTiles.cpp
|
||||
)
|
||||
|
||||
# Apparently not used at the moment. Listed here just for completeness.
|
||||
SET(AQUARIA_SRCS_UNUSED
|
||||
${SRCDIR}/BoxElement.cpp
|
||||
${SRCDIR}/BubbleRender.cpp
|
||||
${SRCDIR}/FFTNotes.cpp
|
||||
${SRCDIR}/StarRenderer.cpp
|
||||
${SRCDIR}/WaterFont.cpp
|
||||
)
|
||||
|
||||
IF(CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_GNUCXX)
|
||||
SET_SOURCE_FILES_PROPERTIES(
|
||||
# We knowingly apply offsetof to non-POD types.
|
||||
|
@ -562,24 +553,6 @@ SET(PNG_SRCS
|
|||
${PNGDIR}/pngtrans.c
|
||||
)
|
||||
|
||||
# Apparently not used at the moment. Listed here just for completeness.
|
||||
SET(BBGE_SRCS_UNUSED
|
||||
${BBGEDIR}/AnimatedSprite.cpp
|
||||
${BBGEDIR}/BloomEffect.cpp
|
||||
${BBGEDIR}/CShim.cpp
|
||||
${BBGEDIR}/Cutscene.cpp
|
||||
${BBGEDIR}/Datafile.cpp
|
||||
${BBGEDIR}/DFSprite.cpp
|
||||
${BBGEDIR}/FileVars.cpp
|
||||
${BBGEDIR}/Interpolator.cpp
|
||||
${BBGEDIR}/Light.cpp
|
||||
${BBGEDIR}/LightCone.cpp
|
||||
${BBGEDIR}/Model.cpp
|
||||
${BBGEDIR}/OggStream.cpp
|
||||
${BBGEDIR}/PackRead.cpp
|
||||
${BBGEDIR}/PointSprites.cpp
|
||||
)
|
||||
|
||||
IF(CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_GNUCXX)
|
||||
SET_SOURCE_FILES_PROPERTIES(
|
||||
${BBGEDIR}/MT.cpp
|
||||
|
|
|
@ -514,14 +514,6 @@
|
|||
RelativePath="..\..\Aquaria\UserSettings.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\Aquaria\WaterFont.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\Aquaria\WaterFont.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\Aquaria\WaterSurfaceRender.cpp"
|
||||
>
|
||||
|
|
|
@ -224,18 +224,6 @@
|
|||
RelativePath="..\..\BBGE\BitmapFont.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\BBGE\Collision.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\BBGE\Collision.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\BBGE\CommonEvents.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\BBGE\Core.cpp"
|
||||
>
|
||||
|
@ -280,14 +268,6 @@
|
|||
RelativePath="..\..\BBGE\Event.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\BBGE\Flags.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\BBGE\Flags.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\BBGE\FmodOpenALBridge.cpp"
|
||||
>
|
||||
|
@ -320,6 +300,10 @@
|
|||
RelativePath="..\..\BBGE\LensFlare.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\BBGE\LensFlare.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\BBGE\Localization.cpp"
|
||||
>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue