Forum

This forum is for swapping tips or ideas with fellow users, suggesting new features, or showing of what you have created with the system etc, there is no guarantee of an answer to questions posted in the forum. All support questions must be submitted via the Support ticket system

Welcome Guest 

Show/Hide Header

Welcome Guest, posting in this forum requires registration.





Pages: [1]
Author Topic: Getting the verts from MegaModify
ten_hands
Newbie
Posts: 2
Permalink
Post Getting the verts from MegaModify
on: May 30, 2012, 13:41
Quote

Hi, I need to get the position of a vertex from a mesh that is deformed with megafiers. I tried getting it from the "mesh" variable of MegaModify, but it keeps giving me the same position even if the mesh is deforming. Where can I get the verts os the deformed mesh from? Thanks

spookycat
Administrator
Posts: 148
Permalink
Post Re: Getting the verts from MegaModify
on: May 30, 2012, 13:47
Quote

Hi There
The final state of the deformed vertices can be found in the Vector3[] sverts param on the MegaModifyObject component (well it's actually on the base class MegaModifiers) so do something like

MegaModifyObject modobj = (MegaModifyObject>GetComponent<MegaModifyObject>(gameObject);
Vector3[] deformedVerts = modobj.sverts;

If you are going to use those to say attach an object or get a position there is a MegaAttach script that will do that for you

ten_hands
Newbie
Posts: 2
Permalink
Post Re: Getting the verts from MegaModify
on: May 30, 2012, 13:58
Quote

Thanks for the reply. I've written a simple function in MegaModifyObject:

public Vector3 GetPosition(int vertex)
{
	return sverts[vertex];
}

If I call this function from where I need to call it , it returs the same position everytime. If I call it internally(SetMesh() for example), it returns updated positions. What am I doing wrong? Thanks

spookycat
Administrator
Posts: 148
Permalink
Post Re: Getting the verts from MegaModify
on: May 30, 2012, 14:27
Quote

Well that should work just fine, word of warning though if you add code to any of the MegaFier source files and you download an update you will lose all your changes, best to try and add code externally, otherwise submit a ticket on the site for changes to the source you would like to see and I will add it in.

As for why you are not seeing any changes, are there enabled modifiers on the object? There should be no reason for that not working, the values in sverts are what are sent to Unity to update the mesh, could you just be looking at a vertex that hasnt actually been deformed. Other people are using sverts and that scipt in the video above uses sverts to position objects etc so it does work, there must be some little logic flaw somewhere, can you post more code of what it is you are trying to do?

Pages: [1]
Mingle Forum by cartpauj
Version: 1.0.34 ; Page loaded in: 0.026 seconds.