Terraintree - Was ist das hier?



  • Hallo, ich bins wieder.

    terraintree=
    {
    	{name="ground_gradient",          type="gradient",           x1=0, x2=0, y1=0, y2=1},
    	{name="ground_shape_fractal",     type="fractal",            fractaltype=anl.FBM, basistype=anl.GRADIENT, interptype=anl.QUINTIC, octaves=6, frequency=2},
    	{name="ground_scale",             type="scaleoffset",        scale=0.5, offset=0, source="ground_shape_fractal"},
    	{name="ground_perturb",           type="translatedomain",    source="ground_gradient", ty="ground_scale"},
    
    	{name="ground_select",            type="select",             low=0, high=1, threshold=0.5, control="ground_perturb"}
    }
    

    Ich bin auf diese Ausdrucksweise hier gestoßen: http://accidentalnoise.sourceforge.net/minecraftworlds.html
    Allerdings sagt mir das nicht viel. Was genau ist "das"? Und in wie fern nützt es mir?



  • Steht doch dabei ?

    <a href= schrieb:

    http://accidentalnoise.sourceforge.net/minecraftworlds.html">(A quick note on notation. The example code is written in the form of a Lua table of declarations. See the section on Lua integration for more information on the format. Basically, the format is intended to be parsed by a special class, which reads declarations and turns them into actual trees of noise module instances. I prefer this format rather than a more wordy step-by-step C++ format because it is less verbose and far cleaner.

    Und hier: http://accidentalnoise.sourceforge.net/lua.html


  • Mod

    Das sind "designated initializers". Das ist eine Art Ersatz für Konstruktoren in C und gibt es in C++ so nicht. Es macht das, was man erwartet: Es initialisiert das benannte Feld mit dem besagten Wert.

    Weiterhin ist diese spezielle Schreibweise eine GCC-Erweiterung (mag sein, dass sie auch im C++ des GCC funktioniert, bin gerade zu faul, zu gucken. Tu es selbst, wenn du es wissen möchtest), in standardgemäßem C99 würde man eigentlich einen Punkt vor dem Feldnamen benötigen: struct Foo foo = { .x =123 };

    edit: Die Erklärung hat sich wohl erledigt, siehe Antwort über mir. Man kann ja nicht ahnen, dass hier jemand mit LUA-Code im C++-Forum fragt.



  • Achso, danke. Hab den Verweiß irgendwie übersehen, ich kenne C++ noch nicht ganz so gut, deshalb habe ich nachgefragt - aber das hat sich jetzt wohl erledigt.


Anmelden zum Antworten