implement cubes exporter for web viewer
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@@ -19,3 +19,4 @@ data/thumbs
|
||||
PanoPainter.aps
|
||||
panopainter-log.txt
|
||||
*.pano
|
||||
frames/
|
||||
|
||||
@@ -127,7 +127,7 @@
|
||||
<border height="30" color=".5" align="center" justify="center">
|
||||
<text text="Colors" font-face="arial" font-size="11" color="1 1 1 1"/>
|
||||
</border>
|
||||
<border color=".3" pad="5" dir="row" height="150">
|
||||
<border color=".3" pad="5" dir="row" height="250">
|
||||
<color-quad id="quad" color="1 0 0 1" height="100%" grow="1"/>
|
||||
<node width="30" dir="col" pad="0 0 0 5"><slider-hue id="hue"/></node>
|
||||
</border>
|
||||
@@ -559,6 +559,10 @@
|
||||
<icon icon="disk" width="20"/>
|
||||
<text text="Export JPG" margin="0 0 0 5" font-face="arial" font-size="11"/>
|
||||
</button-custom>
|
||||
<button-custom id="file-export-cubes" text="Menu" height="40" align="center" color=".2" pad="0 0 0 10" dir="row">
|
||||
<icon icon="page_white_stack" width="20"/>
|
||||
<text text="Export Cubes" margin="0 0 0 5" font-face="arial" font-size="11"/>
|
||||
</button-custom>
|
||||
<button-custom id="file-cloud-upload" text="Menu" height="40" align="center" color=".2" pad="0 0 0 10" dir="row">
|
||||
<icon icon="weather_clouds" width="20"/>
|
||||
<text text="Cloud Upload" margin="0 0 0 5" font-face="arial" font-size="11"/>
|
||||
|
||||
BIN
data/spritesheet_names.png
Normal file
BIN
data/spritesheet_names.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 941 KiB |
@@ -22,7 +22,7 @@
|
||||
<ProjectGuid>{6D5028CE-4D76-4B6A-A7C2-DE5A3268D433}</ProjectGuid>
|
||||
<Keyword>Win32Proj</Keyword>
|
||||
<RootNamespace>engine</RootNamespace>
|
||||
<WindowsTargetPlatformVersion>10.0.16299.0</WindowsTargetPlatformVersion>
|
||||
<WindowsTargetPlatformVersion>10.0.17134.0</WindowsTargetPlatformVersion>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
||||
@@ -353,6 +353,9 @@
|
||||
<ItemGroup>
|
||||
<Natvis Include="libs\glm\util\glm.natvis" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Xml Include="data\layout.xml" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||
<ImportGroup Label="ExtensionTargets">
|
||||
</ImportGroup>
|
||||
|
||||
@@ -445,4 +445,9 @@
|
||||
<Filter>extras</Filter>
|
||||
</Natvis>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Xml Include="data\layout.xml">
|
||||
<Filter>extras</Filter>
|
||||
</Xml>
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
@@ -140,6 +140,7 @@ public:
|
||||
void dialog_open();
|
||||
void dialog_browse();
|
||||
void dialog_export();
|
||||
void dialog_export_cubes();
|
||||
void dialog_layer_rename();
|
||||
|
||||
void cloud_upload();
|
||||
|
||||
@@ -258,6 +258,14 @@ void App::dialog_export()
|
||||
}
|
||||
}
|
||||
|
||||
void App::dialog_export_cubes()
|
||||
{
|
||||
if (canvas)
|
||||
{
|
||||
canvas->m_canvas->export_cubes(data_path + "/" + doc_name);
|
||||
}
|
||||
}
|
||||
|
||||
void App::dialog_layer_rename()
|
||||
{
|
||||
auto dialog = std::make_shared<NodeDialogLayerRename>();
|
||||
|
||||
@@ -401,6 +401,11 @@ void App::init_menu_file()
|
||||
dialog_export();
|
||||
popup->mouse_release();
|
||||
popup->destroy();
|
||||
};
|
||||
popup->find<NodeButtonCustom>("file-export-cubes")->on_click = [this](Node*) {
|
||||
dialog_export_cubes();
|
||||
popup->mouse_release();
|
||||
popup->destroy();
|
||||
};
|
||||
popup->find<NodeButtonCustom>("file-cloud-upload")->on_click = [this](Node*) {
|
||||
cloud_upload();
|
||||
|
||||
@@ -1254,6 +1254,72 @@ void ui::Canvas::export_anim(std::string data_path)
|
||||
glActiveTexture(GL_TEXTURE0);
|
||||
}
|
||||
|
||||
void ui::Canvas::export_cubes(std::string data_path)
|
||||
{
|
||||
std::array<std::string, 6> names {
|
||||
"pz", "px", "nz", "nx",
|
||||
"py", "ny"
|
||||
};
|
||||
const int stride = m_width * 4;
|
||||
auto buffer = std::make_unique<uint8_t[]>(m_width * m_height * 4);
|
||||
auto flipped = std::make_unique<uint8_t[]>(m_width * m_height * 4);
|
||||
for (auto i : m_order)
|
||||
{
|
||||
for (int plane = 0; plane < 6; plane++)
|
||||
{
|
||||
auto& l = m_layers[i];
|
||||
l.m_rtt[plane].bindFramebuffer();
|
||||
glReadPixels(0, 0, m_width, m_height, GL_RGBA, GL_UNSIGNED_BYTE, buffer.get());
|
||||
l.m_rtt[plane].unbindFramebuffer();
|
||||
|
||||
if (plane < 4)
|
||||
{
|
||||
for (int y = 0; y < m_height; y++)
|
||||
{
|
||||
int y_rev = m_height - y - 1;
|
||||
std::copy_n(buffer.get() + y * stride, stride, flipped.get() + y_rev * stride);
|
||||
}
|
||||
std::swap(buffer, flipped);
|
||||
}
|
||||
else
|
||||
{
|
||||
for (int y = 0; y < m_height; y++)
|
||||
{
|
||||
auto src = (glm::u8vec4*)(buffer.get() + y * stride);
|
||||
auto dst = (glm::u8vec4*)(flipped.get() + y * stride);
|
||||
for (int x = 0; x < m_width; x++)
|
||||
{
|
||||
int x_rev = m_width - x - 1;
|
||||
dst[x_rev] = src[x];
|
||||
}
|
||||
//std::copy_backward(src + stride, src, dst + stride);
|
||||
}
|
||||
std::swap(buffer, flipped);
|
||||
}
|
||||
|
||||
static char name[128];
|
||||
sprintf(name, "%s-%02d-%d.png", data_path.c_str(), i, plane);
|
||||
int ret = stbi_write_png(name, m_width, m_height, 4, buffer.get(), 0);
|
||||
|
||||
|
||||
#ifdef __IOS__
|
||||
[[PHPhotoLibrary sharedPhotoLibrary] performChanges:^{
|
||||
NSURL* url = [NSURL fileURLWithPath : [NSString stringWithUTF8String : name]];
|
||||
PHAssetChangeRequest *changeRequest = [PHAssetChangeRequest creationRequestForAssetFromImageAtFileURL : url];
|
||||
changeRequest.creationDate = [NSDate date];
|
||||
} completionHandler: ^ (BOOL success, NSError *error) {
|
||||
if (success) {
|
||||
NSLog(@"successfully saved");
|
||||
}
|
||||
else {
|
||||
NSLog(@"error saving to photos : %@", error);
|
||||
}
|
||||
}];
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void ui::Canvas::project_save(std::string file_path)
|
||||
{
|
||||
std::thread t(&ui::Canvas::project_save_thread, this, file_path);
|
||||
|
||||
@@ -139,6 +139,7 @@ public:
|
||||
void export_equirectangular(std::string file_path);
|
||||
void export_equirectangular_thread(std::string file_path);
|
||||
void export_anim(std::string data_path);
|
||||
void export_cubes(std::string data_path);
|
||||
void project_save(std::string file_path);
|
||||
void project_save_thread(std::string file_path);
|
||||
void project_open(std::string file_path, std::function<void()> on_complete = nullptr);
|
||||
|
||||
@@ -12,7 +12,7 @@ void NodePopupMenu::init()
|
||||
m_flood_events = true;
|
||||
SetPosition(0, 0);
|
||||
SetWidth(100);
|
||||
SetHeight(400);
|
||||
SetHeight(500);
|
||||
SetPositioning(YGPositionTypeAbsolute);
|
||||
m_mouse_ignore = false;
|
||||
m_capture_children = false;
|
||||
|
||||
Reference in New Issue
Block a user