Gamestudio Links
Zorro Links
Newest Posts
What are you working on?
by rayp. 10/15/25 20:44
Help!
by VoroneTZ. 10/14/25 05:04
Zorro 2.70
by jcl. 10/13/25 09:01
ZorroGPT
by TipmyPip. 10/12/25 13:58
Sam Foster Sound | Experienced Game Composer for Hire
by titanicpiano14. 10/11/25 18:45
Reality Check results on my strategy
by dBc. 10/11/25 06:15
AUM Magazine
Latest Screens
Rocker`s Revenge
Stug 3 Stormartillery
Iljuschin 2
Galactic Strike X
Who's Online Now
2 registered members (AndrewAMD, 1 invisible), 7,036 guests, and 2 spiders.
Key: Admin, Global Mod, Mod
Newest Members
joenxxx, Jota, krishna, DrissB, James168
19170 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Morphing Code #417713
02/16/13 09:44
02/16/13 09:44
Joined: Jul 2005
Posts: 187
L
lostzac Offline OP
Member
lostzac  Offline OP
Member
L

Joined: Jul 2005
Posts: 187
Code:
function morph_target(ENTITY* e, ENTITY* m, p)
{
	VECTOR Current;  //Current Mesh Vert Pos 
	VECTOR Target;  	//Morph1 Vert Pos

	VECTOR Base;     //Base or unchanged mesh vert pos
	VECTOR Diff;   
	VECTOR morph;
	
	var vert;
	var vert_cnt = ent_status(e,0);	
	
	for(vert=1;vert<vert_cnt;vert++)
	{
		//Base Model Postions
		CONTACT* c1 = ent_getvertex(e,NULL,vert);
		Base.x = c1.x;
		Base.y = c1.y;
		Base.z = c1.z;		
		
		//Target Models Postions
		CONTACT* c2 = ent_getvertex(m,NULL,vert);
		Target.x = c2.x;
		Target.y = c2.y;
		Target.z = c2.z;
		
		vec_set(morph.x,Base.x);
				
		vec_lerp(Diff.x,Base.x,Target.x,p);
		morph.x += Diff.x - Base.x;
		morph.y += Diff.y - Base.y;
		morph.z += Diff.z - Base.z;	
			
		c1.v = NULL;
		c1.x = morph.x;
		c1.y = morph.y;
		c1.z = morph.z;
		ent_setvertex(e,c1,vert);		
	}
	
	ent_fixnormals(e,0);
	c_updatehull(e,0);	
}



Note* Both models have to have the same number of verts and the morph object should be derived from the base object or you will get weird results..

p - this is the percentage of the morph you want your entity to take on. Use decimals so a 50% morph would be 0.5


John C Leutz II

Re: Morphing Code [Re: lostzac] #417716
02/16/13 10:38
02/16/13 10:38
Joined: Mar 2006
Posts: 1,993
Karlsruhe
PadMalcom Offline
Serious User
PadMalcom  Offline
Serious User

Joined: Mar 2006
Posts: 1,993
Karlsruhe
Hey, nice idea! If you manage to deal with models with a different number of vertices it would not only be great but awesome! laugh

Re: Morphing Code [Re: PadMalcom] #417718
02/16/13 10:44
02/16/13 10:44
Joined: Jul 2005
Posts: 187
L
lostzac Offline OP
Member
lostzac  Offline OP
Member
L

Joined: Jul 2005
Posts: 187
Hmmm never thought about that...I think I could get a system like that working...off the top of my head I would think about using target areas...and proximate distance of the target vert...I may have to look into that after I finish what I am working on... The hardest part would be morphing entities into targets with more verts as the detail would be hard to mimic....suppose you could fake it with normal maps, and if you used some sort of multi-texture with it as well like you would use in a terrain, that could handle the stretching of the textures.....

Last edited by lostzac; 02/16/13 10:58.

John C Leutz II


Moderated by  HeelX, Lukas, rayp, Rei_Ayanami, Superku, Tobias, TWO, VeT 

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