|
| Author |
Message |
|
Lumooja
|
Post subject: Re: AddBodyTorque ?? Cant get it to work. Posted: Mon Nov 23, 2009 9:44 pm |
Joined: Sat Jul 12, 2008 9:04 pm Posts: 3889 Location: Helsinki, Finland
|
I just edited the code, now the heli body has also gravity. Yes, a Hind has tons of blades which are sloppily connected to a center disc. So you would need to do the same. Have a center disc, to which you apply the torque, so the blades just follow it. Lots of hingework to do though 
_________________ Q6600 2.4G/ 8800GTS 640MB (190.62/OpenGL3.1/GLSL1.40)/ 2GB/ Debian 3DWS 5.53/ Blender 2.50/ UU3D 3.17 Pro/ Gimp 2.67/ XS7 1.51/ WavePad 4.26/ LE 2.3 Programmer/ Painter/ Musician/ Prodigy Try Leadwerks Community GameLib, and help to improve it!
|
|
|
|
 |
|
Gibbon
|
Post subject: Re: AddBodyTorque ?? Cant get it to work. Posted: Mon Nov 23, 2009 9:45 pm |
Joined: Thu Oct 01, 2009 9:44 am Posts: 142 Location: Derbyshire UK
|
|
And excuse my little knowledge of C/C++ if i copy and paste the C code into my C++ would it work stright off?
Andy
_________________ Conflict Development Blog : http://conflict-the-game.blogspot.com/
|
|
|
|
 |
|
Gibbon
|
Post subject: Re: AddBodyTorque ?? Cant get it to work. Posted: Mon Nov 23, 2009 9:50 pm |
Joined: Thu Oct 01, 2009 9:44 am Posts: 142 Location: Derbyshire UK
|
|
lol.. im laughing to my self with anger! I just cannot seem to get it so the hinge is at one end and it rotates as it should do?? Why on earth can i not.. I modified your code and moved the hing so it should be at the end of the blade and it simply doesnt work???
Andy
_________________ Conflict Development Blog : http://conflict-the-game.blogspot.com/
|
|
|
|
 |
|
Gibbon
|
Post subject: Re: AddBodyTorque ?? Cant get it to work. Posted: Mon Nov 23, 2009 9:52 pm |
Joined: Thu Oct 01, 2009 9:44 am Posts: 142 Location: Derbyshire UK
|
|
|
|
 |
|
Lumooja
|
Post subject: Re: AddBodyTorque ?? Cant get it to work. Posted: Mon Nov 23, 2009 9:52 pm |
Joined: Sat Jul 12, 2008 9:04 pm Posts: 3889 Location: Helsinki, Finland
|
Simple: You can't rotate the blade anymore, if it's hinged at its end. You need a disc which can be rotated from its center, and to which the blade connects with its end. This is nothing LE specific, it's just physics 
_________________ Q6600 2.4G/ 8800GTS 640MB (190.62/OpenGL3.1/GLSL1.40)/ 2GB/ Debian 3DWS 5.53/ Blender 2.50/ UU3D 3.17 Pro/ Gimp 2.67/ XS7 1.51/ WavePad 4.26/ LE 2.3 Programmer/ Painter/ Musician/ Prodigy Try Leadwerks Community GameLib, and help to improve it!
|
|
|
|
 |
