【问题标题】:How to display PointGeometryModel3D in GroupModel3D via Binding如何通过绑定在 GroupModel3D 中显示 PointGeometryModel3D
【发布时间】:2020-12-09 07:52:18
【问题描述】:

我正在使用 SharpDX 加载和显示模型。

<hx:Viewport3DX  EffectsManager="{Binding EffectsManager}" 
                   Camera="{Binding Camera}" ModelUpDirection="0,0,1">
    <hx:AmbientLight3D Color="{StaticResource ModelAmbientLightColor}" />
    <hx:DirectionalLight3D Direction="{Binding Camera.LookDirection}" Color="{StaticResource ModelDirectionalLightColor}" />
    <hx:Element3DPresenter Content="{Binding MainModel}" />
    <hx:GroupModel3D ItemsSource="{Binding ListOfAdditionalModels}"/>
  </hx:Viewport3DX>

列表“ListOfAdditionalModels”是 MeshGeometryModel3D 的 ObservableElement3DCollection。 这按预期工作。所有模型/3d 项目都能正确显示。

现在我想基本上对 PointGeometryModel3D 列表做同样的事情。但它不会显示任何内容。

<hx:Viewport3DX EffectsManager="{Binding EffectsManager}" 
                Camera="{Binding Camera}" ZoomExtentsWhenLoaded="True" 
                 > 
    <hx:AmbientLight3D Color="#030303" />
    <hx:DirectionalLight3D Direction="{Binding Camera.LookDirection}" Color="White" />
    <hx:GroupModel3D ItemsSource="{Binding ListOfPointCloudModels, UpdateSourceTrigger=PropertyChanged}" >
    </hx:GroupModel3D>

这有什么问题?我想我必须告诉 GroupModel 使用其项目的“几何”属性。但我不知道怎么做。

直接使用列表“ListOfPointCloudModels”中的一个 PointGeometryModel3D 可以正常工作:

<hx:Viewport3DX EffectsManager="{Binding EffectsManager}" 
            Camera="{Binding Camera}" BackgroundColor="#FF88AACD" ZoomExtentsWhenLoaded="True" >
    <hx:AmbientLight3D Color="#030303" />
    <hx:DirectionalLight3D Direction="{Binding Camera.LookDirection}" Color="White" />
    <hx:PointGeometryModel3D Color="{x:Static Colors.White}"  
                             Geometry="{Binding PointsModel.Geometry}" Figure="Rect" Size="10 10" >          
    </hx:PointGeometryModel3D>
  </hx:Viewport3DX>

【问题讨论】:

    标签: c# wpf sharpdx


    【解决方案1】:

    解决方案是使用 ItemsModel3D 而不是 GroupModel3d 并定义项目模板:

    <hx:ItemsModel3D ItemsSource="{Binding ListOfPointCloudModels}" >
          <hx:ItemsModel3D.ItemTemplate>
            <DataTemplate>
              <hx:PointGeometryModel3D Geometry="{Binding Geometry}" Color="{x:Static Colors.White}" Figure="Rect" Size="2 2"/>
            </DataTemplate>
          </hx:ItemsModel3D.ItemTemplate>
        </hx:ItemsModel3D>
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-09-21
      • 2016-07-25
      • 1970-01-01
      • 1970-01-01
      • 2023-03-16
      相关资源
      最近更新 更多