Gamestudio Links
Zorro Links
Newest Posts
Newbie Questions
by fairtrader. 12/06/23 11:29
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
7 registered members (fairtrader, Quad, miwok, Martin_HH, AndrewAMD, alibaba, dpn), 581 guests, and 0 spiders.
Key: Admin, Global Mod, Mod
Newest Members
fairtrader, hus, Vurtis, Harry5, KelvinC
19019 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Page 2 of 2 1 2
Re: Ragdoll (limbs) auto generator : [Re: EvilSOB] #277504
07/09/09 12:48
07/09/09 12:48
Joined: Jan 2004
Posts: 3,023
The Netherlands
Helghast Offline
Expert
Helghast  Offline
Expert

Joined: Jan 2004
Posts: 3,023
The Netherlands
Originally Posted By: EvilSOB
Helghast : can you post a link to your latest 'public' lite-c rag-dolling code.
I should be able to re-structure it fairly easily(?), as most of the code I
write myself follows most of the guidelines anyway.

Thats just the way I code, cause I re-use my own code a lot, and coding this way makes it easier.


Sure, but that doesnt learn me anything :P hahahaa
Can you add me on MSN maybe, so we could go over it together (it would be usefull to me for future projects to be able to set it up as template, so i can contribute more often ;)).

http://www.designorhea.com/ragdoll/Ragdoll_A7_src.rar for the source codes smile

regards,


Formerly known as dennis_fantasy
Portfolio - http://www.designorhea.com/
Project - http://randomchance.cherrygames.org/
Re: Ragdoll (limbs) auto generator : [Re: Helghast] #277578
07/09/09 17:26
07/09/09 17:26
Joined: Feb 2008
Posts: 3,232
Australia
EvilSOB Offline
Expert
EvilSOB  Offline
Expert

Joined: Feb 2008
Posts: 3,232
Australia
Yeah, you'll be able to learn from looking at the changes Ive made.

From what I remember from looking at your code from ages back,
I dont expect they'll actually be that much that needs changing.

PS. I dont have MSN or any on-line chat tools. Dont like em...
PM here is the closest I have. ANd I wanna keep it thast way.

Last edited by EvilSOB; 07/09/09 17:27.

"There is no fate but what WE make." - CEO Cyberdyne Systems Corp.
A8.30.5 Commercial
Re: Ragdoll (limbs) auto generator : [Re: EvilSOB] #278463
07/14/09 00:33
07/14/09 00:33
Joined: Feb 2008
Posts: 3,232
Australia
EvilSOB Offline
Expert
EvilSOB  Offline
Expert

Joined: Feb 2008
Posts: 3,232
Australia
Helghast, here is my "interpretation" of the Template/Library guidelines.
Only changes of importance
1> "bodypart" folder need renaming to "RD_Bodypart"
2> All models in "RD_Bodypart" folder need renaming to "RD_samename.mdl"
3> The primary Action is now called "RagDoll_Spawn()"

If you look through the code, you will see that "...only the names have been changed to protect the innocent".
Mind you, you should re-post this somewhere public, AFTER you've added your credits /creation-date
AND some helpful documentation for noobies in 'Rag_Doll.H' somewhere.
(packaged with the RD_Bodyparts directory too, somehow)

