Special Aircraft Service

Please login or register.

Login with username, password and session length
Advanced search  
Pages: 1 ... 7 8 9 [10] 11 12 13 ... 50   Go Down

Author Topic: msh Binary format  (Read 109354 times)

0 Members and 4 Guests are viewing this topic.

Stainless

  • Modder
  • member
  • Offline Offline
  • Posts: 1534
Re: msh Binary format
« Reply #108 on: April 28, 2014, 05:19:06 AM »

Thanks, this is helping.

I can look at the class files now.

Just need to think of a cool way to use them.
Logged

Stainless

  • Modder
  • member
  • Offline Offline
  • Posts: 1534
Re: msh Binary format
« Reply #109 on: April 28, 2014, 05:42:33 AM »

Do modders typically do the java classes themselves as well?

I could convert the java classes to a .NET dll, and invoke them... but that involves the modders installing new tools and me writing a huge amount of code.

Another option would be to load the java source code myself and convert it to C#, then I could compile and run the source code.

Or I could just treat the source code as a script and write my own script parser.

It really comes down to the main question "Do modders have the source code for the java classes".
Logged

SAS~Storebror

  • Editor
  • member
  • Offline Offline
  • Posts: 23875
  • Taking a timeout
    • STFU
Re: msh Binary format
« Reply #110 on: April 28, 2014, 08:52:26 AM »

Do modders have the source code for the java classes
Yes they do.
We do the Java coding ourselves and frankly there's no use in trying to find a generic way to simulate gear animations since they're just too different among the different available aircraft types.

I've got roughly 500GB of Java projects for IL-2 lying around here, so there's little use in trying to find a common way through if you know what I mean.

Best regards - Mike
Logged
Don't split your mentality without thinking twice.

Stainless

  • Modder
  • member
  • Offline Offline
  • Posts: 1534
Re: msh Binary format
« Reply #111 on: April 28, 2014, 12:08:40 PM »

Well what I'm trying is to convert the java to c#

I've written a parser that just converts the bits I want to support, it's not 100% so it allows you to edit the result before it is compiled.

This is a working converted script.

Code: [Select]
using System;
using System.Collections.Generic;
using System.Text;
using IL2Modder.IL2;

 
 
 public  class B26
