Implemented cross chunk objects. This concludes the chunk render implementation and closes #4.
This commit is contained in:
parent
f9212c9938
commit
43b752ee63
@ -5,6 +5,7 @@
|
|||||||
<composition>
|
<composition>
|
||||||
<typeID>20</typeID>
|
<typeID>20</typeID>
|
||||||
<ignoreHeightmap>false</ignoreHeightmap>
|
<ignoreHeightmap>false</ignoreHeightmap>
|
||||||
|
<crossesChunks>true</crossesChunks>
|
||||||
<object>
|
<object>
|
||||||
<modelPath>marbleSmooth.obj</modelPath>
|
<modelPath>marbleSmooth.obj</modelPath>
|
||||||
<xOffset>0.0</xOffset>
|
<xOffset>0.0</xOffset>
|
||||||
@ -22,6 +23,7 @@
|
|||||||
<composition>
|
<composition>
|
||||||
<typeID>40</typeID>
|
<typeID>40</typeID>
|
||||||
<ignoreHeightmap>false</ignoreHeightmap>
|
<ignoreHeightmap>false</ignoreHeightmap>
|
||||||
|
<crossesChunks>true</crossesChunks>
|
||||||
<object>
|
<object>
|
||||||
<modelPath>block.obj</modelPath>
|
<modelPath>block.obj</modelPath>
|
||||||
<xOffset>0.0</xOffset>
|
<xOffset>0.0</xOffset>
|
||||||
@ -39,6 +41,7 @@
|
|||||||
<composition>
|
<composition>
|
||||||
<typeID>60</typeID>
|
<typeID>60</typeID>
|
||||||
<ignoreHeightmap>false</ignoreHeightmap>
|
<ignoreHeightmap>false</ignoreHeightmap>
|
||||||
|
<crossesChunks>false</crossesChunks>
|
||||||
<object>
|
<object>
|
||||||
<modelPath>column.obj</modelPath>
|
<modelPath>column.obj</modelPath>
|
||||||
<xOffset>0.0</xOffset>
|
<xOffset>0.0</xOffset>
|
||||||
@ -56,6 +59,7 @@
|
|||||||
<composition>
|
<composition>
|
||||||
<typeID>80</typeID>
|
<typeID>80</typeID>
|
||||||
<ignoreHeightmap>false</ignoreHeightmap>
|
<ignoreHeightmap>false</ignoreHeightmap>
|
||||||
|
<crossesChunks>false</crossesChunks>
|
||||||
<object>
|
<object>
|
||||||
<modelPath>torch.obj</modelPath>
|
<modelPath>torch.obj</modelPath>
|
||||||
<xOffset>0.0</xOffset>
|
<xOffset>0.0</xOffset>
|
||||||
@ -85,6 +89,7 @@
|
|||||||
<composition>
|
<composition>
|
||||||
<typeID>81</typeID>
|
<typeID>81</typeID>
|
||||||
<ignoreHeightmap>false</ignoreHeightmap>
|
<ignoreHeightmap>false</ignoreHeightmap>
|
||||||
|
<crossesChunks>false</crossesChunks>
|
||||||
<object>
|
<object>
|
||||||
<modelPath>torch.obj</modelPath>
|
<modelPath>torch.obj</modelPath>
|
||||||
<xOffset>0.0</xOffset>
|
<xOffset>0.0</xOffset>
|
||||||
@ -129,6 +134,7 @@
|
|||||||
<composition>
|
<composition>
|
||||||
<typeID>100</typeID>
|
<typeID>100</typeID>
|
||||||
<ignoreHeightmap>false</ignoreHeightmap>
|
<ignoreHeightmap>false</ignoreHeightmap>
|
||||||
|
<crossesChunks>false</crossesChunks>
|
||||||
<object>
|
<object>
|
||||||
<modelPath>column.obj</modelPath>
|
<modelPath>column.obj</modelPath>
|
||||||
<xOffset>0.0</xOffset>
|
<xOffset>0.0</xOffset>
|
||||||
@ -168,6 +174,7 @@
|
|||||||
<composition>
|
<composition>
|
||||||
<typeID>120</typeID>
|
<typeID>120</typeID>
|
||||||
<ignoreHeightmap>false</ignoreHeightmap>
|
<ignoreHeightmap>false</ignoreHeightmap>
|
||||||
|
<crossesChunks>false</crossesChunks>
|
||||||
<object>
|
<object>
|
||||||
<modelPath>switchInner.obj</modelPath>
|
<modelPath>switchInner.obj</modelPath>
|
||||||
<xOffset>0.0</xOffset>
|
<xOffset>0.0</xOffset>
|
||||||
@ -251,6 +258,7 @@
|
|||||||
<composition>
|
<composition>
|
||||||
<typeID>140</typeID>
|
<typeID>140</typeID>
|
||||||
<ignoreHeightmap>true</ignoreHeightmap>
|
<ignoreHeightmap>true</ignoreHeightmap>
|
||||||
|
<crossesChunks>false</crossesChunks>
|
||||||
<object>
|
<object>
|
||||||
<modelPath>block.obj</modelPath>
|
<modelPath>block.obj</modelPath>
|
||||||
<xOffset>0.0</xOffset>
|
<xOffset>0.0</xOffset>
|
||||||
@ -268,6 +276,7 @@
|
|||||||
<composition>
|
<composition>
|
||||||
<typeID>141</typeID>
|
<typeID>141</typeID>
|
||||||
<ignoreHeightmap>true</ignoreHeightmap>
|
<ignoreHeightmap>true</ignoreHeightmap>
|
||||||
|
<crossesChunks>false</crossesChunks>
|
||||||
<object>
|
<object>
|
||||||
<modelPath>block.obj</modelPath>
|
<modelPath>block.obj</modelPath>
|
||||||
<xOffset>0.0</xOffset>
|
<xOffset>0.0</xOffset>
|
||||||
@ -289,6 +298,7 @@
|
|||||||
<composition>
|
<composition>
|
||||||
<typeID>160</typeID>
|
<typeID>160</typeID>
|
||||||
<ignoreHeightmap>true</ignoreHeightmap>
|
<ignoreHeightmap>true</ignoreHeightmap>
|
||||||
|
<crossesChunks>false</crossesChunks>
|
||||||
<object>
|
<object>
|
||||||
<modelPath>block.obj</modelPath>
|
<modelPath>block.obj</modelPath>
|
||||||
<xOffset>0.0</xOffset>
|
<xOffset>0.0</xOffset>
|
||||||
@ -339,6 +349,7 @@
|
|||||||
<composition>
|
<composition>
|
||||||
<typeID>161</typeID>
|
<typeID>161</typeID>
|
||||||
<ignoreHeightmap>true</ignoreHeightmap>
|
<ignoreHeightmap>true</ignoreHeightmap>
|
||||||
|
<crossesChunks>false</crossesChunks>
|
||||||
<object>
|
<object>
|
||||||
<modelPath>block.obj</modelPath>
|
<modelPath>block.obj</modelPath>
|
||||||
<xOffset>0.0</xOffset>
|
<xOffset>0.0</xOffset>
|
||||||
@ -389,6 +400,7 @@
|
|||||||
<composition>
|
<composition>
|
||||||
<typeID>163</typeID>
|
<typeID>163</typeID>
|
||||||
<ignoreHeightmap>true</ignoreHeightmap>
|
<ignoreHeightmap>true</ignoreHeightmap>
|
||||||
|
<crossesChunks>false</crossesChunks>
|
||||||
<object>
|
<object>
|
||||||
<modelPath>torch.obj</modelPath>
|
<modelPath>torch.obj</modelPath>
|
||||||
<xOffset>0.0</xOffset>
|
<xOffset>0.0</xOffset>
|
||||||
@ -462,6 +474,7 @@
|
|||||||
<composition>
|
<composition>
|
||||||
<typeID>164</typeID>
|
<typeID>164</typeID>
|
||||||
<ignoreHeightmap>true</ignoreHeightmap>
|
<ignoreHeightmap>true</ignoreHeightmap>
|
||||||
|
<crossesChunks>false</crossesChunks>
|
||||||
<object>
|
<object>
|
||||||
<modelPath>torch.obj</modelPath>
|
<modelPath>torch.obj</modelPath>
|
||||||
<xOffset>-1.5</xOffset>
|
<xOffset>-1.5</xOffset>
|
||||||
@ -535,6 +548,7 @@
|
|||||||
<composition>
|
<composition>
|
||||||
<typeID>180</typeID>
|
<typeID>180</typeID>
|
||||||
<ignoreHeightmap>true</ignoreHeightmap>
|
<ignoreHeightmap>true</ignoreHeightmap>
|
||||||
|
<crossesChunks>false</crossesChunks>
|
||||||
<object>
|
<object>
|
||||||
<modelPath>simpleWall.obj</modelPath>
|
<modelPath>simpleWall.obj</modelPath>
|
||||||
<xOffset>0.0</xOffset>
|
<xOffset>0.0</xOffset>
|
||||||
@ -552,6 +566,7 @@
|
|||||||
<composition>
|
<composition>
|
||||||
<typeID>181</typeID>
|
<typeID>181</typeID>
|
||||||
<ignoreHeightmap>true</ignoreHeightmap>
|
<ignoreHeightmap>true</ignoreHeightmap>
|
||||||
|
<crossesChunks>false</crossesChunks>
|
||||||
<object>
|
<object>
|
||||||
<modelPath>simpleWall.obj</modelPath>
|
<modelPath>simpleWall.obj</modelPath>
|
||||||
<xOffset>0.0</xOffset>
|
<xOffset>0.0</xOffset>
|
||||||
@ -569,6 +584,7 @@
|
|||||||
<composition>
|
<composition>
|
||||||
<typeID>200</typeID>
|
<typeID>200</typeID>
|
||||||
<ignoreHeightmap>false</ignoreHeightmap>
|
<ignoreHeightmap>false</ignoreHeightmap>
|
||||||
|
<crossesChunks>true</crossesChunks>
|
||||||
<object>
|
<object>
|
||||||
<modelPath>block.obj</modelPath>
|
<modelPath>block.obj</modelPath>
|
||||||
<xOffset>0.0</xOffset>
|
<xOffset>0.0</xOffset>
|
||||||
@ -586,6 +602,7 @@
|
|||||||
<composition>
|
<composition>
|
||||||
<typeID>220</typeID>
|
<typeID>220</typeID>
|
||||||
<ignoreHeightmap>true</ignoreHeightmap>
|
<ignoreHeightmap>true</ignoreHeightmap>
|
||||||
|
<crossesChunks>false</crossesChunks>
|
||||||
<object>
|
<object>
|
||||||
<modelPath>gate.obj</modelPath>
|
<modelPath>gate.obj</modelPath>
|
||||||
<xOffset>0.0</xOffset>
|
<xOffset>0.0</xOffset>
|
||||||
@ -603,6 +620,7 @@
|
|||||||
<composition>
|
<composition>
|
||||||
<typeID>221</typeID>
|
<typeID>221</typeID>
|
||||||
<ignoreHeightmap>true</ignoreHeightmap>
|
<ignoreHeightmap>true</ignoreHeightmap>
|
||||||
|
<crossesChunks>false</crossesChunks>
|
||||||
<object>
|
<object>
|
||||||
<modelPath>gate.obj</modelPath>
|
<modelPath>gate.obj</modelPath>
|
||||||
<xOffset>0.0</xOffset>
|
<xOffset>0.0</xOffset>
|
||||||
@ -620,6 +638,7 @@
|
|||||||
<composition>
|
<composition>
|
||||||
<typeID>240</typeID>
|
<typeID>240</typeID>
|
||||||
<ignoreHeightmap>false</ignoreHeightmap>
|
<ignoreHeightmap>false</ignoreHeightmap>
|
||||||
|
<crossesChunks>true</crossesChunks>
|
||||||
<object>
|
<object>
|
||||||
<modelPath>movableBlock.obj</modelPath>
|
<modelPath>movableBlock.obj</modelPath>
|
||||||
<xOffset>0.0</xOffset>
|
<xOffset>0.0</xOffset>
|
||||||
@ -637,6 +656,7 @@
|
|||||||
<composition>
|
<composition>
|
||||||
<typeID>245</typeID>
|
<typeID>245</typeID>
|
||||||
<ignoreHeightmap>false</ignoreHeightmap>
|
<ignoreHeightmap>false</ignoreHeightmap>
|
||||||
|
<crossesChunks>false</crossesChunks>
|
||||||
<object>
|
<object>
|
||||||
<modelPath>brazier.obj</modelPath>
|
<modelPath>brazier.obj</modelPath>
|
||||||
<xOffset>0.0</xOffset>
|
<xOffset>0.0</xOffset>
|
||||||
@ -654,6 +674,7 @@
|
|||||||
<composition>
|
<composition>
|
||||||
<typeID>250</typeID>
|
<typeID>250</typeID>
|
||||||
<ignoreHeightmap>false</ignoreHeightmap>
|
<ignoreHeightmap>false</ignoreHeightmap>
|
||||||
|
<crossesChunks>false</crossesChunks>
|
||||||
<object>
|
<object>
|
||||||
<modelPath>hint.obj</modelPath>
|
<modelPath>hint.obj</modelPath>
|
||||||
<xOffset>0.0</xOffset>
|
<xOffset>0.0</xOffset>
|
||||||
@ -671,6 +692,7 @@
|
|||||||
<composition>
|
<composition>
|
||||||
<typeID>254</typeID>
|
<typeID>254</typeID>
|
||||||
<ignoreHeightmap>false</ignoreHeightmap>
|
<ignoreHeightmap>false</ignoreHeightmap>
|
||||||
|
<crossesChunks>false</crossesChunks>
|
||||||
<object>
|
<object>
|
||||||
<modelPath>exit.obj</modelPath>
|
<modelPath>exit.obj</modelPath>
|
||||||
<xOffset>0.0</xOffset>
|
<xOffset>0.0</xOffset>
|
||||||
|
@ -88,6 +88,14 @@ void Level::render(ACGL::OpenGL::SharedShaderProgram shader, bool lightingPass,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
for (unsigned int i = 0; i<crossChunkObjects.size(); i++) {
|
||||||
|
if (lightingPass) {
|
||||||
|
crossChunkObjects.at(i)->render(shader, lightingPass, true, viewProjectionMatrix, shadowVPs);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
crossChunkObjects.at(i)->render(shader, lightingPass, false, viewProjectionMatrix, shadowVPs);
|
||||||
|
}
|
||||||
|
}
|
||||||
if (lightingPass && waterPlane) {
|
if (lightingPass && waterPlane) {
|
||||||
waterPlane->render(shader, lightingPass, true, viewProjectionMatrix, shadowVPs);
|
waterPlane->render(shader, lightingPass, true, viewProjectionMatrix, shadowVPs);
|
||||||
}
|
}
|
||||||
@ -253,11 +261,16 @@ void Level::setSkydomeObject(Skydome object){
|
|||||||
this->skydome = object;
|
this->skydome = object;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Level::addObject(Object* object) {
|
void Level::addObject(Object* object, bool crossesChunks) {
|
||||||
allObjects.push_back(object);
|
allObjects.push_back(object);
|
||||||
int xPosition = ((int)object->getPosition().x + (terrain.getHeightmapWidth()/2))/chunkSize;
|
if (crossesChunks) {
|
||||||
int zPosition = ((int)object->getPosition().z + (terrain.getHeightmapHeight()/2))/chunkSize;
|
crossChunkObjects.push_back(object);
|
||||||
chunks.at(xPosition).at(zPosition).addObject(object);
|
}
|
||||||
|
else {
|
||||||
|
int xPosition = ((int)object->getPosition().x + (terrain.getHeightmapWidth()/2))/chunkSize;
|
||||||
|
int zPosition = ((int)object->getPosition().z + (terrain.getHeightmapHeight()/2))/chunkSize;
|
||||||
|
chunks.at(xPosition).at(zPosition).addObject(object);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Level::addToSpecificChunk(Object* object, int xPosition, int zPosition) {
|
void Level::addToSpecificChunk(Object* object, int xPosition, int zPosition) {
|
||||||
|
@ -49,7 +49,7 @@ class Level {
|
|||||||
void moveObject(int objectIndex, float strength, float xPos, float yPos, float zPos);
|
void moveObject(int objectIndex, float strength, float xPos, float yPos, float zPos);
|
||||||
void setStrength(float strength);
|
void setStrength(float strength);
|
||||||
void setSkydomeObject(Skydome object);
|
void setSkydomeObject(Skydome object);
|
||||||
void addObject(Object* object);
|
void addObject(Object* object, bool crossesChunks);
|
||||||
void addPhysicsObject(Object* object);
|
void addPhysicsObject(Object* object);
|
||||||
void setAmbientLight(glm::vec3 colour);
|
void setAmbientLight(glm::vec3 colour);
|
||||||
void setFogColourDay(glm::vec4 colour);
|
void setFogColourDay(glm::vec4 colour);
|
||||||
|
@ -294,7 +294,8 @@ void Loader::load(std::string filePath, Level* level, std::string compositionsPa
|
|||||||
objectRot[2] = queryFloat(xmlObject, "zRot");
|
objectRot[2] = queryFloat(xmlObject, "zRot");
|
||||||
objectRot *= 0.0174532925; //transform degrees to radians
|
objectRot *= 0.0174532925; //transform degrees to radians
|
||||||
Object* object = new Object(model, material, objectPosition, compRot+objectRot, renderable);
|
Object* object = new Object(model, material, objectPosition, compRot+objectRot, renderable);
|
||||||
level->addObject(object);
|
bool crossesChunks = queryBool(composition, "crossesChunks");
|
||||||
|
level->addObject(object, crossesChunks);
|
||||||
|
|
||||||
//add object to physics
|
//add object to physics
|
||||||
std::string physicType = queryString(objectData, "physicType");
|
std::string physicType = queryString(objectData, "physicType");
|
||||||
|
Loading…
Reference in New Issue
Block a user