PDA

View Full Version : Spacewarp modified geometry


mobeen
02-07-2006, 04:57 AM
Hello all,

Problem definition:
I am trying to export a flag waving animation. I made the flag cloth out of a plane and applied a wave spacewarp on it. I animated the flag wave and it worked out ok in max. Now i am trying to export the mesh info by using
for f=0 to 100 do(--iterate over all frames
for i=1 to pMesh.numfaces do at time f( --for all faces
local fIndices = (getFace pMesh i)--get face indices
local v1=(getvert pMesh fIndices[1]) --get the corresponding vertices
local v2=(getvert pMesh fIndices[2])
local v3=(getvert pMesh fIndices[3])

...Write to file
)
)

Now when i load the data in my dxloader, i do not see the flag animating. Please note that if i do not modify the geometry using spacewarp and move the vertices in the ui, the animation exports correctly.

What I want to know:
1) Can i use getVert to get the modified vertex positions when a mesh is modified by a spacewarp?
2) How do i get the spacewarp modified vertex information?
Thanx in advance
Mobeen

rdg
02-07-2006, 06:46 AM
hello mobeen,

you could bake the geometry with Tools -> Snapshot, which would give you the mesh of the deformed object. Don't forget to delete the temporary mesh each frame.

I guess this is a workaround, but I hope it helps.

Georg

mobeen
02-07-2006, 07:15 AM
Thanx Georg
I did per frame snapshot and it worked. Although this is a workaround but why doesn't it work out without the snapshot???

Mobeen

rdg
02-07-2006, 07:35 AM
<smattering class="dangerous">
The modifier stack and how modification are passed in it causes this.
The spacewarp deformation are applied after something ...
Anyway the space warp doesnt deform the object, it just looks like it would ...
</smattering>

Georg

Bobo
02-07-2006, 02:30 PM
Hello all,

Problem definition:
I am trying to export a flag waving animation. I made the flag cloth out of a plane and applied a wave spacewarp on it. I animated the flag wave and it worked out ok in max. Now i am trying to export the mesh info by using
for f=0 to 100 do(--iterate over all frames
for i=1 to pMesh.numfaces do at time f( --for all faces
local fIndices = (getFace pMesh i)--get face indices
local v1=(getvert pMesh fIndices[1]) --get the corresponding vertices
local v2=(getvert pMesh fIndices[2])
local v3=(getvert pMesh fIndices[3])

...Write to file
)
)

Now when i load the data in my dxloader, i do not see the flag animating. Please note that if i do not modify the geometry using spacewarp and move the vertices in the ui, the animation exports correctly.

What I want to know:
1) Can i use getVert to get the modified vertex positions when a mesh is modified by a spacewarp?
2) How do i get the spacewarp modified vertex information?
Thanx in advance
Mobeen



You should use the method snapshotAsMesh() in MAXScript to create a TriMesh value in memory containing the world state of the vertices.
This method takes into account the Transformation Matrix AND Space Warps (which are applied after the node transforms). Unfortunately, this means that the object will be pre-transformed, so in your target application, you wouldn't have to transform the object into world space anymore. If you DO want to do that, you will have to model your flag in Max with respect to the world origin, so that it is placed relatively to the world as you want its pivot point to be placed in the target application.

Then you can run your code as it is on this virtual mesh (all mesh methods work on it) and export. Once you are done, delete the TriMesh value from memory.

for f=0 to 100 do(--iterate over all frames
local theMesh = at time f snapshotAsMesh pMesh --get a TriMesh at the frame f
for i=1 to theMesh.numfaces do ( --for all faces, don't need at time anymore
local fIndices = (getFace theMesh i)--get face indices
local v1=(getvert theMesh fIndices[1]) --get the corresponding vertices
local v2=(getvert theMesh fIndices[2])
local v3=(getvert theMesh fIndices[3])
...
)--end i loop
delete theMesh --release memory to avoid a memory leak
)--end f loop

mobeen
02-08-2006, 09:04 AM
Thanx Bobo for the info
Mobeen

CGTalk Moderation
02-08-2006, 09:04 AM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.