Jump to content
Sign in to follow this  
chris330

SetPitch and SetBank Idea

Recommended Posts

I have often wondered how this could be done. I have done a search on this forum and unless my searching abilities are very poor (I would not completely overlook this possibility) it would appear a solid,wide ranging, near complete and user friendly solution was never found. I have something of a habit of digging up dead old projects and trying to bring them to life. Perhaps I have some Japanese genes in me?

Seeing as I will not be able to continue with my dropship addon for a while (although this certainly will be completed) I thought maybe I'd attack this one instead, as I don't need a computer capable of running flashpoint to design code.

I once saw a very good idea of how to get ships to look as if they were rolling in heavy seas by using a large invisible cube addon coupled with the setvelocity command. I'm sure the rest is obvious as to how it was proposed to have worked.

Well I thought maybe it might work for setting pitch and bank, without having to do anything which would compromise the LOD's attached to any particular vehicle, and without compromising any part of the vehicle's abilities and communications with the game engine.

In short I want to make it as clean as I possibly can.

So,

My idea would be to have a vehicle (a plane or a helicopter) impacted by small and invisible spheres which would operate in tandem about its centre of gravity (I believe this is more commonly termed 'center of mass' in the United States). The spheres would have to have a reasonable amount of mass so as provide enough momentum exchange to the vehicle they were impacting to get it to change its attitude.

By attitude I am not referring to trying to get the aircraft in question to stop eating too much junk food and watching non-educational value TV, I am talking about its pitch and bank tounge2.gif  biggrin_o.gif

So far this theory is sound. The next bit is the part which needs some very serious debate, and a hell of alot of thought put into it. Obviously I would be using the setvelocity command to move the spheres. Here is where I am about to step into a grey area:

The following lines are all first-pass guess work. I originally suffered the mis-understanding that if a vehicle behaving as described above were impacted by two objects one either side of its centre of gravity which were acting in opposite vertical directions and therefore attemtping to induce a turning motion, then it would always rotate about its centre of gravity. I'm pretty sure this conclusion is wrong. I think the virtual 'pivot point' would actually be midway between the perpendicular distance between the lines of action of the forces of each object/sphere. The centre of gravity would then become an additional turning force about this pivot point which would have to be countered by applying more force to one of the objects on the appropriate side of its centre of gravity.

Hmm..reading back through that it doesn't appear quite as shakey as I had first expected to. From what I have seen OFP's game engine seems to deal with collision physics in a manner very applicable to that of the real world given how realistically objects react to each other when they collide in game. So I suppose were safe in thinking along the lines of real-world physics in this case. Please tell me otherwise if I am wrong (as I'll need to know if I am to get anywhere). RKSL of RockofSL studios pointed out to me that the game uses somewhat non-realistic physics for the helicopter class so maybe that is the same with collisions but I don't think that is the case.

So for this to work I would need some way of finding out an object's centre of gravity which I'm pretty sure is defined by where you add weight to the vehicle when it is constructed in Oxygen. This would not be an easy way to do it, and it would dramatically dcrease its user friendly qualities which puts it pretty much outside of the functional concept limits I want it to be inside of. An easier way would be to do something I did in school years ago about using known values of turning forces to deduce an objects' centre of gravity. I could run a script which found this out first before executing any other code (I'd have to check this). I suspect centre of gravity location issues would be far less of a problem when altering bank than it would be when altering pitch.

So the only thing I can perceive at this time being a problem is how Flashpoint treats air resistance. Seeing as the vehicle is being moved very quickly to the required bank and pitch rather than being temporarily deleted for a split second and then replaced at the required values it will impact the air as it goes round, which again will provide a resistive turning force which must be calculated and allowed for to get very accurate settings.

Oh one more thing, I would need to be able to detect what damage had been done to the vehicle's armour by being impacted by these spheres and reverse that damage after the impact were complete.

Just thought I'd vomit all that out in its rawest form to begin with so you can see the bare essentials of my idea. That way we can begin the hefty process of refining all these ideas over the next few days to see if we can actually get them to work smile_o.gif

Obviously on a final note this would not work well at all for ground vehicles and I really do not believe it would allow us to script any extra vehicle turrets (which I am told is currently impossible - and is likely to remain that way for some time).

Please use this thread to share your ideas so we can work out a viable solution to this problem (assuming there is one).

Thanks in advance thumbs-up.gif

Share this post


Link to post
Share on other sites

I don't know about air vehicles Chris, but its easy to pitch and roll ships / subs by animating their LandContacts ..... works real nice smile_o.gif

Sub_3.jpg

Share this post


Link to post
Share on other sites

Interesting idea, but AFAIK you can forget anything in OFP that includes the words collision and precision. Sad but true.

Share this post


Link to post
Share on other sites

