Gamestudio Links
Zorro Links
Newest Posts
Newbie Questions
by fairtrader. 12/06/23 11:29
Zorro Trader GPT
by TipmyPip. 12/04/23 11:34
Square root rule
by Smallz. 12/02/23 09:15
RTest not found error
by TipmyPip. 12/01/23 21:43
neural function for Python to [Train]
by TipmyPip. 12/01/23 14:47
Xor Memory Problem.
by TipmyPip. 11/28/23 14:23
Training with command line parameters
by TipmyPip. 11/26/23 08:42
Combine USD & BTC Pairs In Asset Loop
by TipmyPip. 11/26/23 08:30
AUM Magazine
Latest Screens
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Tactics of World War I
Who's Online Now
7 registered members (fairtrader, Quad, miwok, Martin_HH, AndrewAMD, alibaba, dpn), 581 guests, and 0 spiders.
Key: Admin, Global Mod, Mod
Newest Members
fairtrader, hus, Vurtis, Harry5, KelvinC
19019 Registered Users
Previous Thread
Next Thread
Print Thread
Rating: 5
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 Offline OP
Serious User
Lion_Ts  Offline 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: Lion_Ts] #56673
10/01/05 13:40
10/01/05 13:40
Joined: Oct 2003
Posts: 206
N
nkl Offline
Member
nkl  Offline
Member
N

Joined: Oct 2003
Posts: 206
Hi.
Your code is very useful.
After I create 1000 materials.
How do I remove an unused materials pointer?
Thanks for your advance.
Thanks already.

Re: 1000 entities VS 1000 materials [Re: nkl] #56674
10/01/05 14:38
10/01/05 14:38
Joined: Jan 2004
Posts: 3,023
The Netherlands
Helghast Offline
Expert
Helghast  Offline
Expert

Joined: Jan 2004
Posts: 3,023
The Netherlands
using ptr_for_handle...


Formerly known as dennis_fantasy
Portfolio - http://www.designorhea.com/
Project - http://randomchance.cherrygames.org/
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 Offline OP
Serious User
Lion_Ts  Offline 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 Offline
Senior Expert
ulillillia  Offline
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

A
Anonymous
Unregistered
Anonymous
Unregistered
A



I heard you can get unlimited skills (local variables) for each object with C++, do you know how to do that too?

Re: 1000 entities VS 1000 materials [Re: Helghast] #56678
10/02/05 04:41
10/02/05 04:41
Joined: Oct 2003
Posts: 206
N
nkl Offline
Member
nkl  Offline
Member
N

Joined: Oct 2003
Posts: 206
Hi
It is because A6 manual describe Material's pointers very shortly.
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:
Would you tell me more about using ptr_for_handle for release a mtl_create() materials, please?
Thanks for any advance!

Re: 1000 entities VS 1000 materials [Re: nkl] #56679
10/02/05 21:20
10/02/05 21:20
Joined: Aug 2005
Posts: 1,185
Ukraine
Lion_Ts Offline OP
Serious User
Lion_Ts  Offline OP
Serious User

Joined: Aug 2005
Posts: 1,185
Ukraine
Sorry for "panels, bmaps and so on...". But about materials it's truth.

Re: 1000 entities VS 1000 materials [Re: Lion_Ts] #56680
10/02/05 23:38
10/02/05 23:38
Joined: Aug 2005
Posts: 1,185
Ukraine
Lion_Ts Offline OP
Serious User
Lion_Ts  Offline OP
Serious User

Joined: Aug 2005
Posts: 1,185
Ukraine
For noobs like me:
no command like 'mtl_remove' in the manual. If you create material with mtl_create and forget assign it to entity, you'll have engine crash after level reload (engine don't deallocate your material). Materials, assigned to entities, deallocates automatically by engine (with level_load() or exit() ). I tested it with 200000 materials, all ok. One footprint: with big number of materials (even unassigned to entities or assigned to invisible static entities) you have bad FPS (big time for entity updates)


Moderated by  adoado, checkbutton, mk_1, Perro 

Gamestudio download | chip programmers | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1