Jump to content

View more

Image of the Day

The night is still, but the invasion brings chaos. #screenshotsaturday #hanako #indiegame #gameart #ue4 #samurai https://t.co/cgILXuokoS
IOTD | Top Screenshots

The latest, straight to your Inbox.

Subscribe to GameDev.net Direct to receive the latest updates and exclusive content.


Sign up now

Need resources on raycast suspensions/springs.

4: Adsense

Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.


  • You cannot reply to this topic
2 replies to this topic

#1 vadevaman   Members   

157
Like
0Likes
Like

Posted 03 June 2014 - 06:35 AM

Hi, could someone post resources to raycast suspensions/springs ?

I'd like to re learn some bits of this aspect, I might have gone on a wrong bath

 

I'm facing a problem where my rest length is causing the normal force to be zero (as if it the ray distance had an offset)

I'm using physX as my physics engine.

 

This is a cut down code of what I do:

// -----> Init
const float radius = 0.3f;			// static ray offset (30cm)
const float length = 0.150f;		// the ammount the suspension can travel (150mm)
const float restLength = 0.100f;	// actual spring position (100mm)

const float springK = 55000;		// Spring stiffness
const float daperRate = 2500;		// Spring friction

float rayMaxLength;	// define the maximum length at where ray works
float rayDistance;	// ray's actual distance

float x0p;	// previous compresion (for velocity calcs)
float x0;	// current compression
float dV;	// damper velocity
float sF,dF;// Forces (spring / damper)
float suspensionForce;
float normalForce;

// -----> The loop at 1000hz
rayMaxLength = length+radius;			// spring max length + radius should be the correct way of initializing the ray lengt?
rayCast = CreateNewRay(rayMaxLength);	// ray function here
rayDistance = rayCast.distance;			// get actual picking distance (but where does this offset come from?)

// Compresion
x0p = x0;
x0 = (length - (rayDistance - radius));

// Force calcs
sF = springK * (x0-restLength); // after removing rest length the forces get fixed
dV = (x0 - x0p) / timeStep;	
dF = daperRate * dV;

// Resulting vertical force
suspensionForce = sF + dF;

// Normal force (for some reason this goes negative when compression is really small, (50mm) )
normalForce = sF;

// Normal force cant go negative...
if (normalForce<0.0f)
	normalForce = 0.0f;

In bullet's raycar I noticed that the maximum ray length is restLength + radius. But imo it should be length + radius. Am I right or wrong?

The funny thing here is also that in my C# vaersion of the code the normal force doesnt go negative, while in identical C++ code it goes...


Edited by vadevaman, 05 June 2014 - 12:36 AM.


#2 unbird   Members   

8307
Like
0Likes
Like

Posted 04 June 2014 - 02:50 AM

Actually after this:
if (normalForce)
	normalForce = 0.0f;

normalForce will be 0.0f. Always.

#3 vadevaman   Members   

157
Like
0Likes
Like

Posted 05 June 2014 - 12:36 AM

oh sorry my bad, fixed it






Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.