PDA

View Full Version : Simulation problem


NRat
10-15-2007, 03:00 PM
Hi,
i have problem combinig shape animation and softbody (or syflex) in one object.
For example, i have a sphere and a cube. Sphere is translated by shape animation and interferes with cube. So i need a softbody deformation of the sphere by collision with the cube.
I really tried different ways of combining them, but they doesnt work.
If you know the working one plz let me know... http://www.xsibase.com/forum/YaBBImages/smiley.gif

Thanx a lot...

XSI 6.01

matt8
10-16-2007, 09:43 AM
Hey there NRat,

welcome to the horrible world of non-unified symulation systems. This, as I'm sure you know, is not xsi's strength. I do have a work around for you, but it is very dependent on how willing you are to settle for the results that you are going to get.

Basicly what you can do is extract each of your shapes as a peice of geometry. Then simulate each of these peices seperately. Then create one master peice of geometry that selects all of the symulated geametry as shapes. Then you can animate the weight between each shape basicly as you would have on the original mesh. Hope this makes sense....

I have used this method successfully in the past, but I've also had situations where it didn't quite look right. Maybe it will work for you.

m@

NRat
10-16-2007, 06:30 PM
Hi matt8,
OMG - you described smth terrible :)
But i didnt quite understand - you mean simulating shapes frame by frame?!
If yes - its impossible - a lot of frames, heavy geometry, not much time... :)
If not - can you explain a little bit more detailed?

Thanx a lot...

PerfectLine
10-16-2007, 09:38 PM
If I am reading you right you are trying to make the sphere act like cloth and deform over a moving solid cube right?

In any case there are many ways to make syflex and hardbody dynamics work together with little trouble. The problem you are having is probably due to trying to do both at the same time.

Can you be more specific? I am sure there are ways to get exactly what you need in a few steps.

NRat
10-17-2007, 08:26 AM
2PerfectLine
You didn quite understand my problem - i need to combine shape animation and cloth simulation in one object. It must be deformed by shapes and simulation at the same time.

matt8
10-17-2007, 02:31 PM
Hi matt8,
OMG - you described smth terrible :)
But i didnt quite understand - you mean simulating shapes frame by frame?!
If yes - its impossible - a lot of frames, heavy geometry, not much time... :)
If not - can you explain a little bit more detailed?

Thanx a lot...

OK let me try explain using a simple example. Lets say you have a sphere that changes shape over 100 frames from being a perfect sphere (shape1) to being a stretched sphere (shape2). So this basic example has two shapes. OK if we extract the two shapes and remove the shape animation from each, we will have two sphere's one that is perfectly round... another that is stretched.

Now you make the perfect sphere a soft body and do a simulation. Then you make the stretched sphere a soft body and do a simulation. Now you have a scene with two objects each of which has a softbody simulation on it.

Now you get a thrid sphere that has no deformers on it, and you pick the two simulated sphere's as shapes for this new sphere. So now you can blend between the two simulations by animating the weight of the shape clips on the third sphere. Thus getting a simulation that has shape animation on it.

Hope this explains better.
m@

