|
|
ent_morphskin & ent_getskin
#414302
12/28/12 14:39
12/28/12 14:39
|
Joined: Jul 2002
Posts: 3,208 Germany
Error014
OP
Expert
|
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: 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:
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: jcl]
#414409
01/01/13 18:45
01/01/13 18:45
|
Joined: Jul 2002
Posts: 3,208 Germany
Error014
OP
Expert
|
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!
|
|
|
|