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
Question on ent_setvertex #403713
06/25/12 11:12
06/25/12 11:12
Joined: Jul 2005
Posts: 187
L
lostzac Offline OP
Member
lostzac  Offline OP
Member
L

Joined: Jul 2005
Posts: 187
Ok I am sure I am missing something basic, but after two days of trying to find it, I thought I would ask before I pull what little hair I have left out.

I am trying to create a morphing system for character creation in my game. I use to know how to do it with the old vec_for_mesh and vec_to_mesh functions but having difficulty with the ent_setvertex and ent_getvertex...

I have two structs each holding the positions of the verts for the base and morph...

Here is my function
Code:
function morph_ent(ENTITY* ent, morID,s)
{
	VECTOR start;
	VECTOR end;

	var percent = s / 100;
	
	var a;
	
	switch(morID)
	{
		case MORPH_HUMAN_MALE_JAW:
			for(a=0;a<humanMaleVerts;a++)
			{
				//Starting Postion
				start.x = morphMaleBase[0].vert[a].x;
				start.y = morphMaleBase[0].vert[a].y;
				start.z = morphMaleBase[0].vert[a].z;
				
				//Ending Postion
				end.x = morphMaleJaw[0].vert[a].x;
				end.y = morphMaleJaw[0].vert[a].y;
				end.z = morphMaleJaw[0].vert[a].z;
				
				CONTACT* c = ent_getvertex(ent,NULL,a);
				c.x = start.x + (percent* (end.x - start.x));
				c.y = start.y + (percent* (end.y - start.y));
				c.z = start.z + (percent* (end.z - start.z));
				ent_setvertex(ent,c,a);
			}
		break;
	}
	
	
	wait(1);
	c_updatehull(ent,0);
}


The idea is when the slider is moved , the verts on the entity should move a percentage the distance of the verts on the morph

I have tested the slider and know the value is being sent...but the entity is not changing at all.....any ideas of where to look or start, I have searched the forums for ideas, and have read the manual ...and still hopelessly lost...any help would be appreciated


John C Leutz II

Re: Question on ent_setvertex [Re: lostzac] #403714
06/25/12 11:44
06/25/12 11:44
Joined: Jul 2005
Posts: 187
L
lostzac Offline OP
Member
lostzac  Offline OP
Member
L

Joined: Jul 2005
Posts: 187
Update

after adding c.v = NULL;

I do get the model to preform sort of as is suppose to do, however the mesh and the texture are messed up..


John C Leutz II

Re: Question on ent_setvertex [Re: lostzac] #403992
06/30/12 11:01
06/30/12 11:01
Joined: Jul 2005
Posts: 187
L
lostzac Offline OP
Member
lostzac  Offline OP
Member
L

Joined: Jul 2005
Posts: 187
Laugh posted this in the wrong topic

anyways I solved the issue...Here is the code for anyone who wants it

Code:
function morph_target(ACTOR* pc, MORPH* mt, value)
{
	VECTOR start;
	VECTOR end;

	var percent = value / 100;
	
	var a;
	for(a=1;a<mt.num_points;a++)
	{
		//Starting Postion
		start.x = pc.baseFace.morph[a].x;
		start.y = pc.baseFace.morph[a].y;
		start.z = pc.baseFace.morph[a].z;
				
		//Ending Postion
		end.x = mt.morph[a].x;
		end.y = mt.morph[a].y;
		end.z = mt.morph[a].z;
			
		CONTACT* c = ent_getvertex(pc.mdl_Head,NULL,a);
		c.v = NULL;
		c.x = start.x + (percent* (end.x - start.x));
		c.y = start.y + (percent* (end.y - start.y));
		c.z = start.z + (percent* (end.z - start.z));
		ent_setvertex(pc.mdl_Head,c,a);
	}
	
	ent_fixnormals(pc.mdl_Head,0);
	c_updatehull(pc.mdl_Head,0);	
}



To use this you will need something that holds the positions for both base mesh and the morph target, I did my own custom struct for this...

If you have any question's feel free to pm me


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