paint method
void
paint(
- DiTreDiConfig config,
- DiTreDiController controller,
- PaintViewPort viewPort,
- FastSphere3D model,
- Matrix4 matrix,
- int vertexIndex,
- Float32List zIndices,
- Int32List colors,
- Float32List vertices,
Fills the buffer with the Model3D
data.
Implementation
@override
void paint(
DiTreDiConfig config,
DiTreDiController controller,
PaintViewPort viewPort,
FastSphere3D model,
vm64.Matrix4 matrix,
int vertexIndex,
Float32List zIndices,
Int32List colors,
Float32List vertices) {
Vector3List v = model.sphereVertices;
var pos = model.position.clone();
matrix.perspectiveTransform(pos);
final baseIndex = vertexIndex ~/ 3;
for (int i = 0; i < model.indices.length ~/ 3; i++) {
zIndices[baseIndex + i] = pos.z;
}
Vector2List vertex = Vector2List(v.length);
// print(model.position);
var vec = vm64.Vector3.zero();
for (var i = 0; i < v.length; i++) {
vec.setValues(v[i].x, v[i].y, v[i].z);
matrix.perspectiveTransform(vec);
vertex.setValues(i, vec.x, vec.y);
}
for (var i = 0; i < model.verticesCount(); i++) {
vertices[vertexIndex * 2 + i * 2] = vertex[model.indices[i]].x;
vertices[vertexIndex * 2 + i * 2 + 1] = vertex[model.indices[i]].y;
// zIndices[vertexIndex + i] = vertex[model.indices[i]].y;
}
// print("vertexIndex:${v.length}");
// print(vertices.length);
colors.fillRange(vertexIndex, vertexIndex + model.verticesCount(),
model.color?.value ?? 0);
}