Skip to content

Commit ed9fe75

Browse files
Merge pull request #37 from ModiaSim/an_initializeScene
An initialize scene
2 parents 6411883 + 0efa9a6 commit ed9fe75

File tree

10 files changed

+132
-129
lines changed

10 files changed

+132
-129
lines changed

src/Composition/_module.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ export deleteMaterialLastContactDictContactEnd
4545

4646
export NoGravityField, UniformGravityField, PointGravityField, gravityAcceleration
4747
export G, EarthMass, EarthRadius
48-
export Scene, SceneOptions
48+
export Scene
4949
export upwardsDirection, cameraPosition
5050
export animationData, animationStep
5151

src/Composition/dynamicCollision.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ function visualizeContactAndSupportPoints(ch, world)
189189
end
190190
end
191191

192-
printWarnContSupPoints(nVisualContSupPoints) = @warn("If all contact points and/or support points should be visualized please set nVisualContSupPoints = $nVisualContSupPoints in SceneOptions.")
192+
printWarnContSupPoints(nVisualContSupPoints) = @warn("If all contact points and/or support points should be visualized please set nVisualContSupPoints = $nVisualContSupPoints in Scene.")
193193

194194
# the sphere is visible and its absolute position is updated (this point was computed by the mpr algorithm)
195195
function setVisualizationContactProperties!(obj::Composition.Object3D, transparency::Float64, point::SVector{3,Float64})

src/Composition/dynamics.jl

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ function getJointsAndObject3DsWithoutParents!(evaluatedParameters,
66
if typeof(value) == Object3D
77
if value.parent === value
88
push!(object3DWithoutParents, value)
9-
elseif typeof(value.feature) == Modia3D.Composition.SceneOptions
10-
error(value.path, ": Object3D has a parent and defines SceneOptions!")
9+
elseif typeof(value.feature) == Modia3D.Composition.Scene
10+
error(value.path, ": Object3D has a parent and defines Scene!")
1111
end
1212

1313
elseif typeof(value) <: Modia3D.AbstractJoint
@@ -66,10 +66,10 @@ end
6666

6767

6868
function initAnalysis2!(world)
69-
# Construct Scene(..) object
69+
# use Scene(..) of world object
7070
Modia3D.Composition.EmptyObject3DFeature
71-
if typeof(world.feature) <: Modia3D.SceneOptions
72-
scene = Modia3D.Scene(world.feature)
71+
if typeof(world.feature) <: Modia3D.Scene
72+
scene = world.feature
7373
else
7474
scene = Modia3D.Scene()
7575
end
@@ -150,9 +150,11 @@ function setModiaJointVariables!(id::Int, _leq_mode, instantiatedModel::ModiaLan
150150
separateObjects[id] = mbs
151151

152152
# Print
153+
#=
153154
if false
154155
printScene(scene)
155156
end
157+
=#
156158

157159
if scene.visualize
158160
TimerOutputs.@timeit instantiatedModel.timer "Modia3D_0 initializeVisualization" Modia3D.Composition.initializeVisualization(Modia3D.renderer[1], scene.allVisuElements)

src/Composition/handler.jl

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -299,8 +299,7 @@ function build_superObjs!(scene::Scene, world::Object3D)::Nothing
299299
end
300300

301301

302-
function visualizeWorld!(world::Object3D; sceneOptions = SceneOptions())::Nothing
303-
scene = Scene(sceneOptions)
302+
function visualizeWorld!(world::Object3D; scene = Scene())::Nothing
304303
scene.analysis = Modia3D.KinematicAnalysis
305304
initAnalysis!(world, scene)
306305
updatePosition!(world)
@@ -400,7 +399,7 @@ function chooseAndBuildUpTree(world::Object3D, scene::Scene)
400399
else
401400
build_tree!(scene, world)
402401
if scene.options.enableContactDetection
403-
error("Collision handling is only possible with the optimized structure. Please set useOptimizedStructure = true in Modia3D.SceneOptions.")
402+
error("Collision handling is only possible with the optimized structure. Please set useOptimizedStructure = true in Modia3D.Scene.")
404403
end
405404
end
406405
if length(scene.allVisuElements) > 0

src/Composition/object3D.jl

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ mutable struct Object3D <: Modia3D.AbstractObject3D
108108
I_CM::SMatrix{3,3,Float64,9} # Inertia matrix at Center of Mass resolved in a frame in the center of mass that is parallel to Object3D in [kg*m^2]
109109

110110
# Additional information associated with Object3D
111-
feature::Union{Modia3D.AbstractObject3DFeature, Modia3D.AbstractSceneOptions} # Optional feature associated with Object3D
111+
feature::Union{Modia3D.AbstractObject3DFeature, Modia3D.AbstractScene} # Optional feature associated with Object3D
112112
twoObject3Dobject::Vector{Modia3D.AbstractTwoObject3DObject} # Optional AbstractTwoObject3DObject object associated with Object3D
113113
hasCutJoint::Bool # = true if it has a cut joint
114114
hasForceElement::Bool # = true if it has a force element
@@ -123,7 +123,7 @@ mutable struct Object3D <: Modia3D.AbstractObject3D
123123

124124
# = True: Coordinate system of Object3D is always visualized
125125
# = False: Coordinate system of Object3D is never visualized
126-
# = Inherited: Coordinate system of Object3D is visualized, if SceneOptions(visualizeFrames=true)
126+
# = Inherited: Coordinate system of Object3D is visualized, if Scene(visualizeFrames=true)
127127
visualizeFrame::Modia3D.Ternary
128128
visualizationFrame::Vector{Object3D} # If to be visualized, the Object3D holding the coordinate system.
129129

@@ -496,7 +496,7 @@ hasParent( obj::Object3D) = !(obj.parent === obj)
496496
hasNoParent( obj::Object3D) = obj.parent === obj
497497
hasChildren( obj::Object3D) = length(obj.children) > 0
498498
hasNoChildren( obj::Object3D) = length(obj.children) == 0
499-
isWorld( obj::Object3D) = hasNoParent(obj) && typeof(obj.feature) == Modia3D.SceneOptions
499+
isWorld( obj::Object3D) = hasNoParent(obj) && typeof(obj.feature) == Modia3D.Scene
500500
isNotWorld( obj::Object3D) = !(isWorld(obj))
501501
isMovable( obj::Object3D) = obj.interactionManner.movable
502502
isLockable( obj::Object3D) = obj.interactionManner.lockable
@@ -517,13 +517,13 @@ objectHasMovablePos( obj::Object3D) = !isnothing(obj.interactionManner.movableP
517517

518518
featureHasMass(obj::Object3D) = featureHasMass(obj.feature)
519519
featureHasMass(feature::Modia3D.AbstractObject3DFeature) = false
520-
featureHasMass(feature::Modia3D.AbstractSceneOptions) = false
520+
featureHasMass(feature::Modia3D.AbstractScene) = false
521521
featureHasMass(feature::Shapes.Solid) = !isnothing(feature.massProperties)
522522

523523
isVisible(obj::Object3D, renderer::Modia3D.AbstractRenderer) = isVisible(obj.feature, renderer)
524524
isVisible(feature::Modia3D.AbstractObject3DFeature, renderer::Modia3D.AbstractRenderer) = false
525525

526-
isVisible(feature::Modia3D.AbstractSceneOptions, renderer::Modia3D.AbstractRenderer) = false
526+
isVisible(feature::Modia3D.AbstractScene, renderer::Modia3D.AbstractRenderer) = false
527527

528528
canCollide(feature::Modia3D.AbstractObject3DFeature) = false
529529

0 commit comments

Comments
 (0)