Generated velocity bobj always has zero triangle
wyxgoishin opened this issue · 1 comments
System Information
Blender Version: 3.1.2, master, 2022-03-31 17:40, cc66d1020c3b
Addon Version: A FLIP Fluid Simulation Tool for Blender (v1.2.0 Stable 25-NOV-2021)
OS: Windows-10-10.0.17763-SP0
GPU: NVIDIA GeForce RTX 3060/PCIe/SSE2 NVIDIA Corporation 4.5.0 NVIDIA 512.95
CPU: 11th Gen Intel(R) Core(TM) i7-11700K @ 3.60GHz
RAM: 32G
Describe the bug
I toggled on Geometry Attribute -> Generate Velocity Attribute, but I found the whole output "velocityxxx.bobj" always has zero triangle.
Below is the python code for parsing "velocityxxx.bobj" file according to source cpp file(sorry to say that I forget where actually the code for saving bobj locates). And I set args.byte_order
to little
in my case. I wonder if there are some error in my python code or blender settings.
import struct
import argparse
import os
import numpy as np
def parse_bobj(filepath):
with open(filepath, "rb") as f:
numVertex = int.from_bytes(f.read(4), byte_order_int)
if numVertex != 0:
velocity = np.zeros((numVertex, 3))
for i in range(numVertex):
for j in range(3):
velocity[i, j] = struct.unpack(byte_order_float, f.read(4))[0]
save_path = filepath.replace(".bobj", "_v.npy")
np.save(save_path, velocity)
print("save 3D velocity of %d vertexs to %s" % (numVertex, save_path))
numTriangle = int.from_bytes(f.read(4), byte_order_int)
if numTriangle != 0:
triangle = np.zeros((numTriangle, 3), dtype=int)
for i in range(numTriangle):
for j in range(3):
triangle[i, j] = int.from_bytes(f.read(4), byte_order_int)
save_path = filepath.replace(".bobj", "_loc.npy")
np.save(save_path, triangle)
print("save 3D location of %d vertexs to %s" % (numTriangle, save_path))
if __name__ == "__main__":
parser = argparse.ArgumentParser()
parser.add_argument("-filepath", "-S", type=str, default="velocity000100.bobj", help="filepath of input, must end with \".bobj\"")
parser.add_argument("-byte_order", '-BO', type=str, default='little', help="byte order of the given file, default little end, or you can input \"big\" for big end")
args = parser.parse_args()
assert os.path.isfile(args.filepath) and args.filepath.endswith(".bobj"), "filepath be path of a file with extension as bobj"
assert args.byte_order in ["little", "big"], "byte order must be little or big"
byte_order_int = args.byte_order
byte_order_float = "<f" if byte_order_int == "little" else ">f"
parse_bobj(args.filepath)
To Reproduce
Blender file and a sample "velocity.bobj" is uploaded in google drive.
Expected Behaviour
As far as I think, the numTriangle
and numVertex
should equal as they equal in the source cpp file.
Actual Behaviour
But the generated bobj file always has numTriangle equaling zero.
Screenshots
If applicable, add screenshots to help explain your problem.
Hi, this is working as expected. Velocity attribute data does not contain any triangles and only carries information stored on the vertices. Each vertex of the velocity bobj represents the 3D velocity vector that corresponds to the vertex on the final fluid surface meshes (000000.bobj, 000001.bobj, ...).