# Physics Simulation Forum

 All times are UTC

 Page 1 of 1 [ 1 post ]
 Print view Previous topic | Next topic
Author Message
 Post subject: Bullet Linear Math and OpenGL Conversion QuestionPosted: Tue Aug 07, 2012 9:51 am

Joined: Mon Aug 06, 2012 8:27 am
Posts: 8
SO I am working on integrating Bullet into an OpenGL simulation on the iPhone and I have a standard piece of setup code

Code:
- (void)setupGL {
[EAGLContext setCurrentContext:self.context];
// aspect has to be created prior to the screen rotating.
_aspect = fabsf(self.view.bounds.size.height / self.view.bounds.size.width);
_cameraPosition = GLKVector3Make(0.0f, 0.0f, 8.0f);
_baseModelView = GLKMatrix4MakeLookAt(_cameraPosition.x, _cameraPosition.y, _cameraPosition.z, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f);
_projection = GLKMatrix4MakePerspective(_fieldOfView, _aspect, 0.1f, 1000.0f);

// [self.obstacle setupGL];
self.ball.position = GLKVector3Make(0.0f, 0.0f, 0.0f);
[self.ball setupGL];
}

This is some Objective-C magic that creates a 4x4 matrix that represents the world transformation. In the update phase of the simulation I currently have the following code.

Code:
- (void)updateUsingInterval:(NSTimeInterval)interval andDynamicsWorld:(btDiscreteDynamicsWorld *)dynamicsWorld {
btTransform transform = self.sphereBody->getCenterOfMassTransform();
btVector3 velocity = self.sphereBody->getTurnVelocity();
btVector3 position = transform.getOrigin();
btMatrix3x3 rotation = transform.getBasis();

//---------- old code below, how the heck do I go from bullet to this?
GLKMatrix4 modelViewMatrix = GLKMatrix4MakeTranslation(self.position.x, self.position.y, self.position.z);
modelViewMatrix = GLKMatrix4Multiply(modelViewMatrix, GLKMatrix4MakeWithQuaternion(_rotation));
modelViewMatrix = GLKMatrix4Multiply(self.viewController.baseModelView, modelViewMatrix);

_normalMatrix = GLKMatrix3InvertAndTranspose(GLKMatrix4GetMatrix3(modelViewMatrix), NULL);
_modelViewProjection = GLKMatrix4Multiply(self.viewController.projection, modelViewMatrix);
}

The code above the comment line is from bullet and the code below from the standard linear math library that comes with GLKit on iOS 5+. What I need to do is integrate the two approaches. I figure i have two potential solutions, either implement the math operaitons in the bullet linear math library or convert the bullet objects to GLKMatrix objects. Is there any way to do all of this math inside bullet and thus reduce my complexity? I wasn't able to find a 4x4 matrix class in the API anywhere but perhaps I was looking in the wrong spot.

I suppose a third option would be to pass the world transform and object transform separately to the vertex shader and do the combination there.

Top

 Display posts from previous: All posts1 day7 days2 weeks1 month3 months6 months1 year Sort by AuthorPost timeSubject AscendingDescending
 Page 1 of 1 [ 1 post ]

 All times are UTC

#### Who is online

Users browsing this forum: Google [Bot] and 7 guests

 You cannot post new topics in this forumYou cannot reply to topics in this forumYou cannot edit your posts in this forumYou cannot delete your posts in this forumYou cannot post attachments in this forum

Search for:
 Jump to:  Select a forum ------------------ BULLET PHYSICS LIBRARY USERS    General Bullet Physics Support and Feedback    Release Announcements    Applications, Games, Demos or Movies using Bullet PHYSICS AUTHORING TOOLS, SERIALIZATION AND STANDARDS    Physics authoring tools, serialization, standards and related topics RESEARCH AND DEVELOPMENT IN COLLISION DETECTION & PHYSICS. Don't post Bullet support questions here!    Research and development discussion about Collision Detection and Physics Simulation    Links, Papers, Libraries, Demos, Movies, Comparisons       Non-technical forum and license/patent discussion    Career Opportunities