Gamestudio Links
Zorro Links
Newest Posts
Help with plotting multiple ZigZag
by degenerate_762. 04/30/24 23:23
M1 Oversampling
by 11honza11. 04/30/24 08:16
Trading Journey
by howardR. 04/28/24 09:55
Zorro Trader GPT
by TipmyPip. 04/27/24 13:50
Data from CSV not parsed correctly
by jcl. 04/26/24 11:18
Why Zorro supports up to 72 cores?
by jcl. 04/26/24 11:09
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
4 registered members (7th_zorro, degenerate_762, AndrewAMD, ozgur), 774 guests, and 0 spiders.
Key: Admin, Global Mod, Mod
Newest Members
firatv, wandaluciaia, Mega_Rod, EternallyCurious, howardR
19050 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
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 Offline OP
Serious User
txesmi  Offline 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
Code:
#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/tozj882s0qvlztcp19tm

Is 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 Offline
Expert
oliver2s  Offline
Expert

Joined: Aug 2002
Posts: 3,258
Mainz
This is not a bug. It's desired behavior and works very well. From the manual:

Quote:
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 Offline OP
Serious User
txesmi  Offline 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:

Originally Posted By: manual - ent_bonehandle

// 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.
Re: ent_boneparent behavior [Re: txesmi] #440581
04/28/14 12:54
04/28/14 12:54
Joined: Aug 2002
Posts: 3,258
Mainz
oliver2s Offline
Expert
oliver2s  Offline
Expert

Joined: Aug 2002
Posts: 3,258
Mainz
Now I understand. It seems this is really a bug.

Re: ent_boneparent behavior [Re: oliver2s] #440586
04/28/14 14:06
04/28/14 14:06
Joined: Jul 2000
Posts: 27,986
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 27,986
Frankfurt
Yes, I have to agree. We'll look into that.

Re: ent_boneparent behavior [Re: jcl] #440629
04/28/14 22:22
04/28/14 22:22
Joined: Jun 2007
Posts: 1,337
Hiporope and its pain
txesmi Offline OP
Serious User
txesmi  Offline OP
Serious User

Joined: Jun 2007
Posts: 1,337
Hiporope and its pain
Thanks for your attention.
Cheers!


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