diff --git a/src/emitter.cpp b/src/emitter.cpp index 4777ef75..40213707 100644 --- a/src/emitter.cpp +++ b/src/emitter.cpp @@ -1,7 +1,7 @@ // // Lol Engine // -// Copyright: (c) 2010-2011 Sam Hocevar +// Copyright: (c) 2010-2012 Sam Hocevar // This program is free software; you can redistribute it and/or // modify it under the terms of the Do What The Fuck You Want To // Public License, Version 2, as published by Sam Hocevar. See @@ -76,7 +76,7 @@ void Emitter::TickDraw(float deltams) for (int i = 0; i < data->nparticles; i++) Scene::GetDefault()->AddTile(data->tileset, data->particles[i], - data->positions[i], 0); + data->positions[i], 0, vec2(1.0f)); } void Emitter::AddParticle(int id, vec3 pos, vec3 vel) diff --git a/src/font.cpp b/src/font.cpp index fc6f691e..d0be713b 100644 --- a/src/font.cpp +++ b/src/font.cpp @@ -1,7 +1,7 @@ // // Lol Engine // -// Copyright: (c) 2010-2011 Sam Hocevar +// Copyright: (c) 2010-2012 Sam Hocevar // This program is free software; you can redistribute it and/or // modify it under the terms of the Do What The Fuck You Want To // Public License, Version 2, as published by Sam Hocevar. See @@ -46,7 +46,7 @@ Font::Font(char const *path) data->name = (char *)malloc(7 + strlen(path) + 1); sprintf(data->name, " %s", path); - data->tileset = Tiler::Register(path, ivec2(0), ivec2(16), vec2(1.0f)); + data->tileset = Tiler::Register(path, ivec2(0), ivec2(16)); data->size = data->tileset->GetSize(0); m_drawgroup = DRAWGROUP_BEFORE; @@ -69,7 +69,7 @@ char const *Font::GetName() return data->name; } -void Font::Print(vec3 pos, char const *str) +void Font::Print(vec3 pos, char const *str, vec2 scale) { Scene *scene = Scene::GetDefault(); @@ -78,9 +78,9 @@ void Font::Print(vec3 pos, char const *str) uint32_t ch = (uint8_t)*str++; if (ch != ' ') - scene->AddTile(data->tileset, ch & 255, pos, 0); + scene->AddTile(data->tileset, ch & 255, pos, 0, scale); - pos.x += data->size.x; + pos.x += data->size.x * scale.x; } } diff --git a/src/font.h b/src/font.h index 800a2637..596af59b 100644 --- a/src/font.h +++ b/src/font.h @@ -1,7 +1,7 @@ // // Lol Engine // -// Copyright: (c) 2010-2011 Sam Hocevar +// Copyright: (c) 2010-2012 Sam Hocevar // This program is free software; you can redistribute it and/or // modify it under the terms of the Do What The Fuck You Want To // Public License, Version 2, as published by Sam Hocevar. See @@ -36,7 +36,7 @@ protected: public: /* New methods */ - void Print(vec3 pos, char const *str); + void Print(vec3 pos, char const *str, vec2 scale = vec2(1.0f)); ivec2 GetSize() const; private: diff --git a/src/map.cpp b/src/map.cpp index d86e7c87..1cca34fc 100644 --- a/src/map.cpp +++ b/src/map.cpp @@ -1,7 +1,7 @@ // // Lol Engine // -// Copyright: (c) 2010-2011 Sam Hocevar +// Copyright: (c) 2010-2012 Sam Hocevar // This program is free software; you can redistribute it and/or // modify it under the terms of the Do What The Fuck You Want To // Public License, Version 2, as published by Sam Hocevar. See @@ -136,7 +136,7 @@ Map::Map(char const *path) { /* This is a tileset image file. Associate it with firstgid. */ data->tilesets[data->ntilers] = Tiler::Register(str, ivec2(32), - ivec2(0), vec2(1.0f, sqrtf(2))); + ivec2(0)); data->ntilers++; //Log::Debug("new tiler %s\n", str); } diff --git a/src/scene.cpp b/src/scene.cpp index 62dac14e..e4f7fc72 100644 --- a/src/scene.cpp +++ b/src/scene.cpp @@ -1,7 +1,7 @@ // // Lol Engine // -// Copyright: (c) 2010-2011 Sam Hocevar +// Copyright: (c) 2010-2012 Sam Hocevar // This program is free software; you can redistribute it and/or // modify it under the terms of the Do What The Fuck You Want To // Public License, Version 2, as published by Sam Hocevar. See @@ -31,6 +31,7 @@ struct Tile TileSet *tileset; uint32_t prio; vec3 pos; + vec2 scale; int id, o; }; @@ -141,7 +142,7 @@ void Scene::Reset() SceneData::scene = NULL; } -void Scene::AddTile(TileSet *tileset, int id, vec3 pos, int o) +void Scene::AddTile(TileSet *tileset, int id, vec3 pos, int o, vec2 scale) { #if !defined _XBOX /* No WPOS on Xbox */ if ((data->ntiles % 1024) == 0) @@ -153,6 +154,7 @@ void Scene::AddTile(TileSet *tileset, int id, vec3 pos, int o) data->tiles[data->ntiles].id = id; data->tiles[data->ntiles].pos = pos; data->tiles[data->ntiles].o = o; + data->tiles[data->ntiles].scale = scale; data->ntiles++; #endif } @@ -407,6 +409,7 @@ void Scene::Render() // XXX: rename to Blit() { data->tiles[i].tileset->BlitTile(data->tiles[j].id, data->tiles[j].pos, data->tiles[j].o, + data->tiles[j].scale, vertex + 18 * (j - i), texture + 12 * (j - i)); } diff --git a/src/scene.h b/src/scene.h index 21c3618b..95fa3c44 100644 --- a/src/scene.h +++ b/src/scene.h @@ -1,7 +1,7 @@ // // Lol Engine // -// Copyright: (c) 2010-2011 Sam Hocevar +// Copyright: (c) 2010-2012 Sam Hocevar // This program is free software; you can redistribute it and/or // modify it under the terms of the Do What The Fuck You Want To // Public License, Version 2, as published by Sam Hocevar. See @@ -34,7 +34,7 @@ public: static Scene *GetDefault(); static void Reset(); - void AddTile(TileSet *tileset, int id, vec3 pos, int o); + void AddTile(TileSet *tileset, int id, vec3 pos, int o, vec2 scale); void Render(); private: diff --git a/src/sprite.cpp b/src/sprite.cpp index 28803dd6..e27dbbeb 100644 --- a/src/sprite.cpp +++ b/src/sprite.cpp @@ -1,7 +1,7 @@ // // Lol Engine // -// Copyright: (c) 2010-2011 Sam Hocevar +// Copyright: (c) 2010-2012 Sam Hocevar // This program is free software; you can redistribute it and/or // modify it under the terms of the Do What The Fuck You Want To // Public License, Version 2, as published by Sam Hocevar. See @@ -50,7 +50,8 @@ void Sprite::TickDraw(float deltams) { Entity::TickDraw(deltams); - Scene::GetDefault()->AddTile(data->tileset, data->id, position, 0); + Scene::GetDefault()->AddTile(data->tileset, data->id, position, + 0, vec2(1.0f)); } Sprite::~Sprite() diff --git a/src/tiler.cpp b/src/tiler.cpp index d34e0c29..8ec30e8f 100644 --- a/src/tiler.cpp +++ b/src/tiler.cpp @@ -1,7 +1,7 @@ // // Lol Engine // -// Copyright: (c) 2010-2011 Sam Hocevar +// Copyright: (c) 2010-2012 Sam Hocevar // This program is free software; you can redistribute it and/or // modify it under the terms of the Do What The Fuck You Want To // Public License, Version 2, as published by Sam Hocevar. See @@ -40,15 +40,14 @@ static TilerData * const data = &tilerdata; * Public Tiler class */ -TileSet *Tiler::Register(char const *path, ivec2 size, ivec2 count, - vec2 scale) +TileSet *Tiler::Register(char const *path, ivec2 size, ivec2 count) { int id = data->tilesets.MakeSlot(path); TileSet *tileset = (TileSet *)data->tilesets.GetEntity(id); if (!tileset) { - tileset = new TileSet(path, size, count, scale); + tileset = new TileSet(path, size, count); data->tilesets.SetEntity(id, tileset); } diff --git a/src/tiler.h b/src/tiler.h index 19ee6827..c91090ac 100644 --- a/src/tiler.h +++ b/src/tiler.h @@ -1,7 +1,7 @@ // // Lol Engine // -// Copyright: (c) 2010-2011 Sam Hocevar +// Copyright: (c) 2010-2012 Sam Hocevar // This program is free software; you can redistribute it and/or // modify it under the terms of the Do What The Fuck You Want To // Public License, Version 2, as published by Sam Hocevar. See @@ -27,8 +27,7 @@ namespace lol class Tiler { public: - static TileSet *Register(char const *path, ivec2 size, ivec2 count, - vec2 scale); + static TileSet *Register(char const *path, ivec2 size, ivec2 count); static void Deregister(TileSet *); }; diff --git a/src/tileset.cpp b/src/tileset.cpp index 5670c82b..81bb588b 100644 --- a/src/tileset.cpp +++ b/src/tileset.cpp @@ -1,7 +1,7 @@ // // Lol Engine // -// Copyright: (c) 2010-2011 Sam Hocevar +// Copyright: (c) 2010-2012 Sam Hocevar // This program is free software; you can redistribute it and/or // modify it under the terms of the Do What The Fuck You Want To // Public License, Version 2, as published by Sam Hocevar. See @@ -61,7 +61,7 @@ private: * Public TileSet class */ -TileSet::TileSet(char const *path, ivec2 size, ivec2 count, vec2 scale) +TileSet::TileSet(char const *path, ivec2 size, ivec2 count) : data(new TileSetData()) { data->name = (char *)malloc(10 + strlen(path) + 1); @@ -98,7 +98,6 @@ TileSet::TileSet(char const *path, ivec2 size, ivec2 count, vec2 scale) data->tx = (float)data->size.x / PotUp(data->isize.x); data->ty = (float)data->size.y / PotUp(data->isize.y); - data->scale = scale; data->ntiles = data->count.x * data->count.y; m_drawgroup = DRAWGROUP_BEFORE; @@ -219,16 +218,15 @@ void TileSet::Bind() #endif } -void TileSet::BlitTile(uint32_t id, vec3 pos, int o, +void TileSet::BlitTile(uint32_t id, vec3 pos, int o, vec2 scale, float *vertex, float *texture) { float tx = data->tx * ((id & 0xffff) % data->count.x); float ty = data->ty * ((id & 0xffff) / data->count.x); - vec2 scale = data->scale; - int dx = data->size.x; - int dy = o ? 0 : data->size.y; - int dz = o ? data->size.y : 0; + int dx = data->size.x * scale.x; + int dy = o ? 0 : data->size.y * scale.y; + int dz = o ? data->size.y * scale.y : 0; #if defined _XBOX # define STR0(x) #x @@ -241,21 +239,21 @@ void TileSet::BlitTile(uint32_t id, vec3 pos, int o, { float tmp[10]; - *vertex++ = tmp[0] = scale.x * pos.x; - *vertex++ = tmp[1] = scale.y * (pos.y + dy); - *vertex++ = tmp[2] = scale.y * (pos.z + dz); + *vertex++ = tmp[0] = pos.x; + *vertex++ = tmp[1] = pos.y + dy; + *vertex++ = tmp[2] = pos.z + dz; *texture++ = tmp[3] = tx; *texture++ = tmp[4] = ty; - *vertex++ = scale.x * (pos.x + dx); - *vertex++ = scale.y * (pos.y + dy); - *vertex++ = scale.y * (pos.z + dz); + *vertex++ = pos.x + dx; + *vertex++ = pos.y + dy; + *vertex++ = pos.z + dz; *texture++ = tx + data->tx; *texture++ = ty; - *vertex++ = tmp[5] = scale.x * (pos.x + dx); - *vertex++ = tmp[6] = scale.y * pos.y; - *vertex++ = tmp[7] = scale.y * pos.z; + *vertex++ = tmp[5] = pos.x + dx; + *vertex++ = tmp[6] = pos.y; + *vertex++ = tmp[7] = pos.z; *texture++ = tmp[8] = tx + data->tx; *texture++ = tmp[9] = ty + data->ty; @@ -271,9 +269,9 @@ void TileSet::BlitTile(uint32_t id, vec3 pos, int o, *texture++ = tmp[8]; *texture++ = tmp[9]; - *vertex++ = scale.x * pos.x; - *vertex++ = scale.y * pos.y; - *vertex++ = scale.y * pos.z; + *vertex++ = pos.x; + *vertex++ = pos.y; + *vertex++ = pos.z; *texture++ = tx; *texture++ = ty + data->ty; } diff --git a/src/tileset.h b/src/tileset.h index bf2fe9f9..8f4fae3b 100644 --- a/src/tileset.h +++ b/src/tileset.h @@ -1,7 +1,7 @@ // // Lol Engine // -// Copyright: (c) 2010-2011 Sam Hocevar +// Copyright: (c) 2010-2012 Sam Hocevar // This program is free software; you can redistribute it and/or // modify it under the terms of the Do What The Fuck You Want To // Public License, Version 2, as published by Sam Hocevar. See @@ -31,7 +31,7 @@ class TileSetData; class TileSet : public Entity { public: - TileSet(char const *path, ivec2 size, ivec2 count, vec2 scale); + TileSet(char const *path, ivec2 size, ivec2 count); virtual ~TileSet(); protected: @@ -44,7 +44,7 @@ public: ivec2 GetCount() const; ivec2 GetSize(int tileid) const; void Bind(); - void BlitTile(uint32_t id, vec3 pos, int o, + void BlitTile(uint32_t id, vec3 pos, int o, vec2 scale, float *vertex, float *texture); private: