Gamestudio Links
Zorro Links
Newest Posts
Zorro FIX plugin - Experimental
by flink. 04/21/24 07:12
Data from CSV not parsed correctly
by EternallyCurious. 04/20/24 21:39
M1 Oversampling
by 11honza11. 04/20/24 20:57
Scripts not found
by juergen_wue. 04/20/24 18:51
zorro 64bit command line support
by 7th_zorro. 04/20/24 10:06
StartWeek not working as it should
by jcl. 04/20/24 08:38
folder management functions
by VoroneTZ. 04/17/24 06:52
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
2 registered members (AndrewAMD, rki), 390 guests, and 0 spiders.
Key: Admin, Global Mod, Mod
Newest Members
EternallyCurious, howardR, 11honza11, ccorrea, sakolin
19047 Registered Users
Previous Thread
Next Thread
Print Thread
Rating: 5
Page 20 of 41 1 2 18 19 20 21 22 40 41
Re: Newton 2 wrapper [Re: Vulder] #254856
03/05/09 22:03
03/05/09 22:03
Joined: Aug 2004
Posts: 1,345
Kyiv, Ukraine
VeT Offline OP

Serious User
VeT  Offline OP

Serious User

Joined: Aug 2004
Posts: 1,345
Kyiv, Ukraine
moving straight ahead to car's physics wink
seeking for volunteers to help me to deal with character controls and buoyancy


1st prize: Lite-C and Newton 2.17 by Vasilenko Vitaliy

Newton2 videos: http://tinyurl.com/NewtonVideos
LiteC+Newton2 discussion: http://tinyurl.com/NewtonWrapperDiscussion
Latest LiteC+Newton2 version(v23, from 29.10.2009): http://depositfiles.com/files/ae1l0tpro
Re: Newton 2 wrapper [Re: VeT] #256216
03/15/09 11:36
03/15/09 11:36
Joined: Aug 2004
Posts: 1,345
Kyiv, Ukraine
VeT Offline OP

Serious User
VeT  Offline OP

Serious User

Joined: Aug 2004
Posts: 1,345
Kyiv, Ukraine
Hey, guys... nobody wants to help me? I have some troubles.
Now i'm working in 3 direction: DG car(times faster than usual raycast car), buoyancy(physic of the bodies that falls in the water) and character controler(we would be able to create person control physic).
Next steps would be different examples of cars(after basic DG car) and ragdoll (after character controler).

I really want to finish this as fast as possible, but i haven't enough time (and, sometimes, knowledges).

So, if somebody would have some time and desire to improve Wrapper, write here or PM me.


1st prize: Lite-C and Newton 2.17 by Vasilenko Vitaliy

Newton2 videos: http://tinyurl.com/NewtonVideos
LiteC+Newton2 discussion: http://tinyurl.com/NewtonWrapperDiscussion
Latest LiteC+Newton2 version(v23, from 29.10.2009): http://depositfiles.com/files/ae1l0tpro
Re: Newton 2 wrapper [Re: VeT] #256245
03/15/09 15:17
03/15/09 15:17
Joined: Jul 2008
Posts: 18
Y
YNG Offline
Newbie
YNG  Offline
Newbie
Y

Joined: Jul 2008
Posts: 18
I have a working car physic with Newton but it uses 1.53. I dunno what are the diffrences between 1.53 and 2.16 so the code i gave is working at 1.53. I have shown simply how to use torque, how to set the car etc. Making better steering formulas, rpm-torque formulas or similar things can be made as you wish. Hope it will be useful for the community. And btw, nice contribution and great work by you VET smile

Code:
var temp_var;
float temp_float;

ENTITY* car;
ENTITY* FLwheelPtr;
ENTITY* FRwheelPtr;
ENTITY* BLwheelPtr;
ENTITY* BRwheelPtr;
ENTITY* tireId;
ENTITY* tireModel;
D3DXMATRIX m;

void tireUpdate(NewtonJoint* vehicle)
{
	// FOR EACH TIRE APPLY THESE VALUES
	for (tireId = NewtonVehicleGetFirstTireID (vehicle); tireId!=NULL; tireId = NewtonVehicleGetNextTireID (vehicle, tireId)) 
	{
		NewtonVehicleSetTireSideSleepCoeficient(vehicle,tireId,0.0);
		NewtonVehicleSetTireMaxSideSleepSpeed (vehicle,tireId,999.0);
		NewtonVehicleSetTireLongitudinalSlideCoeficient(vehicle,tireId,0.0);
		NewtonVehicleSetTireMaxLongitudinalSlideSpeed (vehicle,tireId,999.0);
	}
	
	
	// CALCULATE AVERAGE TIRE SPEED
	tireId = NewtonVehicleGetFirstTireID(vehicle);
	temp_var = NewtonVehicleGetTireLongitudinalSpeed(vehicle,tireId);
	tireId = NewtonVehicleGetNextTireID(vehicle, tireId);
	temp_var += NewtonVehicleGetTireLongitudinalSpeed(vehicle,tireId);
	tireId = NewtonVehicleGetNextTireID(vehicle, tireId);
	temp_var += NewtonVehicleGetTireLongitudinalSpeed(vehicle,tireId);
	tireId = NewtonVehicleGetNextTireID(vehicle, tireId);
	temp_var += NewtonVehicleGetTireLongitudinalSpeed(vehicle,tireId);
	temp_var *= 0.25;
	
	
	if(key_w)
	{
		if(temp_var<-2) //if tires average speed is smaller than -2 and key W pressed  >>>>>> APPLY BRAKE TO ALL TIRES
		{
			tireId = NewtonVehicleGetFirstTireID(vehicle);        //tireId 0   //Front Left
			temp_float = NewtonVehicleTireCalculateMaxBrakeAcceleration(vehicle,tireId) * 0.7;
			NewtonVehicleTireSetBrakeAcceleration(vehicle,tireId,temp_float,temp_float);
			
			tireId = NewtonVehicleGetNextTireID(vehicle, tireId); //tireId 1   //Front Right
			temp_float = NewtonVehicleTireCalculateMaxBrakeAcceleration(vehicle,tireId) * 0.7;
			NewtonVehicleTireSetBrakeAcceleration(vehicle,tireId,temp_float,temp_float);
			
			tireId = NewtonVehicleGetNextTireID(vehicle, tireId); //tireId 2   //Back Left
			temp_float = NewtonVehicleTireCalculateMaxBrakeAcceleration(vehicle,tireId) * 0.7;
			NewtonVehicleTireSetBrakeAcceleration(vehicle,tireId,temp_float,temp_float);
			
			tireId = NewtonVehicleGetNextTireID(vehicle, tireId); //tireId 3   //Back Right
			temp_float = NewtonVehicleTireCalculateMaxBrakeAcceleration(vehicle,tireId) * 0.7;
			NewtonVehicleTireSetBrakeAcceleration(vehicle,tireId,temp_float,temp_float);
		}
		else //else >>>>>> APPLY 1500 TORQUE FORWARD TO REAR TIRES 
		{
			tireId = NewtonVehicleGetFirstTireID(vehicle);        //tireId 0   //Front Left	
			tireId = NewtonVehicleGetNextTireID(vehicle, tireId); //tireId 1   //Front Right
			
			tireId = NewtonVehicleGetNextTireID(vehicle, tireId); //tireId 2   //Back Left
			NewtonVehicleSetTireTorque(vehicle,tireId,1500);
			
			tireId = NewtonVehicleGetNextTireID(vehicle, tireId); //tireId 3   //Back Right
			NewtonVehicleSetTireTorque(vehicle,tireId,1500);
		}
	}
	else if(key_s)
	{
		if(temp_var<2) //if tires average speed is smaller than 2 >>>>>> APPLY 1500 TORQUE BACKWARD TO REAR TIRES 
		{
			tireId = NewtonVehicleGetFirstTireID(vehicle);        //tireId 0   //Front Left	
			tireId = NewtonVehicleGetNextTireID(vehicle, tireId); //tireId 1   //Front Right
			
			tireId = NewtonVehicleGetNextTireID(vehicle, tireId); //tireId 2   //Back Left
			NewtonVehicleSetTireTorque(vehicle,tireId,-1500);
			
			tireId = NewtonVehicleGetNextTireID(vehicle, tireId); //tireId 3   //Back Right
			NewtonVehicleSetTireTorque(vehicle,tireId,-1500);
		}
		else //else >>>>>> APPLY BRAKE TO ALL TIRES
		{
			tireId = NewtonVehicleGetFirstTireID(vehicle);        //tireId 0   //Front Left
			temp_float = NewtonVehicleTireCalculateMaxBrakeAcceleration(vehicle,tireId) * 0.7;
			NewtonVehicleTireSetBrakeAcceleration(vehicle,tireId,temp_float,temp_float);
			
			tireId = NewtonVehicleGetNextTireID(vehicle, tireId); //tireId 1   //Front Right
			temp_float = NewtonVehicleTireCalculateMaxBrakeAcceleration(vehicle,tireId) * 0.7;
			NewtonVehicleTireSetBrakeAcceleration(vehicle,tireId,temp_float,temp_float);
			
			tireId = NewtonVehicleGetNextTireID(vehicle, tireId); //tireId 2   //Back Left
			temp_float = NewtonVehicleTireCalculateMaxBrakeAcceleration(vehicle,tireId) * 0.7;
			NewtonVehicleTireSetBrakeAcceleration(vehicle,tireId,temp_float,temp_float);
			
			tireId = NewtonVehicleGetNextTireID(vehicle, tireId); //tireId 3   //Back Right
			temp_float = NewtonVehicleTireCalculateMaxBrakeAcceleration(vehicle,tireId) * 0.7;
			NewtonVehicleTireSetBrakeAcceleration(vehicle,tireId,temp_float,temp_float);
		}
	}
	
	
	
	if(key_a) //if key A >>>>>> SET FRONT TIRES ANGLE TO 0.35 RADIAN
	{
		tireId = NewtonVehicleGetFirstTireID(vehicle);        //tireId 0   //Front Left
		NewtonVehicleSetTireSteerAngle(vehicle,tireId,0.35);
		
		tireId = NewtonVehicleGetNextTireID(vehicle, tireId); //tireId 1   //Front Right
		NewtonVehicleSetTireSteerAngle(vehicle,tireId,0.35);
	}
	else if(key_d) //if key D >>>>>> SET FRONT TIRES ANGLE TO -0.35 RADIAN
	{
		tireId = NewtonVehicleGetFirstTireID(vehicle);        //tireId 0   //Front Left
		NewtonVehicleSetTireSteerAngle(vehicle,tireId,-0.35);
		
		tireId = NewtonVehicleGetNextTireID(vehicle, tireId); //tireId 1   //Front Right
		NewtonVehicleSetTireSteerAngle(vehicle,tireId,-0.35);
	}
	else //else >>>>>> SET FRONT TIRES ANGLE TO 0.0 RADIAN
	{
		tireId = NewtonVehicleGetFirstTireID(vehicle);        //tireId 0   //Front Left
		NewtonVehicleSetTireSteerAngle(vehicle,tireId,0.0);
		
		tireId = NewtonVehicleGetNextTireID(vehicle, tireId); //tireId 1   //Front Right
		NewtonVehicleSetTireSteerAngle(vehicle,tireId,0.0);
	}
	
}

action Newton_Car()
{	
	car = me;
	while(!newton_running){wait(1);}
	
	NewtonBody* car_body = newton_addentity(me, 1000, NEWTON_CONVEXHULL, tireRubberID, onforceandtorque);
	NewtonBodySetAutoFreeze( car_body, 0);
	NewtonBodySetLinearDamping(car_body,0.005);
//	NewtonBodySetAngularDamping(car_body,vectorf(0.5,0.5,0.5));


	float upDir[3] = {0.0, 0.0, 1.0};
	NewtonJoint* car_joint = NewtonConstraintCreateVehicle(nworld, upDir[0], car_body);
	
	
	int tireMass = 30;
	float suspensionLength = 0.25;
	float suspensionSpring =700.0;
	float suspensionShock = 60.0;
	float wheelradius = 0.4;
	float tirePin[3] = {0.0, 1.0, 0.0};
	D3DXMATRIX tire_offset;
	VECTOR tirepos;
	
	vec_for_bone(tirepos,me,"FLBone");
	vec_sub(tirepos,my.x);
	D3DXMatrixTranslation(&tire_offset, tirepos.x * QUANTTOMETER,tirepos.y * QUANTTOMETER,tirepos.z * QUANTTOMETER);												
	NewtonVehicleAddTire(car_joint, &tire_offset, tirePin[0], tireMass, wheelradius, wheelradius, suspensionShock,suspensionSpring,suspensionLength, FLwheelPtr, 5);
	
	vec_for_bone(tirepos,me,"FRBone");
	vec_sub(tirepos,my.x);
	D3DXMatrixTranslation(&tire_offset, tirepos.x * QUANTTOMETER,tirepos.y * QUANTTOMETER,tirepos.z * QUANTTOMETER);		
	NewtonVehicleAddTire(car_joint, &tire_offset, tirePin[0], tireMass, wheelradius, wheelradius, suspensionShock,suspensionSpring,suspensionLength, FRwheelPtr, 5);
	
	vec_for_bone(tirepos,me,"BLBone");
	vec_sub(tirepos,my.x);
	D3DXMatrixTranslation(&tire_offset, tirepos.x * QUANTTOMETER,tirepos.y * QUANTTOMETER,tirepos.z * QUANTTOMETER);		
	NewtonVehicleAddTire(car_joint, &tire_offset, tirePin[0], tireMass, wheelradius, wheelradius, suspensionShock,suspensionSpring,suspensionLength, BLwheelPtr, 5);
	
	vec_for_bone(tirepos,me,"BRBone");
	vec_sub(tirepos,my.x);
	D3DXMatrixTranslation(&tire_offset, tirepos.x * QUANTTOMETER,tirepos.y * QUANTTOMETER,tirepos.z * QUANTTOMETER);		
	NewtonVehicleAddTire(car_joint, &tire_offset, tirePin[0], tireMass, wheelradius, wheelradius, suspensionShock,suspensionSpring,suspensionLength, BRwheelPtr, 5);
	
	NewtonVehicleSetTireCallback(car_joint, tireUpdate); 
	

	while(me!=NULL)
	{
		// SET ALL TIRES POSITION AND ANGLE [ THESE LINES ARE NOT AT TIRE CALLBACK FUNC. BECAUSE MAKING THAT CAUSES VISUAL TIRES TO UPDATE 1 FRAME LATER THAN NEWTON TIRES ]
		for (tireId = NewtonVehicleGetFirstTireID (car_joint); tireId!=NULL; tireId = NewtonVehicleGetNextTireID (car_joint, tireId)) 
		{
			tireModel = NewtonVehicleGetTireUserData (car_joint, tireId);
			NewtonVehicleGetTireMatrix(car_joint,tireId, m);
			ent_setmatrix_rb(tireModel,m);
		}
		
		wait(1);
	}

}

For the creation of models:
Code:
	FLwheelPtr = ent_create("tekerlekL.mdl",nullvector,NULL);
	FRwheelPtr = ent_create("tekerlekR.mdl",nullvector,NULL);
	BLwheelPtr = ent_create("tekerlekL.mdl",nullvector,NULL);
	BRwheelPtr = ent_create("tekerlekR.mdl",nullvector,NULL);
	
	you = ent_create("350z.mdl",vector(6500,-1200,1100),Newton_Car);




PS:
Code:
// FOR EACH TIRE APPLY THESE VALUES
	for (tireId = NewtonVehicleGetFirstTireID (vehicle); tireId!=NULL; tireId = NewtonVehicleGetNextTireID (vehicle, tireId)) 
	{
		NewtonVehicleSetTireSideSleepCoeficient(vehicle,tireId,0.0);
		NewtonVehicleSetTireMaxSideSleepSpeed (vehicle,tireId,999.0);
		NewtonVehicleSetTireLongitudinalSlideCoeficient(vehicle,tireId,0.0);
		NewtonVehicleSetTireMaxLongitudinalSlideSpeed (vehicle,tireId,999.0);
	}

I don't exactly know how the values should be or their min,max values at these lines of tire Callback. But it just works fine with these also.

Last edited by YNG; 03/15/09 15:21.
Re: Newton 2 wrapper [Re: YNG] #256298
03/15/09 22:33
03/15/09 22:33
Joined: Aug 2004
Posts: 1,345
Kyiv, Ukraine
VeT Offline OP

Serious User
VeT  Offline OP

Serious User

Joined: Aug 2004
Posts: 1,345
Kyiv, Ukraine
Thank you smile
I'm working on the new and another type of car.. but i hope your code would help to finish that smile
Hmm... maybe i'd make one level with your car and then go on.

Btw, still seeking for volunteers to help


1st prize: Lite-C and Newton 2.17 by Vasilenko Vitaliy

