@@ -120,14 +120,17 @@ public Potree2Writer(ref PotreeData potreeData) : base(ref potreeData) { }
120
120
{
121
121
if ( offsetPosition > - 1 )
122
122
{
123
- // TODO: Fix position conversion
124
- //binaryWriter.BaseStream.Position = node.ByteOffset + offsetPosition + i * _potreeData.Metadata.PointSize;
123
+ binaryWriter . BaseStream . Position = node . ByteOffset + offsetPosition + i * _potreeData . Metadata . PointSize ;
125
124
126
- // var position = Potree2Consts.YZflip * point.Position;
125
+ var position = Potree2Consts . YZflip * point . Position ;
127
126
128
- //binaryWriter.Write(position.x);
129
- //binaryWriter.Write(position.y);
130
- //binaryWriter.Write(position.z);
127
+ int x = Convert . ToInt32 ( position . x / _potreeData . Metadata . Scale . x ) ;
128
+ int y = Convert . ToInt32 ( position . y / _potreeData . Metadata . Scale . y ) ;
129
+ int z = Convert . ToInt32 ( position . z / _potreeData . Metadata . Scale . z ) ;
130
+
131
+ binaryWriter . Write ( x ) ;
132
+ binaryWriter . Write ( y ) ;
133
+ binaryWriter . Write ( z ) ;
131
134
}
132
135
133
136
if ( offsetIntensity > - 1 )
@@ -174,16 +177,15 @@ public Potree2Writer(ref PotreeData potreeData) : base(ref potreeData) { }
174
177
175
178
if ( offsetColor > - 1 )
176
179
{
177
- // TODO: Fix color conversion
178
- //binaryWriter.BaseStream.Position = node.ByteOffset + offsetColor + i * _potreeData.Metadata.PointSize;
180
+ binaryWriter . BaseStream . Position = node . ByteOffset + offsetColor + i * _potreeData . Metadata . PointSize ;
179
181
180
- // ushort r = (ushort)MathF.Floor (point.Color.r >= 1f ? 255 : point.Color.r * 256f );
181
- // ushort g = (ushort)MathF.Floor (point.Color.g >= 1f ? 255 : point.Color.g * 256f );
182
- // ushort b = (ushort)MathF.Floor (point.Color.b >= 1f ? 255 : point.Color.b * 256f );
182
+ ushort r = Convert . ToUInt16 ( point . Color . r * 256 ) ;
183
+ ushort g = Convert . ToUInt16 ( point . Color . g * 256 ) ;
184
+ ushort b = Convert . ToUInt16 ( point . Color . b * 256 ) ;
183
185
184
- // binaryWriter.Write(r);
185
- // binaryWriter.Write(g);
186
- // binaryWriter.Write(b);
186
+ binaryWriter . Write ( r ) ;
187
+ binaryWriter . Write ( g ) ;
188
+ binaryWriter . Write ( b ) ;
187
189
}
188
190
}
189
191
0 commit comments