OPENGL + NEWTON

A place to discuss everything related to Newton Dynamics.

Moderators: Sascha Willems, walaber

OPENGL + NEWTON

Postby codemasterpl » Fri Sep 25, 2009 7:58 am

First of all - hello everyone.

I am new to Newton - working previously with Tokamak.

I would like to ask you about methods of 'placing' objects in the scene and rendering them.

I use pure OpenGL and Newton, no additional rendering classes.

How do i:

- place a created object in X,Y,Z location
- rotate that object
- get it's position and rotation (required for rendering)
codemasterpl
 

Re: OPENGL + NEWTON

Postby Julio Jerez » Fri Sep 25, 2009 8:15 am

you can use the function get and set matrix for placemenet and rendering,
There is also convex cast that can be used for precised placement.

I am not clear on what it is you want to know

There is a series of entry level tutorials for first timers, and it uses Open GL, with SDL for initialization.
http://newtondynamics.com/wiki/index.php5?title=Tutorials
Julio Jerez
Moderator
Moderator
 
Posts: 12426
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: OPENGL + NEWTON

Postby JernejL » Fri Sep 25, 2009 9:39 am

First of all, welcome to the forum :)

codemasterpl wrote:How do i:

- place a created object in X,Y,Z location


First create the collision shape with NewtonCreateBody, NewtonCreateBox, etc..
Then create a body to hold the shape with NewtonCreateBody and place it with NewtonBodySetMatrix, set it's mass with NewtonBodySetMassMatrix (or else the body will be considered static).

codemasterpl wrote:- rotate that object


Inside the forcetorque callback you can apply this, as a proper way to interact with the object: NewtonBodyAddTorque, NewtonBodySetOmega
Alternate ways are: NewtonBodySetMatrix (set the orientation directly) OR using the Joint interface

codemasterpl wrote:- get it's position and rotation (required for rendering)


With NewtonBodySetTransformCallback you set a callback which will tell you when the body location and orientation changes, then you use NewtonBodyGetMatrix which gives you a standard 4x4 matrix that you can use as rendering matrix.
Help improving the Newton Game Dynamics WIKI
User avatar
JernejL
 
Posts: 1587
Joined: Mon Dec 06, 2004 2:00 pm
Location: Slovenia


Return to General Discussion

Who is online

Users browsing this forum: No registered users and 1 guest

cron