Skip to content

Commit 5bcb942

Browse files
committed
Updates for openmvgo v1.0.8
1 parent 129c450 commit 5bcb942

8 files changed

Lines changed: 388 additions & 188 deletions

File tree

app/bin/convert_obj_to_glb.py

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,10 @@ def convert_obj_to_glb(input_path, output_path):
1616
bpy.ops.object.select_all(action="SELECT")
1717
bpy.ops.object.delete()
1818

19-
# Import obj file
20-
# bpy.ops.wm.obj_import
21-
bpy.ops.wm.obj_import(filepath=input_path)
19+
# Import obj file with textures
20+
bpy.ops.wm.obj_import(
21+
filepath=input_path,
22+
)
2223

2324
for obj in bpy.context.scene.objects:
2425
obj.rotation_euler[1] += radians(90) # 90 degrees in radians
@@ -46,12 +47,19 @@ def convert_obj_to_glb(input_path, output_path):
4647
bpy.context.view_layer.objects.active = obj
4748
bpy.ops.object.modifier_apply(modifier="Decimate")
4849

49-
# Export as GLB
50+
# Export as GLB with textures
5051
bpy.ops.export_scene.gltf(
5152
filepath=output_path,
5253
export_format="GLB",
5354
use_selection=True,
5455
export_draco_mesh_compression_enable=True, # Enable Draco compression
56+
export_materials="EXPORT", # Export materials
57+
export_texcoords=True, # Export texture coordinates
58+
export_normals=True, # Export normals
59+
export_tangents=True, # Export tangents for normal maps
60+
export_apply=True, # Apply modifiers
61+
export_image_format="AUTO", # Let Blender choose the best format
62+
export_texture_dir="", # Embed textures in GLB
5563
)
5664

5765

@@ -73,3 +81,4 @@ def convert_obj_to_glb(input_path, output_path):
7381
except Exception as e:
7482
print(f"Error during conversion: {str(e)}")
7583
sys.exit(1)
84+

app/go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ go 1.24.3
44

