Added XML load filename and texture references for skybox
--HG-- extra : convert_revision : svn%3A7752d6cf-9f14-4ad2-affc-04f1e67b81a5/trunk%4080
This commit is contained in:
@@ -14,6 +14,7 @@
|
||||
#import "KRSpotLight.h"
|
||||
#import "KRDirectionalLight.h"
|
||||
#import "KRInstance.h"
|
||||
#import "KRSkyBox.h"
|
||||
|
||||
|
||||
KRNode::KRNode(KRContext &context, std::string name) : KRContextObject(context)
|
||||
@@ -142,7 +143,8 @@ KRNode *KRNode::LoadXML(KRContext &context, tinyxml2::XMLElement *e) {
|
||||
new_node = new KRSpotLight(context, szName);
|
||||
} else if(strcmp(szElementName, "mesh") == 0) {
|
||||
new_node = new KRInstance(context, szName, szName, KRMat4(), e->Attribute("light_map"));
|
||||
|
||||
} else if(strcmp(szElementName, "sky_box") == 0) {
|
||||
new_node = new KRSkyBox(context, szName);
|
||||
}
|
||||
|
||||
if(new_node) {
|
||||
|
||||
@@ -16,6 +16,19 @@
|
||||
|
||||
KRSkyBox::KRSkyBox(KRContext &context, std::string name) : KRNode(context, name)
|
||||
{
|
||||
m_frontTexture = "";
|
||||
m_backTexture = "";
|
||||
m_topTexture = "";
|
||||
m_bottomTexture = "";
|
||||
m_leftTexture = "";
|
||||
m_rightTexture = "";
|
||||
|
||||
m_pFrontTexture = NULL;
|
||||
m_pBackTexture = NULL;
|
||||
m_pTopTexture = NULL;
|
||||
m_pBottomTexture = NULL;
|
||||
m_pLeftTexture = NULL;
|
||||
m_pRightTexture = NULL;
|
||||
|
||||
}
|
||||
|
||||
@@ -28,6 +41,60 @@ std::string KRSkyBox::getElementName() {
|
||||
return "sky_box";
|
||||
}
|
||||
|
||||
void KRSkyBox::loadXML(tinyxml2::XMLElement *e) {
|
||||
KRNode::loadXML(e);
|
||||
|
||||
const char *szFrontTexture = e->Attribute("front_texture");
|
||||
if(szFrontTexture) {
|
||||
m_frontTexture = szFrontTexture;
|
||||
} else {
|
||||
m_frontTexture = "";
|
||||
}
|
||||
m_pFrontTexture = NULL;
|
||||
|
||||
const char *szBackTexture = e->Attribute("back_texture");
|
||||
if(szBackTexture) {
|
||||
m_backTexture = szBackTexture;
|
||||
} else {
|
||||
m_backTexture = "";
|
||||
}
|
||||
m_pBackTexture = NULL;
|
||||
|
||||
const char *szTopTexture = e->Attribute("top_texture");
|
||||
if(szTopTexture) {
|
||||
m_topTexture = szTopTexture;
|
||||
} else {
|
||||
m_topTexture = "";
|
||||
}
|
||||
m_pTopTexture = NULL;
|
||||
|
||||
const char *szBottomTexture = e->Attribute("bottom_texture");
|
||||
if(szBottomTexture) {
|
||||
m_bottomTexture = szBottomTexture;
|
||||
} else {
|
||||
m_bottomTexture = "";
|
||||
}
|
||||
m_pBottomTexture = NULL;
|
||||
|
||||
const char *szLeftTexture = e->Attribute("left_texture");
|
||||
if(szLeftTexture) {
|
||||
m_leftTexture = szLeftTexture;
|
||||
} else {
|
||||
m_leftTexture = "";
|
||||
}
|
||||
m_pLeftTexture = NULL;
|
||||
|
||||
const char *szRightTexture = e->Attribute("right_texture");
|
||||
if(szRightTexture) {
|
||||
m_rightTexture = szRightTexture;
|
||||
} else {
|
||||
m_rightTexture = "";
|
||||
}
|
||||
m_pRightTexture = NULL;
|
||||
|
||||
}
|
||||
|
||||
|
||||
#if TARGET_OS_IPHONE
|
||||
|
||||
void KRSkyBox::render(KRCamera *pCamera, KRContext *pContext, KRBoundingVolume &frustrumVolume, KRMat4 &viewMatrix, KRVector3 &cameraPosition, KRNode::RenderPass renderPass) {
|
||||
@@ -42,9 +109,9 @@ void KRSkyBox::render(KRCamera *pCamera, KRContext *pContext, KRBoundingVolume &
|
||||
matModelToView.transpose();
|
||||
matModelToView.invert();
|
||||
|
||||
KRShader *pShader = pContext->getShaderManager()->getShader("sky_box", pCamera, false, false, false, 0, false, false, false, false, false, false, false, false, renderPass);
|
||||
// KRShader *pShader = pContext->getShaderManager()->getShader("sky_box", pCamera, false, false, false, 0, false, false, false, false, false, false, false, false, renderPass);
|
||||
|
||||
pShader->bind(pCamera, matModelToView, mvpmatrix, cameraPosition, NULL, NULL, NULL, 0, renderPass);
|
||||
// pShader->bind(pCamera, matModelToView, mvpmatrix, cameraPosition, NULL, NULL, NULL, 0, renderPass);
|
||||
|
||||
// Disable z-buffer write
|
||||
glDepthMask(GL_FALSE);
|
||||
@@ -67,4 +134,5 @@ void KRSkyBox::render(KRCamera *pCamera, KRContext *pContext, KRBoundingVolume &
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
||||
@@ -12,6 +12,7 @@
|
||||
#include <iostream>
|
||||
#import "KRMat4.h"
|
||||
#import "KRNode.h"
|
||||
#import "KRTexture.h"
|
||||
|
||||
class KRSkyBox : public KRNode {
|
||||
|
||||
@@ -21,6 +22,7 @@ public:
|
||||
virtual ~KRSkyBox();
|
||||
|
||||
virtual std::string getElementName();
|
||||
virtual void loadXML(tinyxml2::XMLElement *e);
|
||||
|
||||
#if TARGET_OS_IPHONE
|
||||
|
||||
@@ -29,6 +31,22 @@ public:
|
||||
|
||||
private:
|
||||
KRMat4 m_modelMatrix;
|
||||
|
||||
protected:
|
||||
std::string m_frontTexture;
|
||||
std::string m_backTexture;
|
||||
std::string m_topTexture;
|
||||
std::string m_bottomTexture;
|
||||
std::string m_leftTexture;
|
||||
std::string m_rightTexture;
|
||||
|
||||
KRTexture *m_pFrontTexture;
|
||||
KRTexture *m_pBackTexture;
|
||||
KRTexture *m_pTopTexture;
|
||||
KRTexture *m_pBottomTexture;
|
||||
KRTexture *m_pLeftTexture;
|
||||
KRTexture *m_pRightTexture;
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user