Rag_Doll.H
Click to reveal..
Code:
#ifndef Rag_Doll_h
#define Rag_Doll_h
//////////////////////////////////////////////////////////////////////////////////
// Rag-Dolling Template															//
//////////////////////////////////////////////////////////////////////////////////
//
//
#define PRAGMA_PATH "RD_Bodyparts";
//
// RagDoll working variables
VECTOR*	RD_Hinge1 = { x=0; y=0; z=0; }
VECTOR*	RD_Hinge2 = { x=0; y=0; z=0; }
var 	RD_GroupID = 2;
//
//
//////////////////////////////////////////////////////////////////////////////////
//	FUNCTIONS																	//
//////////////////////////////////////////////////////////////////////////////////
//
// update bone to hinge
void RD_updateBoneHinge(ENTITY* hingeEnt, STRING* bodyPart, ENTITY* actor) 
{
	VECTOR temp_pos, temp_ang, temp_mov, temp_ang_1;
	ENTITY *hingePointer = hingeEnt, *actorPointer = actor;
	STRING* updatePart = bodyPart;
	//
	while(hingePointer) 
	{
		// reset bone position
		ent_bonereset(actorPointer, updatePart);
		//
		vec_for_bone(temp_pos, actorPointer, updatePart);
		ang_for_bone(temp_ang, actorPointer, updatePart);
		//
		vec_set(temp_mov, hingePointer.x);
		vec_sub(temp_mov, temp_pos);
		//
		temp_mov.x /= actorPointer.scale_x; temp_mov.y /= actorPointer.scale_y; temp_mov.z /= actorPointer.scale_z;
		vec_rotateback (temp_mov, temp_ang);///change this please
		temp_ang.x = 360-temp_ang.x; temp_ang.y = 360-temp_ang.y; temp_ang.z = 360-temp_ang.z;
		//
		vec_set(temp_ang_1, nullvector);
		ang_add(temp_ang_1, vector(temp_ang.x,0,0));
		ang_add(temp_ang_1, vector(0,temp_ang.y,0));
		ang_add(temp_ang_1, vector(0,0,temp_ang.z));
		//
		ang_rotate(temp_ang_1, hingePointer.pan);
		ent_bonerotate(you, updatePart, temp_ang_1);
		ent_bonemove(you, updatePart, temp_mov);	
		//
		wait(1);
	} 
}
//
//
//////////////////////////////////////////////////////////////////////////////////
//
// set rotation limits
void RD_setLimit(VECTOR* vec1, VECTOR* vec2) 
{
	vec_set(RD_Hinge1, vec1);
	vec_set(RD_Hinge2, vec2);
}
//
//
//////////////////////////////////////////////////////////////////////////////////
//
// initialise physics and hinges
void RD_BodyPartInit(var mass, ENTITY* entityMe) 
{
	set(entityMe, PASSABLE);
	entityMe.pan = 180;
	phent_settype(entityMe, PH_RIGID, PH_BOX);
	phent_setmass(entityMe, mass, PH_BOX);
	//
	phent_setgroup(entityMe, RD_GroupID);
	phent_setfriction(entityMe, 15);
	phent_setdamping(entityMe, 35, 35);
	phent_setelasticity(entityMe, 35, 30); // bounciness
	//
	reset(entityMe, PASSABLE);
}
//
//
//////////////////////////////////////////////////////////////////////////////////
//
void RD_setHinge(ENTITY* constr_1, ENTITY* constr_2) {
	var tempHinge;
	
	// make constraint
	tempHinge = phcon_add(PH_HINGE, constr_1, constr_2); // attach to bodypart
	phcon_setparams1(tempHinge, constr_1.x, RD_Hinge1, nullvector); // set hinge limits
	phcon_setparams2(tempHinge, RD_Hinge2, nullvector, nullvector);    // same
}
//
//
//////////////////////////////////////////////////////////////////////////////////
//
void RD_setPart() 
{
	set(my, INVISIBLE);
}
//
//
//////////////////////////////////////////////////////////////////////////////////
//
void RagDoll_Spawn() 
{
	ENTITY* Ent_1;
	ENTITY* Ent_2;
	ENTITY* Ent_3;
	
	RD_GroupID += 1;
	
	var tempVertex;
	
	// create ragdoll actor
	you = ent_create("RD_test_ragdoll.mdl", nullvector, NULL);
	set(you, PASSABLE);
	
	// go on creating the ragdoll PE objects
	Ent_1 = my;
	RD_setPart();
	RD_BodyPartInit(20, Ent_1); // create physics object and set weight
		// make constraint
		RD_setHinge(Ent_1, Ent_1);
	
	// left upper leg
	vec_for_vertex(tempVertex, Ent_1, 23); // get vertex to attach limb to
 	Ent_2 = ent_create("RD_leg_up_left.mdl", tempVertex, RD_setPart); // create bodypart
 	RD_setLimit(vector(1,1,1), vector(-40,40,0)); // set rotational boundaries
	RD_BodyPartInit(5, Ent_2); // same as before, and from here keeps copying, but for different limbs every time
		// make constraint
		RD_setHinge(Ent_2, Ent_1);
		RD_updateBoneHinge(Ent_2, "leg_up_left", you);
		
 	// left lower leg
 	vec_for_vertex(tempVertex, Ent_2, 9);
	Ent_3 = ent_create("RD_leg_down_left.mdl", tempVertex, RD_setPart);
	RD_setLimit(vector(0,1,0), vector(0,120,0));
	RD_BodyPartInit(20, Ent_3);
		// make constraint
		RD_setHinge(Ent_3, Ent_2);
		RD_updateBoneHinge(Ent_3, "leg_down_left", you);
 
	// right upper leg
	vec_for_vertex(tempVertex, Ent_1, 22);
 	Ent_2 =	ent_create("RD_leg_up_right.mdl", tempVertex, RD_setPart);
 	RD_setLimit(vector(1,1,1), vector(-40,40,0));
	RD_BodyPartInit(5, Ent_2);
		// make constraint
		RD_setHinge(Ent_2, Ent_1);
		RD_updateBoneHinge(Ent_2, "leg_up_right", you);
		
	// right lower leg
	vec_for_vertex(tempVertex, Ent_2, 9);
 	Ent_3 =	ent_create("RD_leg_down_right.mdl", tempVertex, RD_setPart);
 	RD_setLimit(vector(0,1,0), vector(0,120,0));
	RD_BodyPartInit(20, Ent_3);
		// make constraint
		RD_setHinge(Ent_3, Ent_2);
		RD_updateBoneHinge(Ent_3, "leg_down_right", you);
	
	// abs
	vec_for_vertex(tempVertex, Ent_1, 21);
	Ent_2 = ent_create("RD_abs.mdl", tempVertex, RD_setPart);
	RD_setLimit(vector(1,1,0), vector(-15,15,0));
	RD_BodyPartInit(20, Ent_2);
		// make constraint
		RD_setHinge(Ent_2, Ent_1);
		RD_updateBoneHinge(Ent_2, "stomach", you);
	
	//torso
	vec_for_vertex(tempVertex, Ent_2, 17);
	Ent_1 = ent_create("RD_torso.mdl", tempVertex, RD_setPart);
	RD_setLimit(vector(1,1,0), vector(-20,20,0));
	RD_BodyPartInit(55, Ent_1);
		// make constraint
		RD_setHinge(Ent_1, Ent_2);
		RD_updateBoneHinge(Ent_1, "torso", you);
	
	// left upper arm
	vec_for_vertex(tempVertex, Ent_1, 21);
 	Ent_2 = ent_create("RD_arm_up_left.mdl", tempVertex, RD_setPart);
 	RD_setLimit(vector(1,1,1), vector(-70, 116,20));
	RD_BodyPartInit(5, Ent_2);
		// make constraint
		RD_setHinge(Ent_2, Ent_1);
		RD_updateBoneHinge(Ent_2, "arm_up_left", you);
		
	// left lower arm
	vec_for_vertex(tempVertex, Ent_2, 9);
 	Ent_3 = ent_create("RD_arm_down_left.mdl", tempVertex, RD_setPart);
 	RD_setLimit(vector(1,1,0), vector(270,0,0));
	RD_BodyPartInit(20, Ent_3);
		// make constraint
		RD_setHinge(Ent_3, Ent_2);
		RD_updateBoneHinge(Ent_3, "arm_down_left", you);

	// right upper arm
	vec_for_vertex(tempVertex, Ent_1, 22);
 	Ent_2 = ent_create("RD_arm_up_right.mdl", tempVertex, RD_setPart);
 	RD_setLimit(vector(1,1,1), vector(-70,116,20));
	RD_BodyPartInit(5, Ent_2);
		// make constraint
		RD_setHinge(Ent_2, Ent_1);
		RD_updateBoneHinge(Ent_2, "arm_up_right", you);
		
	// right lower arm
	vec_for_vertex(tempVertex, Ent_2, 9);
 	Ent_3 = ent_create("RD_arm_down_right.mdl", tempVertex, RD_setPart);
 	RD_setLimit(vector(1,1,0), vector(270,0,0));
	RD_BodyPartInit(20, Ent_3);
		// make constraint
		RD_setHinge(Ent_3, Ent_2);
		RD_updateBoneHinge(Ent_3, "arm_down_right", you);
		
		// head
	vec_for_vertex(tempVertex, Ent_1, 23);
	Ent_2 = ent_create("RD_head.mdl", tempVertex, RD_setPart);
	RD_setLimit(vector(1,1,0), vector(-45,45,0));
	RD_BodyPartInit(25, Ent_2);
		// make constraint
		RD_setHinge(Ent_2, Ent_1);
		RD_updateBoneHinge(Ent_2, "head", you);
	
	while(you) {
		vec_set(you.x, my.x);
		vec_set(you.pan, my.pan);
		
		if(key_space) {
			phent_addvelglobal(my, vector(0,0,500), nullvector);		// THIS ADDS A FORCE TO THE RAGDOLL
		}
		
		wait(1);
	}
}
//
//
//////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////
#endif	//Rag_Doll_h



