MCPcopy Create free account
hub / github.com/OpenEndedGroup/Field2 / LoadPly

Class LoadPly

src/main/java/trace/graphics/LoadPly.kt:11–117  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

9import field.utility.remAssign
10import field.utility.times
11
12import java.io.BufferedReader
13import java.io.File
14import java.io.FileNotFoundException
15import java.io.FileReader
16import java.io.IOException
17import java.io.RandomAccessFile
18import java.nio.ByteOrder
19import java.nio.FloatBuffer
20import java.nio.MappedByteBuffer
21import java.nio.channels.FileChannel.MapMode
22import java.util.ArrayList
23
24
25class LoadPly {
26
27 private var reader: BufferedReader? = null
28 var points: ArrayList<Point> = ArrayList()
29 var filename: String? = null
30
31 data class Point(val at: Vec3, val color: Vec3?, val normal: Vec3?) {
32 }
33
34 @Throws(IOException::class)
35 protected constructor() {
36 }
37
38 @Throws(IOException::class)
39 constructor(filename: String) {
40 this.filename = filename
41 points = ArrayList()
42
43 add(filename)
44 }
45
46 var first = true
47
48 fun show(layer: Stage.ShaderGroup, name: String, size: Float) {
49 val v = layer.pointBuilder(name)
50
51 v.open()
52 v.aux(2, size)
53 points.forEach {
54 v.aux(1, it.color)
55 if (it.normal != null)
56 v.aux(4, it.normal)
57 if (it.color != null)
58 v.aux(1, it.color)
59 v.v(it.at)
60 }
61 v.close()
62 }
63
64 fun planarRotate(center: Vec3, up: Vec3, amount: Float) {
65 val q = Quat().setAngleAxis(amount.toDouble(), up.normalize())
66
67 points.forEach {
68 val d = (it.at.x - center.x) * up.x + (it.at.y - center.y) * up.y + (it.at.z - center.z) * up.z;

Callers 2

PointCloudClass · 0.85
FastLoadPlyClass · 0.85

Calls 1

addFunction · 0.50

Tested by

no test coverage detected