Moving Center of Mass for a Vehicle

Ask questions, discuss ideas, get answers
User avatar
Swaffy
Posts: 1715
Joined: Sun Aug 29, 2010 9:25 pm
Location: Cibolo, Texas

Moving Center of Mass for a Vehicle

Post by Swaffy »

I thank Vilespring for bringing this thought up.

I've asked this question before on this thread but no answer was found. So ...

Is there a way I can move the center of mass (or "center of gravity" for the search function) for a vehicle? I have a few vehicles that have their CM off, as if it is too high or too far forward (Jeep Willy I am staring at you). So I'd like to learn how to move it to a more correct position. I'm getting annoyed by my halftracks rolling over (as Vilespring noticed) and my Jeep Willys rolling forward very easily.
(Forum Thread|Download) Swaffy'sMod v0.34 | Download link to come Soon™
Shrooms
Posts: 70
Joined: Wed Aug 11, 2010 12:35 am

Re: Moving Center of Mass for a Vehicle

Post by Shrooms »

The center of mass is 0/0/0 in 3ds max. Where the main hull of the vehicle is positioned in 3dsmax, you will see where gravity pulls on the vehicle. You can move the position of the hull to change where the 0/0/0 spot is on your vehicle.
User avatar
Vilespring
Posts: 740
Joined: Sat Nov 24, 2012 5:47 am
Location: Somewere in the United States

Re: Moving Center of Mass for a Vehicle

Post by Vilespring »

Idea!
move the LOD that is attached to the PCO around. The LOD bundle that has the simple, the complex, and the destroyed can be moved around. I made a long tank by adding a tiger hull to the back of a tiger, but the center of gravity was too far forward. so I added a setposition below it and moved it forward a meter. so you could do this...

Code: Select all

rem *** M3GMC ***
ObjectTemplate.create PlayerControlObject M3GMC
ObjectTemplate.NameTagOffset 0/-0.4/1
ObjectTemplate.setNetworkableInfo M3GMCBodyInfo
ObjectTemplate.saveInSeparateFile 1
ObjectTemplate.exitTimer 0.75
ObjectTemplate.cullRadiusScale 5
ObjectTemplate.hasMobilePhysics 1
ObjectTemplate.hasDynamicShadow 1
ObjectTemplate.explosionRadius 8
ObjectTemplate.explosionDamage 5
ObjectTemplate.exitSpeedMod 0.75
ObjectTemplate.drag 2
ObjectTemplate.mass 15000
ObjectTemplate.hasCollisionPhysics 1
ObjectTemplate.hasResponsePhysics 1
ObjectTemplate.hasArmor 1
ObjectTemplate.speedMod 2
ObjectTemplate.hitpoints 90
ObjectTemplate.maxhitpoints 90
ObjectTemplate.material 45
ObjectTemplate.criticalDamage 16

ObjectTemplate.damageFromWater 0
ObjectTemplate.submarineData 0 0 0 100 110 1 8
rem ObjectTemplate.hpLostWhileDamageFromWater 10

ObjectTemplate.hpLostWhileCriticalDamage 1.5
ObjectTemplate.explosionForceMod 0
ObjectTemplate.hpLostWhileUpSideDown 10
ObjectTemplate.addArmorEffect 50 e_M3A1Damage 0/0.5/2.5
ObjectTemplate.addArmorEffect 16 e_M3A1Fire 0/0.7/3
ObjectTemplate.addArmorEffect 0 e_ExplGas 0/0/0
rem ObjectTemplate.addArmorEffect 0 e_scrapmetal 0/0/0
ObjectTemplate.addArmorEffect -1 WaterWaterExplosion 0/0/0
ObjectTemplate.aiTemplate M3GMC
rem -------------------------------------
ObjectTemplate.addTemplate lodM3GMC
ObjectTemplate.setPosition 0/1.5/0  <------------------------------------------------------
rem -------------------------------------
ObjectTemplate.setSoldierExitLocation -2/0/0 0/0/0
ObjectTemplate.GUIIndex 23
ObjectTemplate.setVehicleIcon "Vehicle/Icon_m3gmc.tga"
ObjectTemplate.setVehicleIconPos 67/70
ObjectTemplate.setNumberOfWeaponIcons 1
ObjectTemplate.setPrimaryAmmoIcon "Ammo/Icon_cannon.tga"
ObjectTemplate.setPrimaryAmmoBar ABAmmoBarReloadBar
ObjectTemplate.setCrossHairType CHTIcon
ObjectTemplate.setVehicleCategory VCLand
ObjectTemplate.setVehicleType  VTTankHunter
ObjectTemplate.setToolTipType TTM3GMC
ObjectTemplate.setMinimapIcon "Minimap/minimap_icon_apc_16x16.tga"
ObjectTemplate.setHasTurretIcon 1
ObjectTemplate.hasRestrictedExit 1
A picture is worth a thousand words, but takes up three thousand times the memory.

Area 51: http://battlefieldarea51mod.weebly.com/

Image
"I didn't steal your pizza"
User avatar
Swaffy
Posts: 1715
Joined: Sun Aug 29, 2010 9:25 pm
Location: Cibolo, Texas

Re: Moving Center of Mass for a Vehicle

Post by Swaffy »

That's a good idea, but I tried this on my Jeep Willy and this is what happened: I moved the LOD forward and it seems like the collision mesh was left in its original position (in turn making the back drag and collide with the ground), and also I saw a window and a front grill floating behind (part of a 1P mesh perhaps). I'm not sure what those are, but if I can move those too then your idea should work fine.

