diff --git a/assets/games/liminal/prefabs/EthPrefab.xml b/assets/games/liminal/prefabs/EthPrefab.xml
new file mode 100644
index 00000000..552d0fd8
--- /dev/null
+++ b/assets/games/liminal/prefabs/EthPrefab.xml
@@ -0,0 +1,8 @@
+
+
+
+
+
+
+
+
diff --git a/src/dawn/display/animation/TiledSpriteAnimation.cpp b/src/dawn/display/animation/TiledSpriteAnimation.cpp
index a4722fad..91abd2d1 100644
--- a/src/dawn/display/animation/TiledSpriteAnimation.cpp
+++ b/src/dawn/display/animation/TiledSpriteAnimation.cpp
@@ -15,5 +15,5 @@ TiledSpriteAnimation::TiledSpriteAnimation(TiledSprite *sprite) :
void TiledSpriteAnimation::tick(float_t delta) {
SimpleAnimation::tick(delta);
- this->sprite->setTile(frame);
+ this->sprite->tile = frame;
}
\ No newline at end of file
diff --git a/src/dawn/scene/components/display/TiledSprite.cpp b/src/dawn/scene/components/display/TiledSprite.cpp
index fdb7d336..45fab2ef 100644
--- a/src/dawn/scene/components/display/TiledSprite.cpp
+++ b/src/dawn/scene/components/display/TiledSprite.cpp
@@ -8,84 +8,36 @@
using namespace Dawn;
-TiledSprite::TiledSprite(SceneItem *item) : SceneItemComponent(item) {
+TiledSprite::TiledSprite(SceneItem *item) :
+ SceneItemComponent(item),
+ tile(-1),
+ tileset(nullptr),
+ meshHost(nullptr)
+{
}
-glm::vec2 TiledSprite::getUV0() {
- assertNotNull(this->tileset);
- auto tile = this->tileset->getTile(tileIndex);
- return glm::vec2(
- (this->flipState & TILED_SPRITE_FLIP_X) == 0 ? tile.uv0.x : tile.uv1.x,
- (this->flipState & TILED_SPRITE_FLIP_Y) == 0 ? tile.uv0.y : tile.uv1.y
- );
-}
-
-glm::vec2 TiledSprite::getUV1() {
- assertNotNull(this->tileset);
- auto tile = this->tileset->getTile(tileIndex);
- return glm::vec2(
- (this->flipState & TILED_SPRITE_FLIP_X) == 0 ? tile.uv1.x : tile.uv0.x,
- (this->flipState & TILED_SPRITE_FLIP_Y) == 0 ? tile.uv1.y : tile.uv0.y
- );
-}
-
-void TiledSprite::setTileset(Tileset *tileset) {
- assertNotNull(tileset);
- this->tileset = tileset;
- this->setTile(0);
-}
-
-void TiledSprite::setTilesetAndSize(TilesetGrid *tileset, glm::vec2 center) {
- this->setTileset(tileset);
- this->setSize(glm::vec2(tileset->divX, tileset->divY), center);
-}
-
-void TiledSprite::setTilesetAndSize(TilesetGrid *tileset) {
- this->setTileset(tileset);
- this->setSize(glm::vec2(tileset->divX, tileset->divY));
-}
-
-void TiledSprite::setTile(int32_t tileIndex) {
- if(tileIndex == this->tileIndex) return;
- this->tileIndex = tileIndex;
- if(this->host != nullptr) {
- QuadMesh::bufferCoordinates(
- &this->host->mesh, this->getUV0(), this->getUV1(), 0
- );
- }
-}
-
-void TiledSprite::setSize(glm::vec2 size, glm::vec2 center) {
- this->xy0 = -center;
- this->xy1 = size - center;
- if(this->host != nullptr) {
- QuadMesh::bufferPositions(
- &this->host->mesh, this->xy0, this->xy1, 0
- );
- }
-}
-
-void TiledSprite::setSize(glm::vec2 size) {
- this->setSize(size, size / 2.0f);
-}
-
std::vector TiledSprite::getDependencies() {
- this->host = this->item->getComponent();
+ if(this->meshHost == nullptr) {
+ this->meshHost = this->item->getComponent();
+ }
- return std::vector{
- this->host
+ return {
+ this->meshHost
};
}
void TiledSprite::onStart() {
SceneItemComponent::onStart();
- assertNotNull(this->host);
- assertNotNull(this->tileset);
- QuadMesh::initQuadMesh(&this->host->mesh,
- this->xy0, this->getUV0(),
- this->xy1, this->getUV1(),
- 0
- );
+ useEffect([&]{
+ if(this->meshHost == nullptr || this->tileset == nullptr) return;
+ auto tile = this->tileset->getTile(this->tile);
+ this->meshHost->uv0 = tile.uv0;
+ this->meshHost->uv1 = tile.uv1;
+ }, {
+ &this->tile,
+ &this->meshHost,
+ &this->tileset
+ })();
}
\ No newline at end of file
diff --git a/src/dawn/scene/components/display/TiledSprite.hpp b/src/dawn/scene/components/display/TiledSprite.hpp
index a3efbac7..c98dbbe3 100644
--- a/src/dawn/scene/components/display/TiledSprite.hpp
+++ b/src/dawn/scene/components/display/TiledSprite.hpp
@@ -4,85 +4,21 @@
// https://opensource.org/licenses/MIT
#pragma once
-#include "scene/SceneItemComponent.hpp"
-#include "scene/components/display/mesh/MeshRenderer.hpp"
-#include "scene/components/display/mesh/MeshHost.hpp"
-#include "display/mesh/QuadMesh.hpp"
#include "display/Tileset.hpp"
-
-#define TILED_SPRITE_FLIP_Y FLAG_DEFINE(0)
-#define TILED_SPRITE_FLIP_X FLAG_DEFINE(1)
+#include "scene/components/display/mesh/QuadMeshHost.hpp"
namespace Dawn {
class TiledSprite : public SceneItemComponent {
- protected:
- MeshHost *host = nullptr;
- Tileset *tileset = nullptr;
- flag_t flipState = TILED_SPRITE_FLIP_Y;
- int32_t tileIndex = -1;
- glm::vec2 xy0 = glm::vec2(0, 0);
- glm::vec2 xy1 = glm::vec2(1, 1);
-
- glm::vec2 getUV0();
- glm::vec2 getUV1();
-
public:
+ // @optional
+ StateProperty tileset;
+ // @optional
+ StateProperty meshHost;
+ // @optional
+ StateProperty tile;
+
TiledSprite(SceneItem *item);
-
- std::vector getDependencies() override;
+ std::vector getDependencies();
void onStart() override;
-
- /**
- * Sets which tileset to use for this sprite.
- *
- * @param tileset Tileset to use.
- */
- void setTileset(Tileset *tileset);
-
- /**
- * Sets the tileset for the sprite, and autosizes the sprite based on
- * this tileset.
- *
- * @param gridTileset Tileset to use.
- * @param center The center offset of the sprite.
- */
- void setTilesetAndSize(TilesetGrid *gridTileset, glm::vec2 center);
-
- /**
- * Sets the tileset for the sprite, and autosizes the sprite based on
- * this tileset. This will put the sprite centered on its origin.
- *
- * @param gridTileset Tileset to use.
- */
- void setTilesetAndSize(TilesetGrid *gridTileset);
-
- /**
- * Updates the selected tile.
- *
- * @param tile Tile to use.
- */
- void setTile(int32_t tile);
-
- /**
- * Adjust how the sprite is flippxed.
- *
- * @param flippedState Flipped axis flags.
- */
- void setFlippedState(flag_t flippedState);
-
- /**
- * Sets the dimensions of this tiled sprite.
- *
- * @param size Size of the sprite.
- * @param center Negative center offset.
- */
- void setSize(glm::vec2 size, glm::vec2 center);
-
- /**
- * Sets the size of this sprite. This will center the sprite on its origin
- *
- * @param size Size of the sprite.
- */
- void setSize(glm::vec2 size);
};
}
\ No newline at end of file
diff --git a/src/dawnliminal/CMakeLists.txt b/src/dawnliminal/CMakeLists.txt
index 773059b1..f7729a26 100644
--- a/src/dawnliminal/CMakeLists.txt
+++ b/src/dawnliminal/CMakeLists.txt
@@ -21,4 +21,7 @@ set(LIMINAL_ASSETS_DIR ${DAWN_ASSETS_DIR}/games/liminal)
tool_vnscene(${LIMINAL_ASSETS_DIR}/test.xml)
tool_prefab(${LIMINAL_ASSETS_DIR}/VNTextbox.xml)
-tool_truetype(font_main ${DAWN_ASSETS_DIR}/ark-pixel.ttf)
\ No newline at end of file
+tool_truetype(font_main ${DAWN_ASSETS_DIR}/ark-pixel.ttf)
+
+tool_prefab(${LIMINAL_ASSETS_DIR}/prefabs/EthPrefab.xml)
+tool_texture(texture_eth ${LIMINAL_ASSETS_DIR}/textures/eth.png)
\ No newline at end of file
diff --git a/src/dawnliminal/scenes/HelloWorldScene.hpp b/src/dawnliminal/scenes/HelloWorldScene.hpp
index 4683712b..1bd3aa75 100644
--- a/src/dawnliminal/scenes/HelloWorldScene.hpp
+++ b/src/dawnliminal/scenes/HelloWorldScene.hpp
@@ -10,6 +10,7 @@
#include "prefabs/VNTextbox.hpp"
#include "display/TextureRenderTarget.hpp"
#include "scene/components/ui/UIImage.hpp"
+#include "prefabs/EthPrefab.hpp"
namespace Dawn {
class HelloWorldScene : public Scene {
@@ -19,51 +20,59 @@ namespace Dawn {
UICanvas *canvas;
TextureRenderTarget *renderTarget;
Texture text;
+ TilesetGrid grid;
int32_t test = 0;
void stage() override {
- canvas = UICanvas::create(this);
+ // canvas = UICanvas::create(this);
camera = Camera::create(this);
- glm::vec3 off = glm::vec3(90000, 100, 100);
+ glm::vec3 off = glm::vec3(0, 0, 0);
camera->transform->lookAt(glm::vec3(10, 10, 10) + off, glm::vec3(0, 0, 0) + off);
- camNew = Camera::create(this);
- auto camTexture = camNew->item->addComponent();
- camNew->fov = 0.436332f;
- camNew->transform->lookAt(glm::vec3(10, 10, 10), glm::vec3(0, 0, 0));
- camTexture->renderTarget.setSize(1024, 1024);
+ // auto textbox = VNTextbox::create(this);
+ // textbox->transform.setParent(canvas->transform);
- auto cube = SimpleSpinningCubePrefab::create(this);
+ // camNew = Camera::create(this);
+ // auto camTexture = camNew->item->addComponent();
+ // camNew->fov = 0.436332f;
+ // camNew->transform->lookAt(glm::vec3(10, 10, 10), glm::vec3(0, 0, 0));
+ // camTexture->renderTarget.setSize(1024, 1024);
- auto textbox = VNTextbox::create(this);
- textbox->transform.setParent(canvas->transform);
+ // auto uiTest = this->createSceneItem();
+ // uiTest->transform.setParent(canvas->transform);
+ // auto image = uiTest->addComponent();
+ // image->texture = camTexture->renderTarget.getTexture();
+ // image->alignment = glm::vec4(0, 0, 50, 0);
+ // image->alignX = UI_COMPONENT_ALIGN_START;
+ // image->alignUnitRight = UI_COMPONENT_ALIGN_UNIT_PERCENT;
+ // image->alignY = UI_COMPONENT_ALIGN_STRETCH;
- auto uiTest = this->createSceneItem();
- uiTest->transform.setParent(canvas->transform);
- auto image = uiTest->addComponent();
- image->texture = camTexture->renderTarget.getTexture();
- image->alignment = glm::vec4(0, 0, 50, 0);
- image->alignX = UI_COMPONENT_ALIGN_START;
- image->alignUnitRight = UI_COMPONENT_ALIGN_UNIT_PERCENT;
- image->alignY = UI_COMPONENT_ALIGN_STRETCH;
+ this->grid = TilesetGrid(
+ 1, 26,
+ 741, 20540,
+ 0, 0,
+ 0, 0
+ );
+ auto eth = EthPrefab::create(this);
+ // eth->tiledSprite->tileset = &grid;
- struct Color colors[] = {
- COLOR_BLUE, COLOR_MAGENTA, COLOR_WHITE,
- COLOR_MAGENTA, COLOR_CORNFLOWER_BLUE, COLOR_MAGENTA,
- COLOR_BLACK, COLOR_MAGENTA, COLOR_BLUE
- };
- text.setSize(3, 3);
- text.buffer(colors);
- textbox->border->texture = &text;
+ // struct Color colors[] = {
+ // COLOR_BLUE, COLOR_MAGENTA, COLOR_WHITE,
+ // COLOR_MAGENTA, COLOR_CORNFLOWER_BLUE, COLOR_MAGENTA,
+ // COLOR_BLACK, COLOR_MAGENTA, COLOR_BLUE
+ // };
+ // text.setSize(3, 3);
+ // text.buffer(colors);
+ // textbox->border->texture = &text;
}
std::vector getRequiredAssets() override {
auto assMan = &this->game->assetManager;
std::vector assets;
- vectorAppend(&assets, SimpleSpinningCubePrefab::prefabAssets(assMan));
vectorAppend(&assets, VNTextbox::prefabAssets(assMan));
+ vectorAppend(&assets, EthPrefab::prefabAssets(assMan));
return assets;
}
diff --git a/src/dawnopengl/display/shader/SimpleTexturedShader.cpp b/src/dawnopengl/display/shader/SimpleTexturedShader.cpp
index baac27ab..cc2576e0 100644
--- a/src/dawnopengl/display/shader/SimpleTexturedShader.cpp
+++ b/src/dawnopengl/display/shader/SimpleTexturedShader.cpp
@@ -107,7 +107,7 @@ std::vector SimpleTexturedShader::getPassItems(
Material *material,
Camera *camera
) {
- SimpleTexturedMaterial *simpleMaterial = dynamic_cast(material);
+ auto simpleMaterial = dynamic_cast(material);
assertNotNull(simpleMaterial);
struct ShaderPassItem onlyPass;
diff --git a/src/dawntools/texturetool/TextureTool.cpp b/src/dawntools/texturetool/TextureTool.cpp
index adafb4dd..9b66163c 100644
--- a/src/dawntools/texturetool/TextureTool.cpp
+++ b/src/dawntools/texturetool/TextureTool.cpp
@@ -18,7 +18,10 @@ int32_t TextureTool::start() {
// Load input file
File in(flags["input"]);
- if(!in.open(FILE_MODE_READ)) return 1;
+ if(!in.open(FILE_MODE_READ)) {
+ std::cout << "Failed to open input file " << in.filename << std::endl;
+ return 1;
+ }
int w, h, channels;
auto imageRaw = stbi_load_from_file(in.file, &w, &h, &channels, STBI_rgb_alpha);