December 22, 2024, 09:18:47

Author Topic: PRT file editing  (Read 9540 times)

Offline jstubbles

  • Petty Officer
  • **
  • Posts: 169
  • Karma: 2
    • View Profile
    • http://www.ivassago.com
PRT file editing
« on: February 07, 2010, 20:21:58 »
Hey guys, just wondering if anyone has information on editing the PRT files for particle creation. The documentation included with nexus mod tools is extremely vague, limited and doesn't even have examples. The PRT's themselves break down like heavy scripting, but as an artist it's hard to figure out. Custom PRT's allow for extremely complex particle effects and I'd certainly like to be able to do something with them.

Thanks!

Offline Arparso

  • Administrator
  • Lieutenant
  • *****
  • Posts: 558
  • Karma: 14
  • I can see you...
    • View Profile
    • http://arparso.de/nexus
(No subject)
« Reply #1 on: February 09, 2010, 18:26:36 »
I'm not an expert at Nexus' particle system, but I understand a fair bit about it. What part do you actually struggle with?

In order to create your particles you usually just create a set of nested blocks of the various types the modding manual mentions. Every particle starts with a PARTICLE-block:

Code: [Select]
PARTICLE "name"
[parameters]
[other-blocks]
END

Allowed parameters for PARTICLE are "duration" and "position", which define the particle's lifetime and actual position. Often you can leave out the position parameter, since that is being calculated by the game anyway.

[other-blocks] can be one (or more) of the following blocks: FLARE, SEQUENCE or EMITTER. FLARE is just one of several different flare effects, SEQUENCE can be an animated image sequence (like an explosion) or a still image and EMITTER makes the current Particle actually emit other particles.

FLARE and SEQUENCE are pretty self-explanatory looking at the modding manual... each takes some parameters like type, size, color, etc.
EMITTER is more complex:

Code: [Select]
EMITTER
[projection-parameter]
[frequency-parameter]
[velocity]

EMIT
[particle-description]
END
END

Projection parameters define how this particle emitter actually distributes the created particles. There are three variants, of which you may choose one:
sphere - particles will be distributed randomly inside a sphere with the given radius and fly outwards
cone - particles will shoot out from a cone pointing in the given direction
cylinder - particles shoot out from a cylinder with the given radius and direction, travelling parallel to each other

Frequency parameters control how often particles will be generated. There are again three variantes:
period - particles will be released with this interval in seconds
distanceperiod - if the emitter itself is moving, a particle is released for each distance travelled (useful for smoke trails)
maxcount - the maximum number of particles that'll be emitted; can be combined with period or distanceperiod; has to be given, if neither period nor distanceperiod have been defined

The last parameter, velocity, simply gives the speed of the projected particles.

[particle-description] is a complete PARTICLE-description (without the PARTICLE and END keywords, though). So you can give the duration and position parameters and insert FLARE, SEQUENCE or another EMITTER there.

Defining parameters:
When assigning values to parameters, you have a few choices:

- giving a concrete value (color red):
color <1,0,0>

- giving a random value with giving MIN/MAX:
velocity [100,200]

- making the parameter value change over time using effectors, e.g.:
size 100 {dur 2.0 lerpto 200}

Effectors allow for some neat effects. In this case, the above example increases the size of the FLARE or SEQUENCE from 100 to 200 during the first 2 seconds of the particles lifetime. To learn more about effectors, you should consult the modding manual.

A very simple, but complete particle example to end this overly long post:

Code: [Select]
PARTICLE "Warp"

duration 4
   
SEQUENCE
type 40
fps 25
startframe 0
size 0 {dur 1 lerpto 50} {dur 2.5 lerpto 50} {dur .5 lerpto 0}
END
   
END

This displays the animated warp sequence of my FS2 mod. The particle lives for 4 seconds (duration 4) and displays a single SEQUENCE of my own custom type 40. The animation is played back with a speed of 25 fps, starting at frame 0. It grows in size from 0 to 50 during the first second, stays at size 50 for another 2.5 seconds and shrinks to 0 again during the last half second.

Offline jstubbles

  • Petty Officer
  • **
  • Posts: 169
  • Karma: 2
    • View Profile
    • http://www.ivassago.com
(No subject)
« Reply #2 on: February 09, 2010, 21:31:04 »
Thanks Asaparso.

Being an artist, it's a little harder to understand some of this. I'm used to using more robust real-time particle systems, not editing the underlying script/code for them...

The parameter types listed in the documentation are not well explained. For instance, there's no examples of how to use the "scalar", "3d vector", "RGB color" or "temerature color" parameter types. If they're called something else that that (which they're called in the docs) then it's just another example of shoddy documentation, hah.

There is also no documentation on how to use the snake function within the custom particle. It shows it's possible in the docs, but doesn't explain anything about it.

also, is there a way to adjust the e.wind settings somehow??

Basically, I'm looking for a way to have a missile drag a tail that flows side to side. Better yet, would be to have the actual projectile move side to side (kind of a "wave" motion) as it traveled to the target. If you've seen Battlestar Galactica, I'm trying to to recreate the cylon missile effect.




Any further help would be greatly appreciated!

Offline Arparso

  • Administrator
  • Lieutenant
  • *****
  • Posts: 558
  • Karma: 14
  • I can see you...
    • View Profile
    • http://arparso.de/nexus
(No subject)
« Reply #3 on: February 09, 2010, 23:21:51 »
Quote
Thanks Arparso.
Fixed ;)

