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 (TipmyPip, 1 invisible), 18,758 guests, and 8 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 2 of 2 1 2
Re: Vector Scale [Re: lostzac] #404207
07/04/12 19:04
07/04/12 19:04
Joined: Jul 2005
Posts: 187
L
lostzac Offline OP
Member
lostzac  Offline OP
Member
L

Joined: Jul 2005
Posts: 187
Ok Now how would I move the current point the same distance/length as the temp point ? I have been reading up on Translation but haven't figured that out yet


John C Leutz II

Re: Vector Scale [Re: lostzac] #404212
07/04/12 22:54
07/04/12 22:54
Joined: Nov 2007
Posts: 2,568
Germany, BW, Stuttgart
MasterQ32 Offline
Expert
MasterQ32  Offline
Expert

Joined: Nov 2007
Posts: 2,568
Germany, BW, Stuttgart
vec_add(current, temp);


Visit my site: www.masterq32.de
Re: Vector Scale [Re: MasterQ32] #404237
07/05/12 14:03
07/05/12 14:03
Joined: Jul 2005
Posts: 187
L
lostzac Offline OP
Member
lostzac  Offline OP
Member
L

Joined: Jul 2005
Posts: 187
Ok this works, I am still cleaning it up but should provide a basis for anyone wanting to use multiple morphs

Code:
typedef struct
{
	var x;
	var y;
	var z;
}VERTEX;

typedef struct
{
	var weight;
	var num_points;  //Number of Verts in the Mesh
	VERTEX* morph[5000];
}MORPH;


function morph_target(ENTITY* ent)
{
	VECTOR Current;  //Current Mesh Vert Pos 
	VECTOR Target0;  //Morph1 Vert Pos
	VECTOR Target1;  //Morph2 Vert Pos
	VECTOR Base;     //Base or unchanged mesh vert pos
	VECTOR Diff;   
	VECTOR m;
	
	var a;
	
	mt.weight = value;
	
	//Curent Vertex Postion
	CONTACT* c = ent_getvertex(pc.mdl_Head,NULL,a);
	for(a=1;a<mt.num_points;a++)
	{
		//Base Model Postions

		Base.x = RFMORPH.morph[a].x;
		Base.y = RFMORPH.morph[a].y;
		Base.z = RFMORPH.morph[a].z;	
			
		//Target Morph Postion
		Target0.x = MORPH1.morph[a].x;
		Target0.y = MORPH1.morph[a].y;
		Target0.z = MORPH1.morph[a].z;	
		
		Target1.x = MORPH2.morph[a].x;
		Target1.y = MORPH2.morph[a].y;
		Target1.z = MORPH2.morph[a].z;			

		vec_set(m.x,Base.x);
			
		vec_lerp(Diff.x,Base.x,Target0.x,MORPH1.weight);
		m.x += Diff.x - Base.x;
		m.y += Diff.y - Base.y;
		m.z += Diff.z - Base.z;	
				
		vec_lerp(Diff.x,Base.x,Target1.x,MORPH2.weight);
		m.x += Diff.x - Base.x;
		m.y += Diff.y - Base.y;
		m.z += Diff.z - Base.z;		
		
		c.v = NULL;
		c.x = m.x;
		c.y = m.y;
		c.z = m.z;
		ent_setvertex(pc.mdl_Head,c,a);	
				
	}
	
	ent_fixnormals(pc.mdl_Head,0);
	c_updatehull(pc.mdl_Head,0);	
}




To use you would have to create a morph object and place each vert postion into the vertex struct of that morph. This can be done with the following script

Code:
function create_morph(ENTITY* ent, MORPH* m)
{
   var max = ent_status(ent,1);
   var a;
   VECTOR temp;
   m = malloc(sizeof(MORPH));
   for(a=1;a<max;a++)
   { 
        m.morph[a] = malloc(sizeof(VERTEX));
	vec_for_vertex(temp,obj,a);
	m.morph[a].x = temp.x;
	m.morph[a].y = temp.y;
	m.morph[a].z = temp.z;
   }
}




Hope someone can use this..Like I said its ruff and I am working on cleaning up but should point people in the right direction

Last edited by lostzac; 07/05/12 14:04.

John C Leutz II

Page 2 of 2 1 2

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