Gamestudio Links
Zorro Links
Newest Posts
Zorro 2.70
by jcl. 09/29/25 09:24
optimize global parameters SOLVED
by dBc. 09/27/25 17:07
ZorroGPT
by TipmyPip. 09/27/25 10:05
assetHistory one candle shift
by jcl. 09/21/25 11:36
Plugins update
by Grant. 09/17/25 16:28
AUM Magazine
Latest Screens
Rocker`s Revenge
Stug 3 Stormartillery
Iljuschin 2
Galactic Strike X
Who's Online Now
2 registered members (OptimusPrime, AndrewAMD), 14,580 guests, and 5 spiders.
Key: Admin, Global Mod, Mod
Newest Members
krishna, DrissB, James168, Ed_Love, xtns
19168 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Page 1 of 4 1 2 3 4
Rotating a bone with mouse #455284
10/15/15 23:47
10/15/15 23:47
Joined: Jun 2010
Posts: 590
California
Ruben Offline OP
User
Ruben  Offline OP
User

Joined: Jun 2010
Posts: 590
California
I am just starting to get into bones for models in MED.

I am currently using the classic Gamestudio medieval guard model with a feather on his head, to test functionality for the game, and using it as the player model.

I am sure most of you know that this model uses vertex animation, not bone animation. I manually added two bones to this model, one in the middle of the waist, and one in the middle of the shoulders. I attached the waist vertices to the waist "bone", and the upper body vertices to the shoulders "bone".

When I press the Animate button in MED, I can rotate the entire upper body of the player model by manually rotating the waist "bone", since the shoulders "bone" that is linked to the upper body vertices is connected to the waist "bone".

I am trying to figure out how to rotate the waist bone during gameplay, with the mouse. I would like to make it so that if the player moves the mouse upward, the waist "bone" rotates, causing the player model to bend forward at the waist. If the player moves the mouse downward, the waist "bone" also rotates, causing the player model to bend backward at the waist.

I found some functions relating to bone manipulation, which are ent_bonename() and ent_bonerotate().

I think I initialize the waist "bone" in the code like this:

Code:
ent_bonename(me, "waist", 194);
   // me = player, 194 = vertex attached to waist "bone"



I also assume that I would use the ent_bonerotate() function to be used when trying to make the mouse rotate the waist "bone" forward and backward. I also assume I would use the tilt and mickey functions to work with the ent_bonerotate() function to make this work.

Would it go something like:

Code:
mickey.y = ent_bonerotate(me, "waist", vector(0,my.skill2,0);



Any help in helping me me understand how the Lite-C code works with the bone functions would be greatly appreciated. Thank you.


Last edited by Ruben; 10/16/15 01:18.
Re: Rotating a bone with mouse [Re: Ruben] #455287
10/16/15 01:35
10/16/15 01:35
Joined: Feb 2012
Posts: 371
Dico Offline
Senior Member
Dico  Offline
Senior Member

Joined: Feb 2012
Posts: 371
you just need something like this :

modifier skill2 with mouse

Code:
my.skill2 += 5 * mouse_force.x;



now add skill to ent_bonerotate
Code:
ent_bonerotate(me, "waist", vector(0,my.skill2,0);




this code just give you a start for how to use mouse with bone

Re: Rotating a bone with mouse [Re: Dico] #455288
10/16/15 03:47
10/16/15 03:47

M
Malice
Unregistered
Malice
Unregistered
M



Just as a note mickey.y should be used as a read value not a write.

var this=mickey.y; // Correct
mickey.y= anything // worng

Re: Rotating a bone with mouse [Re: ] #455289
10/16/15 06:44
10/16/15 06:44
Joined: Jun 2010
Posts: 590
California
Ruben Offline OP
User
Ruben  Offline OP
User

Joined: Jun 2010
Posts: 590
California
I tried doing this:

Code:
#define BEND_WAIST    skill17

...

action player_code()
{
	...
	
	ent_bonename(me, "waist", 194);

	my.BEND_WAIST += 5 * mouse_force.y;
	ent_bonerotate(me, "waist", vector(0,my.BEND_WAIST,0));
	
        ...
 
        while(1)
        {
           ...

            wait(1);
        }
}



...but no such luck. The waist is not bending forward or backward when I move the mouse up or down.

I also get a pop-up error message that says:

Code:
Error E1515
Invalid function arguments in player_code
OK             Cancel


Re: Rotating a bone with mouse [Re: Ruben] #455302
10/16/15 17:27
10/16/15 17:27

M
Malice
Unregistered
Malice
Unregistered
M



Ruben if I follow the manual then you have an invalid arg as the string

"waist" is a constant in both lines of code, that is wrong.

If I fallow ent_bonename SETS' then name into not reads the string arg. So the actual bone-name should be saved into our string pointer. Then you should be able to use it in the ent_bonemove.
Please try ...
Code:
#define BEND_WAIST    skill17

...

action player_code()
{
	...
	STRING* str_waist_bone = "";

	ent_bonename(me, str_waist_bone, 194);

	my.BEND_WAIST += 5 * mouse_force.y;
	ent_bonerotate(me, str_waist_bone, vector(0,my.BEND_WAIST,0));
	
        ...
 
        while(1)
        {
           ...

            wait(1);
        }
}


Last edited by Malice; 10/16/15 17:45.
Re: Rotating a bone with mouse [Re: ] #455303
10/16/15 17:39
10/16/15 17:39
Joined: Feb 2012
Posts: 371
Dico Offline
Senior Member
Dico  Offline
Senior Member

Joined: Feb 2012
Posts: 371
Malice , just note : You put Ent bone rotate outside while loop so it not able to update bone every frame.

Last edited by Dico; 10/16/15 17:45.
Re: Rotating a bone with mouse [Re: ] #455304
10/16/15 17:42
10/16/15 17:42

M
Malice
Unregistered
Malice
Unregistered
M



It is important to remember your gets' and sets'.

You bone most likely doesn't have a name... So lets use a set to give it one.
ent_bonehandle -
Quote:
Modifies:
name (set to the name of the bone resp. parent bone when both name and index are nonzero) .

Code:
ent_bonehandle(my,"waist",5); // Get the bone number from MED in this ex '5'



If this did set the name, than you should now be able to use the name as a constant

Code:
my.BEND_WAIST += 5 * mouse_force.y;
	ent_bonerotate(me, "waist", vector(0,my.BEND_WAIST,0));


Re: Rotating a bone with mouse [Re: Dico] #455305
10/16/15 17:42
10/16/15 17:42
Joined: Feb 2012
Posts: 371
Dico Offline
Senior Member
Dico  Offline
Senior Member

Joined: Feb 2012
Posts: 371
Ruben , don't use ent_bonename and . You not need it , just get bone name from med and use it in ent_bonerotate.

Last edited by Dico; 10/16/15 17:43.
Re: Rotating a bone with mouse [Re: ] #455306
10/16/15 17:43
10/16/15 17:43

M
Malice
Unregistered
Malice
Unregistered
M



Dico - Thanks, but actually Ruben did that, I just copied out his code. Good catch, I was to focused on the E1515.

Thanks
Mal

EDIT - Ok Ruben - Dico knows and doesn't have to guess like me. So listen to Dico!!


Last edited by Malice; 10/16/15 17:47.
Re: Rotating a bone with mouse [Re: ] #455307
10/16/15 17:46
10/16/15 17:46
Joined: Feb 2012
Posts: 371
Dico Offline
Senior Member
Dico  Offline
Senior Member

Joined: Feb 2012
Posts: 371
Oh okey , I'm just run from mobile so I'm not see his post ^^

Page 1 of 4 1 2 3 4

Gamestudio download | 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