55
require (
66
firebase.google.com/go/v4 v4.15.2
7-
github.com/2024-dissertation/openmvgo v1.0.5
7+
github.com/2024-dissertation/openmvgo v1.0.8
88
github.com/appleboy/go-fcm v1.2.5
99
github.com/aws/aws-sdk-go-v2 v1.36.3
1010
github.com/aws/aws-sdk-go-v2/config v1.29.14

app/go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,8 @@ cloud.google.com/go/trace v1.11.6/go.mod h1:GA855OeDEBiBMzcckLPE2kDunIpC72N+Pq8W
4343
dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU=
4444
firebase.google.com/go/v4 v4.15.2 h1:KJtV4rAfO2CVCp40hBfVk+mqUqg7+jQKx7yOgFDnXBg=
4545
firebase.google.com/go/v4 v4.15.2/go.mod h1:qkD/HtSumrPMTLs0ahQrje5gTw2WKFKrzVFoqy4SbKA=
46-
github.com/2024-dissertation/openmvgo v1.0.5 h1:juKy2McCKfqj7eZSLbKhxk1UQqDxu+6JdwB/4hn41fQ=
47-
github.com/2024-dissertation/openmvgo v1.0.5/go.mod h1:J/Jz76PZhkdjLc7+p3mp7BnpkxbWWVeKQDM5SlvpcCo=
46+
github.com/2024-dissertation/openmvgo v1.0.8 h1:HW0NZS8DtA+QtVBDSQxmPFArBeN+ZVfNvBzLIKOY9io=
47+
github.com/2024-dissertation/openmvgo v1.0.8/go.mod h1:J/Jz76PZhkdjLc7+p3mp7BnpkxbWWVeKQDM5SlvpcCo=
4848
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
4949
github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo=
5050
github.com/GoogleCloudPlatform/opentelemetry-operations-go/detectors/gcp v1.27.0 h1:ErKg/3iS1AKcTkf3yixlZ54f9U1rljCkQyEXWUnIUxc=

app/main.go

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,10 @@ package main
22

33
import (
44
"context"
5+
"fmt"
56
"log"
67
"os"
8+
"strings"
79

810
"github.com/Soup666/modelmaker/controller"
911
db "github.com/Soup666/modelmaker/database"
@@ -17,7 +19,60 @@ import (
1719
_ "github.com/joho/godotenv/autoload"
1820
)
1921

22+
func printEnvironmentBanner() {
23+
appEnv := os.Getenv("APP_ENV")
24+
if appEnv == "" {
25+
appEnv = "production"
26+
}
27+
28+
// ANSI color codes
29+
const (
30+
colorRed = "\033[1;31m" // Bold Red
31+
colorGreen = "\033[1;32m" // Bold Green
32+
colorYellow = "\033[1;33m" // Bold Yellow
33+
colorBlue = "\033[1;34m" // Bold Blue
34+
colorMagenta = "\033[1;35m" // Bold Magenta
35+
colorCyan = "\033[1;36m" // Bold Cyan
36+
colorReset = "\033[0m"
37+
)
38+
39+
var bannerColor, envText string
40+
switch appEnv {
41+
case "dev":
42+
bannerColor = colorYellow
43+
envText = "DEVELOPMENT"
44+
case "staging":
45+
bannerColor = colorCyan
46+
envText = "STAGING"
47+
case "test":
48+
bannerColor = colorMagenta
49+
envText = "TEST"
50+
case "production":
51+
bannerColor = colorGreen
52+
envText = "PRODUCTION"
53+
default:
54+
bannerColor = colorRed
55+
envText = strings.ToUpper(appEnv)
56+
}
57+
58+
banner := []string{
59+
"",
60+
"╔════════════════════════════════════════╗",
61+
"║ MODEL MAKER ║",
62+
fmt.Sprintf("║ Environment: %-16s ║", envText),
63+
"╚════════════════════════════════════════╝",
64+
"",
65+
}
66+
67+
for _, line := range banner {
68+
fmt.Printf("%s%s%s\n", bannerColor, line, colorReset)
69+
}
70+
}
71+
2072
func main() {
73+
// Print environment banner
74+
printEnvironmentBanner()
75+
2176
// Set up the database connection
2277
log.Println("Connecting to database...")
2378

app/repository/task_repository_impl.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,12 @@ func (repo *TaskRepositoryImpl) GetArchivedTasks(userID uint) ([]*models.Task, e
3838

3939
func (repo *TaskRepositoryImpl) GetTaskByID(taskID uint) (*models.Task, error) {
4040
var task models.Task
41-
if err := database.DB.Where("id = ?", taskID).Preload("ChatMessages").Preload("Images").First(&task).Error; err != nil {
41+
if err := database.DB.Where("id = ?", taskID).
42+
Preload("ChatMessages").
43+
Preload("Images", "file_type = ?", "upload").
44+
Preload("Mesh", "file_type = ?", "mesh").
45+
Preload("Logs").
46+
First(&task).Error; err != nil {
4247
return nil, err
4348
}
4449
return &task, nil

app/services/katapult_storage_service.go

Lines changed: 26 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import (
77
"io"
88
"mime/multipart"
99
"os"
10+
"strings"
1011

1112
"github.com/aws/aws-sdk-go-v2/aws"
1213
"github.com/aws/aws-sdk-go-v2/config"
@@ -19,6 +20,7 @@ type KatapultStorageService struct {
1920
bucketName string
2021
region string
2122
endpoint string
23+
isDev bool
2224
}
2325

2426
func NewKatapultStorageService() *KatapultStorageService {
@@ -27,6 +29,7 @@ func NewKatapultStorageService() *KatapultStorageService {
2729
endpoint := os.Getenv("KATAPULT_ENDPOINT")
2830
accessKey := os.Getenv("KATAPULT_ACCESS_KEY")
2931
secretKey := os.Getenv("KATAPULT_SECRET_KEY")
32+
isDev := os.Getenv("APP_ENV") == "dev"
3033

3134
// Configure AWS SDK
3235
cfg, err := config.LoadDefaultConfig(context.TODO(),
@@ -47,9 +50,31 @@ func NewKatapultStorageService() *KatapultStorageService {
4750
bucketName: bucketName,
4851
region: region,
4952
endpoint: endpoint,
53+
isDev: isDev,
5054
}
5155
}
5256

57+
func (s *KatapultStorageService) getObjectKey(taskID uint, filename string, fileType string) string {
58+
var path string
59+
if fileType == "mesh" {
60+
path = fmt.Sprintf("objects/%d/%s", taskID, filename)
61+
} else {
62+
path = fmt.Sprintf("uploads/%d/%s", taskID, filename)
63+
}
64+
65+
if s.isDev {
66+
return "development/" + path
67+
}
68+
return path
69+
}
70+
71+
func (s *KatapultStorageService) getFilePath(filepath string) string {
72+
if s.isDev && !strings.HasPrefix(filepath, "development/") {
73+
return "development/" + filepath
74+
}
75+
return filepath
76+
}
77+
5378
func (s *KatapultStorageService) UploadFile(file *multipart.FileHeader, taskID uint, fileType string) (string, error) {
5479
src, err := file.Open()
5580
if err != nil {
@@ -86,7 +111,7 @@ func (s *KatapultStorageService) GetFile(filepath string) (io.ReadCloser, error)
86111
// Get object from S3
87112
result, err := s.client.GetObject(context.TODO(), &s3.GetObjectInput{
88113
Bucket: aws.String(s.bucketName),
89-
Key: aws.String(filepath),
114+
Key: aws.String(s.getFilePath(filepath)),
90115
})
91116
if err != nil {
92117
return nil, fmt.Errorf("failed to get file: %w", err)
@@ -109,10 +134,3 @@ func (s *KatapultStorageService) DeleteFile(taskID uint, filename string) error
109134

110135
return nil
111136
}
112-
113-
func (s *KatapultStorageService) getObjectKey(taskID uint, filename string, fileType string) string {
114-
if fileType == "mesh" {
115-
return fmt.Sprintf("objects/%d/%s", taskID, filename)
116-
}
117-
return fmt.Sprintf("uploads/%d/%s", taskID, filename)
118-
}

0 commit comments

Comments
 (0)