Try it yourself on my Willy (since you have my mod, hahah) and move its LOD forward by five units just for testing purposes. Set it to 0/0/5.
(Forum Thread|Download) Swaffy'sMod v0.34 | Download link to come Soon™
User avatar
Apache Thunder
Posts: 1210
Joined: Mon Oct 19, 2009 2:48 am
Location: Levelland Texas, USA
Contact:

Re: Moving Center of Mass for a Vehicle

Post by Apache Thunder »

There's an unused command that might help. Try this command on the main PCO:

Code: Select all

ObjectTemplate.centerOfMassOffset 0/0/0
It uses a vector 3. Fiddle with the numbers to see what results you can get from it.

It doesn't always work as intended. If it fails to help, you'll have to re-export with the mesh moved over which means you'll need to reposition the engine/cameras/passenger seats, etc. I noticed I had already mentioned this command in that thread about the floaters. Sounds like you might have already tried this?

You could instead use setPosition on the child objects of the Lod Object instead of moving the lod object on the main PCO. But this might still result in the collision mesh being in the wrong place.
ImageImageImage
I have cameras in your head!
User avatar
Swaffy
Posts: 1715
Joined: Sun Aug 29, 2010 9:25 pm
Location: Cibolo, Texas

Re: Moving Center of Mass for a Vehicle

Post by Swaffy »

I think I remember someone saying the centerOfMassOffset line is bugged. I remember it being kind of awkward when testing it. Anyway, I'll try your idea, moving the objects attached to the LOD object.
(Forum Thread|Download) Swaffy'sMod v0.34 | Download link to come Soon™
User avatar
Vilespring
Posts: 740
Joined: Sat Nov 24, 2012 5:47 am
Location: Somewere in the United States

Re: Moving Center of Mass for a Vehicle

Post by Vilespring »

Swaffy wrote:...I moved the LOD forward and it seems like the collision mesh was left in its original position (in turn making the back drag and collide with the ground)...
wait a second....
how could that happen? If you move the WHOLE THING, complex and all, that shouldn't happen, because collision is part of the complex mesh....
did you stick that move code right after the LOD globs was added?

EDIT: I'm gonna back up your mod and see if I can destroy, I mean, fix it. :lol:
A picture is worth a thousand words, but takes up three thousand times the memory.

Area 51: http://battlefieldarea51mod.weebly.com/

Image
"I didn't steal your pizza"
User avatar
Sarge31FR
Posts: 25
Joined: Sun Dec 16, 2012 5:55 pm
Location: Germany
Contact:

Re: Moving Center of Mass for a Vehicle

Post by Sarge31FR »

The only proper way to change the center is to move the mesh inside 3ds max and re-export it (which entails a re-coding of the vehicle).

I did that for a lot of our own vehicles and of course the vanilla vehicles, because they tipped over too easily. The higher the mesh is positioned in max, the LOWER the center will be, which means that the vehicle's engine and therefore its main "mass" will be positioned lower. Just take the M3A1 APC from vanilla as example: The original one tips over very easily, so i took the main hull mesh and positioned it a bit higher in max, re-exported and re-coded it, and now it's far more stable on the ground. I remember one of our own Japanese tanks, i think it was the Ha-Go, which tipped over just by looking at it, so to speak. After i had changed the mesh's position and re-coded the tank, the problem was solved.

Same goes for planes of course. If the fuselage mesh is wrongly positioned, the plane is bound to either tip "arse over tits" (quote from Battle of Britain :D ) or vice versa.
User avatar
Vilespring
Posts: 740
Joined: Sat Nov 24, 2012 5:47 am
Location: Somewere in the United States

Re: Moving Center of Mass for a Vehicle

Post by Vilespring »

I tried moving up the LOD as I said, but I ended up with a floating halftrack....
guess you have to move the geometrys in max around. Please do this to the vanilla halftrack and the M3. I would make it just as stable as the M16 MGMC, because that guys is stable, but it does roll over still. (It is very hard to flip. I had to drive it off a cliff sideways! :lol: )
A picture is worth a thousand words, but takes up three thousand times the memory.

Area 51: http://battlefieldarea51mod.weebly.com/

Image
"I didn't steal your pizza"
User avatar
Swaffy
Posts: 1715
Joined: Sun Aug 29, 2010 9:25 pm
Location: Cibolo, Texas

Re: Moving Center of Mass for a Vehicle

Post by Swaffy »

Sarge31FR wrote:The only proper way to change the center is to move the mesh inside 3ds max and re-export it (which entails a re-coding of the vehicle).

I did that for a lot of our own vehicles and of course the vanilla vehicles, because they tipped over too easily. The higher the mesh is positioned in max, the LOWER the center will be, which means that the vehicle's engine and therefore its main "mass" will be positioned lower. Just take the M3A1 APC from vanilla as example: The original one tips over very easily, so i took the main hull mesh and positioned it a bit higher in max, re-exported and re-coded it, and now it's far more stable on the ground. I remember one of our own Japanese tanks, i think it was the Ha-Go, which tipped over just by looking at it, so to speak. After i had changed the mesh's position and re-coded the tank, the problem was solved.

Same goes for planes of course. If the fuselage mesh is wrongly positioned, the plane is bound to either tip "arse over tits" (quote from Battle of Britain :D ) or vice versa.
Thanks for the input Sarge! It's much appreciated. I agree with using 3DS Max. Now are you talking about importing the whole vehicle into 3DS Max or the StandardMeshes themselves?
(Forum Thread|Download) Swaffy'sMod v0.34 | Download link to come Soon™
Post Reply