:AircraftInterface
{
  List<IL2Modder.IL2.AircraftActions>actions = new List<IL2Modder.IL2.AircraftActions>();

  private void SetAngles(String name, float t0, float t1, float t2)
  {
     IL2Modder.IL2.AircraftActions a = new IL2Modder.IL2.AircraftActions();
     a.name = name;
     a.y = t0;
     a.p = t1;
     a.r = t2;
     a.type = 0;
     actions.Add(a);
  }
  private void SetVisible(String name, bool value)
  {
     IL2Modder.IL2.AircraftActions a = new IL2Modder.IL2.AircraftActions();
     a.name = name;
     a.type = 1;
     a.visible = value;
     actions.Add(a);
  }
  public void update()
  {
     actions.Clear();
  }
  public List<IL2Modder.IL2.AircraftActions> GetResults()
  {
     return actions;
  }
   public B26()
   {
     kl = 1.0F;
     kr = 1.0F;
     kc = 1.0F;
   }
   
   private   float[] anglesc7 = new float[] { 0.0F, -6.5F, -13.5F, -24.5F, -32.5F, -39.75F, -47.0F, -54.75F,
     -62.5F, -69.75F, -83.5F };
   private   float[] anglesc6 = new float[] { 0.0F, -20.5F, -39.5F, -57.25F, -70.0F, -79.75F, -87.5F, -92.75F,
     -95.0F, -94.0F, -85.0F };
   private float kangle0 = 0.0F;
   private float kangle1 = 0.0F;
   
   private   float floatindex(float f, float[] fs)
   {
     int i = (int)f;
     if (i >= fs.GetLength(0) - 1) {
       return fs[(fs.GetLength(0) - 1)];
     }
     if (i < 0) {
       return fs[0];
     }
     if (i == 0)
     {
       if (f > 0.0F) {
         return fs[0] + f * (fs[1] - fs[0]);
       }
       return fs[0];
     }
     return fs[i] + f % i * (fs[(i + 1)] - fs[i]);
   }
   
   public void moveGear(float f)
   {
     moveGear("", f);
   }
   
   public  void moveGear(String h, float f)
   {
     SetAngles("GearC2_D0", 0.0F, 109.0F * f, 0.0F);
     SetAngles("GearC6_D0", 0.0F, floatindex(Aircraft.cvt(f, 0.0F, 1.0F, 0.0F, 10.0F), anglesc6), 0.0F);
     SetAngles("GearC4_D0", 0.0F, Aircraft.cvt(f, 0.0F, 0.1F, 0.0F, -95.0F), 0.0F);
     SetAngles("GearC7_D0", 0.0F, floatindex(Aircraft.cvt(f, 0.0F, 1.0F, 0.0F, 10.0F), anglesc7), 0.0F);
     SetAngles("L", 0.0F, Aircraft.cvt(f, 0.0F, 0.1F, 0.0F, -95.0F), 0.0F);
     
     SetAngles("GearL2_D0", 0.0F, 0.0F, -89.5F * f);
     
     SetAngles("GearL4_D0", 0.0F, Aircraft.cvt(f, 0.01F, 0.1F, 0.0F, -50.0F), 0.0F);
     SetAngles("GearL5_D0", 0.0F, Aircraft.cvt(f, 0.01F, 0.1F, 0.0F, 57.0F), 0.0F);
     
     SetAngles("GearR2_D0", 0.0F, 0.0F, -89.5F * f);
     
     SetAngles("GearR4_D0", 0.0F, Aircraft.cvt(f, 0.01F, 0.1F, 0.0F, -57.0F), 0.0F);
     SetAngles("GearR5_D0", 0.0F, Aircraft.cvt(f, 0.01F, 0.1F, 0.0F, 50.0F), 0.0F);
   }
   
   public void moveWheelSink()
   {
   }
   
   public void moveRudder(float f)
   {
     SetAngles("GearC31_D0", -20.0F * f, 0.0F, 0.0F);
   }
   
   public void doMurderPilot(int i)
   {
     switch (i)
     {
     case 0:
       SetVisible("Pilot1_D0", false);
       SetVisible("HMask1_D0", false);
       SetVisible("Pilot1_D1", true);
       SetVisible("Head1_D0", false);
       break;
     case 1:
       SetVisible("Pilot2_D0", false);
       SetVisible("HMask2_D0", false);
       SetVisible("Pilot2_D1", true);
       break;
     case 2:
       SetVisible("Pilot3_D0", false);
       SetVisible("HMask3_D0", false);
       SetVisible("Pilot3_D1", true);
       break;
     case 3:
       SetVisible("Pilot4_D0", false);
       SetVisible("HMask4_D0", false);
       SetVisible("Pilot4_D1", true);
       break;
     case 4:
       SetVisible("Pilot5_D0", false);
       SetVisible("HMask5_D0", false);
       SetVisible("Pilot5_D1", true);
       break;
     case 5:
       SetVisible("Pilot6_D0", false);
       SetVisible("HMask6_D0", false);
       SetVisible("Pilot6_D1", true);
       break;
     }
   }
   
   
   
   
   public void moveBayDoor(float f)
   {
     SetAngles("Bay1_D0", 0.0F, -110.0F * f, 0.0F);
     SetAngles("Bay3_D0", 0.0F, 110.0F * f, 0.0F);
     SetAngles("Bay2_D0", 0.0F, 110.0F * f, 0.0F);
     SetAngles("Bay4_D0", 0.0F, -110.0F * f, 0.0F);
   }
   
   
   
   
   private  float kl = 1.0F;
   private  float kr = 1.0F;
   private  float kc = 1.0F;
   
 }

I can use this to animate the B26.
Logged

SAS~Storebror

  • Editor
  • member
  • Offline Offline
  • Posts: 23875
  • Taking a timeout
    • STFU
Re: msh Binary format
« Reply #112 on: April 29, 2014, 01:16:26 AM »

