Simulate Spring scaling the object

A place to discuss everything related to Newton Dynamics.

Moderators: Sascha Willems, walaber

Simulate Spring scaling the object

Postby telmopereira » Fri Jun 04, 2010 10:41 am

Hi everybody,

I am trying to simulate the behavior of a spring in my application. My idea was: when i make force on the object that is a spring, i scale the object...graphically that part is easy. But i don't know how to do that physically with Newton...there is some way to scale in one axis the physic object ?

Thanks,
Telmo
telmopereira
 
Posts: 29
Joined: Thu Apr 15, 2010 12:52 pm

Re: Simulate Spring scaling the object

Postby JernejL » Fri Jun 04, 2010 2:11 pm

well, you can scale a newton object with a convex hull modifier.
Help improving the Newton Game Dynamics WIKI
User avatar
JernejL
 
Posts: 1587
Joined: Mon Dec 06, 2004 2:00 pm
Location: Slovenia

Re: Simulate Spring scaling the object

Postby telmopereira » Fri Jun 04, 2010 2:21 pm

How exactly ?

By doing NewtonConvexHullModifierSetMatrix ?
telmopereira
 
Posts: 29
Joined: Thu Apr 15, 2010 12:52 pm

Re: Simulate Spring scaling the object

Postby JernejL » Fri Jun 04, 2010 5:04 pm

yes, that function exactly, you can set scaling there.
Help improving the Newton Game Dynamics WIKI
User avatar
JernejL
 
Posts: 1587
Joined: Mon Dec 06, 2004 2:00 pm
Location: Slovenia

Re: Simulate Spring scaling the object

Postby Carli » Sat Jun 05, 2010 5:17 am

Seems to me that most of the newton newbies don't know what a matrix is.
I can give you a hint: use Wiki http://en.wikipedia.org/wiki/Matrix_(mathematics)
Carli
 
Posts: 245
Joined: Fri Oct 02, 2009 5:28 am

Re: Simulate Spring scaling the object

Postby telmopereira » Fri Jun 11, 2010 9:33 am

Hi,

I try to use the NewtonConvexHullModifier, but something is wrong.
When i am creating an hull collision, i did something like this:

Code: Select all
collision = NewtonCreateConvexHull(p_world, totalVertices, cloud, sizeof(dFloat)*3, 20, shapeId, NULL);
collModifier = NewtonCreateConvexHullModifier(p_world,collision,shapeId);

body = NewtonCreateBody(p_world, collModifier);
NewtonReleaseCollision(p_world, collModifier);



Then, when i do something like setPosition of the object, i do something like this:
Code: Select all
matrix4 mat;
NewtonBodyGetMatrix(p_body, mat.pointer());
mat.setTranslation(pos);
if(strcmp(getExpType().c_str(), "spring") ==0)
   NewtonConvexHullModifierSetMatrix(ApplicationManager::sprExp->collMod,mat.pointer());   
else
        NewtonBodySetMatrix(p_body, mat.pointer());


The problem is if i use the NewtonConvexHullModifierSetMatrix instead of NewtonBodySetMatrix, the object is just represented graphically, there are no collisions...it's like object is not there.
I think that is because with the NewtonBodySetMatrix it's told to Newton which body will have that matrix, and in HullModifier, is not told which body will be affected... is that the problem ? Someone knows how to solve this?

Thanks,
Telmo
telmopereira
 
Posts: 29
Joined: Thu Apr 15, 2010 12:52 pm

Re: Simulate Spring scaling the object

Postby JernejL » Fri Jun 11, 2010 2:59 pm

ofcourse there will be no collisions from just that, if you are going to move objects manually that's not the way newton is intended to be used. use newtonupdate and look at some tutorials.
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 0 guests

cron