-
Notifications
You must be signed in to change notification settings - Fork 0
/
PmdfViewer.cpp
89 lines (78 loc) · 3.68 KB
/
PmdfViewer.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
#include "PmdfViewer.h"
#define GLM_ENABLE_EXPERIMENTAL
#include <glm/gtc/quaternion.hpp>
#include <glm/gtx/euler_angles.hpp>
#include <glm/gtx/transform.hpp>
#include "MainWindow.h"
extern MainWindow* globalWindowPointer;
PmdfViewer::PmdfViewer(){
builder = Gtk::Builder::create_from_file("res/bsp.glade");
Gtk::Grid* root;
builder->get_widget("root", root);
add(*root);
root->show();
Gtk::Button* loadBSP;
builder->get_widget("loadMap", loadBSP);
loadBSP->signal_clicked().connect([this]{
if(tag != nullptr){
/*int c = tag->getGeoInstanceCount();
for(int i = 0; i < c; i++){
auto inst = tag->getGeoInstanceInfo(i);
if(inst.geo == nullptr){
// later, maybe add an error here (maybe like source?), but for now, just skip it
continue;
}
glm::mat3 rot_mat(inst.forward, inst.left, inst.up);
//glm::mat3 rot_mat(glm::vec3(inst.up.x,inst.forward.x,inst.left.x), glm::vec3(inst.up.y,inst.forward.y,inst.left.y), glm::vec3(inst.up.z,inst.forward.z,inst.left.z));
//glm::mat3 rot_mat(inst.up, inst.forward, inst.left);
glm::mat4 bigrotmat(rot_mat);
//bigrotmat = glm::transpose(bigrotmat);
glm::vec3 rotation = glm::eulerAngles(glm::quat_cast(rot_mat));
rotation = glm::degrees(rotation);
glm::vec4 rotatedPos = glm::rotate(glm::radians(-90.0f), glm::vec3(1.0,0.0,0.0)) * glm::vec4(inst.position,1.0f);
globalWindowPointer->viewer3D.addRenderGeo(&inst.geo->geoHandle, inst.meshIndex, inst.position, bigrotmat, -inst.scale); // glm::vec3(rotatedPos.x,rotatedPos.y,rotatedPos.z)
}*/
globalWindowPointer->viewer3D.addRenderGeo(&(dynamic_cast<pmdfHandle*>(tag))->geoHandle, 0, glm::vec3(0.0,0.0,0.0), glm::vec3(0.0,0.0,0.0), glm::vec3(1.0,1.0,1.0));
//globalWindowPointer->currentExporter->addRenderGeo(&(dynamic_cast<pmdfHandle*>(tag))->geoHandle, 0, glm::vec3(0.0,0.0,0.0), glm::vec3(0.0,0.0,0.0), glm::vec3(1.0,1.0,1.0),"owo");
}
});
Gtk::Button* exportBSP;
builder->get_widget("addExportScene", exportBSP);
exportBSP->signal_clicked().connect([this]{
if(tag != nullptr){
/*int c = tag->getGeoInstanceCount();
for(int i = 0; i < c; i++){
auto inst = tag->getGeoInstanceInfo(i);
if(inst.geo == nullptr){
// later, maybe add an error here (maybe like source?), but for now, just skip it
continue;
}
glm::mat3 rot_mat(inst.forward, inst.left, inst.up);
//glm::mat3 rot_mat(glm::vec3(inst.up.x,inst.forward.x,inst.left.x), glm::vec3(inst.up.y,inst.forward.y,inst.left.y), glm::vec3(inst.up.z,inst.forward.z,inst.left.z));
//glm::mat3 rot_mat(inst.up, inst.forward, inst.left);
glm::mat4 bigrotmat(rot_mat);
//bigrotmat = glm::transpose(bigrotmat);
glm::vec3 rotation = glm::eulerAngles(glm::quat_cast(rot_mat));
rotation = glm::degrees(rotation);
glm::vec4 rotatedPos = glm::rotate(glm::radians(-90.0f), glm::vec3(1.0,0.0,0.0)) * glm::vec4(inst.position,1.0f);
globalWindowPointer->viewer3D.addRenderGeo(&inst.geo->geoHandle, inst.meshIndex, inst.position, bigrotmat, -inst.scale); // glm::vec3(rotatedPos.x,rotatedPos.y,rotatedPos.z)
}*/
//globalWindowPointer->viewer3D.addRenderGeo(&(dynamic_cast<pmdfHandle*>(tag))->geoHandle, 0, glm::vec3(0.0,0.0,0.0), glm::vec3(0.0,0.0,0.0), glm::vec3(1.0,1.0,1.0));
globalWindowPointer->currentExporter->addRenderGeo(&(dynamic_cast<pmdfHandle*>(tag))->geoHandle, 0, glm::vec3(0.0,0.0,0.0), glm::vec3(0.0,0.0,0.0), glm::vec3(1.0,1.0,1.0),"owo");
}
});
tag = nullptr;
item = nullptr;
}
PmdfViewer::~PmdfViewer(){
}
void PmdfViewer::setItem(Item* item){
this->item = item;
if(item->tagManager != nullptr){
Tag* tmptag = item->tagManager->getTag(item->moduleItem->assetID);
tag = dynamic_cast<pmdfHandle*>(tmptag);
if(tag == nullptr){
return;
}
}
}