Commits

Jason McKesson committed 44b3a49

Added extra matrices to nodes in the scene system.

Comments (0)

Files changed (3)

Tut 18 Bumpy Textures/Bumpy Square.cpp

 		glBindBuffer(GL_UNIFORM_BUFFER, 0);
 	}
 
+	{
+		glm::mat4 temp(1.0f);
+		g_nodes[0].SetNodePreTransform(glm::rotate(temp, 20.0f, glm::vec3(0.0f, 1.0f, 0.0f)));
+	}
+
 	g_pScene->Render(modelMatrix.Top());
 
 	if(g_pObjPole && g_bDrawLightPos)
 		glUseProgram(g_unlitProg);
 		glUniformMatrix4fv(g_unlitModelToCameraMatrixUnif, 1, GL_FALSE,
 			glm::value_ptr(modelMatrix.Top()));
-		glUniform4f(g_unlitObjectColorUnif, 0.25f, 0.25f, 0.25f, 1.0f);
+		glUniform4f(g_unlitObjectColorUnif, 0.01f, 0.01f, 0.01f, 1.0f);
 		g_pSphereMesh->Render("flat");
 	}
 

framework/Scene.cpp

 			: m_orient(1.0f, 0.0f, 0.0f, 0.0f)
 			, m_scale(1.0f, 1.0f, 1.0f)
 			, m_trans(0.0f, 0.0f, 0.0f)
+			, m_postTransform(1.0f)
+			, m_preTransform(1.0f)
 		{}
 
 		glm::mat4 GetMatrix() const
 		{
-			glm::mat4 ret;
+			glm::mat4 ret = m_postTransform;
 			ret = glm::translate(ret, m_trans);
 			ret *= glm::mat4_cast(m_orient);
 			ret = glm::scale(ret, m_scale);
+			ret *= m_preTransform;
 			return ret;
 		}
 
 		glm::fquat m_orient;
 		glm::vec3 m_scale;
 		glm::vec3 m_trans;
+
+		glm::mat4 m_postTransform;
+		glm::mat4 m_preTransform;
 	};
 
 	enum SamplerTypes
 			m_nodeTm.m_scale = nodeScale;
 		}
 
+		void SetNodePreTransform(const glm::mat4 &preTransform)
+		{
+			m_nodeTm.m_preTransform = preTransform;
+		}
+
+		void SetNodePostTransform(const glm::mat4 &postTransform)
+		{
+			m_nodeTm.m_postTransform = postTransform;
+		}
+
 		void Render(const std::vector<GLuint> &samplers, glm::mat4 baseMat) const
 		{
 			if(m_baseVariant.pProg)
 		m_pNode->NodeSetTrans(offset);
 	}
 
+	void NodeRef::SetNodePreTransform( const glm::mat4 &preTransform )
+	{
+		m_pNode->SetNodePreTransform(preTransform);
+	}
+
+	void NodeRef::SetNodePostTransform( const glm::mat4 &postTransform )
+	{
+		m_pNode->SetNodePostTransform(postTransform);
+	}
+
 	void NodeRef::SetStateBinder( StateBinder *pBinder )
 	{
 		m_pNode->SetStateBinder(pBinder);

framework/Scene.h

 		//Sets the current translation to the given one.
 		void NodeSetTrans(const glm::vec3 &offset);
 
+		//Sets the pre-transform matrix.
+		void SetNodePreTransform(const glm::mat4 &preTransform);
+		//Sets the post-transform matrix.
+		void SetNodePostTransform(const glm::mat4 &postTransform);
+
 		//This object does *NOT* claim ownership of the pointer.
 		//You must ensure that it stays around so long as this Scene exists.
 		void SetStateBinder(StateBinder *pBinder);