Seek for info about a few functions in Newton

A place to discuss everything related to Newton Dynamics.

Moderators: Sascha Willems, walaber

Seek for info about a few functions in Newton

Postby aqnuep » Sat Nov 28, 2009 11:05 am

Hi,

So far I managed to cover with documentation almost all Newton API functions, but there are some for which I haven't found example usage in the SDK demos or I barely understood them:

NewtonBodyCalculateInverseDynamicsForce
NewtonBodyGetForceAcc
NewtonBodyGetRotation
NewtonBodyGetTorqueAcc
NewtonCalculateSpringDamperAcceleration
NewtonCorkscrewCalculateStopAccel
NewtonHingeCalculateStopAlpha
NewtonJointGetInfo
NewtonMaterialSetSurfaceThickness
NewtonMeshClip
NewtonReadPerformanceTicks
NewtonSetPerformanceClock
NewtonSliderCalculateStopAccel
NewtonTreeCollisionGetVertexListIndexListInAABB
NewtonTreeCollisionSetUserRayCastCallback
NewtonUserJointSetFeedbackCollectorCallback
NewtonWorldGetFirstMaterial
NewtonWorldGetNextMaterial

If any of you have already know how to use one of these and maybe even have source code using them, please share it with me to be able to complete the Newton 2.0 API documentation.

Any help is welcomed!
aqnuep
 
Posts: 97
Joined: Sat Dec 22, 2007 4:14 pm

Re: Seek for info about a few functions in Newton

Postby Stucuk » Sat Nov 28, 2009 6:13 pm

NewtonMeshClip is discussed in the NewtonMesh thread.

Code: Select all
procedure TFME_Map.ClipObject(MapObject : TMapObject);
var
NM1,NM2,
TopMesh,
BottomMesh : TNewtonMesh;
M : TMatrix4;
MObject : Pointer;
begin
NM1 := SizeToTNewtonMesh(SetVector(100,100,100));
NM2 := TNewtonMesh.CreatePlane(@IdentityMatrix[0][0],100,100,-1,@IdentityMatrix[0][0]);

TopMesh    := TNewtonMesh.Create(Nil);
BottomMesh := TNewtonMesh.Create(Nil);

M := IdentityMatrix;
NM1.Clip(NM2.Mesh,@M[0,0],TopMesh.Mesh,BottomMesh.Mesh);

MObject := TNewtonMeshToTMapObject(TopMesh,MapObject);
If Assigned(MObject) then
AddObject(MObject);
MObject := TNewtonMeshToTMapObject(BottomMesh,MapObject);
If Assigned(MObject) then
AddObject(MObject);

NM1.Free;
NM1 := Nil;
NM2.Free;
NM2 := Nil;
TopMesh.Free;
TopMesh := Nil;
BottomMesh.Free;
BottomMesh := Nil;
Update;
end;


If there is a specific part you don't understand then please elaberate.
User avatar
Stucuk
 
Posts: 801
Joined: Sat Mar 12, 2005 3:54 pm
Location: Scotland

Re: Seek for info about a few functions in Newton

Postby aqnuep » Sat Nov 28, 2009 9:37 pm

Stucuk wrote:If there is a specific part you don't understand then please elaberate.


Yes.
I know what is it for, but it's a bit unclear for me how to feed it with parameters.

- const NewtonMesh* clipper
This is the clipper geometry as I understand. What kind of clipper geometry can be used? I suppose we cannot use arbitrary geometry to clip the mesh.
- const NewtonMesh* mesh
This is the mesh to be split.
- const dFloat* matrix
What is this for? Is it used to transform to clipper or the clipped geometry or something else?
- NewtonMesh** topMesh
- NewtonMesh** bottomMesh
These are two sets of mesh primitives generated based on the clipping. What does top and bottom mean? If the clipper is only a plane then this makes sense, otherwise I don't really understand how is this two set created if the clipper can be arbitrary geometry.
aqnuep
 
Posts: 97
Joined: Sat Dec 22, 2007 4:14 pm

Re: Seek for info about a few functions in Newton

Postby Stucuk » Sun Nov 29, 2009 2:36 am

procedure NewtonMeshClip (const mesh : PNewtonMesh; const clipper : PNewtonMesh; const clippermatrix : PFloat; topMesh : PNewtonMesh; bottomMesh : PNewtonMesh); cdecl; external{$IFDEF __GPC__}name 'NewtonMeshClip'{$ELSE}NewtonDLL{$ENDIF __GPC__};