This looks promising, however let me point out a few potential issues:

  • Newer IL-2 versions implement "moveGear" methods with different set of arguments in order to provide independent gear movement.
    Your parser would need to distinguish between those different game versions in order to call the right method.
  • Some aircraft have their "moveGear" code in parent classes. Does your parser take care of inheritance?
  • I did some cross-version compatible mods already (He-177, P-47 pack, Whirlwind) and there's a good chance that such mods contain Java specific code (Reflection) in some of these methods in order to provide cross-platform compatibility. For the future the Reflection part is intended to be "outsourced" to a specific class ("SAS Common Utils" Reflection class) so your parser might not be aware of what's going on "behind the scenes".
As much as I like the idea of resembling code based animations, I'm a little afraid that it'll be quite hard to reliably implement it that way.

Best regards - Mike
Logged
Don't split your mentality without thinking twice.

Stainless

  • Modder
  • member
  • Offline Offline
  • Posts: 1534
Re: msh Binary format
« Reply #113 on: April 29, 2014, 02:06:52 AM »

Sounding like a major issue.

I could embed a JVM, but that would require the entire class library from the game and give me some headaches extracting the animation data from the JVM.

Any ideas?
Logged

SAS~Storebror

  • Editor
  • member
  • Offline Offline
  • Posts: 23875
  • Taking a timeout
    • STFU
Re: msh Binary format
« Reply #114 on: April 29, 2014, 04:03:01 AM »

If you manage to fix point 1 you should have nailed about 90% of it.
Forget about the rest. I don't think it's too important anyway.

Best regards - Mike
Logged
Don't split your mentality without thinking twice.

Stainless

  • Modder
  • member
  • Offline Offline
  • Posts: 1534
Re: msh Binary format
« Reply #115 on: April 29, 2014, 04:39:34 AM »

Can you send me an example java file that you think will be impossible for me to parse please?

I'll let the little grey cells mull it over for a while, have a few pints, and when i wake up with a hangover I should have a solution.

Logged

Stainless

  • Modder
  • member
  • Offline Offline
  • Posts: 1534
Re: msh Binary format
« Reply #116 on: April 30, 2014, 02:29:32 AM »

Had a few beers and thought about it.

Think it may work.

1) Create a jar file of all the class files from the game.
     (could do it for all versions if I had some help)
2) Convert the jar file to .NET dll using ILKVM
3) Embed dynamic IKVM into my app, link against the dll
4) Run the java class directly
5) Extract animation values from java and apply.

It still looks complex as I need a java HeirMesh so I will have two copies of the mesh in memory, which I don't like.

Logged

hello

  • member
  • Offline Offline
  • Posts: 287
  • aka Aufpassen! aka Alfie!
Re: msh Binary format
« Reply #117 on: April 30, 2014, 02:40:58 AM »

How many class files does the game have?
How many beers did you have?
:)

Judging on what I have seen so far, I am sure you'll pull it off: to paraphrase a certain coder:  " ... either mad, or bordering on genius"

Maybe Storebror can help out.
Logged

SAS~Storebror

  • Editor
  • member
  • Offline Offline
  • Posts: 23875
  • Taking a timeout
    • STFU
Re: msh Binary format
« Reply #118 on: April 30, 2014, 03:00:57 AM »

I'd recommend to just stick to your existing parser and let the user edit the source if there's something special in the particular aircaft he's working on.
Any other will end in reinventing not just the wheel, but the whole universe.

Best regards - Mike
Logged
Don't split your mentality without thinking twice.

Stainless

  • Modder
  • member
  • Offline Offline
  • Posts: 1534
Re: msh Binary format
« Reply #119 on: April 30, 2014, 03:51:30 AM »

Hey I believe the universe is just a simulation anyway  ;D

The argument goes like this.

We can already simulate the universe at a low level of detail, it just needs a lot of computing power

Computing power is doubling every ten years, so in the future it will be possible to simulate the universe to a level of detail that makes it impossible to distinguish from reality.

Since there is only one real universe, and there could be many simulations, the probability is that we are more likely to be living in a simulation than in the real universe.
 
Logged
Pages: 1 ... 7 8 9 [10] 11 12 13 ... 50   Go Up
 

Page created in 0.032 seconds with 28 queries.