|
Gibbon
|
Post subject: Re: AddBodyTorque ?? Cant get it to work. Posted: Mon Nov 23, 2009 9:58 pm |
Joined: Thu Oct 01, 2009 9:44 am Posts: 142 Location: Derbyshire UK
|
lol... now i know that... and if you look at my first example code... thats what i was trying to do... I had a shft (or disc as you call it) with the blades hinged at one end and i was tying to turn the shaft which should then turn the blade... but it wasnt doing. Ive tryed modifying your code to rotate the shaft (disc  )but... doesnt seem to work. The shaft turns.. the blades dont? #include "engine.h"
int main( int argn, char* argv[] ) { Initialize() ; RegisterAbstractPath("C:/Program Files/Leadwerks Engine SDK"); SetAppTitle( "physics" ) ; Graphics( 1440, 900 ) ; AFilter() ; TFilter() ; TWorld world; TBuffer gbuffer; TCamera camera; TMesh mesh; TLight light; TMesh ground; TMaterial material;
world = CreateWorld() ; if (!world) { MessageBoxA(0,"Error","Failed to create world.",0); return Terminate(); } gbuffer=CreateBuffer(GraphicsWidth(),GraphicsHeight(),BUFFER_COLOR|BUFFER_DEPTH|BUFFER_NORMAL); camera=CreateCamera(); PositionEntity(camera,Vec3(0,4,-10)); RotateEntity(camera,Vec3(2,0,0));
light=CreateDirectionalLight(); RotateEntity(light,Vec3(45,45,45)); MoveEntity(light,Vec3(0,10,0));
TBody ground1=CreateBodyBox(10,0.1,10); TMesh groundmesh=CreateCube(); ScaleEntity(groundmesh,Vec3(10,0.1,10)); EntityParent(groundmesh,ground1); PositionEntity(ground1,Vec3(0,-3,0)); EntityType(ground1,1);
TBody shaft=CreateBodyCylinder(1,4); SetBodyMass(shaft,1); TMesh shaftmesh=CreateCylinder(); ScaleEntity(shaftmesh,Vec3(1,4,1)); EntityParent(shaftmesh,shaft); EntityType(shaft,1);
TBody body=CreateBodyBox(16,0.2,0.5); SetBodyMass(body,1); TMesh box=CreateCube(); ScaleEntity(box,Vec3(16,0.2,0.5)); EntityParent(box,body); PositionEntity(body,Vec3(8,3,0)); EntityType(body,1); TEntity joint = CreateJointHinge(shaft,body,Vec3(0,3,0),Vec3(0,3,0)); //SetBodyGravityMode(body, 0);
TBody body2=CreateBodyBox(16,0.2,0.5); SetBodyMass(body2,1); TMesh box2=CreateCube(); ScaleEntity(box2,Vec3(16,0.2,0.5)); EntityParent(box2,body2); PositionEntity(body2,Vec3(-8,3,0)); EntityType(body2,1); TEntity joint2 = CreateJointHinge(shaft,body2,Vec3(0,3,0),Vec3(0,3,0)); //SetBodyGravityMode(body2, 0);
Collisions(1,1,1);
DebugPhysics(1);
// Game loop while( !KeyHit() && !AppTerminate() ) { if( !AppSuspended() ) // We are not in focus! { //AddBodyTorque(shaft,Vec3(0,100,0),0); if ( KeyDown(KEY_SPACE) ){ AddBodyTorque(shaft,Vec3(0,1000,0),0); }
// Update timing and world UpdateAppTime(); UpdateWorld(AppSpeed()) ; // Render SetBuffer(gbuffer); RenderWorld(); SetBuffer(BackBuffer()); RenderLights(gbuffer);
// Send to screen Flip(0) ; } }
// Done return Terminate() ; }
Andy
_________________ Conflict Development Blog : http://conflict-the-game.blogspot.com/
|
|
|
|
 |
|
Lumooja
|
Post subject: Re: AddBodyTorque ?? Cant get it to work. Posted: Mon Nov 23, 2009 10:03 pm |
Joined: Sat Jul 12, 2008 9:04 pm Posts: 3889 Location: Helsinki, Finland
|
The shaft in your code, as I see it, is the helicopter body. That's why I moved the blade a bit more up, since it was colliding with the helicopter. In your original code, you also tried to rotate the helicopter (=shaft), and not the blade! I beg your pardon, but that's not how a helicopter works  So you really need that disc above the helicopter, which is hingejointed just the same way as the blade is now in my code. And then you connect the blades to that disc, and rotate the disc. You will notice that there will be also a turnforce on the helicopter, so you need next also a tail rotor to stabilize the helicopter body, or to make doubledecker rotors (like in sci-fi movies), or tandem rotors (on front and back of heli).
_________________ Q6600 2.4G/ 8800GTS 640MB (190.62/OpenGL3.1/GLSL1.40)/ 2GB/ Debian 3DWS 5.53/ Blender 2.50/ UU3D 3.17 Pro/ Gimp 2.67/ XS7 1.51/ WavePad 4.26/ LE 2.3 Programmer/ Painter/ Musician/ Prodigy Try Leadwerks Community GameLib, and help to improve it!
|
|
|
|
 |
|
Gibbon
|
Post subject: Re: AddBodyTorque ?? Cant get it to work. Posted: Mon Nov 23, 2009 10:08 pm |
Joined: Thu Oct 01, 2009 9:44 am Posts: 142 Location: Derbyshire UK
|
|
We are getting two things mixed up here the shaft as i call it is whats called the main shaft of the rotor.. that would go up from the body (or engine) to the blades... there is no body in my example.... just a shaft (named shaft) and its connected blades.
the shaft will be rotated from the source of power and spin the blades that are hinged to it.
Andy
_________________ Conflict Development Blog : http://conflict-the-game.blogspot.com/
|
|
|
|
 |
|
Lumooja
|
Post subject: Re: AddBodyTorque ?? Cant get it to work. Posted: Mon Nov 23, 2009 10:09 pm |
Joined: Sat Jul 12, 2008 9:04 pm Posts: 3889 Location: Helsinki, Finland
|
|
Yeah, I guessed that already. But you can't make a demo without somekind of heli body, since the shaft=disc would then collide with the ground, and it can't do that since it rotates.
_________________ Q6600 2.4G/ 8800GTS 640MB (190.62/OpenGL3.1/GLSL1.40)/ 2GB/ Debian 3DWS 5.53/ Blender 2.50/ UU3D 3.17 Pro/ Gimp 2.67/ XS7 1.51/ WavePad 4.26/ LE 2.3 Programmer/ Painter/ Musician/ Prodigy Try Leadwerks Community GameLib, and help to improve it!
|
|
|
|
 |
|
Gibbon
|
Post subject: Re: AddBodyTorque ?? Cant get it to work. Posted: Mon Nov 23, 2009 10:11 pm |
Joined: Thu Oct 01, 2009 9:44 am Posts: 142 Location: Derbyshire UK
|
ok.. ill stick another box there as a body !  But that still wont fix the current issue (in the code i put in above) Ok, ive kind of got it working by setting a hinge max/min angle... so the shaft rotates so far round then starts spinning the blades... I guess this i because of the pin its sees it as a absolute non friction pin, is there way of adding friction somehow between hinges or joints? Thanks andy
_________________ Conflict Development Blog : http://conflict-the-game.blogspot.com/
|
|
|
|
 |
|
Lumooja
|
Post subject: Re: AddBodyTorque ?? Cant get it to work. Posted: Mon Nov 23, 2009 11:57 pm |
Joined: Sat Jul 12, 2008 9:04 pm Posts: 3889 Location: Helsinki, Finland
|
Yes, you can add static and kinetic friction to bodies: http://www.leadwerks.com/wiki/index.php ... dyFriction
_________________ Q6600 2.4G/ 8800GTS 640MB (190.62/OpenGL3.1/GLSL1.40)/ 2GB/ Debian 3DWS 5.53/ Blender 2.50/ UU3D 3.17 Pro/ Gimp 2.67/ XS7 1.51/ WavePad 4.26/ LE 2.3 Programmer/ Painter/ Musician/ Prodigy Try Leadwerks Community GameLib, and help to improve it!
|
|
|
|
 |
|
Gibbon
|
Post subject: Re: AddBodyTorque ?? Cant get it to work. Posted: Tue Nov 24, 2009 8:46 am |
Joined: Thu Oct 01, 2009 9:44 am Posts: 142 Location: Derbyshire UK
|
|
Cheers Lumooja, Having a good play with it all now. One more thing, if i upgrade can all this be done in the editor with lua (physics ETC?)?
Thanks Andy
_________________ Conflict Development Blog : http://conflict-the-game.blogspot.com/
|
|
|
|
 |
|
Lumooja
|
Post subject: Re: AddBodyTorque ?? Cant get it to work. Posted: Tue Nov 24, 2009 8:56 am |
Joined: Sat Jul 12, 2008 9:04 pm Posts: 3889 Location: Helsinki, Finland
|
|
Yes.
_________________ Q6600 2.4G/ 8800GTS 640MB (190.62/OpenGL3.1/GLSL1.40)/ 2GB/ Debian 3DWS 5.53/ Blender 2.50/ UU3D 3.17 Pro/ Gimp 2.67/ XS7 1.51/ WavePad 4.26/ LE 2.3 Programmer/ Painter/ Musician/ Prodigy Try Leadwerks Community GameLib, and help to improve it!
|
|
|
|
 |
|
Gibbon
|
Post subject: Re: AddBodyTorque ?? Cant get it to work. Posted: Tue Nov 24, 2009 9:15 am |
Joined: Thu Oct 01, 2009 9:44 am Posts: 142 Location: Derbyshire UK
|
|
|
|
 |
|
|