|
7 registered members (fairtrader, Quad, miwok, Martin_HH, AndrewAMD, alibaba, dpn),
581
guests, and 0
spiders. |
|
Key:
Admin,
Global Mod,
Mod
|
|
|
1000 entities VS 1000 materials
#56672
10/01/05 11:29
10/01/05 11:29
|
Joined: Aug 2005
Posts: 1,185 Ukraine
Lion_Ts
OP
Serious User
|
OP
Serious User
Joined: Aug 2005
Posts: 1,185
Ukraine
|
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:
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 
|
|
|
Re: 1000 entities VS 1000 materials
[Re: Helghast]
#56675
10/01/05 19:55
10/01/05 19:55
|
Joined: Aug 2005
Posts: 1,185 Ukraine
Lion_Ts
OP
Serious User
|
OP
Serious User
Joined: Aug 2005
Posts: 1,185
Ukraine
|
Quote:
using ptr_for_handle...
Tell about it more, please. I don't know how to release materials, bmaps, panels and so on. It's not described in the manual. And as described in the manual:
Quote:
handle (object); Returns a handle of an object. A handle is a unique number that can be assigned to any variable, and identifies that object. The object can be an entity, an action, a string, a bmap, a panel, or a pointer to them. Parameters: object - Entity, Action, String, Bitmap, Panel or Pointer of an object
Material's pointers in the manual described very short... Can you tell your idea ?
|
|
|
Re: 1000 entities VS 1000 materials
[Re: Lion_Ts]
#56676
10/01/05 23:19
10/01/05 23:19
|
Joined: Feb 2003
Posts: 6,818 Minot, North Dakota, USA
ulillillia
Senior Expert
|
Senior Expert
Joined: Feb 2003
Posts: 6,818
Minot, North Dakota, USA
|
Actually, the version I have is shorter - useful for multi-colored things: Code:
material* platform_colors;
// unrelated defines go here define base_red, skill16; define base_green, skill17; define base_blue, skill18; define base_alpha, skill19;
//uses: base_red, base_green, base_blue, base_alpha action platforms { platform_colors = mtl_create(); platform_colors.ambient_red = my.skill16; platform_colors.ambient_green = my.skill17; platform_colors.ambient_blue = my.skill18; if (my.skill19 != 0) { my.transparent = on; my.alpha = my.skill19*100/255; } }
For best use, have a white texture with any decals on it. Then, set the color through the skills. Alpha is based on 0 to 255, as it's supposed to be. 8-bit means from 0-255, not 0-100 (I hate the 0-100 method - it means lots of guessing). To set the color to a bright orange, set skill16 to 255, skill17 to 160, and skill18 to 64. For an alpha of 160, set skill19 to 160 to get 5/8 visible. This is a good technique for lights (models) without using any dynamic lights.
"You level up the fastest and easiest if you do things at your own level and no higher or lower" - useful tip
My 2D game - release on Jun 13th; My tutorials
|
|
|
Re: 1000 entities VS 1000 materials
[Re: ulillillia]
#56677
10/02/05 01:24
10/02/05 01:24
|
Anonymous
Unregistered
|
Anonymous
Unregistered
|
I heard you can get unlimited skills (local variables) for each object with C++, do you know how to do that too?
|
|
|
|