Fix NB mesh not being built correctly on .nbe file load

master
rubenwardy 2015-09-10 21:19:22 +01:00
parent 2da4ad0718
commit 2ac7f5a56b
3 changed files with 22 additions and 21 deletions

View File

@ -292,19 +292,20 @@ void NBEFileFormat::parseLine(Project * project, std::string & line)
s[i] = trim(n.substr(0, nid));
n = trim(n.substr(nid));
}
node->addNodeBox();
node->GetCurrentNodeBox()->name = s[0];
node->GetCurrentNodeBox()->one = vector3df(
(f32)atof(s[1].c_str()),
(f32)atof(s[2].c_str()),
(f32)atof(s[3].c_str())
);
node->GetCurrentNodeBox()->two = vector3df(
(f32)atof(s[4].c_str()),
(f32)atof(s[5].c_str()),
(f32)atof(s[6].c_str())
);
node->remesh();
NodeBox *box = node->addNodeBox(
vector3df(
(f32)atof(s[1].c_str()),
(f32)atof(s[2].c_str()),
(f32)atof(s[3].c_str())
),
vector3df(
(f32)atof(s[4].c_str()),
(f32)atof(s[5].c_str()),
(f32)atof(s[6].c_str())
));
box->name = s[0];
box->rebuild_needed = true;
node->remesh(box);
} else if (lower.find("end node") == 0){
project->AddNode(node);
node = NULL;

View File

@ -60,19 +60,18 @@ NodeBox* Node::GetNodeBox(int id)
}
// Operation functions
NodeBox* Node::addNodeBox()
NodeBox* Node::addNodeBox(vector3df one, vector3df two)
{
_box_count++;
// Name it
std::string name = "NodeBox" + num_to_str(_box_count);
// Set up structure
NodeBox* tmp = new NodeBox(name,
vector3df(-0.5, -0.5, -0.5),
vector3df(0.5, 0.5, 0.5));
std::string name = "NodeBox" + num_to_str(_box_count);
NodeBox *tmp = new NodeBox(name, one, two);
boxes.push_back(tmp);
// Select
select(boxes.size() - 1);
tmp->buildMesh(state, position, device, images);
return tmp;

View File

@ -21,7 +21,8 @@ public:
unsigned int NodeId() const { return _nid; }
NodeBox* GetCurrentNodeBox();
NodeBox* GetNodeBox(int id);
NodeBox* addNodeBox();
NodeBox* addNodeBox(vector3df one = vector3df(-0.5, -0.5, -0.5),
vector3df two = vector3df(0.5, 0.5, 0.5));
void deleteNodebox(int id);
void cloneNodebox(int id);
void select(int id) { _selected = id; }