NRat
10-17-2007, 07:41 PM
Oh, ive got your idea, Matt, but i dont think it works in my case.
The problem is that i dont have separate shapes - i have one plotted from "pointcache" shape, that ive got from other department. And i have to simulate softbody over it.
Ive made a fake for a moment, but it doesnt look good. (

janimatic
02-10-2008, 09:11 PM
hey it looks like an old thread, sorry if it's too late for answering.

Here is what i would do :
1 - use syflex pin
2 - use weighmap modulated shapes

1 - use syflex pin
- Import your already animated piece of tissue "animClothMesh"
- Duplicate freeze and apply cloth to the the copy "simClothMesh"
- tag select the vertices that should exactly follow the existing animation, then
shift select "animClothMesh", syflex>create pin.

2 - use weighmap modulated shapes
You might say that you want to add a smooth trasition between pined vertices and syflex simulation. I'd say that syflex should make the trasition natural, but here is a solution that let you paint a weightmap to bring back the animated version ("animClothMesh") gradually on the sycloth parts.
- create a 3rd object that will blend anim and sim meshes
- keep it selected, select shape key select anim and sim meshes, right clic. Set each shape weight to 0.5
- create a weighmap on the belnd shape mesh
- use lmWeightMapTools to add an expression map that let you create a 2nd weight map which is the inverse of th 1st map (the operator is constantly updated).
- in the shpe menu there is the modulate shape with weightmap command, use each map with each shape...
- you can know interactively paint the anim sim blending while playing back syflex simulation.

Here is a script that does step 2 for you (you need to change object names, or add selection methods)


/*

sy cloth / anim blending

*/
var clothAnimMesh = Dictionary.GetObject( "cube" );
var dups = SIDuplicate(clothAnimMesh.Fullname, 2);
var clothSimMesh = dups(0);
var clothBlendMesh = dups(1);

var colMesh = Dictionary.GetObject( "cube3" , false);

//pointcache
//apply point cache reader

ApplyOp("POXSI", clothAnimMesh.Fullname, siUnspecified, siPersistentOperation, null, 0);
AddExpr(clothAnimMesh.Fullname + "." + clothAnimMesh.Type + ".PO_XSI_Reader.POTime", "T", true);

//cloth
//apply syCloth

var clus = CreateCluster( clothSimMesh.Fullname + ".pnt
" )
var clu = clus.Item(0)
clu.Name = "ClothCls"
var massMap = CreateWeightMap( "WeightMap", clu, "MassMap", "Weight Map Property", 0 )
SetValue ( massMap(0).Fullname + ".weightmapop.weight", 1)
var stiffMap = CreateWeightMap( "WeightMap", clu, "StiffMap", "Weight Map Property", 0 )
SetValue (stiffMap(0).Fullname + ".weightmapop.weight", 1)
var clo = ApplyOperator( "syCloth", clothSimMesh.FullName + ";"
+ massMap(0).FullName + ";"
+ stiffMap(0).FullName )
var stf = ApplyOperator( "syProperties", clo )
//selectobj clo
SetValue ( clo.FullName + ".FirstFrame", GetValue( "PlayControl.In" ) )
SetKey ( clo.FullName + ".Update", 1, 1 )


//Collision
if (colMesh!=null) {
//colMesh = Dictionary.GetObject( "cube3" );
var pnts = CreateCluster( clothSimMesh.FullName + ".pnt
" )
var pols = CreateCluster( colMesh.FullName + ".poly
" )
var col = applyoperator( "syCollide", clo.fullname + ";"
+ pnts(0).fullname + ";"
+ colMesh.fullname +";"+ colMesh.kinematics.fullname +";"
+ pols(0).fullname +";"+ clothSimMesh.kinematics.fullname )
pnts(0).Name = (col.name + "Pnts")
pols(0).Name = (col.name + "Pols")
}

//blend shapes

var clothBlendMesh = Dictionary.GetObject( "cube2" );
//apply blend shape
var shapeKeys = SelectShapeKey(clothBlendMesh.Fullname,
clothAnimMesh.Fullname+","+clothSimMesh.Fullname,
siShapeObjectReferenceMode, true, true);
var shapeKey = shapeKeys(0);


var clothAnimMesh_shapeKey = shapeKeys(0);
var clothSimMesh_shapeKey = shapeKeys(1);

var shapeWeightsProp = Dictionary.GetObject(clothBlendMesh.Fullname+".ShapeWeights")
LogMessage ("shapeWeightsProp :" + shapeWeightsProp.Fullname)
for (var i=0; i< shapeWeightsProp.Parameters.Count; i++) {
LogMessage ("param :" + shapeWeightsProp.Parameters(i).Fullname)
LogMessage ("param :" + shapeWeightsProp.Parameters(i).MasterParameter.FullName)
RemoveAnimation( shapeWeightsProp.Parameters(i).MasterParameter.FullName , 1 , null);
SetValue( shapeWeightsProp.Parameters(i).MasterParameter.FullName , 0.5 );
}

SelectObj( clothBlendMesh.Fullname, null, null);
var clus2 = CreateCluster( clothBlendMesh.Fullname + ".pnt
" )
var clu2 = clus2.Item(0)
clu2.Name = "WeightMapCls"
CreateWeightMap("WeightMap", null, "Weight_Map", null, null);

SelectObj( clothBlendMesh.Fullname, null, null);
lmWeightMapTools_lmExpressionMapApplyCmd();
lmWeightMapTools_lmExpressionMapAddConnexionCmd(
clothBlendMesh.Fullname + ".polymsh.cls.WeightMapCls.ExpressionWeightMap_ExpressionMap",
clothBlendMesh.Fullname+".polymsh.cls.WeightMapCls.Weight_Map");
SetValue(clothBlendMesh.Fullname+".polymsh.cls.WeightMapCls.ExpressionWeightMap_ExpressionMap.Expression", "1 - w0", null);

ApplyOp("ClsKeyWeightMapOp",
clothBlendMesh.Fullname+".polymsh.cls.cube_ShapeKey.cube1_ShapeKey;"
+clothBlendMesh.Fullname+".polymsh.cls.WeightMapCls.Weight_Map",
3, siPersistentOperation, null, 0);

ApplyOp("ClsKeyWeightMapOp",
clothBlendMesh.Fullname+".polymsh.cls.cube_ShapeKey.cube_ShapeKey;"
+clothBlendMesh.Fullname+".polymsh.cls.WeightMapCls.ExpressionWeightMap",
3, siPersistentOperation, null, 0);


SelectObj(clothBlendMesh.Fullname+".polymsh.cls.WeightMapCls.Weight_Map", null, null);

NRat
02-11-2008, 05:59 PM
janimatic

Thanx a lot for your detailed answer!
The shot is done two months ago and i faked it with lmWeightMapTools connected to distance between objects.
I appreciate your attention and i will try your decision.

Thanx

janimatic
02-12-2008, 10:09 PM
you're welcome
In fact I was just working on a similar problem.

There is a little mistake : blendshape sliders should all be set to 1.0 so the weighmaps properly do the job of blending shapes locally.
Please correct this line
SetValue( shapeWeightsProp.Parameters(i).MasterParameter.FullName , 0.5 );
like this

SetValue( shapeWeightsProp.Parameters(i).MasterParameter.FullName , 1.0 );


best regards

CGTalk Moderation
02-12-2008, 10:09 PM
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.