Skip to content

Commit 549224b

Browse files
author
Helge Mathee
committed
bullet softbodies to use tori
1 parent 2418c44 commit 549224b

File tree

2 files changed

+43
-79
lines changed

2 files changed

+43
-79
lines changed

Apps/Sample/Bullet/Bullet_Softbody.html

Lines changed: 15 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -106,36 +106,24 @@
106106
// create a simulation world
107107
var bulletWorldNode = scene.constructNode('BulletWorldNode');
108108

109+
var torusNode = scene.constructNode('Torus', {detail: 24});
109110

110-
// import the cow
111-
var assets = scene.importAssetFile('../Alembic/Models/cow.abc', {
112-
dependentNode: viewport,
111+
var softBodyNode = bulletWorldNode.addSoftBody('Torus',new FABRIC.RT.BulletSoftBody({
112+
trianglesNode: torusNode,
113+
transform: FABRIC.RT.xfo({
114+
tr: new FABRIC.RT.Vec3(0,16,0),
115+
ori: new FABRIC.RT.Quat().setFromAxisAndAngle(new FABRIC.RT.Vec3(1,-1,0),190)
116+
}),
117+
recover: 0.01,
118+
pressure: 5,
119+
piterations: 4,
120+
}));
121+
122+
scene.constructNode('Instance', {
123+
geometryNode: softBodyNode,
124+
materialNode: phongMaterial
113125
});
114126

115-
assets['cow'].addOnLoadSuccessCallback(function(){
116-
// add a softbody to the sim
117-
var parsedNodes = assets['cow'].getParsedNodes();
118-
var softBodyNode = bulletWorldNode.addSoftBody('Cow'+i,new FABRIC.RT.BulletSoftBody({
119-
trianglesNode: parsedNodes['/polymsh/polymshShape'],
120-
transform: FABRIC.RT.xfo({
121-
tr: new FABRIC.RT.Vec3(0,10,0),
122-
ori: new FABRIC.RT.Quat().setFromAxisAndAngle(new FABRIC.RT.Vec3(1,-1,0),190)
123-
}),
124-
recover: 0.01,
125-
//conservation: 0.6,
126-
pressure: 5,
127-
piterations: 4,
128-
}));
129-
130-
scene.constructNode('Instance', {
131-
geometryNode: softBodyNode,
132-
materialNode: phongMaterial
133-
});
134-
135-
$('#loadingDialog').dialog('close');
136-
viewport.redraw();
137-
});
138-
139127
FABRIC.appendOnResolveAsyncTaskCallback(function(label, nbRemaining, doneWeight, totalWeight) {
140128
$('#loadingProgressBar').progressbar({
141129
value: (1.0-(doneWeight/totalWeight))*100

Apps/Sample/Bullet/Bullet_SoftbodyAnchors.html

Lines changed: 28 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -167,60 +167,36 @@
167167
radius: 0.75
168168
});
169169

170-
// import the cow
171-
var assets = scene.importAssetFile('../Alembic/Models/cow.abc', {
172-
dependentNode: viewport
170+
var torusNode = scene.constructNode('Torus', {detail: 24});
171+
172+
var softBodyNode = bulletWorldNode.addSoftBody('Torus',new FABRIC.RT.BulletSoftBody({
173+
trianglesNode: torusNode,
174+
transform: FABRIC.RT.xfo({
175+
tr: new FABRIC.RT.Vec3(0,10,0),
176+
}),
177+
recover: 0.01,
178+
pressure: 5,
179+
piterations: 4,
180+
}));
181+
182+
scene.constructNode('Instance', {
183+
geometryNode: softBodyNode,
184+
materialNode: phongMaterial
173185
});
186+
187+
bulletWorldNode.addAnchor('toCubeB',new FABRIC.RT.BulletAnchor({
188+
softBodyNodeIndices: [701,702,703,704,705,706]
189+
}),
190+
'CubeA',
191+
'Torus'
192+
);
174193

175-
assets['cow'].addOnLoadSuccessCallback(function(){
176-
// add a softbody to the sim
177-
var parsedNodes = assets['cow'].getParsedNodes();
178-
var softBodyNode = bulletWorldNode.addSoftBody('Cow',new FABRIC.RT.BulletSoftBody({
179-
trianglesNode: parsedNodes['/polymsh/polymshShape'],
180-
transform: FABRIC.RT.xfo({
181-
tr: new FABRIC.RT.Vec3(0,10,0),
182-
}),
183-
recover: 0.01,
184-
//conservation: 0.6,
185-
pressure: 5,
186-
piterations: 4,
187-
}));
188-
189-
scene.constructNode('Instance', {
190-
geometryNode: softBodyNode,
191-
materialNode: phongMaterial
192-
});
193-
194-
bulletWorldNode.addAnchor('toCubeA',new FABRIC.RT.BulletAnchor({
195-
softBodyNodeIndices: [1941, 1943, 1951, 1959, 1966, 1988, 1990, 2729, 2731, 2732, 2733, 2734,
196-
2735, 2736, 2737, 2738, 2739, 2740, 2741, 2742, 2743, 2744, 2745, 2746,
197-
2747, 2748, 2749, 2750, 2751, 2752, 2753, 2754, 2755, 2756, 2757, 2758,
198-
2759, 2760, 2761, 2762, 2763, 2764, 2765, 2766, 2767, 2768, 2769, 2770,
199-
2771, 2772, 2773, 2774, 2775, 2776, 2777, 2778, 2779, 2780, 2781, 2782,
200-
2783, 2784, 2785, 2786, 2787, 2788, 2789, 2790, 2791, 2792, 2793, 2794,
201-
2795, 2796, 2797, 2798, 2799, 2812, 1973, 1982, 1984, 1986, 2806]
202-
}),
203-
'CubeA',
204-
'Cow'
205-
);
206-
bulletWorldNode.addAnchor('toCubeB',new FABRIC.RT.BulletAnchor({
207-
softBodyNodeIndices: [0, 1, 2, 21, 22, 23, 24, 25, 26, 29, 30, 33, 34, 35, 36, 37, 38, 39,
208-
43, 44, 45, 46, 61, 62, 63, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75,
209-
76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 150, 151,
210-
152, 153, 154, 155, 156, 157, 160, 161, 162, 1014, 1015, 1016, 1021, 1022,
211-
1023, 1024, 1025, 1026, 1027, 1028, 1029, 1030, 1031, 1033, 1034, 1035, 1036,
212-
1037, 1038, 1039, 1040, 1041, 1042, 1043, 1046, 1047, 1048, 1051, 1052, 1053,
213-
1054, 1055, 1058, 1060, 1061, 1062, 1064, 1075, 1076, 1082, 1083, 2107, 2108,
214-
2109, 2110, 2114, 2115, 2116, 2117, 2118, 2119, 2120, 2121, 2122, 2123, 2124,
215-
2125, 2126, 2127, 2128, 2129, 2130, 2131, 2135, 2136]
216-
}),
217-
'CubeB',
218-
'Cow'
219-
);
220-
221-
$('#loadingDialog').dialog('close');
222-
viewport.redraw();
223-
});
194+
bulletWorldNode.addAnchor('toCubeA',new FABRIC.RT.BulletAnchor({
195+
softBodyNodeIndices: [0,1,2,3,4,5,6,7,8]
196+
}),
197+
'CubeB',
198+
'Torus'
199+
);
224200

225201
FABRIC.appendOnResolveAsyncTaskCallback(function(label, nbRemaining, doneWeight, totalWeight) {
226202
$('#loadingProgressBar').progressbar({

0 commit comments

Comments
 (0)