|
ent_boneparent behavior
#440563
04/28/14 10:39
04/28/14 10:39
|
Joined: Jun 2007
Posts: 1,337 Hiporope and its pain
txesmi
OP
Serious User
|
OP
Serious User
Joined: Jun 2007
Posts: 1,337
Hiporope and its pain
|
Hello, I have been playing with 'ent_bonehandle' and 'ent_boneparent' and as far I undertand when any of both functions are called with a NULL bone handle it returns the bone handle of the bone name the string contains. 'ent_bonehandle' works good as far as the bone name continues been the same but 'ent_boneparent' also overwrites the bone name contained in the string. I guess it should not overwrite the bone name string when called with a null bone handle in order to mantain the source string as it is. The code I used to test the instructions functionality
#include <acknex.h>
void main ()
{
int bone_index = 0, parent_index = 0, child_index = 0;
video_mode = 12;
wait(2);
level_load ( "" );
FONT *fnt10 = font_create ( "Arial#12" );
ENTITY *entBones = ent_create ( "biped.mdl", nullvector, NULL );
int numBones = ent_bones ( entBones );
int step = screen_size.x / numBones;
//----------------------------------------------------------------------------------------
TEXT **txtBones = sys_malloc ( sizeof(TEXT*) * numBones );
for ( bone_index=0; bone_index<numBones; bone_index+=1 )
{
txtBones[bone_index] = txt_create ( numBones, 1 );
txtBones[bone_index]->pos_x = bone_index * step;
txtBones[bone_index]->font = fnt10;
txtBones[bone_index]->flags = SHOW;
}
for ( bone_index=0; bone_index<numBones; bone_index+=1 )
ent_bonehandle ( entBones, (txtBones[bone_index]->pstring)[0], bone_index+1 );
for ( bone_index=0; bone_index<numBones; bone_index+=1 )
{
int parent_index = 1;
long handle = ent_boneparent ( entBones, (txtBones[bone_index]->pstring)[parent_index], bone_index+1 );
while ( handle )
{
parent_index += 1;
handle = ent_boneparent ( entBones, (txtBones[bone_index]->pstring)[parent_index], (var)handle );
}
}
//----------------------------------------------------------------------------------------
TEXT **txtBones2 = sys_malloc ( sizeof(TEXT*) * numBones );
for ( bone_index=0; bone_index<numBones; bone_index+=1 )
{
txtBones2[bone_index] = txt_create ( numBones, 1 );
txtBones2[bone_index]->pos_x = bone_index * step;
txtBones2[bone_index]->pos_y = 250;
txtBones2[bone_index]->font = fnt10;
txtBones2[bone_index]->flags = SHOW;
}
for ( bone_index=0; bone_index<numBones; bone_index+=1 )
ent_bonehandle ( entBones, (txtBones2[bone_index]->pstring)[0], bone_index+1 );
for ( bone_index=0; bone_index<numBones; bone_index+=1 )
{
child_index = 0;
long handle = ent_boneparent ( entBones, (txtBones2[bone_index]->pstring)[child_index], 0 );
while ( handle )
{
child_index += 1;
ent_bonehandle ( entBones, (txtBones2[bone_index]->pstring)[child_index], (var)handle );
handle = ent_boneparent ( entBones, (txtBones2[bone_index]->pstring)[child_index], 0 );
}
}
//----------------------------------------------------------------------------------------
while ( !key_esc )
wait(1);
sys_exit ( NULL );
}
The model: https://app.box.com/s/tozj882s0qvlztcp19tmIs this a desired behavior? Thanks in advance, txes
Last edited by txesmi; 04/28/14 10:41.
|
|
|
Re: ent_boneparent behavior
[Re: txesmi]
#440570
04/28/14 11:48
04/28/14 11:48
|
Joined: Aug 2002
Posts: 3,258 Mainz
oliver2s
Expert
|
Expert
Joined: Aug 2002
Posts: 3,258
Mainz
|
This is not a bug. It's desired behavior and works very well. From the manual: If name and index are both given, index is used to find the bone and name is set to the name of the bone resp. of the parent bone.
|
|
|
Re: ent_boneparent behavior
[Re: oliver2s]
#440574
04/28/14 12:08
04/28/14 12:08
|
Joined: Jun 2007
Posts: 1,337 Hiporope and its pain
txesmi
OP
Serious User
|
OP
Serious User
Joined: Jun 2007
Posts: 1,337
Hiporope and its pain
|
Hi, I tryed to explain that the case I was speaking about is the case where the name and index are both not given. Just the bone name contained in the string and a NULL handle (The second part of the code). I based my speculations on the example into the manual: // get the name of the parent bone when a child name is given. STRING* child_name = "foot_left"; long handle = ent_setboneparent(ent,child_name,0); // return a handle to the parent bone ent_setbonehandle(ent,parent_name,(var)handle); // retrieve the parant name from the parent handle.
Ignore the instructions names in the example. They are also wrong in the manual...This example retrieves the parent bone name after retrieving the parent bone handle, but with the actual 'ent_boneparent' behavior 'child_name' has been already overwritten with the parent bone name so there is no need of retrieving the parent bone name in the las instruction. That is why I thougth it is a bug. Salud!
Last edited by txesmi; 04/28/14 12:17.
|
|
|
|