Gamestudio Links
Zorro Links
Newest Posts
Newbie Questions
by fairtrader. 12/05/23 14:22
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
6 registered members (Quad, miwok, Martin_HH, AndrewAMD, alibaba, dpn), 584 guests, and 1 spider.
Key: Admin, Global Mod, Mod
Newest Members
fairtrader, hus, Vurtis, Harry5, KelvinC
19019 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
ent_morphskin & ent_getskin #414302
12/28/12 14:39
12/28/12 14:39
Joined: Jul 2002
Posts: 3,208
Germany
Error014 Offline OP
Expert
Error014  Offline OP
Expert

Joined: Jul 2002
Posts: 3,208
Germany
Hello!

This may not be a bug but me misinterpreting the manual. If that's the case, apologies!

ent_morphskin is a pretty useful function, and it says:
Quote:

Loads a new skin for a model entity from a separate file at runtime. Only the given entity will change it's skin, other entities with the same model remain unchanged.
[...]
The instruction only affects level entities, not view entities. The skin image must exist in the local resource file or the local game folder. Video memory for the new skin is only allocated when the entity is visible. The new skin can be accessed with the bmap_for_entity function.


But what about ent_getskin?
If an entity changed it's skin using ent_morphskin, ent_getskin will still return the old skin:



In case you want to see it in action, I have uploaded a demo here. It runs the below code:

Code:
function main() {
	ENTITY* a;
	ENTITY* b;
	ENTITY* c;
	BMAP* myskinmap;
	video_set(800,600,0,2);
	level_load(NULL);	
	//Create three entities to play around with
	a = ent_create("tile.mdl",vector(100,30,0),simplemove);
	b = ent_create("tile.mdl",vector(100,0,0),simplemove);
	c = ent_create("tile.mdl",vector(100,-30,0),simplemove);
	while(!key_space) {
		draw_text("Hit space to switch skins!",1,1,vector(255,255,255)); 
		wait(1);
	}
	while(key_space) wait(1);
	//b with ent_morphskin. . .
	ent_morphskin(b,"b.bmp");
	//and c with the "manual method"
	ent_cloneskin(c);
	ptr_remove(ent_getskin(c,1));
	ent_setskin(c,bmap_create("c.bmp"),1);
	while(!key_space) {
		draw_text("Hit space to show skins!",1,1,vector(255,255,255)); 
		wait(1);
	}
	while(key_space) wait(1);
	while(1) {
		DEBUG_BMAP(ent_getskin(a,1),133,4);
		DEBUG_BMAP(ent_getskin(b,1),366,4);
		DEBUG_BMAP(ent_getskin(c,1),600,4);
		wait(1);
	}
}



(and the rest is just for a prettier display)

~ ~ ~ ~ ~ ~

Again, this may be intentional behaviour, the manual is not too clear about this (what exactly ent_morphskin does and how it's handled). I suppose it's not too big a problem since I can get the skin via bmap_for_entity. This makes this more a source of confusion rather than an actual problem, but perhaps we can still adress that.


Thanks in advance, and all the best!


Perhaps this post will get me points for originality at least.

Check out Dungeon Deities! It's amazing and will make you happy, successful and almost certainly more attractive! It might be true!
Re: ent_morphskin & ent_getskin [Re: Error014] #414390
12/31/12 11:11
12/31/12 11:11
Joined: Jul 2000
Posts: 27,967
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 27,967
Frankfurt
ent_morphskin does indeed not really change the skin. This is not a bug, it's just the used method. It sets a second skin pointer that overrides the first one. The old skin still exists.

For really setting a new skin, your ent_cloneskin/ent_setskin method is the right one. Still the old ent_morphskin method has the advantage that it does not clone anything and thus consumes no memory.

Re: ent_morphskin & ent_getskin [Re: jcl] #414409
01/01/13 18:45
01/01/13 18:45
Joined: Jul 2002
Posts: 3,208
Germany
Error014 Offline OP
Expert
Error014  Offline OP
Expert

Joined: Jul 2002
Posts: 3,208
Germany
Ah, alright, that does make a lot of sense. Thank you for the explanation!

Do you think that you could add that explanation to the manual under ent_morphskin? I think that'd have helped in my confusion.


Perhaps this post will get me points for originality at least.

Check out Dungeon Deities! It's amazing and will make you happy, successful and almost certainly more attractive! It might be true!
Re: ent_morphskin & ent_getskin [Re: Error014] #414460
01/02/13 15:48
01/02/13 15:48
Joined: Jul 2000
Posts: 27,967
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 27,967
Frankfurt
Yes, this will be added.


Moderated by  jcl, Nems, Spirit, Tobias 

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