Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Importing OBJ with very large coordinate values
#1
I am prototyping an application importing geospatial data from OBJ files.  The coordinates in these files can be quite large (UTM coordinates for example: 696828.4312,  5710204.1743,  23.453   ). The resulting visualisation is jittery due to the floating point precision on the transformation matrices not being high enough, so I need to apply a translation on import to centre the model on 0,0,0.    

Is there any way I can do this with the current OBJ importer, or would I need to write a custom one?   

Is it possible to switch off the backface culling on the imported OBJ's?

I am working with SharpEngine with WinUI 3. 

Thanks.
Dave.
#2
SharpEngine is using float on the CPU and on the GPU in the shaders. As you have found out, when using big numbers, this can lead to some floating point precision problems. This can be solved by somehow normalizing the data - this can be done by centering around (0, 0, 0) as you have done.

To prevent losing precision, it would be best to read the obj data as double and immediately transform that to center around (0, 0, 0) and then store that adjusted value as a float value.

I will send you the source code of the ReaderObj to your email so you will be able to adjust the code. But if all your obj files have the same structure, you can simpfly the ReaderObj and create your own parser.


The current version of SharpEngine does not support disabling culling (or using custom RasterizationState). For now, you will need to set the BackMaterial to the same material as set to the Material property - this will render both the front and the back side of each triangle.
Andrej Benedik
  


Forum Jump:


Users browsing this thread:
1 Guest(s)