Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How do you represent a object like mesh with data class in taichi? #8512

Open
artmortal93 opened this issue Apr 16, 2024 · 0 comments
Open
Labels
question Question on using Taichi

Comments

@artmortal93
Copy link

For signed distance function of 3D object, It could represent the object like this:
@ti.dataclass
class Sphere:
center: vec3
radius: float

@ti.dataclass
class Triangle:
p1: vec3
p2: vec3
p3:vec3

Or more generally

@ti.dataclass
class SDFObject:
floatField1:float
...
floatFieldN:float
vec3Field1:vec3
...
vec3FieldN:vec3
GeoType:int # 1 for sphere 2 for triangle and so on

But how do you represent a triangle mesh object? I want to do somethng like this:

@ti.dataclass:
class Mesh:
face: ti.Matrix(n,3) #dynamic size,but can be determined on runtime
normal:ti.Matrix() #same size as face
n:int #number of triangles
Meshfield = Mesh.field(shape=(10,)) #represent all the mesh in the scene

Or do I need to construct the cloud into something like this, this solution make the AABB box searching difficult?
AllFaces = ti.root.dynamic(ti.i, N, chunk_size=32) #represent all the faces of all mesh,precaculate the total faces number in the scene?
face = ti.Vector.field(n=3, dtype=float, shape=(3,))
AllFaces.place(face)

@artmortal93 artmortal93 added the question Question on using Taichi label Apr 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Question on using Taichi
Projects
Status: Untriaged
Development

No branches or pull requests

1 participant