The order of the parameters you wrote is wrong (At least based on 2.11's header). NewtonMesh parameters can be any NewtonMesh. topMesh and bottom mesh are the result of the operation. One is the mesh with the hole cut in it, the other is the space which occupied the hole. I think the bottom mesh is the latter.

NM1.Clip(NM2.Mesh,@M[0,0],TopMesh.Mesh,BottomMesh.Mesh);


NM1.Clip is the same as NewtonMeshClip(NM1.Mesh,.....); So the code i posted should show you how its used. TNewtonMesh is just a wrapper for the NewtonMesh procedures where the mesh parameter is just handled inside the class.
User avatar
Stucuk
 
Posts: 801
Joined: Sat Mar 12, 2005 3:54 pm
Location: Scotland

Re: Seek for info about a few functions in Newton

Postby aqnuep » Sun Nov 29, 2009 10:40 am

OK! This is new to me. There is beta version 11 already? I've found download link only to beta 10 on the main page. How can I get Newton 2.0 beta 11?
aqnuep
 
Posts: 97
Joined: Sat Dec 22, 2007 4:14 pm

Re: Seek for info about a few functions in Newton

Postby Stucuk » Sun Nov 29, 2009 11:36 am

aqnuep wrote:OK! This is new to me. There is beta version 11 already? I've found download link only to beta 10 on the main page. How can I get Newton 2.0 beta 11?


By sending a PM to Julio to ask for it. 2.11 is a WIP hence why its not released.
User avatar
Stucuk
 
Posts: 801
Joined: Sat Mar 12, 2005 3:54 pm
Location: Scotland

Re: Seek for info about a few functions in Newton

Postby Julio Jerez » Sun Nov 29, 2009 10:42 pm

There are few important bug fixes for 2.11 so I am realeasing it is.
http://newtondynamics.com/forum/viewtopic.php?f=9&t=4922

The destrution words but I still need to fix some problems with pieces gettiong stocked in precarious porsitions.
and the strategy I implemented last so adress that isses did not really worked because my assumtion tah pieces will alway be conve and will have a clean way to detach from teh compund is no really correct.
So I have to thonk abput a nopt gemetrical solution tah wor with the contacts.
I have not have the time to worked on it in the last two weeks mosth because I have no have any reall godd idea.
I beleive I have a solution but I will implement it for 2.12
Julio Jerez
Moderator
Moderator
 
Posts: 12426
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Seek for info about a few functions in Newton

Postby aqnuep » Mon Nov 30, 2009 9:12 am

As I understand your problem is the following:
When you do the destruction it often happens that you end up with concave geometries which are sometimes very problematic to be converted to compound convexes. Actually this is the same problem why NewtonCreateCompoundCollisionFromMesh is currently not fully functional. It's hard to compose a general algorithm for this.
aqnuep
 
Posts: 97
Joined: Sat Dec 22, 2007 4:14 pm

Re: Seek for info about a few functions in Newton

Postby Julio Jerez » Mon Nov 30, 2009 10:21 am

in a word yes, by it is not that simple. the brakable object is made of convex pieces only, you would think that the most outer pieces will have a half space to move out, and this in fact is true.
you can actually write an procedure that can calculate the half space that a piece is allow to move, but it is complicated and does not always produce the result you would want.
It is better to handle it by using a Material and adding some special function to control solver contact relaxation.
That way when a piece is dettaches the solver will find a compromised solution even is there are many contact producing singular matrices.
In any case I still trying some other solutions but for what I can see there is not real gemrtical solution to the problem.


NewtonCreateCompoundCollisionFromMesh is not funtionalnal because I have not implemnet teh function yet.
Basically that function will do a simple convex aproximation form a Mesh. I will try to get it ready for 2.12
Julio Jerez
Moderator
Moderator
 
Posts: 12426
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Seek for info about a few functions in Newton

Postby aqnuep » Mon Nov 30, 2009 10:32 am

Ehh, I did not think through that after decompositing the geometry it should also not crush the rigid body simulation.
Now I understand the main problem is that after the mesh is broken to pieces, then the contacts generated at the next integration step would cause forces that cannot be handled normally due to numerical mathematics done by computers.

Yeah, this is a tough one, it's not that simple as I supposed. Btw I know how usually rigid body dynamics libraries work inside, I mean the math. I don't know how these are actually done by Newton, but it's for sure that this kind of stuff is not something what traditional rigid body engine approaches can handle.

Keep up the good work, I think you'll figure out an elegant and stable solution :D
aqnuep
 
Posts: 97
Joined: Sat Dec 22, 2007 4:14 pm


Return to General Discussion

Who is online

Users browsing this forum: No registered users and 1 guest