runtime/blitz3d: Fixup C++ification
This commit is contained in:
@@ -5,7 +5,6 @@ add_library(${PROJECT_NAME} STATIC
|
||||
"animation.hpp"
|
||||
"animator.cpp"
|
||||
"animator.hpp"
|
||||
"blitz3d.hpp"
|
||||
"brush.cpp"
|
||||
"brush.hpp"
|
||||
"cachedtexture.cpp"
|
||||
@@ -61,8 +60,6 @@ add_library(${PROJECT_NAME} STATIC
|
||||
"rendercontext.hpp"
|
||||
"sprite.cpp"
|
||||
"sprite.hpp"
|
||||
"std.cpp"
|
||||
"std.hpp"
|
||||
"surface.cpp"
|
||||
"surface.hpp"
|
||||
"terrain.cpp"
|
||||
@@ -76,11 +73,9 @@ add_library(${PROJECT_NAME} STATIC
|
||||
)
|
||||
|
||||
target_link_libraries(${PROJECT_NAME}
|
||||
PRIVATE
|
||||
config
|
||||
gxruntime
|
||||
stdutil
|
||||
PUBLIC
|
||||
config
|
||||
runtime_gfx
|
||||
stdutil
|
||||
)
|
||||
|
||||
target_include_directories(${PROJECT_NAME}
|
||||
|
||||
@@ -1,11 +1,10 @@
|
||||
|
||||
#include "animation.hpp"
|
||||
#include "std.hpp"
|
||||
#include <map>
|
||||
|
||||
struct Animation::Rep {
|
||||
int ref_cnt;
|
||||
|
||||
typedef map<int, Quat> KeyList;
|
||||
typedef std::map<int, Quat> KeyList;
|
||||
|
||||
KeyList scale_anim, rot_anim, pos_anim;
|
||||
|
||||
|
||||
@@ -1,9 +1,4 @@
|
||||
|
||||
#ifndef ANIMATION_H
|
||||
#define ANIMATION_H
|
||||
|
||||
#include <list>
|
||||
|
||||
#pragma once
|
||||
#include "geom.hpp"
|
||||
|
||||
class Animation {
|
||||
@@ -33,5 +28,3 @@ class Animation {
|
||||
|
||||
Rep* write();
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -1,7 +1,5 @@
|
||||
|
||||
#include "animator.hpp"
|
||||
#include "object.hpp"
|
||||
#include "std.hpp"
|
||||
|
||||
Animator::Animator(Animator* t) : _seqs(t->_seqs)
|
||||
{
|
||||
@@ -24,7 +22,7 @@ Animator::Animator(Object* obj, int frames)
|
||||
reset();
|
||||
}
|
||||
|
||||
Animator::Animator(const vector<Object*>& objs, int frames) : _objs(objs)
|
||||
Animator::Animator(const std::vector<Object*>& objs, int frames) : _objs(objs)
|
||||
{
|
||||
_anims.resize(_objs.size());
|
||||
addSeq(frames);
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
|
||||
#ifndef ANIMATOR_H
|
||||
#define ANIMATOR_H
|
||||
|
||||
#pragma once
|
||||
#include <vector>
|
||||
#include "animation.hpp"
|
||||
|
||||
class Object;
|
||||
@@ -14,7 +12,7 @@ class Animator {
|
||||
|
||||
Animator(Object* tree, int frames);
|
||||
|
||||
Animator(const vector<Object*>& objs, int frames);
|
||||
Animator(const std::vector<Object*>& objs, int frames);
|
||||
|
||||
void addSeq(int frames);
|
||||
|
||||
@@ -28,28 +26,28 @@ class Animator {
|
||||
|
||||
void update(float elapsed);
|
||||
|
||||
int animSeq() const
|
||||
inline int animSeq() const
|
||||
{
|
||||
return _seq;
|
||||
}
|
||||
int animLen() const
|
||||
inline int animLen() const
|
||||
{
|
||||
return _seq_len;
|
||||
}
|
||||
float animTime() const
|
||||
inline float animTime() const
|
||||
{
|
||||
return _time;
|
||||
}
|
||||
bool animating() const
|
||||
inline bool animating() const
|
||||
{
|
||||
return !!_mode;
|
||||
}
|
||||
|
||||
int numSeqs() const
|
||||
inline int numSeqs() const
|
||||
{
|
||||
return _seqs.size();
|
||||
}
|
||||
const vector<Object*>& getObjects() const
|
||||
inline const std::vector<Object*>& getObjects() const
|
||||
{
|
||||
return _objs;
|
||||
}
|
||||
@@ -61,7 +59,7 @@ class Animator {
|
||||
|
||||
struct Anim {
|
||||
//anim keys
|
||||
vector<Animation> keys;
|
||||
std::vector<Animation> keys;
|
||||
//for transitions...
|
||||
bool pos, scl, rot;
|
||||
Vector src_pos, dest_pos;
|
||||
@@ -70,10 +68,10 @@ class Animator {
|
||||
Anim() : pos(false), scl(false), rot(false) {}
|
||||
};
|
||||
|
||||
vector<Seq> _seqs;
|
||||
std::vector<Seq> _seqs;
|
||||
|
||||
vector<Anim> _anims;
|
||||
vector<Object*> _objs;
|
||||
std::vector<Anim> _anims;
|
||||
std::vector<Object*> _objs;
|
||||
|
||||
int _seq, _mode, _seq_len;
|
||||
float _time, _speed, _trans_time, _trans_speed;
|
||||
@@ -84,5 +82,3 @@ class Animator {
|
||||
void beginTrans();
|
||||
void updateTrans();
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -1,5 +0,0 @@
|
||||
|
||||
#ifndef BLITZ3D_H
|
||||
#define BLITZ3D_H
|
||||
|
||||
#endif
|
||||
@@ -1,8 +1,8 @@
|
||||
|
||||
#include "brush.hpp"
|
||||
#include "std.hpp"
|
||||
|
||||
#include "../gxruntime/gxgraphics.hpp"
|
||||
#include <gxgraphics.hpp>
|
||||
#include <gxscene.hpp>
|
||||
#include <gxcanvas.hpp>
|
||||
|
||||
struct Brush::Rep {
|
||||
union {
|
||||
|
||||
@@ -1,10 +1,9 @@
|
||||
|
||||
#ifndef BRUSH_H
|
||||
#define BRUSH_H
|
||||
|
||||
#pragma once
|
||||
#include "geom.hpp"
|
||||
#include "texture.hpp"
|
||||
|
||||
#include <gxscene.hpp>
|
||||
|
||||
class Brush {
|
||||
public:
|
||||
Brush();
|
||||
@@ -38,5 +37,3 @@ class Brush {
|
||||
|
||||
Rep* write() const;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1,23 +1,25 @@
|
||||
|
||||
#include "cachedtexture.hpp"
|
||||
#include "std.hpp"
|
||||
|
||||
#include <stdutil.hpp>
|
||||
#include <gxcanvas.hpp>
|
||||
#include <gxgraphics.hpp>
|
||||
|
||||
int active_texs;
|
||||
|
||||
extern gxRuntime* gx_runtime;
|
||||
extern gxGraphics* gx_graphics;
|
||||
|
||||
set<CachedTextureFactory::CachedTexture*> CachedTextureFactory::rep_set;
|
||||
std::set<CachedTexture::CTInstance*> CachedTexture::rep_set;
|
||||
|
||||
static string path;
|
||||
static std::string path;
|
||||
|
||||
struct CachedTextureFactory::CachedTexture {
|
||||
struct CachedTexture::CTInstance {
|
||||
int ref_cnt;
|
||||
string file;
|
||||
std::string file;
|
||||
int flags, w, h, first;
|
||||
vector<gxCanvas*> frames;
|
||||
std::vector<gxCanvas*> frames;
|
||||
|
||||
CachedTexture(int w, int h, int flags, int cnt) : ref_cnt(1), flags(flags), w(w), h(h), first(0)
|
||||
CTInstance(int w, int h, int flags, int cnt) : ref_cnt(1), flags(flags), w(w), h(h), first(0)
|
||||
{
|
||||
++active_texs;
|
||||
while (cnt-- > 0) {
|
||||
@@ -28,7 +30,7 @@ struct CachedTextureFactory::CachedTexture {
|
||||
}
|
||||
}
|
||||
|
||||
CachedTexture(const string& f, int flags, int w, int h, int first, int cnt)
|
||||
CTInstance(const std::string& f, int flags, int w, int h, int first, int cnt)
|
||||
: ref_cnt(1), file(f), flags(flags), w(w), h(h), first(first)
|
||||
{
|
||||
++active_texs;
|
||||
@@ -94,7 +96,7 @@ struct CachedTextureFactory::CachedTexture {
|
||||
gx_graphics->freeCanvas(t);
|
||||
}
|
||||
|
||||
~CachedTexture()
|
||||
~CTInstance()
|
||||
{
|
||||
--active_texs;
|
||||
for (int k = 0; k < frames.size(); ++k)
|
||||
@@ -102,12 +104,11 @@ struct CachedTextureFactory::CachedTexture {
|
||||
}
|
||||
};
|
||||
|
||||
CachedTextureFactory::CachedTexture* CachedTextureFactory::findRep(const string& f, int flags, int w, int h, int first,
|
||||
int cnt)
|
||||
CachedTexture::CTInstance* CachedTexture::findRep(const std::string& f, int flags, int w, int h, int first, int cnt)
|
||||
{
|
||||
set<CachedTexture*>::const_iterator it;
|
||||
std::set<CTInstance*>::const_iterator it;
|
||||
for (it = rep_set.begin(); it != rep_set.end(); ++it) {
|
||||
CachedTexture* rep = *it;
|
||||
CTInstance* rep = *it;
|
||||
if (rep->file == f && rep->flags == flags && rep->w == w && rep->h == h && rep->first == first
|
||||
&& rep->frames.size() == cnt) {
|
||||
++rep->ref_cnt;
|
||||
@@ -117,38 +118,37 @@ CachedTextureFactory::CachedTexture* CachedTextureFactory::findRep(const string&
|
||||
return 0;
|
||||
}
|
||||
|
||||
CachedTextureFactory::CachedTextureFactory(int w, int h, int flags, int cnt) : rep(new CachedTexture(w, h, flags, cnt))
|
||||
{}
|
||||
CachedTexture::CachedTexture(int w, int h, int flags, int cnt) : rep(new CTInstance(w, h, flags, cnt)) {}
|
||||
|
||||
CachedTextureFactory::CachedTextureFactory(const string& f_, int flags, int w, int h, int first, int cnt)
|
||||
CachedTexture::CachedTexture(const std::string& f_, int flags, int w, int h, int first, int cnt)
|
||||
{
|
||||
string f = f_;
|
||||
std::string f = f_;
|
||||
if (f.substr(0, 2) == ".\\")
|
||||
f = f.substr(2);
|
||||
if (path.size()) {
|
||||
string t = path + tolower(filenamefile(f));
|
||||
std::string t = path + tolower(filenamefile(f));
|
||||
if (rep = findRep(t, flags, w, h, first, cnt))
|
||||
return;
|
||||
rep = new CachedTexture(t, flags, w, h, first, cnt);
|
||||
rep = new CTInstance(t, flags, w, h, first, cnt);
|
||||
if (rep->frames.size()) {
|
||||
rep_set.insert(rep);
|
||||
return;
|
||||
}
|
||||
delete rep;
|
||||
}
|
||||
string t = tolower(fullfilename(f));
|
||||
std::string t = tolower(fullfilename(f));
|
||||
if (rep = findRep(t, flags, w, h, first, cnt))
|
||||
return;
|
||||
rep = new CachedTexture(t, flags, w, h, first, cnt);
|
||||
rep = new CTInstance(t, flags, w, h, first, cnt);
|
||||
rep_set.insert(rep);
|
||||
}
|
||||
|
||||
CachedTextureFactory::CachedTextureFactory(const CachedTextureFactory& t) : rep(t.rep)
|
||||
CachedTexture::CachedTexture(const CachedTexture& t) : rep(t.rep)
|
||||
{
|
||||
++rep->ref_cnt;
|
||||
}
|
||||
|
||||
CachedTextureFactory::~CachedTextureFactory()
|
||||
CachedTexture::~CachedTexture()
|
||||
{
|
||||
if (!--rep->ref_cnt) {
|
||||
rep_set.erase(rep);
|
||||
@@ -156,7 +156,7 @@ CachedTextureFactory::~CachedTextureFactory()
|
||||
}
|
||||
}
|
||||
|
||||
CachedTextureFactory& CachedTextureFactory::operator=(const CachedTextureFactory& t)
|
||||
CachedTexture& CachedTexture::operator=(const CachedTexture& t)
|
||||
{
|
||||
++t.rep->ref_cnt;
|
||||
if (!--rep->ref_cnt) {
|
||||
@@ -167,17 +167,17 @@ CachedTextureFactory& CachedTextureFactory::operator=(const CachedTextureFactory
|
||||
return *this;
|
||||
}
|
||||
|
||||
string CachedTextureFactory::getName() const
|
||||
std::string CachedTexture::getName() const
|
||||
{
|
||||
return rep->file;
|
||||
}
|
||||
|
||||
const vector<gxCanvas*>& CachedTextureFactory::getFrames() const
|
||||
const std::vector<gxCanvas*>& CachedTexture::getFrames() const
|
||||
{
|
||||
return rep->frames;
|
||||
}
|
||||
|
||||
void CachedTextureFactory::setPath(const string& t)
|
||||
void CachedTexture::setPath(const std::string& t)
|
||||
{
|
||||
path = tolower(t);
|
||||
if (int sz = path.size()) {
|
||||
|
||||
@@ -1,36 +1,35 @@
|
||||
#pragma once
|
||||
#include <set>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#ifndef CACHEDTEXTURE_H
|
||||
#define CACHEDTEXTURE_H
|
||||
class gxCanvas;
|
||||
|
||||
#include "gxcanvas.hpp"
|
||||
|
||||
class CachedTextureFactory {
|
||||
class CachedTexture {
|
||||
public:
|
||||
CachedTextureFactory(int w, int h, int flags, int cnt);
|
||||
CachedTextureFactory(const string& f, int flags, int w, int h, int first, int cnt);
|
||||
CachedTextureFactory(const CachedTextureFactory& t);
|
||||
~CachedTextureFactory();
|
||||
CachedTexture(int w, int h, int flags, int cnt);
|
||||
CachedTexture(const std::string& f, int flags, int w, int h, int first, int cnt);
|
||||
CachedTexture(const CachedTexture& t);
|
||||
~CachedTexture();
|
||||
|
||||
CachedTextureFactory& operator=(const CachedTextureFactory& t);
|
||||
CachedTexture& operator=(const CachedTexture& t);
|
||||
|
||||
string getName() const;
|
||||
std::string getName() const;
|
||||
|
||||
const vector<gxCanvas*>& getFrames() const;
|
||||
const std::vector<gxCanvas*>& getFrames() const;
|
||||
|
||||
bool operator<(const CachedTextureFactory& t) const
|
||||
bool operator<(const CachedTexture& t) const
|
||||
{
|
||||
return rep < t.rep;
|
||||
}
|
||||
|
||||
static void setPath(const string& t);
|
||||
static void setPath(const std::string& t);
|
||||
|
||||
private:
|
||||
struct CachedTexture;
|
||||
CachedTexture* rep;
|
||||
struct CTInstance;
|
||||
CTInstance* rep;
|
||||
|
||||
CachedTexture* findRep(const string& f, int flags, int w, int h, int first, int cnt);
|
||||
CTInstance* findRep(const std::string& f, int flags, int w, int h, int first, int cnt);
|
||||
|
||||
static set<CachedTexture*> rep_set;
|
||||
static std::set<CTInstance*> rep_set;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
|
||||
#include "camera.hpp"
|
||||
#include "std.hpp"
|
||||
|
||||
#include <gxscene.hpp>
|
||||
|
||||
extern gxScene* gx_scene;
|
||||
|
||||
|
||||
@@ -1,7 +1,4 @@
|
||||
|
||||
#ifndef CAMERA_H
|
||||
#define CAMERA_H
|
||||
|
||||
#pragma once
|
||||
#include "frustum.hpp"
|
||||
#include "mirror.hpp"
|
||||
#include "model.hpp"
|
||||
@@ -56,5 +53,3 @@ class Camera : public Object {
|
||||
mutable Frustum local_frustum;
|
||||
mutable bool local_valid;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
|
||||
#include "collision.hpp"
|
||||
#include "std.hpp"
|
||||
|
||||
#include <gxruntime.hpp>
|
||||
|
||||
const float COLLISION_FLT_EPSILON = .001f;
|
||||
|
||||
|
||||
@@ -1,7 +1,4 @@
|
||||
|
||||
#ifndef COLLISION_H
|
||||
#define COLLISION_H
|
||||
|
||||
#pragma once
|
||||
#include "geom.hpp"
|
||||
|
||||
extern const float COLLISION_FLT_EPSILON;
|
||||
@@ -23,5 +20,3 @@ struct Collision {
|
||||
|
||||
bool boxCollide(const Line& src_line, float src_radius, const Box& box);
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -1,8 +1,4 @@
|
||||
|
||||
#include "entity.hpp"
|
||||
#include "std.hpp"
|
||||
|
||||
//#include "stats.hpp"
|
||||
|
||||
Entity *Entity::_orphans, *Entity::_last_orphan;
|
||||
|
||||
@@ -119,7 +115,7 @@ void Entity::SetParent(Entity* p)
|
||||
InvalidateWorldTransform();
|
||||
}
|
||||
|
||||
void Entity::SetName(const string& t)
|
||||
void Entity::SetName(const std::string& t)
|
||||
{
|
||||
m_name = t;
|
||||
}
|
||||
|
||||
@@ -1,9 +1,5 @@
|
||||
|
||||
#ifndef ENTITY_H
|
||||
#define ENTITY_H
|
||||
|
||||
#pragma once
|
||||
#include <list>
|
||||
|
||||
#include "geom.hpp"
|
||||
|
||||
class Entity;
|
||||
@@ -132,5 +128,3 @@ class Entity {
|
||||
void invalidateLocal();
|
||||
void InvalidateWorldTransform();
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
|
||||
#include "frustum.hpp"
|
||||
#include "std.hpp"
|
||||
|
||||
Frustum::Frustum() {}
|
||||
|
||||
|
||||
@@ -1,7 +1,4 @@
|
||||
|
||||
#ifndef FRUSTUM_H
|
||||
#define FRUSTUM_H
|
||||
|
||||
#pragma once
|
||||
#include "geom.hpp"
|
||||
|
||||
class Frustum {
|
||||
@@ -39,5 +36,3 @@ class Frustum {
|
||||
Vector verts[9];
|
||||
void makePlanes();
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -1,6 +1,4 @@
|
||||
|
||||
#include "geom.hpp"
|
||||
#include "std.hpp"
|
||||
|
||||
Matrix Matrix::tmps[64];
|
||||
Transform Transform::tmps[64];
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
|
||||
#ifndef GEOM_H
|
||||
#define GEOM_H
|
||||
|
||||
#include <math.h>
|
||||
#pragma once
|
||||
#include <cmath>
|
||||
#include <cfloat>
|
||||
|
||||
class Vector;
|
||||
class Line;
|
||||
@@ -738,5 +736,3 @@ inline Quat matrixQuat(const Matrix& p)
|
||||
}
|
||||
return Quat(w, Vector(x, y, z));
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -1,7 +1,7 @@
|
||||
|
||||
#include "light.hpp"
|
||||
#include "../gxruntime/gxscene.hpp"
|
||||
#include "std.hpp"
|
||||
|
||||
#include <gxscene.hpp>
|
||||
#include <gxlight.hpp>
|
||||
|
||||
extern gxScene* gx_scene;
|
||||
|
||||
|
||||
@@ -1,12 +1,9 @@
|
||||
|
||||
#ifndef LIGHT_H
|
||||
#define LIGHT_H
|
||||
|
||||
#pragma once
|
||||
#include "geom.hpp"
|
||||
#include "gxlight.hpp"
|
||||
#include "object.hpp"
|
||||
|
||||
class World;
|
||||
class gxLight;
|
||||
|
||||
class Light : public Object {
|
||||
public:
|
||||
@@ -33,5 +30,3 @@ class Light : public Object {
|
||||
friend class World;
|
||||
gxLight* light;
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -1,6 +1,6 @@
|
||||
|
||||
#include "listener.hpp"
|
||||
#include "std.hpp"
|
||||
|
||||
#include <gxaudio.hpp>
|
||||
|
||||
extern gxAudio* gx_audio;
|
||||
|
||||
|
||||
@@ -1,7 +1,4 @@
|
||||
|
||||
#ifndef LISTENER_H
|
||||
#define LISTENER_H
|
||||
|
||||
#pragma once
|
||||
#include "object.hpp"
|
||||
|
||||
class Listener : public Object {
|
||||
@@ -25,5 +22,3 @@ class Listener : public Object {
|
||||
|
||||
private:
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -1,8 +1,10 @@
|
||||
|
||||
#include "loader_3ds.hpp"
|
||||
#include "animation.hpp"
|
||||
#include "meshmodel.hpp"
|
||||
#include "std.hpp"
|
||||
#include "animator.hpp"
|
||||
#include <fstream>
|
||||
|
||||
#include <gxruntime.hpp>
|
||||
|
||||
extern gxRuntime* gx_runtime;
|
||||
|
||||
@@ -14,9 +16,9 @@ extern gxRuntime* gx_runtime;
|
||||
|
||||
class Box;
|
||||
|
||||
static filebuf in;
|
||||
static std::filebuf in;
|
||||
static int chunk_end;
|
||||
static vector<int> parent_end;
|
||||
static std::vector<int> parent_end;
|
||||
static unsigned short anim_len;
|
||||
|
||||
static bool conv, flip_tris;
|
||||
@@ -28,30 +30,30 @@ struct Face3DS {
|
||||
Brush brush;
|
||||
};
|
||||
|
||||
static vector<Face3DS> faces;
|
||||
static std::vector<Face3DS> faces;
|
||||
//static vector<Surface::Vertex> vertices;
|
||||
|
||||
static map<string, Brush> materials_map;
|
||||
static map<string, MeshModel*> name_map;
|
||||
static map<int, MeshModel*> id_map;
|
||||
static std::map<std::string, Brush> materials_map;
|
||||
static std::map<std::string, MeshModel*> name_map;
|
||||
static std::map<int, MeshModel*> id_map;
|
||||
|
||||
static int nextChunk()
|
||||
{
|
||||
in.pubseekoff(chunk_end, ios_base::beg);
|
||||
in.pubseekoff(chunk_end, std::ios_base::beg);
|
||||
if (chunk_end == parent_end.back())
|
||||
return 0;
|
||||
unsigned short id;
|
||||
int len;
|
||||
in.sgetn((char*)&id, 2);
|
||||
in.sgetn((char*)&len, 4);
|
||||
chunk_end = (int)in.pubseekoff(0, ios_base::cur) + len - 6;
|
||||
chunk_end = (int)in.pubseekoff(0, std::ios_base::cur) + len - 6;
|
||||
return id;
|
||||
}
|
||||
|
||||
static void enterChunk()
|
||||
{
|
||||
parent_end.push_back(chunk_end);
|
||||
chunk_end = (int)in.pubseekoff(0, ios_base::cur);
|
||||
chunk_end = (int)in.pubseekoff(0, std::ios_base::cur);
|
||||
}
|
||||
|
||||
static void leaveChunk()
|
||||
@@ -60,9 +62,9 @@ static void leaveChunk()
|
||||
parent_end.pop_back();
|
||||
}
|
||||
|
||||
static string parseString()
|
||||
static std::string parseString()
|
||||
{
|
||||
string t;
|
||||
std::string t;
|
||||
while (int c = in.sbumpc())
|
||||
t += char(c);
|
||||
return t;
|
||||
@@ -137,7 +139,7 @@ static void parseVertList()
|
||||
|
||||
static void parseFaceMat()
|
||||
{
|
||||
string name = parseString();
|
||||
std::string name = parseString();
|
||||
_log("FaceMat: " + name);
|
||||
Brush mat = materials_map[name];
|
||||
unsigned short cnt;
|
||||
@@ -256,7 +258,7 @@ static void parseTriMesh(MeshModel* mesh)
|
||||
static void parseObject(MeshModel* root)
|
||||
{
|
||||
//skip name
|
||||
string name = parseString();
|
||||
std::string name = parseString();
|
||||
_log("Object:" + name);
|
||||
MeshModel* mesh = 0;
|
||||
|
||||
@@ -279,7 +281,7 @@ static void parseMaterial()
|
||||
{
|
||||
_log("Material");
|
||||
Brush mat;
|
||||
string name, tex_name;
|
||||
std::string name, tex_name;
|
||||
enterChunk();
|
||||
while (int id = nextChunk()) {
|
||||
switch (id) {
|
||||
@@ -339,9 +341,9 @@ static void parseAnimKeys(Animation* anim, int type)
|
||||
int cnt = 0;
|
||||
short t_flags;
|
||||
in.sgetn((char*)&t_flags, 2);
|
||||
in.pubseekoff(8, ios_base::cur);
|
||||
in.pubseekoff(8, std::ios_base::cur);
|
||||
in.sgetn((char*)&cnt, 2);
|
||||
in.pubseekoff(2, ios_base::cur);
|
||||
in.pubseekoff(2, std::ios_base::cur);
|
||||
_log("ANIM_TRACK: frames=" + itoa(cnt));
|
||||
Vector pos, axis, scale;
|
||||
float angle;
|
||||
@@ -403,7 +405,7 @@ static void parseMeshInfo(MeshModel* root, float curr_time)
|
||||
{
|
||||
_log("OBJECT_NODE_TAG");
|
||||
enterChunk();
|
||||
string name, inst;
|
||||
std::string name, inst;
|
||||
Vector pivot;
|
||||
Animation anim;
|
||||
unsigned short id = 65535, parent = 65535, flags1, flags2;
|
||||
@@ -453,7 +455,7 @@ static void parseMeshInfo(MeshModel* root, float curr_time)
|
||||
|
||||
MeshModel* p = root;
|
||||
if (parent != 65535) {
|
||||
map<int, MeshModel*>::const_iterator it = id_map.find(parent);
|
||||
std::map<int, MeshModel*>::const_iterator it = id_map.find(parent);
|
||||
if (it == id_map.end())
|
||||
return;
|
||||
p = it->second;
|
||||
@@ -464,7 +466,7 @@ static void parseMeshInfo(MeshModel* root, float curr_time)
|
||||
mesh->SetName(inst);
|
||||
mesh->SetParent(p);
|
||||
} else {
|
||||
map<string, MeshModel*>::const_iterator it = name_map.find(name);
|
||||
std::map<std::string, MeshModel*>::const_iterator it = name_map.find(name);
|
||||
if (it == name_map.end())
|
||||
return;
|
||||
mesh = it->second;
|
||||
@@ -487,7 +489,7 @@ static void parseKeyFramer(MeshModel* root)
|
||||
{
|
||||
_log("KeyFramer");
|
||||
enterChunk();
|
||||
string file_3ds;
|
||||
std::string file_3ds;
|
||||
unsigned short rev, curr_time = 0;
|
||||
while (int id = nextChunk()) {
|
||||
switch (id) {
|
||||
@@ -522,7 +524,7 @@ static MeshModel* parseFile()
|
||||
in.sgetn((char*)&len, 4);
|
||||
if (id != CHUNK_MAIN)
|
||||
return 0;
|
||||
chunk_end = (int)in.pubseekoff(0, ios_base::cur) + len - 6;
|
||||
chunk_end = (int)in.pubseekoff(0, std::ios_base::cur) + len - 6;
|
||||
|
||||
enterChunk();
|
||||
MeshModel* root = new MeshModel();
|
||||
@@ -540,7 +542,7 @@ static MeshModel* parseFile()
|
||||
return root;
|
||||
}
|
||||
|
||||
MeshModel* Loader_3DS::load(const string& filename, const Transform& t, int hint)
|
||||
MeshModel* Loader_3DS::load(const std::string& filename, const Transform& t, int hint)
|
||||
{
|
||||
conv_tform = t;
|
||||
conv = flip_tris = false;
|
||||
@@ -553,7 +555,7 @@ MeshModel* Loader_3DS::load(const string& filename, const Transform& t, int hint
|
||||
collapse = !!(hint & MeshLoader::HINT_COLLAPSE);
|
||||
animonly = !!(hint & MeshLoader::HINT_ANIMONLY);
|
||||
|
||||
if (!in.open(filename.c_str(), ios_base::in | ios_base::binary)) {
|
||||
if (!in.open(filename.c_str(), std::ios_base::in | std::ios_base::binary)) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,12 +1,7 @@
|
||||
|
||||
#ifndef LOADER_3DS_H
|
||||
#define LOADER_3DS_H
|
||||
|
||||
#pragma once
|
||||
#include "meshloader.hpp"
|
||||
|
||||
class Loader_3DS : public MeshLoader {
|
||||
public:
|
||||
MeshModel* load(const string& f, const Transform& conv, int hint);
|
||||
MeshModel* load(const std::string& f, const Transform& conv, int hint);
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -1,17 +1,16 @@
|
||||
|
||||
#include "loader_b3d.hpp"
|
||||
#include "meshmodel.hpp"
|
||||
#include "meshutil.hpp"
|
||||
#include "pivot.hpp"
|
||||
#include "std.hpp"
|
||||
#include "animator.hpp"
|
||||
|
||||
//#define SHOW_BONES
|
||||
|
||||
static FILE* in;
|
||||
static vector<int> chunk_stack;
|
||||
static vector<Texture> textures;
|
||||
static vector<Brush> brushes;
|
||||
static vector<Object*> bones;
|
||||
static std::vector<int> chunk_stack;
|
||||
static std::vector<Texture> textures;
|
||||
static std::vector<Brush> brushes;
|
||||
static std::vector<Object*> bones;
|
||||
|
||||
static bool collapse;
|
||||
static bool animonly;
|
||||
@@ -108,9 +107,9 @@ static void readColor(unsigned* t)
|
||||
*t = (int(a * 255) << 24) | (int(r * 255) << 16) | (int(g * 255) << 8) | int(b * 255);
|
||||
}
|
||||
|
||||
static string readString()
|
||||
static std::string readString()
|
||||
{
|
||||
string t;
|
||||
std::string t;
|
||||
for (;;) {
|
||||
char c;
|
||||
read(&c, 1);
|
||||
@@ -123,7 +122,7 @@ static string readString()
|
||||
static void readTextures()
|
||||
{
|
||||
while (chunkSize()) {
|
||||
string name = readString();
|
||||
std::string name = readString();
|
||||
int flags = readInt();
|
||||
int blend = readInt();
|
||||
float pos[2], scl[2];
|
||||
@@ -156,7 +155,7 @@ static void readBrushes()
|
||||
int tex_id[8] = {-1, -1, -1, -1, -1, -1, -1, -1};
|
||||
|
||||
while (chunkSize()) {
|
||||
string name = readString();
|
||||
std::string name = readString();
|
||||
float col[4];
|
||||
readFloatArray(col, 4);
|
||||
float shi = readFloat();
|
||||
@@ -291,7 +290,7 @@ static Object* readObject(Object* parent)
|
||||
{
|
||||
Object* obj = 0;
|
||||
|
||||
string name = readString();
|
||||
std::string name = readString();
|
||||
float pos[3], scl[3], rot[4];
|
||||
readFloatArray(pos, 3);
|
||||
readFloatArray(scl, 3);
|
||||
@@ -362,7 +361,7 @@ static Object* readObject(Object* parent)
|
||||
return obj;
|
||||
}
|
||||
|
||||
MeshModel* Loader_B3D::load(const string& f, const Transform& conv, int hint)
|
||||
MeshModel* Loader_B3D::load(const std::string& f, const Transform& conv, int hint)
|
||||
{
|
||||
collapse = !!(hint & MeshLoader::HINT_COLLAPSE);
|
||||
animonly = !!(hint & MeshLoader::HINT_ANIMONLY);
|
||||
|
||||
@@ -1,12 +1,8 @@
|
||||
|
||||
#ifndef LOADER_B3D_H
|
||||
#define LOADER_B3D_H
|
||||
|
||||
#pragma once
|
||||
#include "meshloader.hpp"
|
||||
#include <string>
|
||||
|
||||
class Loader_B3D : public MeshLoader {
|
||||
public:
|
||||
MeshModel* load(const string& f, const Transform& conv, int hint);
|
||||
MeshModel* load(const std::string& f, const Transform& conv, int hint);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1,15 +1,14 @@
|
||||
|
||||
#include "md2model.hpp"
|
||||
#include "md2rep.hpp"
|
||||
#include "std.hpp"
|
||||
#include "animator.hpp"
|
||||
|
||||
struct MD2Model::Rep : public MD2Rep {
|
||||
int ref_cnt;
|
||||
|
||||
Rep(const string& f) : MD2Rep(f), ref_cnt(1) {}
|
||||
Rep(const std::string& f) : MD2Rep(f), ref_cnt(1) {}
|
||||
};
|
||||
|
||||
MD2Model::MD2Model(const string& f)
|
||||
MD2Model::MD2Model(const std::string& f)
|
||||
: rep(new Rep(f)), anim_mode(0), anim_time(0), render_a(0), render_b(0), render_t(0), trans_verts(0)
|
||||
{}
|
||||
|
||||
|
||||
@@ -1,13 +1,11 @@
|
||||
|
||||
#ifndef MD2MODEL_H
|
||||
#define MD2MODEL_H
|
||||
|
||||
#pragma once
|
||||
#include "md2rep.hpp"
|
||||
#include "model.hpp"
|
||||
#include <string>
|
||||
|
||||
class MD2Model : public Model {
|
||||
public:
|
||||
MD2Model(const string& filename);
|
||||
MD2Model(const std::string& filename);
|
||||
MD2Model(const MD2Model& t);
|
||||
~MD2Model();
|
||||
|
||||
@@ -59,5 +57,3 @@ class MD2Model : public Model {
|
||||
//Unimplemented
|
||||
MD2Model& operator=(const MD2Model&);
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -1,6 +1,4 @@
|
||||
|
||||
#include "md2norms.hpp"
|
||||
#include "std.hpp"
|
||||
|
||||
float md2norms[162][3] = {
|
||||
{-0.525731f, 0.000000f, 0.850651f}, {-0.442863f, 0.238856f, 0.864188f}, {-0.295242f, 0.000000f, 0.955423f},
|
||||
|
||||
@@ -1,7 +1,2 @@
|
||||
|
||||
#ifndef MD2NORMS_H
|
||||
#define MD2NORMS_H
|
||||
|
||||
#pragma once
|
||||
extern float md2norms[162][3];
|
||||
|
||||
#endif
|
||||
+14
-12
@@ -1,7 +1,9 @@
|
||||
|
||||
#include "md2rep.hpp"
|
||||
#include "md2norms.hpp"
|
||||
#include "std.hpp"
|
||||
#include <fstream>
|
||||
|
||||
#include <gxruntime.hpp>
|
||||
#include <gxgraphics.hpp>
|
||||
|
||||
extern gxRuntime* gx_runtime;
|
||||
extern gxGraphics* gx_graphics;
|
||||
@@ -57,12 +59,12 @@ struct t_tri {
|
||||
unsigned short verts[3];
|
||||
};
|
||||
|
||||
MD2Rep::MD2Rep(const string& f) : mesh(0), n_verts(0), n_tris(0), n_frames(0)
|
||||
MD2Rep::MD2Rep(const std::string& f) : mesh(0), n_verts(0), n_tris(0), n_frames(0)
|
||||
{
|
||||
filebuf in;
|
||||
std::filebuf in;
|
||||
md2_header header;
|
||||
|
||||
if (!in.open(f.c_str(), ios_base::in | ios_base::binary))
|
||||
if (!in.open(f.c_str(), std::ios_base::in | std::ios_base::binary))
|
||||
return;
|
||||
if (in.sgetn((char*)&header, sizeof(header)) != sizeof(header))
|
||||
return;
|
||||
@@ -73,20 +75,20 @@ MD2Rep::MD2Rep(const string& f) : mesh(0), n_verts(0), n_tris(0), n_frames(0)
|
||||
n_tris = header.numTriangles;
|
||||
|
||||
//read in tex coords
|
||||
vector<md2_uv> md2_uvs;
|
||||
std::vector<md2_uv> md2_uvs;
|
||||
md2_uvs.resize(header.numTexCoords);
|
||||
in.pubseekpos(header.offsetTexCoords);
|
||||
in.sgetn((char*)(&md2_uvs.begin()[0]), header.numTexCoords * sizeof(md2_uv));
|
||||
|
||||
//read in triangles
|
||||
vector<md2_tri> md2_tris;
|
||||
std::vector<md2_tri> md2_tris;
|
||||
md2_tris.resize(n_tris);
|
||||
in.pubseekpos(header.offsetTriangles);
|
||||
in.sgetn((char*)(&md2_tris.begin()[0]), n_tris * sizeof(md2_tri));
|
||||
|
||||
vector<t_tri> t_tris;
|
||||
vector<t_vert> t_verts;
|
||||
map<t_vert, int> t_map;
|
||||
std::vector<t_tri> t_tris;
|
||||
std::vector<t_vert> t_verts;
|
||||
std::map<t_vert, int> t_map;
|
||||
|
||||
int k;
|
||||
for (k = 0; k < n_tris; ++k) {
|
||||
@@ -95,7 +97,7 @@ MD2Rep::MD2Rep(const string& f) : mesh(0), n_verts(0), n_tris(0), n_frames(0)
|
||||
t_vert t;
|
||||
t.i = md2_tris[k].verts[j];
|
||||
t.uv = md2_tris[k].uvs[j];
|
||||
map<t_vert, int>::iterator it = t_map.find(t);
|
||||
std::map<t_vert, int>::iterator it = t_map.find(t);
|
||||
if (it == t_map.end()) {
|
||||
//create new vert
|
||||
tr.verts[j] = t_map[t] = t_verts.size();
|
||||
@@ -117,7 +119,7 @@ MD2Rep::MD2Rep(const string& f) : mesh(0), n_verts(0), n_tris(0), n_frames(0)
|
||||
frames.resize(n_frames);
|
||||
in.pubseekpos(header.offsetFrames);
|
||||
|
||||
vector<md2_vert> md2_verts;
|
||||
std::vector<md2_vert> md2_verts;
|
||||
md2_verts.resize(header.numVertices);
|
||||
|
||||
//read in frames
|
||||
|
||||
@@ -1,8 +1,7 @@
|
||||
|
||||
#ifndef MD2REP_H
|
||||
#define MD2REP_H
|
||||
|
||||
#pragma once
|
||||
#include "model.hpp"
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
class MD2Rep {
|
||||
public:
|
||||
@@ -10,7 +9,7 @@ class MD2Rep {
|
||||
Vector coords, normal;
|
||||
};
|
||||
|
||||
MD2Rep(const string& f);
|
||||
MD2Rep(const std::string& f);
|
||||
virtual ~MD2Rep();
|
||||
|
||||
void render(Vert* verts, int frame);
|
||||
@@ -46,15 +45,13 @@ class MD2Rep {
|
||||
|
||||
struct Frame {
|
||||
Vector scale, trans;
|
||||
vector<Vertex> verts;
|
||||
std::vector<Vertex> verts;
|
||||
};
|
||||
|
||||
Box box;
|
||||
gxMesh* mesh;
|
||||
int n_frames;
|
||||
int n_verts, n_tris;
|
||||
vector<Frame> frames;
|
||||
vector<VertexUV> uvs;
|
||||
std::vector<Frame> frames;
|
||||
std::vector<VertexUV> uvs;
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -1,9 +1,10 @@
|
||||
|
||||
#include "meshcollider.hpp"
|
||||
#include "std.hpp"
|
||||
#include <map>
|
||||
|
||||
#include <gxruntime.hpp>
|
||||
|
||||
static const int MAX_COLL_TRIS = 16;
|
||||
static vector<Vector> tri_centres;
|
||||
static std::vector<Vector> tri_centres;
|
||||
|
||||
extern float stats3d[10];
|
||||
|
||||
@@ -47,9 +48,10 @@ static bool trisIntersect(const Vector a[3], const Vector b[3])
|
||||
return triTest(a, b) || triTest(b, a);
|
||||
}
|
||||
|
||||
MeshCollider::MeshCollider(const vector<Vertex>& verts, const vector<Triangle>& tris) : vertices(verts), triangles(tris)
|
||||
MeshCollider::MeshCollider(const std::vector<Vertex>& verts, const std::vector<Triangle>& tris)
|
||||
: vertices(verts), triangles(tris)
|
||||
{
|
||||
vector<int> ts;
|
||||
std::vector<int> ts;
|
||||
tri_centres.clear();
|
||||
for (int k = 0; k < triangles.size(); ++k) {
|
||||
const MeshCollider::Triangle& t = triangles[k];
|
||||
@@ -122,7 +124,7 @@ bool MeshCollider::collide(const Box& line_box, const Line& line, float radius,
|
||||
return hit;
|
||||
}
|
||||
|
||||
Box MeshCollider::nodeBox(const vector<int>& tris)
|
||||
Box MeshCollider::nodeBox(const std::vector<int>& tris)
|
||||
{
|
||||
Box box;
|
||||
for (int k = 0; k < tris.size(); ++k) {
|
||||
@@ -133,7 +135,7 @@ Box MeshCollider::nodeBox(const vector<int>& tris)
|
||||
return box;
|
||||
}
|
||||
|
||||
MeshCollider::Node* MeshCollider::createLeaf(const vector<int>& tris)
|
||||
MeshCollider::Node* MeshCollider::createLeaf(const std::vector<int>& tris)
|
||||
{
|
||||
Node* c = new Node;
|
||||
c->box = nodeBox(tris);
|
||||
@@ -142,7 +144,7 @@ MeshCollider::Node* MeshCollider::createLeaf(const vector<int>& tris)
|
||||
return c;
|
||||
}
|
||||
|
||||
MeshCollider::Node* MeshCollider::createNode(const vector<int>& tris)
|
||||
MeshCollider::Node* MeshCollider::createNode(const std::vector<int>& tris)
|
||||
{
|
||||
if (tris.size() <= MAX_COLL_TRIS)
|
||||
return createLeaf(tris);
|
||||
@@ -166,16 +168,16 @@ MeshCollider::Node* MeshCollider::createNode(const vector<int>& tris)
|
||||
//sort by axis
|
||||
//
|
||||
int k;
|
||||
multimap<float, int> axis_map;
|
||||
std::multimap<float, int> axis_map;
|
||||
for (k = 0; k < tris.size(); ++k) {
|
||||
pair<float, int> p(tri_centres[tris[k]][axis], tris[k]);
|
||||
std::pair<float, int> p(tri_centres[tris[k]][axis], tris[k]);
|
||||
axis_map.insert(p);
|
||||
}
|
||||
|
||||
//generate left node
|
||||
//
|
||||
vector<int> new_tris;
|
||||
multimap<float, int>::iterator it = axis_map.begin();
|
||||
std::vector<int> new_tris;
|
||||
std::multimap<float, int>::iterator it = axis_map.begin();
|
||||
for (k = axis_map.size() / 2; k--; ++it) {
|
||||
new_tris.push_back(it->second);
|
||||
}
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
|
||||
#ifndef MESHCOLLIDER_H
|
||||
#define MESHCOLLIDER_H
|
||||
|
||||
#pragma once
|
||||
#include <vector>
|
||||
#include "collision.hpp"
|
||||
|
||||
class MeshCollider {
|
||||
@@ -13,7 +11,7 @@ class MeshCollider {
|
||||
void* surface;
|
||||
int verts[3], index;
|
||||
};
|
||||
MeshCollider(const vector<Vertex>& verts, const vector<Triangle>& tris);
|
||||
MeshCollider(const std::vector<Vertex>& verts, const std::vector<Triangle>& tris);
|
||||
~MeshCollider();
|
||||
|
||||
//sphere collision
|
||||
@@ -22,13 +20,13 @@ class MeshCollider {
|
||||
bool intersects(const MeshCollider& c, const Transform& t) const;
|
||||
|
||||
private:
|
||||
vector<Vertex> vertices;
|
||||
vector<Triangle> triangles;
|
||||
std::vector<Vertex> vertices;
|
||||
std::vector<Triangle> triangles;
|
||||
|
||||
struct Node {
|
||||
Box box;
|
||||
Node * left, *right;
|
||||
vector<int> triangles;
|
||||
std::vector<int> triangles;
|
||||
Node() : left(0), right(0) {}
|
||||
~Node()
|
||||
{
|
||||
@@ -38,13 +36,11 @@ class MeshCollider {
|
||||
};
|
||||
|
||||
Node* tree;
|
||||
vector<Node*> leaves;
|
||||
std::vector<Node*> leaves;
|
||||
|
||||
Box nodeBox(const vector<int>& tris);
|
||||
Node* createLeaf(const vector<int>& tris);
|
||||
Node* createNode(const vector<int>& tris);
|
||||
Box nodeBox(const std::vector<int>& tris);
|
||||
Node* createLeaf(const std::vector<int>& tris);
|
||||
Node* createNode(const std::vector<int>& tris);
|
||||
bool collide(const Box& box, const Line& line, float radius, const Transform& tform, Collision* curr_coll,
|
||||
Node* node);
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -1,25 +1,23 @@
|
||||
|
||||
#include "meshloader.hpp"
|
||||
#include "meshmodel.hpp"
|
||||
#include "std.hpp"
|
||||
|
||||
struct Tri {
|
||||
int verts[3];
|
||||
};
|
||||
|
||||
struct Surf {
|
||||
vector<Tri> tris;
|
||||
std::vector<Tri> tris;
|
||||
};
|
||||
|
||||
struct MLMesh {
|
||||
map<Brush, Surf*> brush_map;
|
||||
vector<Surface::Vertex> verts;
|
||||
std::map<Brush, Surf*> brush_map;
|
||||
std::vector<Surface::Vertex> verts;
|
||||
|
||||
MLMesh() {}
|
||||
|
||||
~MLMesh()
|
||||
{
|
||||
map<Brush, Surf*>::const_iterator it;
|
||||
std::map<Brush, Surf*>::const_iterator it;
|
||||
for (it = brush_map.begin(); it != brush_map.end(); ++it) {
|
||||
delete it->second;
|
||||
}
|
||||
@@ -27,7 +25,7 @@ struct MLMesh {
|
||||
};
|
||||
|
||||
static MLMesh* ml_mesh;
|
||||
static vector<MLMesh*> mesh_stack;
|
||||
static std::vector<MLMesh*> mesh_stack;
|
||||
|
||||
void MeshLoader::beginMesh()
|
||||
{
|
||||
@@ -77,12 +75,12 @@ void MeshLoader::addTriangle(int v0, int v1, int v2, const Brush& b)
|
||||
{
|
||||
//find surface
|
||||
Surf* surf;
|
||||
map<Brush, Surf*>::const_iterator it = ml_mesh->brush_map.find(b);
|
||||
std::map<Brush, Surf*>::const_iterator it = ml_mesh->brush_map.find(b);
|
||||
if (it != ml_mesh->brush_map.end())
|
||||
surf = it->second;
|
||||
else {
|
||||
surf = new Surf;
|
||||
ml_mesh->brush_map.insert(make_pair(b, surf));
|
||||
ml_mesh->brush_map.insert(std::make_pair(b, surf));
|
||||
}
|
||||
|
||||
Tri tri;
|
||||
@@ -115,8 +113,8 @@ void MeshLoader::endMesh(MeshModel* mesh)
|
||||
v.bone_weights[j] *= t;
|
||||
}
|
||||
}
|
||||
map<int, int> vert_map;
|
||||
map<Brush, Surf*>::iterator it;
|
||||
std::map<int, int> vert_map;
|
||||
std::map<Brush, Surf*>::iterator it;
|
||||
for (it = ml_mesh->brush_map.begin(); it != ml_mesh->brush_map.end(); ++it) {
|
||||
vert_map.clear();
|
||||
Brush b = it->first;
|
||||
@@ -128,13 +126,13 @@ void MeshLoader::endMesh(MeshModel* mesh)
|
||||
Surface::Triangle tri;
|
||||
for (int j = 0; j < 3; ++j) {
|
||||
int n = t->tris[k].verts[j], id;
|
||||
map<int, int>::const_iterator it = vert_map.find(n);
|
||||
std::map<int, int>::const_iterator it = vert_map.find(n);
|
||||
if (it != vert_map.end())
|
||||
id = it->second;
|
||||
else {
|
||||
id = surf->numVertices();
|
||||
surf->addVertex(ml_mesh->verts[n]);
|
||||
vert_map.insert(make_pair(n, id));
|
||||
vert_map.insert(std::make_pair(n, id));
|
||||
}
|
||||
tri.verts[j] = id;
|
||||
}
|
||||
|
||||
@@ -1,15 +1,14 @@
|
||||
|
||||
#ifndef MESHLOADER_H
|
||||
#define MESHLOADER_H
|
||||
|
||||
#include "model.hpp"
|
||||
#pragma once
|
||||
#include "brush.hpp"
|
||||
#include "surface.hpp"
|
||||
|
||||
class MeshModel;
|
||||
|
||||
class MeshLoader {
|
||||
public:
|
||||
enum { HINT_COLLAPSE = 1, HINT_ANIMONLY = 2 };
|
||||
|
||||
virtual MeshModel* load(const string& f, const Transform& conv, int hint) = 0;
|
||||
virtual MeshModel* load(const std::string& f, const Transform& conv, int hint) = 0;
|
||||
|
||||
//clear
|
||||
static void beginMesh();
|
||||
@@ -35,5 +34,3 @@ class MeshLoader {
|
||||
//finally, update the mesh...
|
||||
static void endMesh(MeshModel* mesh);
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -1,7 +1,8 @@
|
||||
|
||||
#include "meshmodel.hpp"
|
||||
#include "meshcollider.hpp"
|
||||
#include "std.hpp"
|
||||
#include "surface.hpp"
|
||||
#include <vector>
|
||||
#include "animator.hpp"
|
||||
|
||||
extern gxGraphics* gx_graphics;
|
||||
|
||||
@@ -12,7 +13,7 @@ struct MeshModel::Rep : public Surface::Monitor {
|
||||
mutable int box_valid, coll_valid, norms_valid;
|
||||
|
||||
SurfaceList surfaces;
|
||||
vector<Transform> bone_tforms;
|
||||
std::vector<Transform> bone_tforms;
|
||||
|
||||
Rep() : ref_cnt(1), collider(0), box_valid(-1), coll_valid(-1), norms_valid(-1)
|
||||
{
|
||||
@@ -147,8 +148,8 @@ struct MeshModel::Rep : public Surface::Monitor {
|
||||
{
|
||||
if (coll_valid != geom_changes) {
|
||||
delete collider;
|
||||
vector<MeshCollider::Vertex> verts;
|
||||
vector<MeshCollider::Triangle> tris;
|
||||
std::vector<MeshCollider::Vertex> verts;
|
||||
std::vector<MeshCollider::Triangle> tris;
|
||||
for (int k = 0; k < surfaces.size(); ++k) {
|
||||
Surface* s = surfaces[k];
|
||||
int j;
|
||||
@@ -215,7 +216,7 @@ void MeshModel::setRenderBrush(const Brush& b)
|
||||
void MeshModel::createBones()
|
||||
{
|
||||
setRenderSpace(RENDER_SPACE_WORLD);
|
||||
const vector<Object*>& bones = getAnimator()->getObjects();
|
||||
const std::vector<Object*>& bones = getAnimator()->getObjects();
|
||||
|
||||
surf_bones.resize(bones.size());
|
||||
|
||||
@@ -257,7 +258,7 @@ bool MeshModel::render(const RenderContext& rc)
|
||||
}
|
||||
|
||||
//OK, its boned!
|
||||
const vector<Object*>& bones = getAnimator()->getObjects();
|
||||
const std::vector<Object*>& bones = getAnimator()->getObjects();
|
||||
|
||||
int k;
|
||||
for (k = 0; k < bones.size(); ++k) {
|
||||
|
||||
@@ -1,15 +1,14 @@
|
||||
|
||||
#ifndef MESHMODEL_H
|
||||
#define MESHMODEL_H
|
||||
|
||||
#pragma once
|
||||
#include <vector>
|
||||
#include "model.hpp"
|
||||
#include "surface.hpp"
|
||||
|
||||
class MeshCollider;
|
||||
class Collision;
|
||||
|
||||
class MeshModel : public Model {
|
||||
public:
|
||||
typedef vector<Surface*> SurfaceList;
|
||||
typedef std::vector<Surface*> SurfaceList;
|
||||
|
||||
MeshModel();
|
||||
MeshModel(const MeshModel& t);
|
||||
@@ -59,11 +58,9 @@ class MeshModel : public Model {
|
||||
Rep* rep;
|
||||
int brush_changes;
|
||||
Brush render_brush;
|
||||
vector<Brush> brushes;
|
||||
std::vector<Brush> brushes;
|
||||
|
||||
vector<Surface::Bone> surf_bones;
|
||||
std::vector<Surface::Bone> surf_bones;
|
||||
|
||||
MeshModel& operator=(const MeshModel&);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
|
||||
#include "meshutil.hpp"
|
||||
#include "std.hpp"
|
||||
#include "surface.hpp"
|
||||
|
||||
MeshModel* MeshUtil::createCube(const Brush& b)
|
||||
{
|
||||
|
||||
@@ -1,7 +1,4 @@
|
||||
|
||||
#ifndef MESHUTIL_H
|
||||
#define MESHUTIL_H
|
||||
|
||||
#pragma once
|
||||
#include "meshmodel.hpp"
|
||||
|
||||
struct MeshUtil {
|
||||
@@ -25,5 +22,3 @@ struct MeshUtil {
|
||||
static Mesh createCylinder( const Brush &b,int segs );
|
||||
*/
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -1,9 +1,7 @@
|
||||
|
||||
#include "mirror.hpp"
|
||||
#include "std.hpp"
|
||||
|
||||
Mirror::Mirror() {}
|
||||
|
||||
Mirror::Mirror(const Mirror& t) : Object(t) {}
|
||||
|
||||
Mirror::~Mirror() {}
|
||||
Mirror::~Mirror() {}
|
||||
|
||||
@@ -1,7 +1,4 @@
|
||||
|
||||
#ifndef MIRROR_H
|
||||
#define MIRROR_H
|
||||
|
||||
#pragma once
|
||||
#include "object.hpp"
|
||||
|
||||
class Mirror : public Object {
|
||||
@@ -20,5 +17,3 @@ class Mirror : public Object {
|
||||
return this;
|
||||
}
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -1,6 +1,4 @@
|
||||
|
||||
#include "model.hpp"
|
||||
#include "std.hpp"
|
||||
|
||||
extern gxScene* gx_scene;
|
||||
|
||||
@@ -132,7 +130,7 @@ void Model::enqueue(gxMesh* mesh, int fv, int vc, int ft, int tc, const Brush& b
|
||||
|
||||
void Model::renderQueue(int type)
|
||||
{
|
||||
vector<MeshQueue*>* que = &queues[type];
|
||||
std::vector<MeshQueue*>* que = &queues[type];
|
||||
for (; que->size(); que->pop_back()) {
|
||||
MeshQueue* q = que->back();
|
||||
q->render();
|
||||
|
||||
@@ -1,10 +1,8 @@
|
||||
|
||||
#ifndef MODEL_H
|
||||
#define MODEL_H
|
||||
|
||||
#pragma once
|
||||
#include "brush.hpp"
|
||||
#include "object.hpp"
|
||||
#include "rendercontext.hpp"
|
||||
#include "gxmesh.hpp"
|
||||
|
||||
class Sprite;
|
||||
class Terrain;
|
||||
@@ -147,9 +145,7 @@ class Model : public Object {
|
||||
bool auto_fade;
|
||||
float auto_fade_nr, auto_fade_fr;
|
||||
|
||||
vector<MeshQueue*> queues[2];
|
||||
std::vector<MeshQueue*> queues[2];
|
||||
|
||||
void enqueue(MeshQueue* q);
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -1,6 +1,9 @@
|
||||
|
||||
#include "object.hpp"
|
||||
#include "std.hpp"
|
||||
#include "animator.hpp"
|
||||
|
||||
#include <gxruntime.hpp>
|
||||
#include <gxsound.hpp>
|
||||
#include <gxchannel.hpp>
|
||||
|
||||
extern gxRuntime* gx_runtime;
|
||||
|
||||
|
||||
@@ -1,14 +1,12 @@
|
||||
|
||||
#ifndef OBJECT_H
|
||||
#define OBJECT_H
|
||||
|
||||
#pragma once
|
||||
#include <vector>
|
||||
|
||||
#include "animator.hpp"
|
||||
#include "animation.hpp"
|
||||
#include "collision.hpp"
|
||||
#include "entity.hpp"
|
||||
|
||||
class gxSound;
|
||||
class gxChannel;
|
||||
class Animator;
|
||||
|
||||
struct ObjCollision {
|
||||
Object* with;
|
||||
@@ -121,7 +119,7 @@ class Object : public Entity {
|
||||
bool obscurer;
|
||||
float elapsed;
|
||||
Vector velocity;
|
||||
vector<gxChannel*> channels;
|
||||
std::vector<gxChannel*> channels;
|
||||
Vector capt_pos, capt_scl;
|
||||
Quat capt_rot;
|
||||
mutable Object* last_copy;
|
||||
@@ -136,5 +134,3 @@ class Object : public Entity {
|
||||
|
||||
void updateSounds();
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
|
||||
#include "pivot.hpp"
|
||||
#include "std.hpp"
|
||||
|
||||
Pivot::Pivot() {}
|
||||
|
||||
|
||||
@@ -1,7 +1,4 @@
|
||||
|
||||
#ifndef PIVOT_H
|
||||
#define PIVOT_H
|
||||
|
||||
#pragma once
|
||||
#include "object.hpp"
|
||||
|
||||
class Pivot : public Object {
|
||||
@@ -15,5 +12,3 @@ class Pivot : public Object {
|
||||
return new Pivot(*this);
|
||||
}
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -1,8 +1,8 @@
|
||||
|
||||
#include "planemodel.hpp"
|
||||
#include "camera.hpp"
|
||||
#include "frustum.hpp"
|
||||
#include "std.hpp"
|
||||
|
||||
#include <gxgraphics.hpp>
|
||||
|
||||
static Vector vts[17][17];
|
||||
|
||||
|
||||
@@ -1,7 +1,4 @@
|
||||
|
||||
#ifndef PLANEMODEL_H
|
||||
#define PLANEMODEL_H
|
||||
|
||||
#pragma once
|
||||
#include "brush.hpp"
|
||||
#include "model.hpp"
|
||||
|
||||
@@ -33,5 +30,3 @@ class PlaneModel : public Model {
|
||||
return this;
|
||||
}
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -1,15 +1,13 @@
|
||||
|
||||
#include "q3bspmodel.hpp"
|
||||
#include "q3bsprep.hpp"
|
||||
#include "std.hpp"
|
||||
|
||||
struct Q3BSPModel::Rep : public Q3BSPRep {
|
||||
int ref_cnt;
|
||||
|
||||
Rep(const string& f, float gam) : Q3BSPRep(f, gam), ref_cnt(1) {}
|
||||
Rep(const std::string& f, float gam) : Q3BSPRep(f, gam), ref_cnt(1) {}
|
||||
};
|
||||
|
||||
Q3BSPModel::Q3BSPModel(const string& f, float gam) : rep(new Rep(f, gam)) {}
|
||||
Q3BSPModel::Q3BSPModel(const std::string& f, float gam) : rep(new Rep(f, gam)) {}
|
||||
|
||||
Q3BSPModel::Q3BSPModel(const Q3BSPModel& t) : Model(t), rep(t.rep)
|
||||
{
|
||||
@@ -46,4 +44,4 @@ void Q3BSPModel::setLighting(bool l)
|
||||
bool Q3BSPModel::isValid() const
|
||||
{
|
||||
return rep->isValid();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,12 +1,9 @@
|
||||
|
||||
#ifndef Q3BSPMODEL_H
|
||||
#define Q3BSPMODEL_H
|
||||
|
||||
#pragma once
|
||||
#include "model.hpp"
|
||||
|
||||
class Q3BSPModel : public Model {
|
||||
public:
|
||||
Q3BSPModel(const string& f, float gamma_adj);
|
||||
Q3BSPModel(const std::string& f, float gamma_adj);
|
||||
Q3BSPModel(const Q3BSPModel& m);
|
||||
~Q3BSPModel();
|
||||
|
||||
@@ -36,5 +33,3 @@ class Q3BSPModel : public Model {
|
||||
struct Rep;
|
||||
Rep* rep;
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -1,6 +1,8 @@
|
||||
|
||||
#include "q3bsprep.hpp"
|
||||
#include "std.hpp"
|
||||
|
||||
#include <gxgraphics.hpp>
|
||||
#include <gxcanvas.hpp>
|
||||
#include <stdutil.hpp>
|
||||
|
||||
/* Quake3 File format types */
|
||||
|
||||
@@ -89,7 +91,7 @@ struct q3_header {
|
||||
struct Surf {
|
||||
Q3BSPSurf* surf;
|
||||
int texture, lm_index;
|
||||
vector<int> verts, tris;
|
||||
std::vector<int> verts, tris;
|
||||
};
|
||||
|
||||
struct FaceCmp {
|
||||
@@ -105,7 +107,7 @@ struct FaceCmp {
|
||||
}
|
||||
};
|
||||
|
||||
typedef map<q3_face*, Surf*, FaceCmp> FaceMap;
|
||||
typedef std::map<q3_face*, Surf*, FaceCmp> FaceMap;
|
||||
|
||||
/* render reps */
|
||||
|
||||
@@ -114,7 +116,7 @@ struct Q3BSPFace;
|
||||
struct Q3BSPSurf {
|
||||
Brush brush;
|
||||
gxMesh* mesh;
|
||||
vector<Q3BSPFace*> r_faces;
|
||||
std::vector<Q3BSPFace*> r_faces;
|
||||
int texture, lm_index;
|
||||
};
|
||||
|
||||
@@ -127,13 +129,13 @@ struct Q3BSPFace {
|
||||
};
|
||||
|
||||
struct Q3BSPBrush {
|
||||
vector<Plane> planes;
|
||||
std::vector<Plane> planes;
|
||||
};
|
||||
|
||||
struct Q3BSPLeaf {
|
||||
int cluster;
|
||||
Box box;
|
||||
vector<Q3BSPFace*> faces;
|
||||
std::vector<Q3BSPFace*> faces;
|
||||
};
|
||||
|
||||
struct Q3BSPNode {
|
||||
@@ -153,10 +155,10 @@ struct Q3BSPNode {
|
||||
|
||||
static q3_header header;
|
||||
static FaceMap face_map;
|
||||
static vector<Surf*> t_surfs;
|
||||
static vector<q3_vertex> p_verts; //patch vertices
|
||||
static vector<Vector> p_coll_verts;
|
||||
static vector<MeshCollider::Triangle> coll_tris;
|
||||
static std::vector<Surf*> t_surfs;
|
||||
static std::vector<q3_vertex> p_verts; //patch vertices
|
||||
static std::vector<Vector> p_coll_verts;
|
||||
static std::vector<MeshCollider::Triangle> coll_tris;
|
||||
|
||||
static float gamma_adj;
|
||||
|
||||
@@ -164,7 +166,7 @@ static Vector r_eye;
|
||||
static int r_cluster;
|
||||
static Frustum r_frustum;
|
||||
static Vector r_frustedges[12];
|
||||
static map<int, Q3BSPFace*> q3face_map;
|
||||
static std::map<int, Q3BSPFace*> q3face_map;
|
||||
|
||||
extern gxScene* gx_scene;
|
||||
extern gxRuntime* gx_runtime;
|
||||
@@ -182,7 +184,7 @@ static void debuglog(const string& t)
|
||||
gx_runtime->debugLog(t.c_str());
|
||||
}
|
||||
#else
|
||||
static void debuglog(const string& t) {}
|
||||
static void debuglog(const std::string& t) {}
|
||||
#endif
|
||||
|
||||
static Surf* findSurf(q3_face* f)
|
||||
@@ -193,7 +195,7 @@ static Surf* findSurf(q3_face* f)
|
||||
Surf* s = new Surf;
|
||||
s->texture = f->texture;
|
||||
s->lm_index = f->lm_index;
|
||||
face_map.insert(make_pair(f, s));
|
||||
face_map.insert(std::make_pair(f, s));
|
||||
t_surfs.push_back(s);
|
||||
return s;
|
||||
}
|
||||
@@ -203,7 +205,7 @@ void Q3BSPRep::createTextures()
|
||||
int n_texs = header.dir[1].length / sizeof(q3_tex);
|
||||
q3_tex* q3tex = (q3_tex*)header.dir[1].lump;
|
||||
for (int k = 0; k < n_texs; ++k) {
|
||||
string t = string(q3tex->name);
|
||||
std::string t = std::string(q3tex->name);
|
||||
char fl[32], co[32];
|
||||
_itoa(q3tex->flags, fl, 16);
|
||||
_itoa(q3tex->contents, co, 16);
|
||||
@@ -264,7 +266,7 @@ void Q3BSPRep::createVis()
|
||||
|
||||
void Q3BSPRep::createCollider()
|
||||
{
|
||||
vector<MeshCollider::Vertex> coll_verts;
|
||||
std::vector<MeshCollider::Vertex> coll_verts;
|
||||
int n_verts = header.dir[10].length / sizeof(q3_vertex);
|
||||
q3_vertex* t = (q3_vertex*)header.dir[10].lump;
|
||||
MeshCollider::Vertex cv;
|
||||
@@ -350,7 +352,7 @@ static void average(const q3_vertex& a, const q3_vertex& b, q3_vertex* c)
|
||||
}
|
||||
}
|
||||
|
||||
static void subdivide(vector<q3_vertex>& verts, int level, int index, int step)
|
||||
static void subdivide(std::vector<q3_vertex>& verts, int level, int index, int step)
|
||||
{
|
||||
if (!level) {
|
||||
q3_vertex t1, t2;
|
||||
@@ -369,7 +371,7 @@ static void subdivide(vector<q3_vertex>& verts, int level, int index, int step)
|
||||
static void patchFace(Q3BSPFace* face, q3_face* q3face, bool draw, bool solid, int level)
|
||||
{
|
||||
int k, x, y;
|
||||
vector<q3_vertex> verts;
|
||||
std::vector<q3_vertex> verts;
|
||||
|
||||
if (draw) {
|
||||
int step = 1 << level;
|
||||
@@ -422,7 +424,7 @@ static void patchFace(Q3BSPFace* face, q3_face* q3face, bool draw, bool solid, i
|
||||
}
|
||||
|
||||
if (solid) {
|
||||
vector<q3_vertex> verts;
|
||||
std::vector<q3_vertex> verts;
|
||||
int step = 1;
|
||||
int size_x = q3face->patch_size[0];
|
||||
int size_y = q3face->patch_size[1];
|
||||
@@ -472,7 +474,7 @@ static void patchFace(Q3BSPFace* face, q3_face* q3face, bool draw, bool solid, i
|
||||
|
||||
static void meshFace(Q3BSPFace* face, q3_face* q3face, bool draw, bool solid)
|
||||
{
|
||||
static map<int, int> vert_map;
|
||||
static std::map<int, int> vert_map;
|
||||
vert_map.clear();
|
||||
int* meshverts = (int*)header.dir[11].lump + q3face->meshvert;
|
||||
MeshCollider::Triangle ct;
|
||||
@@ -529,7 +531,7 @@ Q3BSPLeaf* Q3BSPRep::createLeaf(int n)
|
||||
for (int k = 0; k < q3leaf->n_leaffaces; ++k) {
|
||||
int face_n = leaffaces[k];
|
||||
|
||||
map<int, Q3BSPFace*>::const_iterator it = q3face_map.find(face_n);
|
||||
std::map<int, Q3BSPFace*>::const_iterator it = q3face_map.find(face_n);
|
||||
if (it != q3face_map.end()) {
|
||||
if (it->second)
|
||||
leaf->faces.push_back(it->second);
|
||||
@@ -567,7 +569,7 @@ Q3BSPLeaf* Q3BSPRep::createLeaf(int n)
|
||||
face->n_verts = face->n_tris = 0;
|
||||
leaf->faces.push_back(face);
|
||||
faces.push_back(face);
|
||||
q3face_map.insert(make_pair(face_n, face));
|
||||
q3face_map.insert(std::make_pair(face_n, face));
|
||||
}
|
||||
|
||||
if (q3face->type == 2) {
|
||||
@@ -608,7 +610,7 @@ Q3BSPNode* Q3BSPRep::createNode(int n)
|
||||
return node;
|
||||
}
|
||||
|
||||
Q3BSPRep::Q3BSPRep(const string& f, float gam) : root_node(0), vis_sz(0), vis_data(0), use_lmap(true)
|
||||
Q3BSPRep::Q3BSPRep(const std::string& f, float gam) : root_node(0), vis_sz(0), vis_data(0), use_lmap(true)
|
||||
{
|
||||
gamma_adj = 1 - gam;
|
||||
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
|
||||
#ifndef Q3BSPREP_H
|
||||
#define Q3BSPREP_H
|
||||
|
||||
#pragma once
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include "meshcollider.hpp"
|
||||
#include "model.hpp"
|
||||
|
||||
@@ -13,7 +12,7 @@ struct Q3BSPNode;
|
||||
class Q3BSPRep {
|
||||
public:
|
||||
//constructor
|
||||
Q3BSPRep(const string& f, float gamma_adj);
|
||||
Q3BSPRep(const std::string& f, float gamma_adj);
|
||||
~Q3BSPRep();
|
||||
|
||||
void render(Model* model, const RenderContext& rc);
|
||||
@@ -32,9 +31,9 @@ class Q3BSPRep {
|
||||
|
||||
Vector ambient;
|
||||
|
||||
vector<Q3BSPFace*> faces;
|
||||
vector<Q3BSPSurf*> surfs, r_surfs;
|
||||
vector<Texture> textures, light_maps;
|
||||
std::vector<Q3BSPFace*> faces;
|
||||
std::vector<Q3BSPSurf*> surfs, r_surfs;
|
||||
std::vector<Texture> textures, light_maps;
|
||||
|
||||
int vis_sz;
|
||||
char* vis_data;
|
||||
@@ -55,5 +54,3 @@ class Q3BSPRep {
|
||||
void render(Q3BSPLeaf* l, int clip);
|
||||
void render(Q3BSPNode* n, int clip);
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -1,7 +1,4 @@
|
||||
|
||||
#ifndef RENDERCONTEXT_H
|
||||
#define RENDERCONTEXT_H
|
||||
|
||||
#pragma once
|
||||
#include "frustum.hpp"
|
||||
|
||||
class RenderContext {
|
||||
@@ -33,5 +30,3 @@ class RenderContext {
|
||||
Frustum world_frustum, camera_frustum;
|
||||
bool ref;
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -1,6 +1,7 @@
|
||||
|
||||
#include "sprite.hpp"
|
||||
#include "std.hpp"
|
||||
|
||||
#include <gxgraphics.hpp>
|
||||
#include <gxruntime.hpp>
|
||||
|
||||
extern float stats3d[];
|
||||
|
||||
@@ -16,7 +17,7 @@ extern gxGraphics* gx_graphics;
|
||||
|
||||
static gxMesh* mesh;
|
||||
static int mesh_size;
|
||||
static vector<int> mesh_indices;
|
||||
static std::vector<int> mesh_indices;
|
||||
|
||||
static int allocIndex()
|
||||
{
|
||||
|
||||
@@ -1,7 +1,4 @@
|
||||
|
||||
#ifndef SPRITE_H
|
||||
#define SPRITE_H
|
||||
|
||||
#pragma once
|
||||
#include "brush.hpp"
|
||||
#include "gxmesh.hpp"
|
||||
#include "model.hpp"
|
||||
@@ -46,5 +43,3 @@ class Sprite : public Model {
|
||||
int view_mode, mesh_index;
|
||||
bool captured;
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -1,2 +0,0 @@
|
||||
|
||||
#include "std.hpp"
|
||||
@@ -1,20 +0,0 @@
|
||||
|
||||
#ifndef STD_H
|
||||
#define STD_H
|
||||
|
||||
#pragma warning(disable : 4786)
|
||||
|
||||
#include "config.hpp"
|
||||
#include "gxruntime.hpp"
|
||||
#include "stdutil.hpp"
|
||||
|
||||
#include <fstream>
|
||||
#include <iostream>
|
||||
#include <map>
|
||||
#include <set>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
using namespace std;
|
||||
|
||||
#endif
|
||||
@@ -1,6 +1,6 @@
|
||||
|
||||
#include "surface.hpp"
|
||||
#include "std.hpp"
|
||||
|
||||
#include <gxgraphics.hpp>
|
||||
|
||||
extern gxGraphics* gx_graphics;
|
||||
|
||||
@@ -22,7 +22,7 @@ void Surface::setBrush(const Brush& b)
|
||||
++mon->brush_changes;
|
||||
}
|
||||
|
||||
void Surface::setName(const string& n)
|
||||
void Surface::setName(const std::string& n)
|
||||
{
|
||||
name = n;
|
||||
}
|
||||
@@ -40,7 +40,7 @@ void Surface::clear(bool verts, bool tris)
|
||||
++mon->geom_changes;
|
||||
}
|
||||
|
||||
void Surface::addVertices(const vector<Vertex>& verts)
|
||||
void Surface::addVertices(const std::vector<Vertex>& verts)
|
||||
{
|
||||
vertices.insert(vertices.end(), verts.begin(), verts.end());
|
||||
++mon->geom_changes;
|
||||
@@ -79,7 +79,7 @@ Vector Surface::getColor(int n) const
|
||||
return Vector(r / 255.0f, g / 255.0f, b / 255.0f);
|
||||
}
|
||||
|
||||
void Surface::addTriangles(const vector<Triangle>& tris)
|
||||
void Surface::addTriangles(const std::vector<Triangle>& tris)
|
||||
{
|
||||
triangles.insert(triangles.end(), tris.begin(), tris.end());
|
||||
}
|
||||
@@ -87,7 +87,7 @@ void Surface::addTriangles(const vector<Triangle>& tris)
|
||||
void Surface::updateNormals()
|
||||
{
|
||||
int k;
|
||||
map<Vector, Vector> norm_map;
|
||||
std::map<Vector, Vector> norm_map;
|
||||
for (k = 0; k < triangles.size(); ++k) {
|
||||
const Triangle& t = triangles[k];
|
||||
const Vector& v0 = vertices[t.verts[0]].coords;
|
||||
@@ -141,7 +141,7 @@ gxMesh* Surface::getMesh()
|
||||
return mesh;
|
||||
}
|
||||
|
||||
gxMesh* Surface::getMesh(const vector<Bone>& bones)
|
||||
gxMesh* Surface::getMesh(const std::vector<Bone>& bones)
|
||||
{
|
||||
valid_vs = valid_ts = 0;
|
||||
|
||||
|
||||
+12
-14
@@ -1,8 +1,8 @@
|
||||
|
||||
#ifndef SURFACE_H
|
||||
#define SURFACE_H
|
||||
|
||||
#pragma once
|
||||
#include "model.hpp"
|
||||
#include "geom.hpp"
|
||||
#include "gxmesh.hpp"
|
||||
#include <vector>
|
||||
|
||||
#define MAX_SURFACE_BONES 4
|
||||
|
||||
@@ -45,7 +45,7 @@ class Surface {
|
||||
Surface(Monitor* mon);
|
||||
~Surface();
|
||||
|
||||
void setName(const string& t);
|
||||
void setName(const std::string& t);
|
||||
void setBrush(const Brush& b);
|
||||
|
||||
void clear(bool verts, bool tris);
|
||||
@@ -103,15 +103,15 @@ class Surface {
|
||||
|
||||
Vector getColor(int index) const;
|
||||
void setColor(int index, const Vector& v);
|
||||
void addVertices(const vector<Vertex>& verts);
|
||||
void addTriangles(const vector<Triangle>& tris);
|
||||
void addVertices(const std::vector<Vertex>& verts);
|
||||
void addTriangles(const std::vector<Triangle>& tris);
|
||||
|
||||
void updateNormals();
|
||||
|
||||
gxMesh* getMesh();
|
||||
gxMesh* getMesh(const vector<Bone>& bones);
|
||||
gxMesh* getMesh(const std::vector<Bone>& bones);
|
||||
|
||||
string getName() const
|
||||
std::string getName() const
|
||||
{
|
||||
return name;
|
||||
}
|
||||
@@ -138,13 +138,11 @@ class Surface {
|
||||
|
||||
private:
|
||||
Brush brush;
|
||||
string name;
|
||||
std::string name;
|
||||
gxMesh* mesh;
|
||||
vector<Vertex> vertices;
|
||||
vector<Triangle> triangles;
|
||||
std::vector<Vertex> vertices;
|
||||
std::vector<Triangle> triangles;
|
||||
int mesh_vs, mesh_ts;
|
||||
int valid_vs, valid_ts;
|
||||
Monitor* mon;
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -1,6 +1,4 @@
|
||||
|
||||
#include "terrain.hpp"
|
||||
#include "std.hpp"
|
||||
#include "terrainrep.hpp"
|
||||
|
||||
Terrain::Terrain(int size_shift) : rep(new TerrainRep(size_shift)) {}
|
||||
|
||||
@@ -1,7 +1,4 @@
|
||||
|
||||
#ifndef TERRAIN_H
|
||||
#define TERRAIN_H
|
||||
|
||||
#pragma once
|
||||
#include "model.hpp"
|
||||
|
||||
struct TerrainRep;
|
||||
@@ -32,5 +29,3 @@ class Terrain : public Model {
|
||||
private:
|
||||
TerrainRep* rep;
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -1,19 +1,24 @@
|
||||
|
||||
#include "terrainrep.hpp"
|
||||
#include <queue>
|
||||
#include "std.hpp"
|
||||
|
||||
#include <gxgraphics.hpp>
|
||||
#include <gxruntime.hpp>
|
||||
|
||||
extern gxRuntime* gx_runtime;
|
||||
extern gxGraphics* gx_graphics;
|
||||
extern float stats3d[10];
|
||||
|
||||
static Vector eye_vec;
|
||||
static Plane eye_plane;
|
||||
static const Vector up_normal(0, 1, 0);
|
||||
static TerrainRep::Tri* tri_pool;
|
||||
static const TerrainRep* curr;
|
||||
static Frustum frustum;
|
||||
static int out_cnt, proc_cnt, clip_cnt;
|
||||
static Vector eye_vec;
|
||||
static Plane eye_plane;
|
||||
static const Vector up_normal(0, 1, 0);
|
||||
static TerrainRep::Tri* tri_pool;
|
||||
static const TerrainRep* curr;
|
||||
static Frustum frustum;
|
||||
static int out_cnt, proc_cnt, clip_cnt;
|
||||
static std::vector<TerrainRep::Tri*> tris;
|
||||
|
||||
static int vert_cnt, max_verts;
|
||||
static TerrainRep::Vert *verts, *next_vert;
|
||||
|
||||
static float proj_epsilon = FLT_EPSILON; //.01f;
|
||||
|
||||
@@ -48,9 +53,6 @@ struct TerrainRep::Vert {
|
||||
Vert(int x, int z, float sy) : x(x), z(z), v((float)x, curr->getHeight(x, z), (float)z), src_y(sy) {}
|
||||
};
|
||||
|
||||
static int vert_cnt, max_verts;
|
||||
static TerrainRep::Vert *verts, *next_vert;
|
||||
|
||||
struct TerrainRep::Tri {
|
||||
int id;
|
||||
short clip, v0, v1, v2;
|
||||
@@ -66,20 +68,20 @@ struct TerrainRep::Tri {
|
||||
{
|
||||
static const int GROW = 64;
|
||||
if (!tri_pool) {
|
||||
tri_pool = new Tri[GROW];
|
||||
tri_pool = new TerrainRep::Tri[GROW];
|
||||
for (int k = 0; k < GROW - 1; ++k)
|
||||
tri_pool[k].e0 = &tri_pool[k + 1];
|
||||
tri_pool[GROW - 1].e0 = 0;
|
||||
}
|
||||
Tri* t = tri_pool;
|
||||
tri_pool = t->e0;
|
||||
TerrainRep::Tri* t = tri_pool;
|
||||
tri_pool = t->e0;
|
||||
return t;
|
||||
}
|
||||
void operator delete(void* q)
|
||||
{
|
||||
Tri* t = (Tri*)q;
|
||||
t->e0 = tri_pool;
|
||||
tri_pool = t;
|
||||
TerrainRep::Tri* t = (TerrainRep::Tri*)q;
|
||||
t->e0 = tri_pool;
|
||||
tri_pool = t;
|
||||
}
|
||||
void unlink()
|
||||
{
|
||||
@@ -117,19 +119,18 @@ struct TriComp {
|
||||
}
|
||||
};
|
||||
|
||||
struct TriQue : public priority_queue<TerrainRep::Tri*, vector<TerrainRep::Tri*>, TriComp> {
|
||||
vector<TerrainRep::Tri*>& getVector()
|
||||
struct TriQue : public std::priority_queue<TerrainRep::Tri*, std::vector<TerrainRep::Tri*>, TriComp> {
|
||||
std::vector<TerrainRep::Tri*>& getVector()
|
||||
{
|
||||
return c;
|
||||
}
|
||||
const vector<TerrainRep::Tri*>& getVector() const
|
||||
const std::vector<TerrainRep::Tri*>& getVector() const
|
||||
{
|
||||
return c;
|
||||
}
|
||||
};
|
||||
|
||||
static TriQue tri_que;
|
||||
static vector<TerrainRep::Tri*> tris;
|
||||
static TriQue tri_que;
|
||||
|
||||
static bool clip(const Line& l, const Box& box)
|
||||
{
|
||||
@@ -497,8 +498,8 @@ void TerrainRep::render(Model* model, const RenderContext& rc)
|
||||
delete t;
|
||||
}
|
||||
|
||||
int k;
|
||||
const vector<Tri*>& q_tris = tri_que.getVector();
|
||||
int k;
|
||||
const std::vector<Tri*>& q_tris = tri_que.getVector();
|
||||
|
||||
if (!mesh)
|
||||
out_cnt = 0;
|
||||
|
||||
@@ -1,9 +1,4 @@
|
||||
|
||||
#ifndef TERRAINREP_H
|
||||
#define TERRAINREP_H
|
||||
|
||||
#include <queue>
|
||||
|
||||
#pragma once
|
||||
#include "model.hpp"
|
||||
|
||||
struct TerrainRep {
|
||||
@@ -53,5 +48,3 @@ struct TerrainRep {
|
||||
bool collide(const Line& line, float radius, Collision* curr_coll, const Transform& tform, int id, const Vert& v0,
|
||||
const Vert& v1, const Vert& v2, const Box& box) const;
|
||||
};
|
||||
|
||||
#endif
|
||||
+18
-18
@@ -1,28 +1,28 @@
|
||||
|
||||
#include "texture.hpp"
|
||||
#include "cachedtexture.hpp"
|
||||
#include "geom.hpp"
|
||||
#include "std.hpp"
|
||||
|
||||
#include "../gxruntime/gxgraphics.hpp"
|
||||
#include <gxgraphics.hpp>
|
||||
#include <gxcanvas.hpp>
|
||||
#include <stdutil.hpp>
|
||||
|
||||
extern gxScene* gx_scene;
|
||||
extern gxGraphics* gx_graphics;
|
||||
|
||||
struct Filter {
|
||||
string t;
|
||||
int flags;
|
||||
Filter(const string& t, int flags) : t(t), flags(flags) {}
|
||||
std::string t;
|
||||
int flags;
|
||||
Filter(const std::string& t, int flags) : t(t), flags(flags) {}
|
||||
};
|
||||
|
||||
static vector<Filter> filters;
|
||||
static std::vector<Filter> filters;
|
||||
|
||||
static int filterFile(const string& t, int flags)
|
||||
static int filterFile(const std::string& t, int flags)
|
||||
{
|
||||
//check filters...
|
||||
string l = tolower(t);
|
||||
std::string l = tolower(t);
|
||||
for (size_t k = 0; k < filters.size(); ++k) {
|
||||
if (l.find(filters[k].t) != string::npos) {
|
||||
if (l.find(filters[k].t) != std::string::npos) {
|
||||
flags |= filters[k].flags;
|
||||
}
|
||||
}
|
||||
@@ -30,9 +30,9 @@ static int filterFile(const string& t, int flags)
|
||||
}
|
||||
|
||||
struct Texture::Rep {
|
||||
int ref_cnt;
|
||||
CachedTextureFactory cached_tex;
|
||||
vector<gxCanvas*> tex_frames;
|
||||
int ref_cnt;
|
||||
CachedTexture cached_tex;
|
||||
std::vector<gxCanvas*> tex_frames;
|
||||
|
||||
int tex_blend, tex_flags;
|
||||
bool transparent;
|
||||
@@ -50,7 +50,7 @@ struct Texture::Rep {
|
||||
memset(&matrix, 0, sizeof(matrix));
|
||||
}
|
||||
|
||||
Rep(const string& f, int flags, int w, int h, int first, int cnt)
|
||||
Rep(const std::string& f, int flags, int w, int h, int first, int cnt)
|
||||
: ref_cnt(1), cached_tex(f, flags, w, h, first, cnt), tex_blend(gxScene::BLEND_MULTIPLY), tex_flags(0), sx(1),
|
||||
sy(1), tx(0), ty(0), rot(0), mat_used(false)
|
||||
{
|
||||
@@ -68,7 +68,7 @@ struct Texture::Rep {
|
||||
|
||||
Texture::Texture() : rep(0) {}
|
||||
|
||||
Texture::Texture(const string& f, int flags)
|
||||
Texture::Texture(const std::string& f, int flags)
|
||||
{
|
||||
flags = filterFile(f, flags) | gxCanvas::CANVAS_TEXTURE;
|
||||
if (flags & gxCanvas::CANVAS_TEX_MASK)
|
||||
@@ -76,7 +76,7 @@ Texture::Texture(const string& f, int flags)
|
||||
rep = new Rep(f, flags, 0, 0, 0, 1);
|
||||
}
|
||||
|
||||
Texture::Texture(const string& f, int flags, int w, int h, int first, int cnt)
|
||||
Texture::Texture(const std::string& f, int flags, int w, int h, int first, int cnt)
|
||||
{
|
||||
flags = filterFile(f, flags) | gxCanvas::CANVAS_TEXTURE;
|
||||
if (flags & gxCanvas::CANVAS_TEX_MASK)
|
||||
@@ -172,7 +172,7 @@ int Texture::getCanvasFlags() const
|
||||
return rep && rep->tex_frames.size() ? rep->tex_frames[0]->getFlags() : 0;
|
||||
}
|
||||
|
||||
CachedTextureFactory* Texture::getCachedTexture() const
|
||||
CachedTexture* Texture::getCachedTexture() const
|
||||
{
|
||||
return rep ? &rep->cached_tex : 0;
|
||||
}
|
||||
@@ -216,7 +216,7 @@ void Texture::clearFilters()
|
||||
filters.clear();
|
||||
}
|
||||
|
||||
void Texture::addFilter(const string& t, int flags)
|
||||
void Texture::addFilter(const std::string& t, int flags)
|
||||
{
|
||||
filters.push_back(Filter(tolower(t), flags));
|
||||
}
|
||||
|
||||
@@ -1,12 +1,10 @@
|
||||
|
||||
#ifndef TEXTURE_H
|
||||
#define TEXTURE_H
|
||||
|
||||
#pragma once
|
||||
#include <string>
|
||||
|
||||
#include "cachedtexture.hpp"
|
||||
|
||||
#include "gxcanvas.hpp"
|
||||
#include <gxscene.hpp>
|
||||
|
||||
class gxCanvas;
|
||||
|
||||
class Texture {
|
||||
public:
|
||||
@@ -30,7 +28,7 @@ class Texture {
|
||||
const gxScene::Matrix* getMatrix() const;
|
||||
int getBlend() const;
|
||||
int getFlags() const;
|
||||
CachedTextureFactory* getCachedTexture() const;
|
||||
CachedTexture* getCachedTexture() const;
|
||||
|
||||
bool isTransparent() const;
|
||||
bool operator<(const Texture& t) const;
|
||||
@@ -42,5 +40,3 @@ class Texture {
|
||||
struct Rep;
|
||||
Rep* rep;
|
||||
};
|
||||
|
||||
#endif
|
||||
+17
-18
@@ -1,7 +1,6 @@
|
||||
|
||||
#include "world.hpp"
|
||||
#include <queue>
|
||||
#include "std.hpp"
|
||||
#include "gxruntime.hpp"
|
||||
|
||||
//0=tris compared for collision
|
||||
//1=max proj err of terrain
|
||||
@@ -30,9 +29,9 @@ static void StaticEnumerateVisible()
|
||||
|
||||
/******************************* Update *******************************/
|
||||
|
||||
static vector<Object*> _objsByType[1000];
|
||||
static std::vector<Object*> _objsByType[1000];
|
||||
|
||||
static vector<ObjCollision*> free_colls, used_colls;
|
||||
static std::vector<ObjCollision*> free_colls, used_colls;
|
||||
|
||||
static ObjCollision* allocObjColl(Object* with, const Vector& coords, const Collision& coll)
|
||||
{
|
||||
@@ -73,7 +72,7 @@ void World::clearCollisions()
|
||||
|
||||
void World::addCollision(int src_type, int dst_type, int method, int response)
|
||||
{
|
||||
vector<CollInfo>& info = _collInfo[src_type];
|
||||
std::vector<CollInfo>& info = _collInfo[src_type];
|
||||
for (size_t k = 0; k < info.size(); ++k) {
|
||||
const CollInfo& t = info[k];
|
||||
if (dst_type == t.dst_type)
|
||||
@@ -183,13 +182,13 @@ void World::collide(Object* src)
|
||||
float td = coll_line.d.length();
|
||||
float td_xz = Vector(coll_line.d.x, 0, coll_line.d.z).length();
|
||||
|
||||
const vector<CollInfo>& collinfos = _collInfo[src->getCollisionType()];
|
||||
const std::vector<CollInfo>& collinfos = _collInfo[src->getCollisionType()];
|
||||
|
||||
int hits = 0;
|
||||
for (;;) {
|
||||
Collision coll;
|
||||
Object* coll_obj = 0;
|
||||
vector<CollInfo>::const_iterator coll_it, coll_info;
|
||||
Collision coll;
|
||||
Object* coll_obj = 0;
|
||||
std::vector<CollInfo>::const_iterator coll_it, coll_info;
|
||||
|
||||
for (coll_it = collinfos.begin(); coll_it != collinfos.end(); ++coll_it) {
|
||||
// const std::list<Object*> &dst_objs = _objsByType[coll_it->dst_type];
|
||||
@@ -501,9 +500,9 @@ void World::update(float elapsed)
|
||||
|
||||
static Transform cam_tform; //current camera transform
|
||||
|
||||
static vector<gxLight*> _lights;
|
||||
static vector<Mirror*> _mirrors;
|
||||
static vector<Listener*> _listeners;
|
||||
static std::vector<gxLight*> _lights;
|
||||
static std::vector<Mirror*> _mirrors;
|
||||
static std::vector<Listener*> _listeners;
|
||||
|
||||
struct OrderComp {
|
||||
bool operator()(Object* a, Object* b)
|
||||
@@ -519,13 +518,13 @@ struct TransComp {
|
||||
}
|
||||
};
|
||||
|
||||
static vector<Model*> ord_mods, unord_mods;
|
||||
static std::vector<Model*> ord_mods, unord_mods;
|
||||
|
||||
static priority_queue<Model*, vector<Model*>, OrderComp> ord_que;
|
||||
static std::priority_queue<Model*, std::vector<Model*>, OrderComp> ord_que;
|
||||
|
||||
static priority_queue<Camera*, vector<Camera*>, OrderComp> cam_que;
|
||||
static std::priority_queue<Camera*, std::vector<Camera*>, OrderComp> cam_que;
|
||||
|
||||
static priority_queue<Model*, vector<Model*>, TransComp> transparents;
|
||||
static std::priority_queue<Model*, std::vector<Model*>, TransComp> transparents;
|
||||
|
||||
void World::capture()
|
||||
{
|
||||
@@ -583,7 +582,7 @@ void World::render(float tween)
|
||||
if (!cam->beginRenderFrame())
|
||||
continue;
|
||||
|
||||
vector<Mirror*>::const_iterator mir_it;
|
||||
std::vector<Mirror*>::const_iterator mir_it;
|
||||
for (mir_it = _mirrors.begin(); mir_it != _mirrors.end(); ++mir_it) {
|
||||
render(cam, *mir_it);
|
||||
}
|
||||
@@ -595,7 +594,7 @@ void World::render(float tween)
|
||||
|
||||
// gx_runtime->debugLog( "End RenderWorld" );
|
||||
|
||||
vector<Listener*>::const_iterator lis_it;
|
||||
std::vector<Listener*>::const_iterator lis_it;
|
||||
for (lis_it = _listeners.begin(); lis_it != _listeners.end(); ++lis_it) {
|
||||
(*lis_it)->renderListener();
|
||||
}
|
||||
|
||||
@@ -1,9 +1,5 @@
|
||||
|
||||
#ifndef WORLD_H
|
||||
#define WORLD_H
|
||||
|
||||
#pragma once
|
||||
#include <list>
|
||||
|
||||
#include "camera.hpp"
|
||||
#include "light.hpp"
|
||||
#include "listener.hpp"
|
||||
@@ -42,7 +38,7 @@ class World {
|
||||
int dst_type, method, response;
|
||||
};
|
||||
|
||||
vector<CollInfo> _collInfo[WORLD_COLLISION_TYPES];
|
||||
std::vector<CollInfo> _collInfo[WORLD_COLLISION_TYPES];
|
||||
std::list<Object*> _objsByType[WORLD_COLLISION_TYPES];
|
||||
std::list<Object*> _objsByTypeSwappable[WORLD_COLLISION_TYPES];
|
||||
|
||||
@@ -51,5 +47,3 @@ class World {
|
||||
void render(Model* m, const RenderContext& rc);
|
||||
void flushTransparent();
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user