Newton2 videos: http://tinyurl.com/NewtonVideos
LiteC+Newton2 discussion: http://tinyurl.com/NewtonWrapperDiscussion
Latest LiteC+Newton2 version(v23, from 29.10.2009): http://depositfiles.com/files/ae1l0tpro
Re: Newton 2 wrapper [Re: Vulder] #257330
03/22/09 17:57
03/22/09 17:57
Joined: Sep 2007
Posts: 48
Deutschland
H
HoopyDerFrood Offline
Newbie
HoopyDerFrood  Offline
Newbie
H

Joined: Sep 2007
Posts: 48
Deutschland
Thank you very much VeT.

But thehe is still a small Problem in both, your map and in mine. The object dont come to rest and moving on an on forever. Even if they just jitter a little, they are playing a sound.

Is there a way to adjust the volume of the sound dependent from the "energy" of the collision?
I've played araound with the BodyFreezeThreshold but without success. My Objects never come to rest completely.

Re: Newton 2 wrapper [Re: HoopyDerFrood] #257528
03/23/09 19:27
03/23/09 19:27
Joined: Aug 2004
Posts: 1,345
Kyiv, Ukraine
VeT Offline OP

Serious User
VeT  Offline OP

Serious User

Joined: Aug 2004
Posts: 1,345
Kyiv, Ukraine
as i remember, NewtonBodySetFreezeTreshold needed to be used in this case... i'd make a demo wink


1st prize: Lite-C and Newton 2.17 by Vasilenko Vitaliy

Newton2 videos: http://tinyurl.com/NewtonVideos
LiteC+Newton2 discussion: http://tinyurl.com/NewtonWrapperDiscussion
Latest LiteC+Newton2 version(v23, from 29.10.2009): http://depositfiles.com/files/ae1l0tpro
Re: Newton 2 wrapper [Re: VeT] #257765
03/25/09 12:27
03/25/09 12:27
Joined: Aug 2004
Posts: 1,345
Kyiv, Ukraine
VeT Offline OP

Serious User
VeT  Offline OP

Serious User

Joined: Aug 2004
Posts: 1,345
Kyiv, Ukraine
Damned, there is about 20K views in this topic and nobody wants to improve wrapper? I really almost have no time, as i may finish my diplom work


1st prize: Lite-C and Newton 2.17 by Vasilenko Vitaliy

Newton2 videos: http://tinyurl.com/NewtonVideos
LiteC+Newton2 discussion: http://tinyurl.com/NewtonWrapperDiscussion
Latest LiteC+Newton2 version(v23, from 29.10.2009): http://depositfiles.com/files/ae1l0tpro
Re: Newton 2 wrapper [Re: VeT] #257841
03/25/09 21:03
03/25/09 21:03
Joined: May 2003
Posts: 567
Spain, Canary Islands
Felixsg Offline
User
Felixsg  Offline
User

Joined: May 2003
Posts: 567
Spain, Canary Islands
Appear is the world crisis (the economy)
I only can help with models and probably
with worlds

but I need to wait to endweek for take part

Re: Newton 2 wrapper [Re: Felixsg] #257916
03/26/09 14:23
03/26/09 14:23
Joined: Aug 2004
Posts: 1,345
Kyiv, Ukraine
VeT Offline OP

Serious User
VeT  Offline OP

Serious User

Joined: Aug 2004
Posts: 1,345
Kyiv, Ukraine
Our 3d artist already helped me with models, thank you smile
I need just scripting help


1st prize: Lite-C and Newton 2.17 by Vasilenko Vitaliy

Newton2 videos: http://tinyurl.com/NewtonVideos
LiteC+Newton2 discussion: http://tinyurl.com/NewtonWrapperDiscussion
Latest LiteC+Newton2 version(v23, from 29.10.2009): http://depositfiles.com/files/ae1l0tpro
Re: Newton 2 wrapper [Re: VeT] #259286
04/05/09 10:04
04/05/09 10:04
Joined: Sep 2007
Posts: 48
Deutschland
H
HoopyDerFrood Offline
Newbie
HoopyDerFrood  Offline
Newbie
H

Joined: Sep 2007
Posts: 48
Deutschland
Can you specify this? What do you want to be coded. Maybe there is a small task I'm able to do.

Page 20 of 41 1 2 18 19 20 21 22 40 41

Moderated by  HeelX, Lukas, rayp, Rei_Ayanami, Superku, Tobias, TWO, VeT 

Gamestudio download | chip programmers | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1