Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ See below for examples
```go
RasterizerConfig{
RenderLabels: false,
Rotation: rasterizer.Rotation{Alpha: 80, Beta: 0, Gamma: 200},
Rotation: rasterizer.Rotation{Alpha: 10, Beta: 0, Gamma: -20},
OverrideColors: OverrideColorMap{},
CanvasConfig: CanvasConfig{
Width: 4000,
Expand All @@ -37,7 +37,7 @@ RasterizerConfig{
```go
RasterizerConfig{
RenderLabels: true,
Rotation: rasterizer.Rotation{Alpha: 90, Beta: 0, Gamma: 180},
Rotation: rasterizer.Rotation{Alpha: 0, Beta: 0, Gamma: 0},
OverrideColors: OverrideColorMap{},
CanvasConfig: CanvasConfig{
Width: 4000,
Expand Down
4 changes: 2 additions & 2 deletions examples/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,13 +95,13 @@ func main() {
LabelFontSize: 10,
}

rotation1 := MeshTypes.GenerateRotationMatrix(80, 0, 200)
rotation1 := MeshTypes.GenerateRotationMatrix(10, 0, -20)
canvas1, err := rasterizer.Draw(&stage_model, rasterizer.RasterizerConfig{RenderLabels: false, Rotation: rotation1, OverrideColors: overrideColors, CanvasConfig: canvasConfig})
if err != nil {
log.Fatal(err)
}

rotation2 := MeshTypes.GenerateRotationMatrix(90, 0, 180)
rotation2 := MeshTypes.GenerateRotationMatrix(0, 0, 0)
rotation2 = rotation2.ReverseTransformation(rotation1)
rasterizer.SaveCanvasAsPNGFile("side.png", canvas1)
canvas2, err := rasterizer.Draw(&stage_model, rasterizer.RasterizerConfig{RenderLabels: true, Rotation: rotation2, OverrideColors: overrideColors, CanvasConfig: canvasConfig})
Expand Down
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ go 1.25.6
require (
github.com/Patch2PDF/GDTF-Mesh-Reader/v2 v2.2.0
github.com/Patch2PDF/GDTF-Parser v0.4.1
github.com/Patch2PDF/MVR-Parser v0.3.1
github.com/Patch2PDF/MVR-Parser v0.3.2
)

require golang.org/x/text v0.34.0 // indirect
require golang.org/x/text v0.35.0 // indirect

require (
github.com/qmuntal/gltf v0.28.0 // indirect
Expand Down
8 changes: 4 additions & 4 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ github.com/Patch2PDF/GDTF-Mesh-Reader/v2 v2.2.0 h1:ykkdyTIl++IaxBbgo2WFF3/k4jy7I
github.com/Patch2PDF/GDTF-Mesh-Reader/v2 v2.2.0/go.mod h1:zAcGHlYdE75hdFo624nQfQHTzw9+NfPJT8Eo2mB1lI8=
github.com/Patch2PDF/GDTF-Parser v0.4.1 h1:RLmzQwIHGuEYc6C6hNtWA3HOpjhUizhkg36u0Px1a7E=
github.com/Patch2PDF/GDTF-Parser v0.4.1/go.mod h1:2l8WWbsYr4D0Uo069HMh9tImKtaUzy2+OeUpl7IN+S4=
github.com/Patch2PDF/MVR-Parser v0.3.1 h1:lg9MieoOL93Bm+huKz1yMlJWuFLzHyJ+afZj1S8UKbs=
github.com/Patch2PDF/MVR-Parser v0.3.1/go.mod h1:2ekLlUhkPCkDli56afCQT/9EGdE/llx3NCF5E1+YiXc=
github.com/Patch2PDF/MVR-Parser v0.3.2 h1:Kpq6BUs31KSUhLEg/f16gnRh1t5YD5Y94WeTo9NRGcY=
github.com/Patch2PDF/MVR-Parser v0.3.2/go.mod h1:2ekLlUhkPCkDli56afCQT/9EGdE/llx3NCF5E1+YiXc=
github.com/go-test/deep v1.0.1 h1:UQhStjbkDClarlmv0am7OXXO4/GaPdCGiUiMTvi28sg=
github.com/go-test/deep v1.0.1/go.mod h1:wGDj63lr65AM2AQyKZd/NYHGb0R+1RLqB8NKt3aSFNA=
github.com/qmuntal/gltf v0.28.0 h1:C4A1temWMPtcI2+qNfpfRq8FEJxoBGUN3ZZM8BCc+xU=
Expand All @@ -12,5 +12,5 @@ golang.org/x/image v0.36.0 h1:Iknbfm1afbgtwPTmHnS2gTM/6PPZfH+z2EFuOkSbqwc=
golang.org/x/image v0.36.0/go.mod h1:YsWD2TyyGKiIX1kZlu9QfKIsQ4nAAK9bdgdrIsE7xy4=
golang.org/x/sync v0.20.0 h1:e0PTpb7pjO8GAtTs2dQ6jYa5BWYlMuX047Dco/pItO4=
golang.org/x/sync v0.20.0/go.mod h1:9xrNwdLfx4jkKbNva9FpL6vEN7evnE43NNNJQ2LF3+0=
golang.org/x/text v0.34.0 h1:oL/Qq0Kdaqxa1KbNeMKwQq0reLCCaFtqu2eNuSeNHbk=
golang.org/x/text v0.34.0/go.mod h1:homfLqTYRFyVYemLBFl5GgL/DWEiH5wcsQ5gSh1yziA=
golang.org/x/text v0.35.0 h1:JOVx6vVDFokkpaq1AEptVzLTpDe9KGpj5tR4/X+ybL8=
golang.org/x/text v0.35.0/go.mod h1:khi/HExzZJ2pGnjenulevKNX1W67CUy0AsXcNubPGCA=
12 changes: 7 additions & 5 deletions model_manipulation.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,14 +91,16 @@ func normalizeAndRotateStageModel(canvas *Canvas, stageModel *StageModel, rotati
height := float64(canvas.height - 1)

// normalizing to canvas dimensions
diff := theoretical_max.Sub(theoretical_min)
scale := width / diff.X
if scale*diff.Y >= float64(canvas.height) {
scale = height / diff.Y
// NOTE: stagemodel coordinate system is z for up and x for right position
visualWidth := theoretical_max.X - theoretical_min.X
visualHeight := math.Abs(theoretical_max.Z - theoretical_min.Z)
scale := width / visualWidth
if scale*visualHeight > height {
scale = height / visualHeight
}
centeringMatrix = centeringMatrix.MulScalar(scale)
centeringMatrix.X03 += width / 2
centeringMatrix.X13 += height / 2
centeringMatrix.X23 -= height / 2

rotateAndTranslateStageModel(stageModel, centeringMatrix)
}
7 changes: 4 additions & 3 deletions triangle.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,11 @@ type Triangle struct {
}

func NewTriangleFromMeshTriangle(triangle MeshTypes.Triangle) Triangle {
// NOTE: mesh coordinate system is z for up and x for right position
return Triangle{
Point{x: math.Round(triangle.V0.Position.X), y: math.Round(triangle.V0.Position.Y), z: triangle.V0.Position.Z},
Point{x: math.Round(triangle.V1.Position.X), y: math.Round(triangle.V1.Position.Y), z: triangle.V1.Position.Z},
Point{x: math.Round(triangle.V2.Position.X), y: math.Round(triangle.V2.Position.Y), z: triangle.V2.Position.Z},
Point{x: (triangle.V0.Position.X), y: -(triangle.V0.Position.Z), z: -triangle.V0.Position.Y},
Point{x: (triangle.V1.Position.X), y: -(triangle.V1.Position.Z), z: -triangle.V1.Position.Y},
Point{x: (triangle.V2.Position.X), y: -(triangle.V2.Position.Z), z: -triangle.V2.Position.Y},
}
}

Expand Down
Loading