void VoxelBlockPersistent::getMeshDataInner(int lastX, int lastY, int lastZ, VoxelBlock* block) { VoxelBlockLoaded* bl = (VoxelBlockLoaded*)block; // For every inner voxel ... for(int z = 0; z <= lastZ - 1; z++) { for(int y = 0; y <= lastY - 1; y++) { for(int x = 0; x <= lastX - 1; x++) { const char v000 = bl->_getVoxelAt(x ,y ,z ); const char v100 = bl->_getVoxelAt(x+1,y ,z ); const char v010 = bl->_getVoxelAt(x ,y+1,z ); const char v110 = bl->_getVoxelAt(x+1,y+1,z ); const char v001 = bl->_getVoxelAt(x ,y ,z+1); const char v101 = bl->_getVoxelAt(x+1,y ,z+1); const char v011 = bl->_getVoxelAt(x ,y+1,z+1); const char v111 = bl->_getVoxelAt(x+1,y+1,z+1); const unsigned char t000 = bl->_getTextureAt(x ,y ,z ); const unsigned char t100 = bl->_getTextureAt(x+1,y ,z ); const unsigned char t010 = bl->_getTextureAt(x ,y+1,z ); const unsigned char t110 = bl->_getTextureAt(x+1,y+1,z ); const unsigned char t001 = bl->_getTextureAt(x ,y ,z+1); const unsigned char t101 = bl->_getTextureAt(x+1,y ,z+1); const unsigned char t011 = bl->_getTextureAt(x ,y+1,z+1); const unsigned char t111 = bl->_getTextureAt(x+1,y+1,z+1); getVoxelData(v000, v100, v010, v110, v001, v101, v011, v111, t000, t100, t010, t110, t001, t101, t011, t111, x, y, z); } } } }
void PolyVoxEntityItem::appendSubclassData(OctreePacketData* packetData, EncodeBitstreamParams& params, EntityTreeElementExtraEncodeData* modelTreeElementExtraEncodeData, EntityPropertyFlags& requestedProperties, EntityPropertyFlags& propertyFlags, EntityPropertyFlags& propertiesDidntFit, int& propertyCount, OctreeElement::AppendState& appendState) const { bool successPropertyFits = true; APPEND_ENTITY_PROPERTY(PROP_VOXEL_VOLUME_SIZE, getVoxelVolumeSize()); APPEND_ENTITY_PROPERTY(PROP_VOXEL_DATA, getVoxelData()); APPEND_ENTITY_PROPERTY(PROP_VOXEL_SURFACE_STYLE, (uint16_t) getVoxelSurfaceStyle()); APPEND_ENTITY_PROPERTY(PROP_X_TEXTURE_URL, getXTextureURL()); APPEND_ENTITY_PROPERTY(PROP_Y_TEXTURE_URL, getYTextureURL()); APPEND_ENTITY_PROPERTY(PROP_Z_TEXTURE_URL, getZTextureURL()); APPEND_ENTITY_PROPERTY(PROP_X_N_NEIGHBOR_ID, getXNNeighborID()); APPEND_ENTITY_PROPERTY(PROP_Y_N_NEIGHBOR_ID, getYNNeighborID()); APPEND_ENTITY_PROPERTY(PROP_Z_N_NEIGHBOR_ID, getZNNeighborID()); APPEND_ENTITY_PROPERTY(PROP_X_P_NEIGHBOR_ID, getXPNeighborID()); APPEND_ENTITY_PROPERTY(PROP_Y_P_NEIGHBOR_ID, getYPNeighborID()); APPEND_ENTITY_PROPERTY(PROP_Z_P_NEIGHBOR_ID, getZPNeighborID()); }
void VoxelBlockPersistent::getMeshData(int lastX, int lastY, int lastZ) { memset(tempIndexField, 255, TEMP_INDEX_FIELD_SIZE * sizeof(Ogre::uint)); tempVertexDataSize = 0; tempIndexDataSize = 0; Point3 relPos = Point3((position.x - volume->windowXInBlocks) * BLOCK_SIDE_LENGTH, (position.y - volume->windowYInBlocks) * BLOCK_SIDE_LENGTH, (position.z - volume->windowZInBlocks) * BLOCK_SIDE_LENGTH); // For every outer voxel ... // handle +Y area for(int z = 0; z <= lastZ - 1; z++) { const int y = lastY; for(int x = 0; x <= lastX - 1; x++) { const char v000 = volume->getVoxelRel(relPos.x + x , relPos.y + y , relPos.z + z ); const char v100 = volume->getVoxelRel(relPos.x + x+1, relPos.y + y , relPos.z + z ); const char v010 = volume->getVoxelRel(relPos.x + x , relPos.y + y+1, relPos.z + z ); const char v110 = volume->getVoxelRel(relPos.x + x+1, relPos.y + y+1, relPos.z + z ); const char v001 = volume->getVoxelRel(relPos.x + x , relPos.y + y , relPos.z + z+1); const char v101 = volume->getVoxelRel(relPos.x + x+1, relPos.y + y , relPos.z + z+1); const char v011 = volume->getVoxelRel(relPos.x + x , relPos.y + y+1, relPos.z + z+1); const char v111 = volume->getVoxelRel(relPos.x + x+1, relPos.y + y+1, relPos.z + z+1); const unsigned char t000 = volume->getTextureRel(relPos.x + x , relPos.y + y , relPos.z + z ); const unsigned char t100 = volume->getTextureRel(relPos.x + x+1, relPos.y + y , relPos.z + z ); const unsigned char t010 = volume->getTextureRel(relPos.x + x , relPos.y + y+1, relPos.z + z ); const unsigned char t110 = volume->getTextureRel(relPos.x + x+1, relPos.y + y+1, relPos.z + z ); const unsigned char t001 = volume->getTextureRel(relPos.x + x , relPos.y + y , relPos.z + z+1); const unsigned char t101 = volume->getTextureRel(relPos.x + x+1, relPos.y + y , relPos.z + z+1); const unsigned char t011 = volume->getTextureRel(relPos.x + x , relPos.y + y+1, relPos.z + z+1); const unsigned char t111 = volume->getTextureRel(relPos.x + x+1, relPos.y + y+1, relPos.z + z+1); getVoxelData(v000, v100, v010, v110, v001, v101, v011, v111, t000, t100, t010, t110, t001, t101, t011, t111, x, y, z); } } // handle +X area for(int z = 0; z <= lastZ - 1; z++) { const int x = lastX; for(int y = 0; y <= lastY; y++) { const char v000 = volume->getVoxelRel(relPos.x + x , relPos.y + y , relPos.z + z ); const char v100 = volume->getVoxelRel(relPos.x + x+1, relPos.y + y , relPos.z + z ); const char v010 = volume->getVoxelRel(relPos.x + x , relPos.y + y+1, relPos.z + z ); const char v110 = volume->getVoxelRel(relPos.x + x+1, relPos.y + y+1, relPos.z + z ); const char v001 = volume->getVoxelRel(relPos.x + x , relPos.y + y , relPos.z + z+1); const char v101 = volume->getVoxelRel(relPos.x + x+1, relPos.y + y , relPos.z + z+1); const char v011 = volume->getVoxelRel(relPos.x + x , relPos.y + y+1, relPos.z + z+1); const char v111 = volume->getVoxelRel(relPos.x + x+1, relPos.y + y+1, relPos.z + z+1); const unsigned char t000 = volume->getTextureRel(relPos.x + x , relPos.y + y , relPos.z + z ); const unsigned char t100 = volume->getTextureRel(relPos.x + x+1, relPos.y + y , relPos.z + z ); const unsigned char t010 = volume->getTextureRel(relPos.x + x , relPos.y + y+1, relPos.z + z ); const unsigned char t110 = volume->getTextureRel(relPos.x + x+1, relPos.y + y+1, relPos.z + z ); const unsigned char t001 = volume->getTextureRel(relPos.x + x , relPos.y + y , relPos.z + z+1); const unsigned char t101 = volume->getTextureRel(relPos.x + x+1, relPos.y + y , relPos.z + z+1); const unsigned char t011 = volume->getTextureRel(relPos.x + x , relPos.y + y+1, relPos.z + z+1); const unsigned char t111 = volume->getTextureRel(relPos.x + x+1, relPos.y + y+1, relPos.z + z+1); getVoxelData(v000, v100, v010, v110, v001, v101, v011, v111, t000, t100, t010, t110, t001, t101, t011, t111, x, y, z); } } // handle +Z area for(int x = 0; x <= lastX; x++) { const int z = lastZ; for(int y = 0; y <= lastY; y++) { const char v000 = volume->getVoxelRel(relPos.x + x , relPos.y + y , relPos.z + z ); const char v100 = volume->getVoxelRel(relPos.x + x+1, relPos.y + y , relPos.z + z ); const char v010 = volume->getVoxelRel(relPos.x + x , relPos.y + y+1, relPos.z + z ); const char v110 = volume->getVoxelRel(relPos.x + x+1, relPos.y + y+1, relPos.z + z ); const char v001 = volume->getVoxelRel(relPos.x + x , relPos.y + y , relPos.z + z+1); const char v101 = volume->getVoxelRel(relPos.x + x+1, relPos.y + y , relPos.z + z+1); const char v011 = volume->getVoxelRel(relPos.x + x , relPos.y + y+1, relPos.z + z+1); const char v111 = volume->getVoxelRel(relPos.x + x+1, relPos.y + y+1, relPos.z + z+1); const unsigned char t000 = volume->getTextureRel(relPos.x + x , relPos.y + y , relPos.z + z ); const unsigned char t100 = volume->getTextureRel(relPos.x + x+1, relPos.y + y , relPos.z + z ); const unsigned char t010 = volume->getTextureRel(relPos.x + x , relPos.y + y+1, relPos.z + z ); const unsigned char t110 = volume->getTextureRel(relPos.x + x+1, relPos.y + y+1, relPos.z + z ); const unsigned char t001 = volume->getTextureRel(relPos.x + x , relPos.y + y , relPos.z + z+1); const unsigned char t101 = volume->getTextureRel(relPos.x + x+1, relPos.y + y , relPos.z + z+1); const unsigned char t011 = volume->getTextureRel(relPos.x + x , relPos.y + y+1, relPos.z + z+1); const unsigned char t111 = volume->getTextureRel(relPos.x + x+1, relPos.y + y+1, relPos.z + z+1); getVoxelData(v000, v100, v010, v110, v001, v101, v011, v111, t000, t100, t010, t110, t001, t101, t011, t111, x, y, z); } } }