-
Notifications
You must be signed in to change notification settings - Fork 557
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 to use btTransform function getOpenGLMatrix? #20
Comments
The bullet functions can't deal with a native JS object like that, I think that is the problem here. getOpenGLMatrix receives a simple float pointer. You should allocate some memory and pass it that pointer, then read from that memory. This might work but I haven't tested it:
|
malloc and free don't seem to be accessible. Here's something I tried. It runs, but doesn't seem to produce the correct matrix. var buffer = Ammo.allocate(16, 'float', 1 /* ALLOC_STACK */);
var transform = new Ammo.btTransform();
transform.getOpenGLMatrix(buffer);
var matrix = Ammo.HEAPF32.subarray(buffer / 4, buffer / 4 + 16);
// Ammo.free(buffer);
Ammo.destroy(transform); |
@cjcliffe , you were doing something similar to this, I think? Do you remember what worked for you? |
Note that in the example above, you need to allocate 16*4 because each float takes 4 bytes. |
Is there any update to this? I would like to use that function if it is possible. |
I can't get btTransform's getOpenGLMatrix function to work. Here's what I thought should work:
var m = new Array(16);
transform.getOpenGLMatrix(m);
I've tried various other things, but can't seem to get anything back from getOpenGLMatrix. I can get my code to work if I use getBasis().getRow()... and getOrigin(), and use that to make a matrix, but that seems like a very roundabout way to do it.
(I can't setOpenGLMatrix to work either, but I assume the issue is probably the same, since both functions expect a pointer to a btScalar array in the original Bullet version.)
The text was updated successfully, but these errors were encountered: