@@ -194,126 +194,84 @@ end
194194
195195# -------------------------------------- Global SceneOptions -------------------------------
196196struct SceneOptions
197-
198197 # Gravity field
199198 gravityField:: Modia3D.AbstractGravityField
200199
201200 # Multibody structure
202201 useOptimizedStructure:: Bool # = true, if the optimized structure (with super objects, and common inertia) is used
203202
204- # Contact detection
205- contactDetection:: Modia3D.AbstractContactDetection
206- nVisualContSupPoints:: Int # amount of visual contact or support points
207- gap:: Float64
203+ # ## Contact detection ###
208204 enableContactDetection:: Bool # = true, if contact detection is enabled
209- defaultContactSphereDiameter :: Float64 # = true, if contact points are visualized
205+ contactDetection :: Modia3D.AbstractContactDetection
210206 elasticContactReductionFactor:: Float64 # c_res_used = c_res * elasticContactReductionFactor (> 0)
207+ gap:: Float64
208+
211209
212- # Visual defaults
213- nominalLength:: Float64 # [m] Nominal length of 3D system
214- defaultFrameLength:: Float64 # [m] Default for frame length if visualizeFrames = true (but not world frame)
215- defaultJointLength:: Float64 # [m] Default for the fixed length of a shape representing a joint
216- defaultJointWidth:: Float64 # [m] Default for the fixed width of a shape representing a joint
217- defaultForceLength:: Float64 # [m] Default for the fixed length of a shape representing a force (e.g., damper)
218- defaultForceWidth:: Float64 # [m] Default for the fixed width of a shape representing a force (e.g., spring, bushing)
219- defaultBodyDiameter:: Float64 # [m] Default for diameter of sphere representing the center of mass of a body
220- defaultWidthFraction:: Float64 # Default for shape width as a fraction of shape length
221- defaultArrowDiameter:: Float64 # [m] Default for arrow diameter (e.g., of forces, torques, sensors)
222- defaultN_to_m:: Float64 # [N/m] Default scaling of force arrows (length = force/defaultN_to_m)
223- defaultNm_to_m:: Float64 # [N.m/m] Default scaling of torque arrows (length = torque/defaultNm_to_m)
224-
225- # Animation
210+ # ## Animation and Visualization ###
226211 enableVisualization:: Bool # = true, if online animation is enabled
227212 animationFile:: Union{Nothing,String} # path&name of animation file
228- visualizeGravity:: Bool # = true, if gravity field shall be visualized (acceleration vector or field center)
229213 visualizeFrames:: Bool # = true, if all frames shall be visualized
230- visualizeConvexHulls:: Bool # = true, if convex hulls (used for contact detection) shall be visualized
231214 visualizeBoundingBox:: Bool # = true, if AABB's are visualized
232215 visualizeContactPoints:: Bool # = true, if contact points shall be visualized
233216 visualizeSupportPoints:: Bool # = true, if support points shall be visualized
217+ # Visual and Animation defaults
218+ nominalLength:: Float64 # [m] Nominal length of 3D system
219+ defaultFrameLength:: Float64 # [m] Default for frame length if visualizeFrames = true (but not world frame)
220+ nVisualContSupPoints:: Int # amount of visual contact or support points
221+ defaultContactSphereDiameter:: Float64 # = true, if contact points are visualized
234222 cameraDistance:: Float64 # Distance between world frame and camera position
235223 cameraLongitude:: Float64 # Longitude angle of camera position (0 = -y/-z/-x direction)
236224 cameraLatitude:: Float64 # Latitude angle of camera position (0 = horizontal)
237225 lightDistance:: Float64 # Distance between world frame and light position
238226 lightLongitude:: Float64 # Longitude angle of light position (0 = -y/-z/-x direction)
239227 lightLatitude:: Float64 # Latitude angle of light position (0 = horizontal)
240228
241- function SceneOptions (;gravityField = UniformGravityField (),
242- useOptimizedStructure = true ,
243- contactDetection = ContactDetectionMPR_handler (),
244- nVisualContSupPoints = 5 ,
245- gap = 0.001 ,
246- enableContactDetection = true ,
247- defaultContactSphereDiameter = 0.1 ,
248- elasticContactReductionFactor = 1.0 ,
249- nominalLength = 1.0 ,
250- defaultFrameLength = 0.2 * nominalLength,
251- defaultJointLength = nominalLength/ 10 ,
252- defaultJointWidth = nominalLength/ 20 ,
253- defaultForceLength = nominalLength/ 10 ,
254- defaultForceWidth = nominalLength/ 20 ,
255- defaultBodyDiameter = nominalLength/ 9 ,
256- defaultWidthFraction = 20 ,
257- defaultArrowDiameter = nominalLength/ 40 ,
258- defaultN_to_m = 1000 ,
259- defaultNm_to_m = 1000 ,
260- enableVisualization = true ,
261- animationFile = nothing ,
262- visualizeGravity = true ,
263- visualizeFrames = false ,
264- visualizeConvexHulls = true ,
265- visualizeBoundingBox = false ,
266- visualizeContactPoints = false ,
267- visualizeSupportPoints = false ,
268- cameraDistance = 10.0 * nominalLength,
269- cameraLongitude = 30 / 180 * pi ,
270- cameraLatitude = 15 / 180 * pi ,
271- lightDistance = 10.0 * nominalLength,
272- lightLongitude = 60 / 180 * pi ,
273- lightLatitude = 45 / 180 * pi )
274- @assert (nVisualContSupPoints > 0 )
229+ function SceneOptions (;gravityField = UniformGravityField (),
230+ useOptimizedStructure = true ,
231+ enableContactDetection = true ,
232+ contactDetection = ContactDetectionMPR_handler (),
233+ elasticContactReductionFactor = 1.0 ,
234+ gap = 0.001 ,
235+ enableVisualization = true ,
236+ animationFile = nothing ,
237+ visualizeFrames = false ,
238+ visualizeBoundingBox = false ,
239+ visualizeContactPoints = false ,
240+ visualizeSupportPoints = false ,
241+ nominalLength = 1.0 ,
242+ defaultFrameLength = 0.2 * nominalLength,
243+ nVisualContSupPoints = 5 ,
244+ defaultContactSphereDiameter = 0.1 ,
245+ cameraDistance = 10.0 * nominalLength,
246+ cameraLongitude = 30 / 180 * pi ,
247+ cameraLatitude = 15 / 180 * pi ,
248+ lightDistance = 10.0 * nominalLength,
249+ lightLongitude = 60 / 180 * pi ,
250+ lightLatitude = 45 / 180 * pi )
275251 @assert (gap > 0.0 )
276- @assert (defaultContactSphereDiameter > 0.0 )
277252 @assert (nominalLength > 0.0 )
278253 @assert (defaultFrameLength > 0.0 )
279- @assert (defaultJointLength > 0.0 )
280- @assert (defaultJointWidth > 0.0 )
281- @assert (defaultForceLength > 0.0 )
282- @assert (defaultForceWidth > 0.0 )
283- @assert (defaultBodyDiameter >= 0.0 )
284- @assert (defaultArrowDiameter > 0.0 )
285- @assert (defaultN_to_m > 0.0 )
286- @assert (defaultNm_to_m > 0.0 )
254+ @assert (nVisualContSupPoints > 0 )
255+ @assert (defaultContactSphereDiameter > 0.0 )
287256 @assert (cameraDistance > 0.0 )
288257 @assert (lightDistance > 0.0 )
289258
290259 sceneOptions = new (gravityField,
291260 useOptimizedStructure,
292- contactDetection,
293- nVisualContSupPoints,
294- gap,
295261 enableContactDetection,
296- defaultContactSphereDiameter ,
262+ contactDetection ,
297263 elasticContactReductionFactor,
298- nominalLength,
299- defaultFrameLength,
300- defaultJointLength,
301- defaultJointWidth,
302- defaultForceLength,
303- defaultForceWidth,
304- defaultBodyDiameter,
305- defaultWidthFraction,
306- defaultArrowDiameter,
307- defaultN_to_m,
308- defaultNm_to_m,
264+ gap,
309265 enableVisualization,
310266 animationFile,
311- visualizeGravity,
312267 visualizeFrames,
313- visualizeConvexHulls,
314268 visualizeBoundingBox,
315269 visualizeContactPoints,
316270 visualizeSupportPoints,
271+ nominalLength,
272+ defaultFrameLength,
273+ nVisualContSupPoints,
274+ defaultContactSphereDiameter,
317275 cameraDistance,
318276 cameraLongitude,
319277 cameraLatitude,
@@ -461,31 +419,20 @@ mutable struct Scene <: Modia3D.AbstractScene
461419
462420 function Scene (;gravityField = UniformGravityField (),
463421 useOptimizedStructure = true ,
464- contactDetection = ContactDetectionMPR_handler (),
465- nVisualContSupPoints = 5 ,
466- gap = 0.001 ,
467422 enableContactDetection = true ,
468- defaultContactSphereDiameter = 0.1 ,
423+ contactDetection = ContactDetectionMPR_handler () ,
469424 elasticContactReductionFactor = 1.0 ,
470- nominalLength = 1.0 ,
471- defaultFrameLength = 0.2 * nominalLength,
472- defaultJointLength = nominalLength/ 10 ,
473- defaultJointWidth = nominalLength/ 20 ,
474- defaultForceLength = nominalLength/ 10 ,
475- defaultForceWidth = nominalLength/ 20 ,
476- defaultBodyDiameter = nominalLength/ 9 ,
477- defaultWidthFraction = 20 ,
478- defaultArrowDiameter = nominalLength/ 40 ,
479- defaultN_to_m = 1000 ,
480- defaultNm_to_m = 1000 ,
425+ gap = 0.001 ,
481426 enableVisualization = true ,
482427 animationFile = nothing ,
483- visualizeGravity = true ,
484428 visualizeFrames = false ,
485- visualizeConvexHulls = true ,
486429 visualizeBoundingBox = false ,
487430 visualizeContactPoints = false ,
488431 visualizeSupportPoints = false ,
432+ nominalLength = 1.0 ,
433+ defaultFrameLength = 0.2 * nominalLength,
434+ nVisualContSupPoints = 5 ,
435+ defaultContactSphereDiameter = 0.1 ,
489436 cameraDistance = 10.0 * nominalLength,
490437 cameraLongitude = 30 / 180 * pi ,
491438 cameraLatitude = 15 / 180 * pi ,
@@ -503,20 +450,9 @@ mutable struct Scene <: Modia3D.AbstractScene
503450 elasticContactReductionFactor = elasticContactReductionFactor,
504451 nominalLength = nominalLength,
505452 defaultFrameLength = defaultFrameLength,
506- defaultJointLength = defaultJointLength,
507- defaultJointWidth = defaultJointWidth,
508- defaultForceLength = defaultForceLength,
509- defaultForceWidth = defaultForceWidth,
510- defaultBodyDiameter = defaultBodyDiameter,
511- defaultWidthFraction = defaultWidthFraction,
512- defaultArrowDiameter = defaultArrowDiameter,
513- defaultN_to_m = defaultN_to_m,
514- defaultNm_to_m = defaultNm_to_m,
515453 enableVisualization = enableVisualization,
516454 animationFile = animationFile,
517- visualizeGravity = visualizeGravity,
518455 visualizeFrames = visualizeFrames,
519- visualizeConvexHulls = visualizeConvexHulls,
520456 visualizeBoundingBox = visualizeBoundingBox,
521457 visualizeContactPoints = visualizeContactPoints,
522458 visualizeSupportPoints = visualizeSupportPoints,
@@ -537,52 +473,6 @@ mutable struct Scene <: Modia3D.AbstractScene
537473 end
538474 end
539475
540- new (" Scene" ,
541- Shapes. CoordinateSystem (length= sceneOptions. defaultFrameLength),
542- Vector{Object3D}[],
543- Vector{Object3D}[],
544- sceneOptions,
545- false ,
546- false ,
547- false ,
548- false ,
549- false ,
550- Modia3D. KinematicAnalysis,
551- Vector{SuperObjsRow}[],
552- Vector{Object3D}[],
553- Vector{Object3D}[],
554- Vector{Object3D}[],
555- Vector{Object3D}[],
556- Vector{Object3D}[],
557- Vector{Object3D}[],
558- Vector{Vector{Int64}}[],
559- Dict {Modia3D.AbstractJoint,Vector{Int64}} (),
560- Vector{Union{Bool}}[],
561- Vector{Vector{Basics. BoundingBox}}[],
562- exportAnimation,
563- Vector{animationStep}[],
564- 0 ,
565- Revolute[],
566- Prismatic[],
567- FreeMotion[])
568-
569- end
570- #=
571- function Scene(sceneOptions::SceneOptions = SceneOptions())
572-
573-
574- exportAnimation = false
575- if !isnothing(sceneOptions.animationFile)
576- (base, ext) = splitext(sceneOptions.animationFile)
577- if ext == ".json"
578- exportAnimation = true
579- else
580- @warn("Extension of animationFile=$(sceneOptions.animationFile) is not 'json'.\n-> Animation export is disabled.")
581- end
582- end
583-
584-
585-
586476 new (" Scene" ,
587477 Shapes. CoordinateSystem (length= sceneOptions. defaultFrameLength),
588478 Vector{Object3D}[],
@@ -612,5 +502,4 @@ mutable struct Scene <: Modia3D.AbstractScene
612502 Prismatic[],
613503 FreeMotion[])
614504 end
615- =#
616505end
0 commit comments