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

Method load

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

Source from the content-addressed store, hash-verified

9
10class PlyReaderToMesh {
11 fun load(fn: String, target: MeshBuilder) {
12 val m = PlyReader.readMesh(File(fn))
13 target.open()
14
15 val startAt = target.vertexCursor
16
17 m.first.forEach {
18
19 var color: Vec4? = null
20 var normal: Vec3? = null
21
22// println(" attributes at this vertex are? :"+it.attributes.keys)
23
24 it.attributes.forEach {
25
26 if (it.key.contains("red")) {
27 if (color == null) color = Vec4(0.0, 0.0, 0.0, 255.0)
28 color!!.x = it.value.get(0).toDouble()
29 }
30 if (it.key.contains("green")) {
31 if (color == null) color = Vec4(0.0, 0.0, 0.0, 255.0)
32 color!!.y = it.value.get(0).toDouble()
33 }
34 if (it.key.contains("blue")) {
35 if (color == null) color = Vec4(0.0, 0.0, 0.0, 255.0)
36 color!!.z = it.value.get(0).toDouble()
37 }
38 if (it.key.contains("alpha")) {
39 if (color == null) color = Vec4(0.0, 0.0, 0.0, 255.0)
40 color!!.w = it.value.get(0).toDouble()
41 }
42
43 if (it.key.contains("nx")) {
44 if (normal == null) normal = Vec3(0.0, 0.0, 0.0)
45 normal!!.x = it.value.get(0).toDouble()
46 }
47 if (it.key.contains("ny")) {
48 if (normal == null) normal = Vec3(0.0, 0.0, 0.0)
49 normal!!.y = it.value.get(0).toDouble()
50 }
51 if (it.key.contains("nz")) {
52 if (normal == null) normal = Vec3(0.0, 0.0, 0.0)
53 normal!!.z = it.value.get(0).toDouble()
54 }
55 }
56
57 if (color != null) {
58 target.aux(1, color!! * 1/255.0)
59 }
60 if (normal != null) {
61 target.aux(4, normal)
62 }
63
64 target.v(it.at)
65
66 }
67
68 val nowAt = target.vertexCursor

Callers 3

getDistributionMethod · 0.45
getDistributionMethod · 0.45
MocapClass · 0.45

Calls 12

FileFunction · 0.85
readMeshMethod · 0.80
openMethod · 0.65
getMethod · 0.65
auxMethod · 0.65
vMethod · 0.65
closeMethod · 0.65
Vec4Class · 0.50
Vec3Class · 0.50
forEachMethod · 0.45
containsMethod · 0.45
eMethod · 0.45

Tested by

no test coverage detected