Skip to content

Commit e251ea4

Browse files
author
Helge Mathee
committed
Merge pull request #28 from fabric-engine/case-18
Case 18
2 parents c388e9a + 4d7e0ae commit e251ea4

File tree

4 files changed

+67
-65
lines changed

4 files changed

+67
-65
lines changed

Apps/Sample/Simulation/Flocking.html

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,72 @@
6363

6464
<script type="text/javascript">
6565

66+
67+
FABRIC.SceneGraph.registerNodeType('Flock', {
68+
briefDesc: 'The Flock node is a Particles node which simulates flocking behaviour.',
69+
detailedDesc: 'The Flock node is a Particles node which simulates flocking behaviour through KL operators. ' +
70+
'The node is furthermore able to visualize the current flocking targets for each particle.',
71+
parentNodeDesc: 'Particles',
72+
optionsDesc: {
73+
displayDebugging: 'Set to true to draw the current flocking target for each particle.',
74+
},
75+
factoryFn: function(options, scene) {
76+
scene.assignDefaults(options, {
77+
displayDebugging: true
78+
});
79+
80+
options.createSpatialHashTable = true;
81+
options.animated = true;
82+
options.simulated = true;
83+
84+
var flockNode = scene.constructNode('Particles', options);
85+
flockNode.pub.addVertexAttributeValue('goals', 'Vec3');
86+
flockNode.pub.addVertexAttributeValue('neighborIndices', 'Integer[]');
87+
flockNode.pub.addVertexAttributeValue('neighborDistances', 'Scalar[]');
88+
89+
flockNode.pub.addVertexAttributeValue('initialized', 'Boolean', false );
90+
flockNode.pub.addVertexAttributeValue('debugDraw', 'DebugGeometry' );
91+
flockNode.pub.addUniformValue('displayDebugging', 'Boolean', options.displayDebugging, true );
92+
93+
flockNode.getAttributesDGNode().bindings.append(scene.constructOperator({
94+
operatorName: 'simulateParticles',
95+
srcFile: 'KL/flocking.kl',
96+
entryFunctionName: 'simulateFlock',
97+
parameterLayout: [
98+
'self.index',
99+
'self.initialized',
100+
101+
'self.positions',
102+
'self.velocities',
103+
'self.goals',
104+
'self.cellindices',
105+
'self.cellcoords',
106+
107+
'self.previousframe_positions<>',
108+
'self.previousframe_velocities<>',
109+
110+
'self.neighborinfluencerange',
111+
'uniforms.hashtable',
112+
113+
'globals.timestep',
114+
115+
'self.neighborIndices',
116+
'self.neighborDistances',
117+
'self.debugDraw',
118+
'uniforms.displayDebugging'
119+
]
120+
}));
121+
122+
123+
var debugGeometryDraw = scene.constructNode('DebugGeometryDraw', {
124+
dgnode: flockNode.getAttributesDGNode(),
125+
debugGemetryMemberName: 'debugDraw'
126+
});
127+
128+
return flockNode;
129+
}});
130+
131+
66132
$(document).ready(function() {
67133

68134
$('#play').button({
File renamed without changes.

Apps/Sample/UseCases/AnimationReviewTool/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -304,7 +304,7 @@
304304

305305
// create a frame operator to the texture
306306
texturedgnode.addMember('drawFrame','Boolean',true);
307-
texturedgnode.addMember('frameColor','RGBA',FABRIC.RT.rgba(255,255,255,255));
307+
texturedgnode.addMember('frameColor','RGBA',FABRIC.RT.rgba(255,0,0,255));
308308
texturedgnode.bindings.append(scene.constructOperator({
309309
operatorName: 'setFramePixels',
310310
entryFunctionName: 'setFramePixels',

SceneGraph/FABRIC.SceneGraph.Particles.js

Lines changed: 0 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -143,68 +143,4 @@ FABRIC.SceneGraph.registerNodeType('Particles', {
143143

144144
}});
145145

146-
FABRIC.SceneGraph.registerNodeType('Flock', {
147-
briefDesc: 'The Flock node is a Particles node which simulates flocking behaviour.',
148-
detailedDesc: 'The Flock node is a Particles node which simulates flocking behaviour through KL operators. ' +
149-
'The node is furthermore able to visualize the current flocking targets for each particle.',
150-
parentNodeDesc: 'Particles',
151-
optionsDesc: {
152-
displayDebugging: 'Set to true to draw the current flocking target for each particle.',
153-
},
154-
factoryFn: function(options, scene) {
155-
scene.assignDefaults(options, {
156-
displayDebugging: true
157-
});
158-
159-
options.createSpatialHashTable = true;
160-
options.animated = true;
161-
options.simulated = true;
162-
163-
var flockNode = scene.constructNode('Particles', options);
164-
flockNode.pub.addVertexAttributeValue('goals', 'Vec3');
165-
flockNode.pub.addVertexAttributeValue('neighborIndices', 'Integer[]');
166-
flockNode.pub.addVertexAttributeValue('neighborDistances', 'Scalar[]');
167-
168-
flockNode.pub.addVertexAttributeValue('initialized', 'Boolean', false );
169-
flockNode.pub.addVertexAttributeValue('debugDraw', 'DebugGeometry' );
170-
flockNode.pub.addUniformValue('displayDebugging', 'Boolean', options.displayDebugging, true );
171-
172-
flockNode.getAttributesDGNode().bindings.append(scene.constructOperator({
173-
operatorName: 'simulateParticles',
174-
srcFile: 'FABRIC_ROOT/SceneGraph/KL/flocking.kl',
175-
entryFunctionName: 'simulateFlock',
176-
parameterLayout: [
177-
'self.index',
178-
'self.initialized',
179-
180-
'self.positions',
181-
'self.velocities',
182-
'self.goals',
183-
'self.cellindices',
184-
'self.cellcoords',
185-
186-
'self.previousframe_positions<>',
187-
'self.previousframe_velocities<>',
188-
189-
'self.neighborinfluencerange',
190-
'uniforms.hashtable',
191-
192-
'globals.timestep',
193-
194-
'self.neighborIndices',
195-
'self.neighborDistances',
196-
'self.debugDraw',
197-
'uniforms.displayDebugging'
198-
]
199-
}));
200-
201-
202-
var debugGeometryDraw = scene.constructNode('DebugGeometryDraw', {
203-
dgnode: flockNode.getAttributesDGNode(),
204-
debugGemetryMemberName: 'debugDraw'
205-
});
206-
207-
return flockNode;
208-
}});
209-
210146

0 commit comments

Comments
 (0)