Shadow Map
OpenGL 4 reflections
This picture wants to have glossy reflections in the dark tiles, and sharp reflections on the bright tiles. :D
It's really cool to see how you've progressed with this project!
I've been doing a similar thing with MagicaVoxel stuff. Although in my own case, I've kept the voxels, and just read in the vox files, rather than converting to obj meshes.
@warp9 thanks! it’s been fun. Which code do you use to load and manipulate Vox files???? In the end, I would love to be able to just read in the Vox file and make my own triangles. Can you help with this?
taby said:
@warp9 thanks! it’s been fun. Which code do you use to load and manipulate Vox files???? In the end, I would love to be able to just read in the Vox file and make my own triangles. Can you help with this?
Yes. :-)
The vox files were really easy to read. Probably one of the easiest formats I've ever dealt with. The vox file formate specifications are here : https://github.com/ephtracy/voxel-model/blob/master/MagicaVoxel-file-format-vox.txt
Things are broken up into chunks. Each chunk has a four letter code (chunk ID)
'MAIN'
'PACK' : optional // tells how many models there are. This chunk only exists for voxel files with multiple models
// models
'SIZE'
'XYZI'
'RGBA' : optional // material/color palette
Following the 4 byte ID, there are two ints (each 4 bytes) that contain the number of bytes of chunk content, and the number of bytes of children chunks.
And I can share my code if you want. Although it would be nice to be sure that it works in all situations before I start putting it out on-line. My code has worked in all my exports so far. However my examples have been simple, single model, exports. Also I know MagicaVoxel can do layers, but I don't know how those are saved (and the specification doesn't seem to mention that).
A simple code would be best. I just need to iterate through the voxels. The rest I can take care of! If you’d prefer to not put it online yet, my email address is mailto:sjhalayka@gmail.com
Thank you very much. I really appreciate it!
taby said:
A simple code would be best. I just need to iterate through the voxels. The rest I can take care of! If you’d prefer to not put it online yet, my email address is mailto:sjhalayka@gmail.com
Thank you very much. I really appreciate it!
All right, the files should be on their way. Enjoy! :-)
I put this stuff in the e-mail, but I'll include the general usage info here as well. . .
Most of the functionality is incorporated into a class called cVOXreader. This is how you set it up to read a vox file, and how you get the data out, once the file has been read. . .
cVOXreader VOX_reader;
std::streampos FileSize;
std::ifstream file("TestVoxelModel40.vox", std::ios::in | std::ios::binary | std::ios::ate);
if (file.is_open())
{
FileSize = file.tellg();
file.seekg(0, std::ios::beg);
VOX_reader.Read_VOX_File(&file);
} // end if File Is Open
file.close(); // done reading file
// Reading the Voxel Data from the VOX_reader
// For each voxel, the data is 1 byte for X, 1 byte for Y, 1 byte for Z and 1 byte for Mateial
for (int CurrVoxel = 0; CurrVoxel < VOX_reader.m_iCurrVoxelBufferSize; CurrVoxel++)
{
TargetData.ucLocalX = VOX_reader.m_VoxelBuffer[CurrVoxel].m_ucX;
TargetData.ucLocalY = VOX_reader.m_VoxelBuffer[CurrVoxel].m_ucY;
TargetData.ucLocalZ = VOX_reader.m_VoxelBuffer[CurrVoxel].m_ucZ;
TargetData.ucMaterial = VOX_reader.m_VoxelBuffer[CurrVoxel].m_ucMaterialIndex -1; // Magica colors run from 1 to 255 (not 0 to 255)
// Note : I omitted the part where I actually used this TargetData, since it is not relvant for reading it
}
It may also be worth noting that, while vox files optionally include RGBA palette data, I've been working with a specific palette (and my game already knows what that is). So I don't bother loading that, and just close the file after reading the voxel data (meaning that part is not implemented in my code).