Closed seghier closed 1 day ago
In VL.Alembic, the data obtained by GetMeshes() is evaluates the mesh data, including at least position, normal and uv, and generates default values at runtime if they are missing. So, if you get mesh data, at least one vertex will contain 32 bytes(12(P)+12(N)+8(UV)) of data. also, this is simply interleaved with the position, normal and uv of each vertex and color if included, so there is no need to check the data at the beginning.
// First try to find the vertex count marker (4 bytes) int vertexCount = BitConverter.ToInt32(vertexBuffer, 0); int currentOffset = 4; // Validate vertex count if (vertexCount <= 0 || vertexCount * 12 > pointer.Size) { // If invalid, assume data is packed without header vertexCount = pointer.Size / (3 * sizeof(float)); currentOffset = 0; }
If you want to know the exact number of vertices, for example
foreach (var (meshData, layout) in meshDataArray.Zip(layouts, (mesh, layout) => (mesh, layout)))
{
int vertexCount = meshData.Pointer.Size / layout.VertexStride;
........
}
Also, Alembic basically uses the Y+ Up right-hand coordinate system, and most DCC exporters, including Blender, should convert to this coordinate system when exporting. Therefore, I think the coordinate transformation that needs to be done at the time of import is Alembic->Rhino, not Blender->Rhino.
VL.Alembic is intended to be used on vvvv gamma (a.k.a VL), which is a Visual Programming Language, and the Stride Game Engine, although I cannot verify that it is fully usable on Rhino or Glasshopper, I hope this reply helps you.
Thank you very much @torinos-yt That's help, and i fix the code
Hi @torinos-yt Is it possible to get particles from alembic file? Blender alembic importer support that
I am not familiar with Blender's alembic export, but if it is included as a Point Schema in the alembic archive, I believe it can be imported using AlembicScene.GetPoints() or similar. However, Point only supports getting Position(xyz). https://github.com/torinos-yt/VL.Alembic/blob/5beb5d0bf15f4959bd3ca818c7a5d1461a746a56/src/AlembicSceneSample.cs#L37
Close the issue once, but feel free to reopen it if not resolved.
Hi Is there any example how to get meshes from alembic file? i tried many times but always get wrong vertices coordinates and wrong results if i try to output the vertices only i get duplicated results with different transformations
`protected override bool ReadFile(string filename, int index, RhinoDoc doc, Rhino.FileIO.FileReadOptions options) { double time = GetTimeFromUser();
}
// Helper method to generate colors based on position private System.Drawing.Color GetColorFromPosition(Point3d point) { // Normalize coordinates to 0-1 range assuming typical model scale float scale = 10.0f; // Adjust this based on your model size float r = (float)(point.X / scale + 0.5); float g = (float)(point.Y / scale + 0.5); float b = (float)(point.Z / scale + 0.5);
}
private Transform ConvertStrideToRhinoTransform(Stride.Core.Mathematics.Matrix strideMatrix) { // Create a transform that converts from Stride's coordinate system to Rhino's var transform = Transform.Identity;
}
private Mesh CreateRhinoMesh(DataPointer pointer) { try { var vertexData = GetVertexDataFromPointer(pointer); if (vertexData == null || vertexData.Vertices.Count == 0) { return null; }
}
private VertexData GetVertexDataFromPointer(DataPointer pointer) { var vertexData = new VertexData();
}
private class VertexData { public List Vertices { get; set; } = new List();
public List Faces { get; set; } = new List();
}
// Example of a method to get the time from the user private double GetTimeFromUser() { // Default time to load double defaultTime = 0.0; string defaultTimeStr = defaultTime.ToString(); // Convert default time to string
}`