That's exactly what DKM's suspension scripts (and derivates from that, like RHS' ones) do.

Share this post


Link to post
Share on other sites
Gnat @ Feb. 15 2006,13:55)]I don't know about air vehicles Chris, but its easy to pitch and roll ships / subs by animating their LandContacts ..... works real nice smile_o.gif

That sub picture looks amazing! A top idea wink_o.gif Just one question then, exactly how are the Land Contact LOD's animated? I know how to animate stuff on vehicles as I've done it before thanks to some help from one of the guys on here.

I'd be most grateful if you could just give me a brief (I'd prefer detailed but I don't want to impose) description of how this is done.

Thanks for that smile_o.gif

Share this post


Link to post
Share on other sites
Interesting idea, but AFAIK you can forget anything in OFP that includes the words collision and precision. Sad but true.

I believe you. But I'd have to test this out for myself to see just how bad it is. I feel a random suggestion about to be thrown out:

If it really is that bad then perhaps I could modify the original idea by adding two extra spheres that do not impact the aircraft with the setvelocity command but operate in tandem with those that do, to dramatically reduce the amount of wild reactional behaviour that can be exhibited by the aircraft when being impacted. It would be kind of like holding the aircraft with a pair of tweezers and then rotating it instead of just pushing it round rotationally and relying on the game's engine to work accurately. If the aircraft were still attempting large reactionary forces when the script finished (these oscillations would be so small you wouldn't see them when it was rotating) I wonder if we could anull them by introducing a setdir command the instant the rotation ended huh.gif

**Edit, I wonder however is this poor precision concept only true because of how different the actual Geometry LOD is compared to the visual model. For those who don't know Geometry LOD's are quite simplified compared to the vehicles visual model becuase they are called constantly throughout the game. I am talking about using tiny spheres to impact the aircraft. Surely wouldn't their tiny size mean very accurate momentum results from impacts?

Share this post


Link to post
Share on other sites
Just one question then, exactly how are the Land Contact LOD's animated?

Simple enough. Example;

- sub has 4 "points" in the Landcontact LOD

- front 2 are called front

- back 2 are called back

- in Memory LOD you have 2 points forming an axis between front and back (axis across sub, left to right)

- define an animation for the front points around the axis

- define an animation for the back points around the same axis, except angle is reversed.

- make the animation time for the back slightly longer.

Call front and back animations at the same time, the sub now dives and surfaces.

Similar can obviously be done to make a ship role.

HTHs

Share this post


Link to post
Share on other sites

Top job. Super idea thumbs-up.gif

I'm amazed the game engine allows us to animate Land Contact LOD's. Hopefully when Armed Assualt is released we will not have to make so many workarounds, however the knowledge we have all built up learning to make these workarounds in this game should benefit us enormously if we can get our hands on something which is more programmer friendly. I would imagine then we can make scripts which are light years ahead of the ones we are all making now becuase there will be so much less hassle involved wink_o.gif

Share this post


Link to post
Share on other sites

I'm going to start testing this out pretty soon. Possibly tonight even. I think I've got enough breathing space to put OFP back onto this computer so I can do some live testing, but first I need to know how the setvelocity command works. Normally I would cruise straight over to OFPEC for this but ala that is no longer an option. Could anyone point me in the way of a good explanation on the web about the setvelocity command?

Plus one more thing before I get back to more mundane things, do you set the weight of the parts of a vehicle's frame in the Geometry LOD or in the model LOD? I think it's the Geometry LOD but can't quite remember smile_o.gif

Share this post


Link to post
Share on other sites

hey, just a thought....

What would happen if I created a vehicle with turret, with the landcontact points defined as member of the elevation section?

Share this post


Link to post
Share on other sites
hey, just a thought....

What would happen if I created a vehicle with turret, with the landcontact points defined as member of the elevation section?

Not sure mate perhaps you're really onto something? I think we'd need a more experienced addon maker than myself to properly answer that question.

As for my original idea theory crunching is now well underway. First up is acquiring accurate values for the position and size of the vehicle's centre of mass, and the scripting required for it is going to be quite a bit trickier than I originally thought but I have proven to be not impossible. Also seeing as this only has to execute once for each vehicle it can be called in script form and I can avoid having to have any function declarations in the init.sqs or init fields of a vehicle.

I'll be posting some ideas up as I make more progress. In the meantime can someone help Matthijs with his question smile_o.gif

Share this post


Link to post
Share on other sites

The 1.85 comref is available from the Operation Flashpoint website.

vehicle setVelocity [x, z, y]

Operand types:

vehicle: Object

[x, z, y]: Array

Compatibility:

Version 1.8 required.

Type of returned value:

Nothing

Description:

Set velocity (speed vector) of vehicle.

x is east west, z is north south, and y is up down. (I think.) Origin is bottom left hand (SW) corner of the map. Values in metres/second. Soldier units won't obey setVelocity if they are in contact with the ground, or something.

Example: to make something move south east at 2.8 m/s:-(You'll need to know Pythagoras' theorem about right angled triangles.)

thing setVelocity [2,-2,0]

The velocity is a one time hit, and air resistance and other interference will slow the thing down.

None of this is guaranteed, I'm not an expert on this one, but hopefully its a start.

Share this post


Link to post
Share on other sites
The 1.85 comref is available from the Operation Flashpoint website.

vehicle setVelocity [x, z, y]

Operand types:

   vehicle: Object

   [x, z, y]: Array

Compatibility:

   Version 1.8 required.

Type of returned value:

   Nothing

Description:

   Set velocity (speed vector) of vehicle.

Super, just as it used to appear on your site. I'll grab the comref as soon as I've typed this.

x is east west, z is north south, and y is up down.  (I think.)   Origin is bottom left hand (SW) corner of the map.  Values in metres/second.   Soldier units won't obey setVelocity if they are in contact with the ground, or something.

Understood, nicely explained

Example:  to make something move south east at 2.8 m/s:-(You'll need to know Pythagoras' theorem about right angled triangles.)

Don't worry about that biggrin_o.gif

thing setVelocity [2,-2,0]

The velocity is a one time hit, and air resistance and other interference will slow the thing down.  

None of this is guaranteed, I'm not an expert on this one, but hopefully its a start.

Super stuff. Just the reply I was hoping for. It has however brought out two more questions in me:

1) Does the vehicle's resultant velocity vector act immediately or does the game engine have to accelerate it to this value (even if that acceleration time is tiny I still need to know about it).

2) How does Flashpoint treat air resistance? Is it dependant upon the vehicle's Geometry LOD, or is it a more simplified version depending upon it's speed and acceleration?

Thanks again, more than likely I'll need some more help as I go, but as soon as any parts of the concept I am working on are complete I shall let you know about it in this thread smile_o.gif

Share this post


Link to post
Share on other sites

1) I think its instantaneous within the game. There will be some computing time of course, so there may be a delay as far as the game engine is concerned. Suspect you will need to experiment on this point.

2) I don't know.

Share this post


Link to post
Share on other sites

This topic may well be old but I'm loathe start a new one about exactly the same thing.

Whilst working away on something incredibly mundane in Oxygen I had a new idea about this yet to exist function/utility.

It supercedes previous ideas I've had in both effectiveness and simplicity. Given that Armed Assault has now arrived and alot of people have stopped playing Flashpoint it seems the perfect time to be working on this idea, as more than likely no-one is working on the idea anymore so no toes to tread on. For me it's a trophy in Flashpoint which I've been after for a while. Now I think I might really have a solution that will work.

Also I need something to take my mind of the very tedious nature of the high precision project I'm working on at the moment in Oxygen.

The idea this time which I think when refined will represent the final solution is to place using a setpos loop an object in the shape of a long high poly (for accuracy) cylinder above the back of a moving aircraft. Then a large setvelocity push will force the aircraft against the cylinder causing it to pitch up. This has been proven to work by guys in the past who setvelocity pushed a helicopter against an invisible cube and the result was it banked so far it turned completely over and crashed.

Using Dschulle's getpitch function I intend to measure the rotational speed of the aircraft at two intervals and determine its rotational speed. I believe setvelocity means exactly that in Flashpoint. The change is instant, and does not require an acceleration time. Given also that the setvelocity command is cumulative to whatever velocity is already present this will not affect the aircraft's forward speed if done fast enough.

Obviously then to complete the process one has to apply the relevant setvelocity push to perfectly counteract the initial one and stop the aircraft from rotating instantly. This can be achieved by acquiring the vehicle's pitch and heading and rotational speed.

I've not got much left to do on my current project before I can release a bit of it and start working on this. A change of career in my life now means I'm in control of when I work and for whom so I can finally devote the amount of my life to game programming that I want to, so I've decided to go and do all the things I wanted to in Flashpoint. This being one of them.

I'd appreciate any ideas anyone has to improve the method, which is why I'm posting this. So thanks in advance for any help thumbs-up.gif

Share this post


Link to post
Share on other sites

After several days atrocious problems with our internet connection I can finally show you this. LOL no-one will probably notice after all that anyway.

The download contains my own version of a getpitch function and a cylinder addon. I've got a much more sophisticated version of this in testing now but I thought I'd release this to demonstrate it works.

Download the file, place the addon in your addons folder and run the mission from the editor. Wait for the helicopter to settle and then in command view trigger radio alpha.

The helicopter will be pitched to 20 degrees before the script stops. It's very slow at the moment but the latest and much faster version is throwing up problems which are taking time to resolve.

The latest version uses two cylinders one front one back but eventually even that will be replaced by many small spheres which will be placed on the vehicle's geometry LOD. I couldn't even get accurate figures for that because with having no internet I couldn't get ODOL explorer again!

Anyway internet is ok this end now so perhaps best to forget about that one before I become more irate.

Here's the link:

setpitch early days demo.

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
Sign in to follow this  

×