The online racing simulator
Trouble reading .LYT file
(5 posts, started )
Trouble reading .LYT file
Hello, I'm trying to read a layout file but I'm struggling with the objects coordinates. On the on LFS Manual, at the OBJECT BLOCK section it says where the coordinate came from:


The problem is that the blockByte[0] and blockByte[1] are related to X and blockByte[2] and blockByte[3] are related to Y.

e.g:
X: -100 equals to 192 and 249


X: 100 equals to 64 and 6


What arithmetic operation can I do to get the correct X value?
** Best answer **
use short not byte.
why you make it harder?
Quote from Draggo :use short not byte.
why you make it harder?

You're right, it was late night here and I couldn't figure it out. Thank you!

BitConverter.ToInt16(new []{blockByte[0], blockByte[1]}, 0) / 16f

works
Why the extra array? You can do:

X = BitConverter.ToInt16(blockByte, 0) / 16f;
Y = BitConverter.ToInt16(blockByte, 2) / 16f;
Quote from PeterN :Why the extra array? You can do:

X = BitConverter.ToInt16(blockByte, 0) / 16f;
Y = BitConverter.ToInt16(blockByte, 2) / 16f;

Thanks

Trouble reading .LYT file
(5 posts, started )
FGED GREDG RDFGDR GSFDG