Author : winged doom


Reply
Reply
 
Thread Tools Display Modes
poopipe's Avatar
Old (#1)
How do I persuade unity to recognise that a mesh has changed shape?

basically I'm trying to stick a box to the surface of a rippling plane

I've stolen the example code for deforming a mesh according to a sine wave but seem to be unable to get a raycast from the box to recognise the changing shape of the plane

I'm recalculating normals and bounds at the end of the mesh deformation script and couldn't see anything in the reference that said "recalculate where all the vertices and stuff are"

Am I missing something? I'm using free unity if that makes a difference




Thanks in advance
Offline , triangle, 397 Posts, Join Date Dec 2010,  
   Reply With Quote

LoTekK's Avatar
Old (#2)
if you're using the official examples (Procedural), have a look at the "Sculpt Vertices" scene (in particular the "PaintVertices" script. From the looks of it, you have to reapply the new mesh to the mesh collider component for it to update that as well.
FlowMap Painter v0.9.2

teckArtist.com
LoTekK.com

"Has anyone really been far even as decided to use even go want to do look more like?" -DKK
Offline , dedicated polycounter, 1,395 Posts, Join Date Jan 2006, Location Singapore Send a message via MSN to LoTekK Send a message via Skype™ to LoTekK  
   Reply With Quote

cupsster's Avatar
Old (#3)
Procedural exmaples should work even with free version but I'm not sure if all of them
Offline , triangle, 359 Posts, Join Date Jan 2010, Location Slovakia Send a message via Skype™ to cupsster  
   Reply With Quote

commander_keen's Avatar
Old (#4)
You assign Mesh.vertices to modify the vertices. Note that you cannot assign individual elements of Mesh.vertices, you have to assign the entire array, for instance:

Code:
Vector3[] verts = myMesh.vertices;
verts[0] = new Vector3(0,10,0);
myMesh.vertices = verts;
Offline , polygon, 618 Posts, Join Date Jan 2005, Location Los Gatos, CA  
   Reply With Quote

poopipe's Avatar
Old (#5)
Lotekk. a bit more reading suggested the same thing. im a little nervous about chucking that much data around on every update but its worth a pop.

Presumably i could use a lower res mesh collider and apply the ripple to that as well?
Cheers

Last edited by poopipe; 03-17-2012 at 03:41 AM..
Offline , triangle, 397 Posts, Join Date Dec 2010,  
   Reply With Quote

LoTekK's Avatar
Old (#6)
Quote:
Originally Posted by poopipe View Post
Lotekk. a bit more reading suggested the same thing. im a little nervous about chucking that much data around on every update but its worth a pop.

Presumably i could use a lower res mesh collider and apply the ripple to that as well?
Cheers
One thing you could try doing is sticking a rigidbody component on the mesh (sans gravity, etc). Physx apparently does an optimisation pass on collision, which is [initially] expensive to do, but I doesn't do this for rigidbodies, which should help the update loop.
FlowMap Painter v0.9.2

teckArtist.com
LoTekK.com

"Has anyone really been far even as decided to use even go want to do look more like?" -DKK
Offline , dedicated polycounter, 1,395 Posts, Join Date Jan 2006, Location Singapore Send a message via MSN to LoTekK Send a message via Skype™ to LoTekK  
   Reply With Quote

poopipe's Avatar
Old (#7)
Is that going to make a difference on phones? The theory is to put it out on android eventually

commander_keen
I have the deformation bit all sorted (didn't post back earlier as I was on my phone and edits are a pain), its getting a raycast to recognise that the mesh has changed that wasn't working out.

ill try lotekk's suggestion a little later - I'll also be looking into simply moving the box according to a kind of global sine wave thingy which i imagine will be a lot faster but will lose me quite a lot of useful information

Last edited by poopipe; 03-17-2012 at 12:08 PM..
Offline , triangle, 397 Posts, Join Date Dec 2010,  
   Reply With Quote

poopipe's Avatar
Old (#8)
Nice one chaps, that all worked great and with a little bit of additional mathematical magic I've now got a box happily driving over a rolling sea in response to mouse clicks.
Offline , triangle, 397 Posts, Join Date Dec 2010,  
   Reply With Quote

Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Copyright 1998-2012 A. Risch