Posted By: Lion_Ts
1000 entities VS 1000 materials - 10/01/05 11:29
Hi!
This is small contrib about pointers.
If you didn't work with C or C++ you can mess one powerfull (but not fully implemented in C-script, where is C-lite ?!) thing - pointers.
In C-script you can use predefined pointer types (refer to 3dgs manual).
One example from Ulillillia (he says it's working, but he want to hard test it
):
You have many objects, you have materials for each, material properties assigned from object's skills... But number of objects is 1000
Simple solution to save your fingers is:
Code:
With this small snippet you have not to define 1000 materials in code
This is small contrib about pointers.
If you didn't work with C or C++ you can mess one powerfull (but not fully implemented in C-script, where is C-lite ?!) thing - pointers.
In C-script you can use predefined pointer types (refer to 3dgs manual).
One example from Ulillillia (he says it's working, but he want to hard test it
):You have many objects, you have materials for each, material properties assigned from object's skills... But number of objects is 1000

Simple solution to save your fingers is:
Code:
material* mymtl; //define material pointer
...
action myobj{
mymtl=mtl_create(); //create temp material
//copy standard model material to temp material
vec_set(mymtl.ambient_blue, mat_model.ambient_blue);
vec_set(mymtl.emissive_blue, mat_model.emissive_blue);
vec_set(mymtl.diffuse_blue, mat_model.diffuse_blue);
vec_set(mymtl.specular_blue, mat_model.specular_blue);
mymtl.power=mat_model.power;
mymtl.alpha=mat_model.alpha;
mymtl.albedo=mat_model.albedo;
//change needed values from skills or random generator or whatever else
mymtl.ambient_red=random(255);
mymtl.specular_blue=my.skill5;
//assign temp material to object
my.material=mymtl;
...
}
With this small snippet you have not to define 1000 materials in code
