192192
193193
194194
195- # -------------------------------------- Global Scene Options -------------------------------
196- struct SceneOptions <: Modia3D.AbstractSceneOptions
195+ # -------------------------------------- Global SceneOptions -------------------------------
196+ struct SceneOptions
197197
198198 # Gravity field
199199 gravityField:: Modia3D.AbstractGravityField
@@ -417,7 +417,7 @@ Defines global properties of the system, such as the gravity field. Exactly one
417417
418418- `lightLatitude::Float64`: latitude angle of light position (0 = horizontal)
419419"""
420- mutable struct Scene
420+ mutable struct Scene <: Modia3D.AbstractScene
421421 name:: String # model name
422422 autoCoordsys:: Shapes.CoordinateSystem # Coordinate system that is automatically included (e.g. due to visualizeFrames=true)
423423 stack:: Vector{Object3D} # Stack to traverse objs
@@ -458,7 +458,75 @@ mutable struct Scene
458458 prismatic:: Vector{Prismatic}
459459 freeMotion:: Vector{FreeMotion}
460460
461- function Scene (sceneOptions:: SceneOptions = SceneOptions ())
461+
462+ function Scene (;gravityField = UniformGravityField (),
463+ useOptimizedStructure = true ,
464+ contactDetection = ContactDetectionMPR_handler (),
465+ nVisualContSupPoints = 5 ,
466+ gap = 0.001 ,
467+ enableContactDetection = true ,
468+ defaultContactSphereDiameter = 0.1 ,
469+ 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 ,
481+ enableVisualization = true ,
482+ animationFile = nothing ,
483+ visualizeGravity = true ,
484+ visualizeFrames = false ,
485+ visualizeConvexHulls = true ,
486+ visualizeBoundingBox = false ,
487+ visualizeContactPoints = false ,
488+ visualizeSupportPoints = false ,
489+ cameraDistance = 10.0 * nominalLength,
490+ cameraLongitude = 30 / 180 * pi ,
491+ cameraLatitude = 15 / 180 * pi ,
492+ lightDistance = 10.0 * nominalLength,
493+ lightLongitude = 60 / 180 * pi ,
494+ lightLatitude = 45 / 180 * pi )
495+
496+ sceneOptions = SceneOptions (gravityField = gravityField,
497+ useOptimizedStructure = useOptimizedStructure,
498+ contactDetection = contactDetection,
499+ nVisualContSupPoints = nVisualContSupPoints,
500+ gap = gap,
501+ enableContactDetection = enableContactDetection,
502+ defaultContactSphereDiameter = defaultContactSphereDiameter,
503+ elasticContactReductionFactor = elasticContactReductionFactor,
504+ nominalLength = nominalLength,
505+ 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,
515+ enableVisualization = enableVisualization,
516+ animationFile = animationFile,
517+ visualizeGravity = visualizeGravity,
518+ visualizeFrames = visualizeFrames,
519+ visualizeConvexHulls = visualizeConvexHulls,
520+ visualizeBoundingBox = visualizeBoundingBox,
521+ visualizeContactPoints = visualizeContactPoints,
522+ visualizeSupportPoints = visualizeSupportPoints,
523+ cameraDistance = cameraDistance,
524+ cameraLongitude = cameraLongitude,
525+ cameraLatitude = cameraLatitude,
526+ lightDistance = lightDistance,
527+ lightLongitude = lightLongitude,
528+ lightLatitude = lightLatitude)
529+
462530 exportAnimation = false
463531 if ! isnothing (sceneOptions. animationFile)
464532 (base, ext) = splitext (sceneOptions. animationFile)
@@ -468,6 +536,7 @@ mutable struct Scene
468536 @warn (" Extension of animationFile=$(sceneOptions. animationFile) is not 'json'.\n -> Animation export is disabled." )
469537 end
470538 end
539+
471540 new (" Scene" ,
472541 Shapes. CoordinateSystem (length= sceneOptions. defaultFrameLength),
473542 Vector{Object3D}[],
@@ -493,9 +562,55 @@ mutable struct Scene
493562 exportAnimation,
494563 Vector{animationStep}[],
495564 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
496583
584+
585+
586+ new("Scene",
587+ Shapes.CoordinateSystem(length=sceneOptions.defaultFrameLength),
588+ Vector{Object3D}[],
589+ Vector{Object3D}[],
590+ sceneOptions,
591+ false,
592+ false,
593+ false,
594+ false,
595+ false,
596+ Modia3D.KinematicAnalysis,
597+ Vector{SuperObjsRow}[],
598+ Vector{Object3D}[],
599+ Vector{Object3D}[],
600+ Vector{Object3D}[],
601+ Vector{Object3D}[],
602+ Vector{Object3D}[],
603+ Vector{Object3D}[],
604+ Vector{Vector{Int64}}[],
605+ Dict{Modia3D.AbstractJoint,Vector{Int64}}(),
606+ Vector{Union{Bool}}[],
607+ Vector{Vector{Basics.BoundingBox}}[],
608+ exportAnimation,
609+ Vector{animationStep}[],
610+ 0,
497611 Revolute[],
498612 Prismatic[],
499613 FreeMotion[])
500614 end
615+ =#
501616end
0 commit comments