File size: 902 Bytes
ffbf761
 
44a5fb8
ffbf761
 
 
 
 
 
 
 
 
 
 
 
674aded
ffbf761
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
import numpy as np
from typing import Dict, Tuple
from utils.geometry import vector3_to_numpy


def create_subject_mesh(subject: Dict) -> Tuple[np.ndarray, np.ndarray]:
    position = vector3_to_numpy(subject['position'])
    size = vector3_to_numpy(subject['size'])

    # Create cube vertices
    vertices = np.array([
        [-0.5, -0.5, -0.5], [0.5, -0.5, -0.5], [0.5, 0.5, -0.5], [-0.5, 0.5, -0.5],
        [-0.5, -0.5, 0.5], [0.5, -0.5, 0.5], [0.5, 0.5, 0.5], [-0.5, 0.5, 0.5]
    ]) * size.reshape(1, 3) + position.reshape(1, 3)

    # Create cube faces (updated to use vertex_indices instead of indices)
    faces = np.array([
        [0, 1, 2], [0, 2, 3],  # front
        [1, 5, 6], [1, 6, 2],  # right
        [5, 4, 7], [5, 7, 6],  # back
        [4, 0, 3], [4, 3, 7],  # left
        [3, 2, 6], [3, 6, 7],  # top
        [4, 5, 1], [4, 1, 0]   # bottom
    ])

    return vertices, faces