| 9 | import field.utility.remAssign |
| 10 | import field.utility.times |
| 11 | |
| 12 | import java.io.BufferedReader |
| 13 | import java.io.File |
| 14 | import java.io.FileNotFoundException |
| 15 | import java.io.FileReader |
| 16 | import java.io.IOException |
| 17 | import java.io.RandomAccessFile |
| 18 | import java.nio.ByteOrder |
| 19 | import java.nio.FloatBuffer |
| 20 | import java.nio.MappedByteBuffer |
| 21 | import java.nio.channels.FileChannel.MapMode |
| 22 | import java.util.ArrayList |
| 23 | |
| 24 | |
| 25 | class 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; |
no test coverage detected