
The following should apply to both BF1942 and BFVietnam respectively. And of coarse this isn't server side.

I discovered a way to get moving shadows for child objects like gun barrels. The trick is that shadows will only appear for a child object if that object is addTemplated to the main PCO and NOT to anything else. It can't be addTemplated to a complex bundle that's attached to a lodObject or addTemplated to a rotation bundle which in turn is on the firearm addTemplated to that, or addTemplated to anywhere else for that matter. It must be on the main PCO. I am NOT talking about soldiers! The game engine treats those differently! This is for vehicles!
Example:
Code: Select all
ObjectTemplate.create PlayerControlObject M1A1
.
.
.
ObjectTemplate.addTemplate lodM1A1
rem *** Make sure to position it so it is mostly close to where the real barrel should be! ***
ObjectTemplate.addTemplate M1A1TurretShadow
ObjectTemplate.setPosition 0/1.5/1.5
.
.
.
ObjectTemplate.create RotationalBundle M1A1Turretshadow
ObjectTemplate.geometry M1A1TurretShadow
ObjectTemplate.hasDynamicShadow 1
ObjectTemplate.hasCollisionPhysics 0
ObjectTemplate.createInvisible 1
.
.
.
So if you want your tank gunbarrels (and maybe turrets too if you want to take it that far), then this is the way to do it. This could also be used on things like planes.
Take the v22 hover plane hybrid as an example. If you want to give shadow meshes to the big prop rotation bundles. You do something similar above. Just position them so they match up with the real bundles and it should work great. This doesn't appear to produce any extra overhead in performance from that of a normal setup. So this shouldn't lag or anything. Dynamic Shadows shouldn't really be a problem even with some slower machines. (plus I think something like this can be turned off in the menu anyway if your machine is too crappy to even handle dynamic shadows).
BF2 and beyond has featured working shadow meshes for turret, gun barrels and all sorts of other things. So this brings a bit more enhancement to the visual side of the mod your working on.

Here's the result as shown in the BF242 mod I'm currently working on: (click to view)

In that video I made the turret shadow mesh and barrel shadow mesh as one SM file. This made it easier to position.

So it is recommended that you make the gun barrel (and all it's pieces) and turret one mesh and use that as the shadow mesh. Since it will be invisible, what the LOD mesh looks like isn't important. You can get way with just making a tiny plane object or box and put it at 0/0/0 and use that as the lod. The new shadow objects will be invisible. But despite this, they MUST have a lod mesh or the game will crash. So just put anything in as a lod as long as it's something simple like a box or plane mesh.

You can try and make the gun barrel a separate shadow object. But you can't addTemplate it to the turret shadow object. It must be separate. So this means you would have to add the pivot position code and play around with the settings till it rotates correctly which by the way I could never get working right. I tried this on a mobile SA-3 tank. I made the turret and missile rails separate rotation bundles.
But the rail (the part that the missiles go on) won't rotate on the vertical axis correctly despite all I have tried with the setPivotPosition code. So it's best just to make any gun barrels and such part of the same mesh as the turret shadow mesh.
Post your results! If you need help doing this for your vehicles. Post here and I'll try my best to help you.
EDIT:
Also you can even do this on other things like helo props for example: (click to view video)

You can't make the new object a engine. It has to be a rotational bundle since engines won't rotate the geometry tied directly to them. Only stuff addTemplated to them will rotate. But we can't do this here since there is a one child object limit to dynamic shadows as already mentioned above.
Happy coding!