|
|
@@ -22,75 +22,75 @@ Chunk::Chunk(Framework::Point location)
|
|
|
{
|
|
|
blocks = new Block*[CHUNK_SIZE * CHUNK_SIZE * WORLD_HEIGHT];
|
|
|
memset(blocks, 0, CHUNK_SIZE * CHUNK_SIZE * WORLD_HEIGHT * sizeof(Block*));
|
|
|
- FactoryCraftModel* ground = new FactoryCraftModel();
|
|
|
- Model3DData* chunkModel
|
|
|
- = uiFactory.initParam.bildschirm->zGraphicsApi()->getModel(
|
|
|
- Text("chunk_ground_") + location.x + location.y);
|
|
|
- if (!chunkModel)
|
|
|
- {
|
|
|
- chunkModel
|
|
|
- = uiFactory.initParam.bildschirm->zGraphicsApi()->createModel(
|
|
|
- Text("chunk_ground_") + location.x + location.y);
|
|
|
- }
|
|
|
- chunkModel->setAmbientFactor(0.f);
|
|
|
- chunkModel->setDiffusFactor(1.f);
|
|
|
- chunkModel->setSpecularFactor(0.f);
|
|
|
- chunkModel->setVertecies(0, 0);
|
|
|
- ground->setModelData(chunkModel);
|
|
|
- ground->setPosition(
|
|
|
- (float)location.x, (float)location.y, (float)WORLD_HEIGHT / 2.f);
|
|
|
- ground->tick(0);
|
|
|
- ChunkModelBuilder* groundModel = new ChunkGroundModel(ground, this);
|
|
|
- modelBuilders.add(groundModel);
|
|
|
- FactoryCraftModel* transparentGround = new FactoryCraftModel();
|
|
|
- chunkModel = uiFactory.initParam.bildschirm->zGraphicsApi()->getModel(
|
|
|
- Text("transparent_chunk_ground_") + location.x + location.y);
|
|
|
- if (!chunkModel)
|
|
|
- {
|
|
|
- chunkModel
|
|
|
- = uiFactory.initParam.bildschirm->zGraphicsApi()->createModel(
|
|
|
- Text("transparent_chunk_ground_") + location.x + location.y);
|
|
|
- }
|
|
|
- chunkModel->setAmbientFactor(0.f);
|
|
|
- chunkModel->setDiffusFactor(1.f);
|
|
|
- chunkModel->setSpecularFactor(0.f);
|
|
|
- chunkModel->setVertecies(0, 0);
|
|
|
- transparentGround->setModelData(chunkModel);
|
|
|
- transparentGround->setPosition(
|
|
|
- (float)location.x, (float)location.y, (float)WORLD_HEIGHT / 2.f);
|
|
|
- transparentGround->tick(0);
|
|
|
- ChunkModelBuilder* transparentGroundModel
|
|
|
- = new TransparentChunkGroundModel(transparentGround, this);
|
|
|
- modelBuilders.add(transparentGroundModel);
|
|
|
- FactoryCraftModel* fluids = new FactoryCraftModel();
|
|
|
- chunkModel = uiFactory.initParam.bildschirm->zGraphicsApi()->getModel(
|
|
|
- Text("chunk_fluids_") + location.x + location.y);
|
|
|
- if (!chunkModel)
|
|
|
- {
|
|
|
- chunkModel
|
|
|
- = uiFactory.initParam.bildschirm->zGraphicsApi()->createModel(
|
|
|
- Text("chunk_fluids_") + location.x + location.y);
|
|
|
- }
|
|
|
- chunkModel->setAmbientFactor(0.f);
|
|
|
- chunkModel->setDiffusFactor(1.f);
|
|
|
- chunkModel->setSpecularFactor(0.f);
|
|
|
- chunkModel->setVertecies(0, 0);
|
|
|
- fluids->setModelData(chunkModel);
|
|
|
- fluids->setPosition(
|
|
|
- (float)location.x, (float)location.y, (float)WORLD_HEIGHT / 2.f);
|
|
|
- fluids->tick(0);
|
|
|
- ChunkModelBuilder* fluidModel = new ChunkFluidModel(fluids, this);
|
|
|
- modelBuilders.add(fluidModel);
|
|
|
+ // FactoryCraftModel* ground = new FactoryCraftModel();
|
|
|
+ // Model3DData* chunkModel
|
|
|
+ // = uiFactory.initParam.bildschirm->zGraphicsApi()->getModel(
|
|
|
+ // Text("chunk_ground_") + location.x + location.y);
|
|
|
+ // if (!chunkModel)
|
|
|
+ // {
|
|
|
+ // chunkModel
|
|
|
+ // = uiFactory.initParam.bildschirm->zGraphicsApi()->createModel(
|
|
|
+ // Text("chunk_ground_") + location.x + location.y);
|
|
|
+ // }
|
|
|
+ // chunkModel->setAmbientFactor(0.f);
|
|
|
+ // chunkModel->setDiffusFactor(1.f);
|
|
|
+ // chunkModel->setSpecularFactor(0.f);
|
|
|
+ // chunkModel->setVertecies(0, 0);
|
|
|
+ // ground->setModelData(chunkModel);
|
|
|
+ // ground->setPosition(
|
|
|
+ // (float)location.x, (float)location.y, (float)WORLD_HEIGHT / 2.f);
|
|
|
+ // ground->tick(0);
|
|
|
+ // ChunkModelBuilder* groundModel = new ChunkGroundModel(ground, this);
|
|
|
+ // modelBuilders.add(groundModel);
|
|
|
+ // FactoryCraftModel* transparentGround = new FactoryCraftModel();
|
|
|
+ // chunkModel = uiFactory.initParam.bildschirm->zGraphicsApi()->getModel(
|
|
|
+ // Text("transparent_chunk_ground_") + location.x + location.y);
|
|
|
+ // if (!chunkModel)
|
|
|
+ //{
|
|
|
+ // chunkModel
|
|
|
+ // = uiFactory.initParam.bildschirm->zGraphicsApi()->createModel(
|
|
|
+ // Text("transparent_chunk_ground_") + location.x + location.y);
|
|
|
+ //}
|
|
|
+ // chunkModel->setAmbientFactor(0.f);
|
|
|
+ // chunkModel->setDiffusFactor(1.f);
|
|
|
+ // chunkModel->setSpecularFactor(0.f);
|
|
|
+ // chunkModel->setVertecies(0, 0);
|
|
|
+ // transparentGround->setModelData(chunkModel);
|
|
|
+ // transparentGround->setPosition(
|
|
|
+ // (float)location.x, (float)location.y, (float)WORLD_HEIGHT / 2.f);
|
|
|
+ // transparentGround->tick(0);
|
|
|
+ // ChunkModelBuilder* transparentGroundModel
|
|
|
+ // = new TransparentChunkGroundModel(transparentGround, this);
|
|
|
+ // modelBuilders.add(transparentGroundModel);
|
|
|
+ // FactoryCraftModel* fluids = new FactoryCraftModel();
|
|
|
+ // chunkModel = uiFactory.initParam.bildschirm->zGraphicsApi()->getModel(
|
|
|
+ // Text("chunk_fluids_") + location.x + location.y);
|
|
|
+ // if (!chunkModel)
|
|
|
+ //{
|
|
|
+ // chunkModel
|
|
|
+ // = uiFactory.initParam.bildschirm->zGraphicsApi()->createModel(
|
|
|
+ // Text("chunk_fluids_") + location.x + location.y);
|
|
|
+ //}
|
|
|
+ // chunkModel->setAmbientFactor(0.f);
|
|
|
+ // chunkModel->setDiffusFactor(1.f);
|
|
|
+ // chunkModel->setSpecularFactor(0.f);
|
|
|
+ // chunkModel->setVertecies(0, 0);
|
|
|
+ // fluids->setModelData(chunkModel);
|
|
|
+ // fluids->setPosition(
|
|
|
+ // (float)location.x, (float)location.y, (float)WORLD_HEIGHT / 2.f);
|
|
|
+ // fluids->tick(0);
|
|
|
+ // ChunkModelBuilder* fluidModel = new ChunkFluidModel(fluids, this);
|
|
|
+ // modelBuilders.add(fluidModel);
|
|
|
}
|
|
|
|
|
|
Chunk::Chunk(Framework::Point location, Framework::StreamReader* zReader)
|
|
|
: Chunk(location)
|
|
|
{
|
|
|
load(zReader);
|
|
|
- for (ChunkModelBuilder* builder : modelBuilders)
|
|
|
- {
|
|
|
- buildModel(builder);
|
|
|
- }
|
|
|
+ // for (ChunkModelBuilder* builder : modelBuilders)
|
|
|
+ //{
|
|
|
+ // buildModel(builder);
|
|
|
+ // }
|
|
|
}
|
|
|
|
|
|
Chunk::~Chunk()
|
|
|
@@ -350,25 +350,25 @@ void Chunk::load(Framework::StreamReader* zReader)
|
|
|
isLoading = 0;
|
|
|
}
|
|
|
|
|
|
-void Chunk::buildModel(ChunkModelBuilder* builder)
|
|
|
-{
|
|
|
- modelChanged &= ~builder->getType();
|
|
|
- lightChanged &= ~builder->getType();
|
|
|
- builder->buildModel();
|
|
|
-}
|
|
|
+// void Chunk::buildModel(ChunkModelBuilder* builder)
|
|
|
+//{
|
|
|
+// modelChanged &= ~builder->getType();
|
|
|
+// lightChanged &= ~builder->getType();
|
|
|
+// builder->buildModel();
|
|
|
+// }
|
|
|
|
|
|
-void Chunk::updateLight(ChunkModelBuilder* builder)
|
|
|
-{
|
|
|
- lightChanged &= ~builder->getType();
|
|
|
- builder->updateLightning();
|
|
|
-}
|
|
|
+// void Chunk::updateLight(ChunkModelBuilder* builder)
|
|
|
+//{
|
|
|
+// lightChanged &= ~builder->getType();
|
|
|
+// builder->updateLightning();
|
|
|
+// }
|
|
|
|
|
|
void Chunk::forAll(std::function<void(Model3D*)> f)
|
|
|
{
|
|
|
- for (ChunkModelBuilder* builder : modelBuilders)
|
|
|
- {
|
|
|
- f(builder->zModel());
|
|
|
- }
|
|
|
+ // for (ChunkModelBuilder* builder : modelBuilders)
|
|
|
+ //{
|
|
|
+ // f(builder->zModel());
|
|
|
+ // }
|
|
|
vLock.lockRead();
|
|
|
for (Block* b : visibleBlocks)
|
|
|
{
|
|
|
@@ -379,21 +379,21 @@ void Chunk::forAll(std::function<void(Model3D*)> f)
|
|
|
|
|
|
bool Chunk::tick(std::function<void(Model3D*)> f, double time)
|
|
|
{
|
|
|
- for (ChunkModelBuilder* builder : modelBuilders)
|
|
|
- {
|
|
|
- if ((modelChanged | builder->getType()) == modelChanged)
|
|
|
- buildModel(builder);
|
|
|
- }
|
|
|
- for (ChunkModelBuilder* builder : modelBuilders)
|
|
|
- {
|
|
|
- if ((lightChanged | builder->getType()) == lightChanged)
|
|
|
- updateLight(builder);
|
|
|
- }
|
|
|
+ // for (ChunkModelBuilder* builder : modelBuilders)
|
|
|
+ //{
|
|
|
+ // if ((modelChanged | builder->getType()) == modelChanged)
|
|
|
+ // buildModel(builder);
|
|
|
+ // }
|
|
|
+ // for (ChunkModelBuilder* builder : modelBuilders)
|
|
|
+ //{
|
|
|
+ // if ((lightChanged | builder->getType()) == lightChanged)
|
|
|
+ // updateLight(builder);
|
|
|
+ // }
|
|
|
bool res = 0;
|
|
|
- for (ChunkModelBuilder* builder : modelBuilders)
|
|
|
- {
|
|
|
- res |= builder->zModel()->tick(time);
|
|
|
- }
|
|
|
+ // for (ChunkModelBuilder* builder : modelBuilders)
|
|
|
+ //{
|
|
|
+ // res |= builder->zModel()->tick(time);
|
|
|
+ // }
|
|
|
aLock.lockRead();
|
|
|
auto iterator = animations.begin();
|
|
|
while (iterator)
|
|
|
@@ -424,16 +424,16 @@ bool Chunk::tick(std::function<void(Model3D*)> f, double time)
|
|
|
|
|
|
void Chunk::destroy()
|
|
|
{
|
|
|
- for (ChunkModelBuilder* builder : modelBuilders)
|
|
|
- {
|
|
|
- Model3DData* chunkModel = builder->zModel()->zModelData();
|
|
|
- // remove old model
|
|
|
- while (chunkModel->getPolygonCount() > 0)
|
|
|
- {
|
|
|
- chunkModel->removePolygon(0);
|
|
|
- }
|
|
|
- chunkModel->setVertecies(0, 0);
|
|
|
- }
|
|
|
+ // for (ChunkModelBuilder* builder : modelBuilders)
|
|
|
+ //{
|
|
|
+ // Model3DData* chunkModel = builder->zModel()->zModelData();
|
|
|
+ // // remove old model
|
|
|
+ // while (chunkModel->getPolygonCount() > 0)
|
|
|
+ // {
|
|
|
+ // chunkModel->removePolygon(0);
|
|
|
+ // }
|
|
|
+ // chunkModel->setVertecies(0, 0);
|
|
|
+ // }
|
|
|
}
|
|
|
|
|
|
void Chunk::api(char* message)
|
|
|
@@ -537,17 +537,17 @@ void Chunk::setBlock(Block* block)
|
|
|
int affectsGround = 0;
|
|
|
int newAffectsGround = 0;
|
|
|
bLock.lockWrite();
|
|
|
- for (ChunkModelBuilder* builder : modelBuilders)
|
|
|
- {
|
|
|
- if (block && builder->isPartOfModel(block))
|
|
|
- {
|
|
|
- newAffectsGround |= builder->getType();
|
|
|
- }
|
|
|
- if (blocks[index] && builder->isPartOfModel(blocks[index]))
|
|
|
- {
|
|
|
- affectsGround |= builder->getType();
|
|
|
- }
|
|
|
- }
|
|
|
+ // for (ChunkModelBuilder* builder : modelBuilders)
|
|
|
+ //{
|
|
|
+ // if (block && builder->isPartOfModel(block))
|
|
|
+ // {
|
|
|
+ // newAffectsGround |= builder->getType();
|
|
|
+ // }
|
|
|
+ // if (blocks[index] && builder->isPartOfModel(blocks[index]))
|
|
|
+ // {
|
|
|
+ // affectsGround |= builder->getType();
|
|
|
+ // }
|
|
|
+ // }
|
|
|
if (blocks[index])
|
|
|
{
|
|
|
vLock.lockWrite();
|