farbrausch / fr_public

Farbrausch demo tools 2001-2011
3.36k stars 344 forks source link

wz4: Cloud2 #57

Open wzman opened 12 years ago

wzman commented 12 years ago

Hi

I was looking to add some new parameters for cloud2 - x and z rotation, because actual rotation is only on y axe. The fix is pretty simple :

in fxparticle_ops.ops - operator Wz4Particles Cloud2() :

array { float30 Pos(-1000000..1000000 step 0.01); float30 Scale(-1000000..1000000 step 0.01)=1; float Speed(-1000000..1000000 step 0.01); (-) float Rot(-16..16 step 0.01); (+) float30 Rot(-16..16 step 0.01); int Count(1..65536 step 16); }

and in fxparticle.cpp - void RPCloud2::Init(Wz4ParticlesArrayCloud2 *Array,sInt ArrayCount)

(-) FastEulerXYZ(mat,0,Array[i].Rot,0); (+) FastEulerXYZ(mat,Array[i].Rot.x,Array[i].Rot.y,Array[i].Rot.z);

It works great, but the problem is that is break backward compatibility, because there is a shift in "Array" due to the new size of Rot variable (float => float30), so "Count" in old files with Cloud2 is set to 0...

I thought to add the 2 new floats at end of array to keep actual structure order and avoid shift data but it's not very sexy because on parameters line you have "Count" between Rotations, like this => Rot(y) - Count - Rot(x) - Rot(z)...

I don't know how to do keep compatibility and have a clean parameter line. Do you have an idea ? At worst I can correct example.wz4 to fix all Cloud2...

Thanks

rygorous commented 12 years ago

You can't change the ordering, it'll break file format compatibility with existing Wz4 files, including the source wz4 files for several FR demos that we plan to make available.

There's ways to reorder parameters outside of arrays, but I'm not sure if you can use that in this case - Chaos would need to answer that.

wzman commented 12 years ago

Possible solution with offsets :

array
{
  float30 Pos:0(-1000000..1000000 step 0.01);
  float30 Scale:3(-1000000..1000000 step 0.01)=1;
  float Speed:6(-1000000..1000000 step 0.01);
  int Count:8(1..65536 step 16);
  float Rotx  :9(-16..16 step 0.01);
  float Roty  :7(-16..16 step 0.01);
  float Rotz  :10(-16..16 step 0.01);
}

inconvenient we have 3 labels (rotx, roty, rotz) instead of 1 (----- rot -----)... What do you think about it ?