Quote
Being an artist, it's a little harder to understand some of this. I'm used to using more robust real-time particle systems, not editing the underlying script/code for them...
Yeah, I'd like to have an actual particle FX editor as well... especially since you have to restart the mission editor each time just to see your changes... :(

Quote
The parameter types listed in the documentation are not well explained. For instance, there's no examples of how to use the "scalar", "3d vector", "RGB color" or "temerature color" parameter types.
Those are just the kind of values the actual parameters expect. Some examples:

duration needs the particle life-time in seconds, so it needs just a single scalar:
duration 0.5

color, however, expects a value of "RGB color" type, so for a white color you'd write:
color <1,1,1>

Quote
There is also no documentation on how to use the snake function within the custom particle. It shows it's possible in the docs, but doesn't explain anything about it.
Right, forgot about SNAKE in my earlier post. It's described more thoroughly in the "EFX table" part of the modding manual, but that refers to the SNAKE-version you can use for your regular EFX in efx.ini or mod_efx.ini. The parameters are very similar though... you can find the valid SNAKE-parameters under "snake-description" in the "Particle effects" section of the modding manual.

Quote
also, is there a way to adjust the e.wind settings somehow??
Not that I'm aware of. I suppose you can multiply it with a constant or random value, but nothing else, I fear.

Quote
Basically, I'm looking for a way to have a missile drag a tail that flows side to side. Better yet, would be to have the actual projectile move side to side (kind of a "wave" motion) as it traveled to the target. If you've seen Battlestar Galactica, I'm trying to to recreate the cylon missile effect.
I don't believe, that's possible in Nexus. You'd have to somehow change the projectile's flight path and that's pretty much hardcoded in Nexus - laser beams hit the target instantly, missiles (such as Nexus' artillery missiles) head more or less directly at the target and projectiles usually fly in a straight line. Actually that's not true: projectiles are also homing weapons - slow projectiles change course to follow their target until they eventually hit it (even if it counts as a miss due to the weapon's hit chances).

With a more sophisticated particle system you could use some clever math to make the particle effect appear to move similar to those cylon missiles... but all the math you've got for use in Nexus' particles is some multiplication and linear interpolation. That won't cut it, I fear.

Offline jstubbles

  • Petty Officer
  • **
  • Posts: 169
  • Karma: 2
    • View Profile
    • http://www.ivassago.com
(No subject)
« Reply #4 on: February 10, 2010, 08:12:09 »
Thanks Arparso, I'll keep messing with it.

Off-hand, do you happen to know what the deal is with font textures? I can't seem to get them working. I wanted to make the ship label text white instead of black, so I decompiled one of the tex files to TGA, copied to our mod, inverted the texture then recompressed. But it crashes in the viewer and doesn't show up at all in the game. If I just copy the original TEX over, it works fine in the viewer and game, but the ship label is black =    I've tried every compression setting, so I'm at a loss here.

Offline Arparso

  • Administrator
  • Lieutenant
  • *****
  • Posts: 558
  • Karma: 14
  • I can see you...
    • View Profile
    • http://arparso.de/nexus
(No subject)
« Reply #5 on: February 10, 2010, 12:12:03 »
Yeah, I noticed that two weeks ago myself, actually. I tried to change the font and/or make it appear white, but noticed the game kept crashing on me no matter the texture.

It appears, these font textures don't just contain the actual image data, but also some additional data as well. You can see that in the Nexus model viewer when opening one of the font .tex files: in the upper left it says "Aux Data Size: x bytes". I think it's some kind of lookup table for the game to know where to find each letter in the texture. If that's the case, then we're out of luck here, because the Nexus texture converter simply doesn't generate this auxiliary data for us. :(

/edit:
Just had a look at the data and yeah, it's a lookup table for all the characters in the font texture storing the letters' coordinates and size information. Should be possible to write a quick converter to import our own font textures using custom fonts, but that won't help with the color problem. The letters themselves are stored in the texture's alpha channel, which doesn't really carry any color information. Simply inverting the texture's colors would only change the red, green and blue channels, but wouldn't have any effect on the font color. The black font on the ship's hull is - like way too many things in Nexus - hardcoded, I fear. It just takes the font texture to determine the shape of the letters, not the color.

Offline jstubbles

  • Petty Officer
  • **
  • Posts: 169
  • Karma: 2
    • View Profile
    • http://www.ivassago.com
(No subject)
« Reply #6 on: February 10, 2010, 19:37:29 »
Damn, that's REAL unfortunate, hah. Guess that just means a lot more model data we'll have to use. :(

Thanks a lot Arparso! :)

Offline Arparso

  • Administrator
  • Lieutenant
  • *****
  • Posts: 558
  • Karma: 14
  • I can see you...
    • View Profile
    • http://arparso.de/nexus
(No subject)
« Reply #7 on: February 10, 2010, 20:44:44 »
You'll probably need to make a separate model and shipclass for each named ship you want to get in the game... at least for the ones you absolutely need to have their names visible, anyway. Keep in mind, that Nexus doesn't allow for an unlimited number of different shipclasses though... I believe the limit is somewhere around 300 including fighters, missiles and asteroids, of course. There is A LOT of hardcoded stuff in Nexus... :(