A way to reset a model's vertices after vec_to_mesh

Posted By: jumpman

A way to reset a model's vertices after vec_to_mesh - 10/04/11 00:26

is there a way to reset a model's vertices after performing a vec_to_mesh?
Posted By: EvilSOB

Re: A way to reset a model's vertices after vec_to_mesh - 10/04/11 00:47

Read up on ent_purge(ENTITY*). But I dunno if its CScript or lite-c only.

Be cautious and read up on it, it affects textures and decals too...

best of luck.
Posted By: jumpman

Re: A way to reset a model's vertices after vec_to_mesh - 10/04/11 03:05

hey evilsob, from what I saw in the manual, ent_purge removes the entity from memory :(, definitely not just resetting mesh. Thank you though. I dont think there is a way to do this frown
Posted By: EvilSOB

Re: A way to reset a model's vertices after vec_to_mesh - 10/04/11 04:31

ent_purge is DIFFERENT from ent_remove.

It only unloads the mesh and the texture and the decals.

Next time it appears on-screen, both mesh and texture are
reloaded from the MDL file in cache, thereby resetting them.
Posted By: bart_the_13th

Re: A way to reset a model's vertices after vec_to_mesh - 10/04/11 06:47

Wouldn't animating the model reset the mesh? I never used mesh transform before.
Using ent_purge may do the trick, but maybe you can also store the original mesh vertex position into an array before you do any transformation and use it to restore it back?
Posted By: jumpman

Re: A way to reset a model's vertices after vec_to_mesh - 10/04/11 22:05

hey everyone thanks for taking a look! The effect im looking for is very simple cloth noise/movement when the wind is blowing. The vertices are moving slightly to simulate cloth in the wind.

The tricky part however is that the character models are made with bones, which cannot be combined with vertex animation, so that rules out animating the mesh as suggested by Barth_the_13th.

Ent_purge, unless I am doing it wrong, didnt seem to reset the mesh. I ran the vertex movement script until the model looked wrinkly enough. turned the camera away so that no part of it was in view, ent_purged on keystroke, returned to look at the model and the model held the same vertex displacement.
Posted By: Superku

Re: A way to reset a model's vertices after vec_to_mesh - 10/04/11 22:09

There's a function called ent_reload, it increases the memory usage, though.
Posted By: Pappenheimer

Re: A way to reset a model's vertices after vec_to_mesh - 10/04/11 22:30

Originally Posted By: bart_the_13th
[...]store the original mesh vertex position into an array before you do any transformation and use it to restore it back?

That's what I do - within A8, but it shouldn't make a difference in A6.

Something like the following:
Code:
var vertices_stored[20][2000][4];
	
function store_model_vertices()
{
	if(vertices_store_slot <= vertices_stored_max)
	{
		vertices_store_slot += 1;
		vertices_stored_last = vertices_store_slot;
		vertices_max = ent_status(my, 0);
		vertex_counter = 0;
		while(vertex_counter < vertices_max)//save all vertices in an array to get them for resetting the model
		{
			vec_for_mesh(temp, me, vertex_counter);
			vertices_stored[vertices_store_slot][vertex_counter][0] = vertex_counter;
			vertices_stored[vertices_store_slot][vertex_counter][1] = temp.x;
			vertices_stored[vertices_store_slot][vertex_counter][2] = temp.y;
			vertices_stored[vertices_store_slot][vertex_counter][3] = temp.z;
			vertex_counter += 1;
		}
		vertex_counter = 0;
	}
}

function reset_model_vertices()
{
	if(vertices_store_slot < vertices_stored_last)
	{
		vertices_store_slot += 1;
		vertices_max = ent_status(my, 0);
		vertex_counter = 0;
		while(vertex_counter < vertices_max)
		{
			temp.x = vertices_stored[vertices_store_slot][vertex_counter][1];
			temp.y = vertices_stored[vertices_store_slot][vertex_counter][2];
			temp.z = vertices_stored[vertices_store_slot][vertex_counter][3];
			vec_to_mesh(temp, me, vertex_counter);
				
			vertex_counter += 1;
		}
		vertex_counter = 0;
		ent_fixnormals(my,0);//recalculate the normal after moving the vertices
		c_updatehull(me,1);//recalculate the collision
	}
}


Posted By: EvilSOB

Re: A way to reset a model's vertices after vec_to_mesh - 10/05/11 09:41

OK, so ent-purge was a bust. Sounds like you tested it sufficiently to me.

Next idea... NO idea on memory usage or effect on bones/animation ...
Code:
// lite_c
ent_morph(player, player.type);

// c_script (or my ATTEMPTS s CScript anyway)
ent_morph(player, str_for_entfile(NULL, player));
or
STRING* temp_name = str_create("#256");
str_for_entfile(temp_name, player));
ent_morph(player, temp_name);


© 2024 lite-C Forums