4.1.5 [opt] Change Node::draw() content
You can skip this subsection if you didn't implement the scene graph.
The original Node::draw() looks like the following, there is only one argument when calling the draw methods of Mesh and Node. We need to change it.
void Node::draw(glm::mat4 mat)
{
//std::cout << "Node::draw()" << std::endl;
for (int i = 0; i < meshes.size(); i++) {
meshes[i]->draw(mat * meshMats[i]);
}
// for (const auto& child : childNodes) {
for (int i = 0; i < childNodes.size(); i++) {
childNodes[i]->draw(mat * childMats[i] );
}
}We need to change it to use the new parameters
void Node::draw(glm::mat4 matModel, glm::mat4 matView, glm::mat4 matProj)
{
//std::cout << "Node::draw()" << std::endl;
for (int i = 0; i < meshes.size(); i++) {
meshes[i]->draw(matModel * meshMats[i], matView, matProj);
}
// for (const auto& child : childNodes) {
for (int i = 0; i < childNodes.size(); i++) {
childNodes[i]->draw(matModel * childMats[i], matView, matProj);
}
}Last updated