Rag_Doll_demo.c
Click to reveal..
Code:
// ragdoll script in, WOOOOOOOOT! :P
#include <acknex.h> // include for Pure Mode
#include <default.c> // default key functions

#include "Rag_Doll.h"




void main() {
	// vector nullifying
	
	fps_max = 60;
	time_smooth = 0;
	ph_iterations = 20; // set itterating physics to smooth out.
	
	level_load("test_level.wmb");
	wait(5);
	
	ph_setgravity(vector(0, 0, -1200)); // set gravity
	ph_setcorrections(9000, 0); // set physics corrections
	ph_setcollisions(1000, 2);
	
	while (1) {
		if (mouse_left) {
			ent_create("RD_pelvis.mdl", vector(0, 0, 400), RagDoll_Spawn); // spawn ragdoll initial bodypart
			while(mouse_left){wait(1);}
		}
		wait(1);
	}
}



[EDIT] PS : This took me less than half an hour to "standardise". It just took 4 days to get around to it.... Sorry.
[EDIT2] PPS : I dont have MSN, or any on-line chatting functionality. REALLY dislike the little buggers.

Last edited by EvilSOB; 07/14/09 00:36. Reason: PS & PPS

"There is no fate but what WE make." - CEO Cyberdyne Systems Corp.
A8.30.5 Commercial
Re: Ragdoll (limbs) auto generator : [Re: EvilSOB] #278534
07/14/09 11:25
07/14/09 11:25
Joined: Jan 2004
Posts: 3,023
The Netherlands
Helghast Offline
Expert
Helghast  Offline
Expert

Joined: Jan 2004
Posts: 3,023
The Netherlands
cool, thanks! I'm gonna work this out, and re-upload it as template then smile
(ofcourse, credits where they are due ;)).

question though...
RagDoll_Spawn funtion should be part of the .c file, am I right, since this is where ragdolls are made, but it's not really a template part (since this has to be setup differently for every type of character in your game).
It's actually just a small tutorial how to set the ragdoll up with my code... lol

thanks again!

regards,


Formerly known as dennis_fantasy
Portfolio - http://www.designorhea.com/
Project - http://randomchance.cherrygames.org/
Re: Ragdoll (limbs) auto generator : [Re: Helghast] #278580
07/14/09 13:59
07/14/09 13:59
Joined: Feb 2008
Posts: 3,232
Australia
EvilSOB Offline
Expert
EvilSOB  Offline
Expert

Joined: Feb 2008
Posts: 3,232
Australia
Yes, thats right, I didnt think of it that way, but your idea is better.
Just remember to put the #include "Rag_Doll.h" into the new Rag_Doll.c


"There is no fate but what WE make." - CEO Cyberdyne Systems Corp.
A8.30.5 Commercial
Page 2 of 2 1 2

Moderated by  aztec, Spirit 

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