6-visual-model.scn?xml version1.0? !-- Adding a visual model to our object -- Node nameroot dt0.01 gravity0 0 0 Node nameplugins RequiredPlugin nameSofa.Component.IO.Mesh/ !-- Needed to use components [MeshGmshLoader] -- RequiredPlugin nameSofa.Component.LinearSolver.Iterative/ !-- Needed to use components [CGLinearSolver] -- RequiredPlugin nameSofa.Component.Mass/ !-- Needed to use components [MeshMatrixMass] -- RequiredPlugin nameSofa.Component.MechanicalLoad/ !-- Needed to use components [ConstantForceField] -- RequiredPlugin nameSofa.Component.StateContainer/ !-- Needed to use components [MechanicalObject] -- RequiredPlugin nameSofa.Component.ODESolver.Backward/ !-- Needed to use components [EulerImplicitSolver] -- RequiredPlugin nameSofa.Component.SolidMechanics.FEM.Elastic/ !-- Needed to use components [TetrahedronFEMForceField] -- RequiredPlugin nameSofa.Component.Topology.Container.Dynamic/ !-- Needed to use components [TetrahedronSetGeometryAlgorithms, TetrahedronSetTopologyContainer] -- RequiredPlugin nameSofa.Component.Visual/ !-- Needed to use components [VisualStyle] -- RequiredPlugin nameSofa.GL.Component.Rendering3D/ !-- Needed to use components [OglModel] -- /Node DefaultAnimationLoop computeBoundingBoxfalse/ !-- Using the VisualStyle choose your visual options! -- !-- ACTIVATE: showVisual showBehavior showForceFields showInteractionForceFields showCollision showCollisionModels showWireFrame -- !-- DE-ACTIVATE: hideVisual hideBehavior hideForceFields hideInteractionForceFields hideCollision hideCollisionModels hideWireFrame -- VisualStyle displayFlagsshowForceFields / MeshGmshLoader namemeshLoaderCoarse filenamemesh/liver.msh / Node nameLiver EulerImplicitSolver / CGLinearSolver iterations200 tolerance1e-09 threshold1e-09/ TetrahedronSetTopologyContainer nametopo src../meshLoaderCoarse / TetrahedronSetGeometryAlgorithms templateVec3d nameGeomAlgo / MechanicalObject templateVec3d nameMechanicalModel showObject1 showObjectScale3 / TetrahedronFEMForceField nameFEM youngModulus1000 poissonRatio0.4 methodlarge / MeshMatrixMass massDensity1 topologytopo / ConstantForceField totalForce1 0 0 / OglModel nameVisualModel src../meshLoaderCoarse / /Node /Node1.视觉模型到这里我们已经完成了一个 full mechanical model完整力学模型。现在这个对象已经不只是“能显示的东西”而是真正有质量、有材料、有外力、有求解器、能运动和变形的力学对象。现在我们要加另一个 representation也就是另一种“表示”。前面已经学过 SOFA 里可以把一个对象拆成几种表示Mechanical model力学模型负责计算运动和变形Visual model / Rendering model视觉模型负责显示给你看Collision model碰撞模型负责碰撞检测这一段加的是Visual model / Rendering model 视觉模型 / 渲染模型2.可变性对象现在和之前的代码5最大的区别是我们有了constitutive model本构模型它来自连续介质力学。continuum的意思是“连续对象”。虽然我们在计算机里把它离散成很多节点和四面体但它在物理意义上是一个整体。一个节点上发生的事情会影响其他节点。按住Shift 鼠标左键会出现绿色箭头这些绿色箭头表示在鼠标和物体之间创建一个临时弹簧拖动物体上的一个点。你会看到整个 lever 发生形变。这说明它不是一堆互相独立的点而是一个连续的可变形物体 deformable object 。3.刚体点云 vs 可变形体前面的点云/刚体 frame每个点是独立的 rigid frame点和点之间没有材料连接你拖一个点不会影响其他点现在的可变形体节点之间通过 3D 网格和材料模型连接拖一个节点会影响整个物体原因是现在有 3D 空间积分、有材料模型、有内部弹性力。某处发生变形会通过连续体模型传递到整个 domain。4.加入visual model现在要添加另一种 representation也就是visual/rendering representation视觉/渲染表示。OglModel nameVisualModel src../meshLoaderCoarse /它的作用是把 meshLoaderCoarse 读入的网格用作可视化显示模型。注意MechanicalObject是力学状态OglModel是显示外观。它们不是同一个东西。5.渲染模型没有力学计算点 Animate 后开始引出核心问题我们现在虽然有了另一个 representation也就是OglModel但是我们忘了一件事——没有把 rendering 和 mechanics 连接起来。渲染模型只负责显示。它不计算力它不解方程它不知道每个节点的新位置和新速度。现在的rendering 上没有任何 mechanics computation渲染模型只负责渲染。所以OglModel需要一个东西来告诉它力学模型现在变成什么形状了、每个节点现在在哪里、速度是多少。缺的东西就是 mapping。
6-SOFA视觉模型Visual Model
发布时间:2026/7/13 16:31:40
6-visual-model.scn?xml version1.0? !-- Adding a visual model to our object -- Node nameroot dt0.01 gravity0 0 0 Node nameplugins RequiredPlugin nameSofa.Component.IO.Mesh/ !-- Needed to use components [MeshGmshLoader] -- RequiredPlugin nameSofa.Component.LinearSolver.Iterative/ !-- Needed to use components [CGLinearSolver] -- RequiredPlugin nameSofa.Component.Mass/ !-- Needed to use components [MeshMatrixMass] -- RequiredPlugin nameSofa.Component.MechanicalLoad/ !-- Needed to use components [ConstantForceField] -- RequiredPlugin nameSofa.Component.StateContainer/ !-- Needed to use components [MechanicalObject] -- RequiredPlugin nameSofa.Component.ODESolver.Backward/ !-- Needed to use components [EulerImplicitSolver] -- RequiredPlugin nameSofa.Component.SolidMechanics.FEM.Elastic/ !-- Needed to use components [TetrahedronFEMForceField] -- RequiredPlugin nameSofa.Component.Topology.Container.Dynamic/ !-- Needed to use components [TetrahedronSetGeometryAlgorithms, TetrahedronSetTopologyContainer] -- RequiredPlugin nameSofa.Component.Visual/ !-- Needed to use components [VisualStyle] -- RequiredPlugin nameSofa.GL.Component.Rendering3D/ !-- Needed to use components [OglModel] -- /Node DefaultAnimationLoop computeBoundingBoxfalse/ !-- Using the VisualStyle choose your visual options! -- !-- ACTIVATE: showVisual showBehavior showForceFields showInteractionForceFields showCollision showCollisionModels showWireFrame -- !-- DE-ACTIVATE: hideVisual hideBehavior hideForceFields hideInteractionForceFields hideCollision hideCollisionModels hideWireFrame -- VisualStyle displayFlagsshowForceFields / MeshGmshLoader namemeshLoaderCoarse filenamemesh/liver.msh / Node nameLiver EulerImplicitSolver / CGLinearSolver iterations200 tolerance1e-09 threshold1e-09/ TetrahedronSetTopologyContainer nametopo src../meshLoaderCoarse / TetrahedronSetGeometryAlgorithms templateVec3d nameGeomAlgo / MechanicalObject templateVec3d nameMechanicalModel showObject1 showObjectScale3 / TetrahedronFEMForceField nameFEM youngModulus1000 poissonRatio0.4 methodlarge / MeshMatrixMass massDensity1 topologytopo / ConstantForceField totalForce1 0 0 / OglModel nameVisualModel src../meshLoaderCoarse / /Node /Node1.视觉模型到这里我们已经完成了一个 full mechanical model完整力学模型。现在这个对象已经不只是“能显示的东西”而是真正有质量、有材料、有外力、有求解器、能运动和变形的力学对象。现在我们要加另一个 representation也就是另一种“表示”。前面已经学过 SOFA 里可以把一个对象拆成几种表示Mechanical model力学模型负责计算运动和变形Visual model / Rendering model视觉模型负责显示给你看Collision model碰撞模型负责碰撞检测这一段加的是Visual model / Rendering model 视觉模型 / 渲染模型2.可变性对象现在和之前的代码5最大的区别是我们有了constitutive model本构模型它来自连续介质力学。continuum的意思是“连续对象”。虽然我们在计算机里把它离散成很多节点和四面体但它在物理意义上是一个整体。一个节点上发生的事情会影响其他节点。按住Shift 鼠标左键会出现绿色箭头这些绿色箭头表示在鼠标和物体之间创建一个临时弹簧拖动物体上的一个点。你会看到整个 lever 发生形变。这说明它不是一堆互相独立的点而是一个连续的可变形物体 deformable object 。3.刚体点云 vs 可变形体前面的点云/刚体 frame每个点是独立的 rigid frame点和点之间没有材料连接你拖一个点不会影响其他点现在的可变形体节点之间通过 3D 网格和材料模型连接拖一个节点会影响整个物体原因是现在有 3D 空间积分、有材料模型、有内部弹性力。某处发生变形会通过连续体模型传递到整个 domain。4.加入visual model现在要添加另一种 representation也就是visual/rendering representation视觉/渲染表示。OglModel nameVisualModel src../meshLoaderCoarse /它的作用是把 meshLoaderCoarse 读入的网格用作可视化显示模型。注意MechanicalObject是力学状态OglModel是显示外观。它们不是同一个东西。5.渲染模型没有力学计算点 Animate 后开始引出核心问题我们现在虽然有了另一个 representation也就是OglModel但是我们忘了一件事——没有把 rendering 和 mechanics 连接起来。渲染模型只负责显示。它不计算力它不解方程它不知道每个节点的新位置和新速度。现在的rendering 上没有任何 mechanics computation渲染模型只负责渲染。所以OglModel需要一个东西来告诉它力学模型现在变成什么形状了、每个节点现在在哪里、速度是多少。缺的东西就是 mapping。