Tiled sprite improvements!

This commit is contained in:
2023-05-14 19:06:37 -07:00
parent f44fe25011
commit e6c966f3dd
10 changed files with 128 additions and 54 deletions

View File

@ -21,51 +21,51 @@ namespace Dawn {
TextureRenderTarget *renderTarget;
Texture text;
TilesetGrid grid;
CameraTexture *camTexture;
UIImage *image;
int32_t test = 0;
void stage() override {
// canvas = UICanvas::create(this);
canvas = UICanvas::create(this);
camera = Camera::create(this);
glm::vec3 off = glm::vec3(0, 0, 0);
camera->transform->lookAt(glm::vec3(10, 10, 10) + off, glm::vec3(0, 0, 0) + off);
// auto textbox = VNTextbox::create(this);
// textbox->transform.setParent(canvas->transform);
auto textbox = VNTextbox::create(this);
textbox->transform.setParent(canvas->transform);
// camNew = Camera::create(this);
// auto camTexture = camNew->item->addComponent<CameraTexture>();
// camNew->fov = 0.436332f;
// camNew->transform->lookAt(glm::vec3(10, 10, 10), glm::vec3(0, 0, 0));
// camTexture->renderTarget.setSize(1024, 1024);
camNew = Camera::create(this);
camTexture = camNew->item->addComponent<CameraTexture>();
camNew->fov = 0.436332f;
camNew->transform->lookAt(glm::vec3(0, 0, 5), glm::vec3(0, 0, 0));
camTexture->renderTarget.setSize(1, 1);
// auto uiTest = this->createSceneItem();
// uiTest->transform.setParent(canvas->transform);
// auto image = uiTest->addComponent<UIImage>();
// 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);
image = uiTest->addComponent<UIImage>();
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,
1, 13,
741, 10270,
0, 0,
0, 0
);
auto eth = EthPrefab::create(this);
// eth->tiledSprite->tileset = &grid;
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;
useEvent([&]{
assertNotNull(camTexture);
assertNotNull(image);
std::cout << "Size Update" << std::endl;
camTexture->renderTarget.setSize(image->getWidth(), image->getHeight());
}, image->eventAlignmentUpdated);
}
std::vector<Asset*> getRequiredAssets() override {