I've been writing desktop apps in VB for personal use for quite a while now. I recently started to dabble in the 3D world using XAML and decided to start off by creating a basic 3D cube with each cube face having a different color. I have run into some problems and now am asking for your help. Some of the cube faces only show up with one of the two triangles visible or the cube face won't show up at all no matter how I adjust the code. There is something I am missing but don't know what it is. I'm thinking that it may be the order I put the "MeshGeometry3D Positions" or the "TriangleIndices" (i.e. counter-clockwise). I also think that I have too many "MeshGeometry3D Positions" points for some of the cube faces but for some reason it seems to work; but not in all cases. It's best if I show you my code and hopefully someone could point out my mistakes and what I'm doing wrong. See code below with screen shot. I'd really appreciate any help you could provide.
<!-- ********************************************************************************************************** -->
<Window x:Class="MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
WindowState="Maximized"
Background="Black">
<Viewport3D>
<Viewport3D.Camera>
<PerspectiveCamera Position="30,25,30" LookDirection="-30,-25,-30" FieldOfView="60"/>
</Viewport3D.Camera>
<Viewport3D.Children>
<ModelVisual3D x:Name="Light">
<ModelVisual3D.Content>
<AmbientLight Color="White"/>
</ModelVisual3D.Content>
</ModelVisual3D>
<ModelVisual3D>
<ModelVisual3D.Content>
<Model3DGroup x:Name="House">
<!-- ********************************************************************************************************** -->
<GeometryModel3D x:Name="CubeSide_1">
<GeometryModel3D.Material>
<DiffuseMaterial Brush="Red"/>
</GeometryModel3D.Material>
<GeometryModel3D.BackMaterial>
<DiffuseMaterial Brush="Red"/>
</GeometryModel3D.BackMaterial>
<GeometryModel3D.Geometry>
<MeshGeometry3D Positions="0,0,0 5,0,0 5,5,0 0,0,0 0,5,0 5,5,0"
TriangleIndices="0 2 1 0 4 2"/>
</GeometryModel3D.Geometry>
</GeometryModel3D>
<!-- ********************************************************************************************************** -->
<GeometryModel3D x:Name="CubeSide_2">
<GeometryModel3D.Material>
<DiffuseMaterial Brush="Blue"/>
</GeometryModel3D.Material>
<GeometryModel3D.BackMaterial>
<DiffuseMaterial Brush="Blue"/>
</GeometryModel3D.BackMaterial>
<GeometryModel3D.Geometry>
<MeshGeometry3D Positions="0,0,0 0,5,5 0,5,0 0,0,0 0,0,5 0,5,5 0,5,0"
TriangleIndices="0 5 4 0 5 6"/>
</GeometryModel3D.Geometry>
</GeometryModel3D>
<!-- ********************************************************************************************************** -->
<GeometryModel3D x:Name="CubeSide_3">
<GeometryModel3D.Material>
<DiffuseMaterial Brush="Orange"/>
</GeometryModel3D.Material>
<GeometryModel3D.BackMaterial>
<DiffuseMaterial Brush="Orange"/>
</GeometryModel3D.BackMaterial>
<GeometryModel3D.Geometry>
<MeshGeometry3D Positions="0,0,0 5,0,5 5,0,0 0,0,0 5,0,5 0,0,5 0,0,0"
TriangleIndices="0 7 1 0 7 6"/>
</GeometryModel3D.Geometry>
</GeometryModel3D>
<!-- ********************************************************************************************************** -->
<GeometryModel3D x:Name="CubeSide_4">
<GeometryModel3D.Material>
<DiffuseMaterial Brush="Purple"/>
</GeometryModel3D.Material>
<GeometryModel3D.BackMaterial>
<DiffuseMaterial Brush="Purple"/>
</GeometryModel3D.BackMaterial>
<GeometryModel3D.Geometry>
<MeshGeometry3D Positions="5,5,5 5,5,0 0,5,0 5,5,5 0,5,0 0,5,5"
TriangleIndices="3 2 4 3 4 5"/>
</GeometryModel3D.Geometry>
</GeometryModel3D>
<!-- ********************************************************************************************************** -->
<GeometryModel3D x:Name="CubeSide_5">
<GeometryModel3D.Material>
<DiffuseMaterial Brush="Yellow"/>
</GeometryModel3D.Material>
<GeometryModel3D.BackMaterial>
<DiffuseMaterial Brush="Yellow"/>
</GeometryModel3D.BackMaterial>
<GeometryModel3D.Geometry>
<MeshGeometry3D Positions="5,5,5 5,0,0 5,5,0 5,5,5 5,0,0 5,0,5 5,5,5"
TriangleIndices="3 1 2 3 7 1"/>
</GeometryModel3D.Geometry>
</GeometryModel3D>
<!-- ********************************************************************************************************** -->
<GeometryModel3D x:Name="CubeSide_6">
<GeometryModel3D.Material>
<DiffuseMaterial Brush="Green"/>
</GeometryModel3D.Material>
<GeometryModel3D.BackMaterial>
<DiffuseMaterial Brush="Green"/>
</GeometryModel3D.BackMaterial>
<GeometryModel3D.Geometry>
<MeshGeometry3D Positions="0,0,5 5,0,5 0,5,5 5,5,5"
TriangleIndices="1 3 0 0 3 2"/>
</GeometryModel3D.Geometry>
</GeometryModel3D>
<!-- ********************************************************************************************************** -->
</Model3DGroup>
</ModelVisual3D.Content>
</ModelVisual3D>
</Viewport3D.Children>
</Viewport3D>
</Window>
<!-- ********************************************************************************************************** -->
<!-- ********************************************************************************************************** -->
<Window x:Class="MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
WindowState="Maximized"
Background="Black">
<Viewport3D>
<Viewport3D.Camera>
<PerspectiveCamera Position="30,25,30" LookDirection="-30,-25,-30" FieldOfView="60"/>
</Viewport3D.Camera>
<Viewport3D.Children>
<ModelVisual3D x:Name="Light">
<ModelVisual3D.Content>
<AmbientLight Color="White"/>
</ModelVisual3D.Content>
</ModelVisual3D>
<ModelVisual3D>
<ModelVisual3D.Content>
<Model3DGroup x:Name="House">
<!-- ********************************************************************************************************** -->
<GeometryModel3D x:Name="CubeSide_1">
<GeometryModel3D.Material>
<DiffuseMaterial Brush="Red"/>
</GeometryModel3D.Material>
<GeometryModel3D.BackMaterial>
<DiffuseMaterial Brush="Red"/>
</GeometryModel3D.BackMaterial>
<GeometryModel3D.Geometry>
<MeshGeometry3D Positions="0,0,0 5,0,0 5,5,0 0,0,0 0,5,0 5,5,0"
TriangleIndices="0 2 1 0 4 2"/>
</GeometryModel3D.Geometry>
</GeometryModel3D>
<!-- ********************************************************************************************************** -->
<GeometryModel3D x:Name="CubeSide_2">
<GeometryModel3D.Material>
<DiffuseMaterial Brush="Blue"/>
</GeometryModel3D.Material>
<GeometryModel3D.BackMaterial>
<DiffuseMaterial Brush="Blue"/>
</GeometryModel3D.BackMaterial>
<GeometryModel3D.Geometry>
<MeshGeometry3D Positions="0,0,0 0,5,5 0,5,0 0,0,0 0,0,5 0,5,5 0,5,0"
TriangleIndices="0 5 4 0 5 6"/>
</GeometryModel3D.Geometry>
</GeometryModel3D>
<!-- ********************************************************************************************************** -->
<GeometryModel3D x:Name="CubeSide_3">
<GeometryModel3D.Material>
<DiffuseMaterial Brush="Orange"/>
</GeometryModel3D.Material>
<GeometryModel3D.BackMaterial>
<DiffuseMaterial Brush="Orange"/>
</GeometryModel3D.BackMaterial>
<GeometryModel3D.Geometry>
<MeshGeometry3D Positions="0,0,0 5,0,5 5,0,0 0,0,0 5,0,5 0,0,5 0,0,0"
TriangleIndices="0 7 1 0 7 6"/>
</GeometryModel3D.Geometry>
</GeometryModel3D>
<!-- ********************************************************************************************************** -->
<GeometryModel3D x:Name="CubeSide_4">
<GeometryModel3D.Material>
<DiffuseMaterial Brush="Purple"/>
</GeometryModel3D.Material>
<GeometryModel3D.BackMaterial>
<DiffuseMaterial Brush="Purple"/>
</GeometryModel3D.BackMaterial>
<GeometryModel3D.Geometry>
<MeshGeometry3D Positions="5,5,5 5,5,0 0,5,0 5,5,5 0,5,0 0,5,5"
TriangleIndices="3 2 4 3 4 5"/>
</GeometryModel3D.Geometry>
</GeometryModel3D>
<!-- ********************************************************************************************************** -->
<GeometryModel3D x:Name="CubeSide_5">
<GeometryModel3D.Material>
<DiffuseMaterial Brush="Yellow"/>
</GeometryModel3D.Material>
<GeometryModel3D.BackMaterial>
<DiffuseMaterial Brush="Yellow"/>
</GeometryModel3D.BackMaterial>
<GeometryModel3D.Geometry>
<MeshGeometry3D Positions="5,5,5 5,0,0 5,5,0 5,5,5 5,0,0 5,0,5 5,5,5"
TriangleIndices="3 1 2 3 7 1"/>
</GeometryModel3D.Geometry>
</GeometryModel3D>
<!-- ********************************************************************************************************** -->
<GeometryModel3D x:Name="CubeSide_6">
<GeometryModel3D.Material>
<DiffuseMaterial Brush="Green"/>
</GeometryModel3D.Material>
<GeometryModel3D.BackMaterial>
<DiffuseMaterial Brush="Green"/>
</GeometryModel3D.BackMaterial>
<GeometryModel3D.Geometry>
<MeshGeometry3D Positions="0,0,5 5,0,5 0,5,5 5,5,5"
TriangleIndices="1 3 0 0 3 2"/>
</GeometryModel3D.Geometry>
</GeometryModel3D>
<!-- ********************************************************************************************************** -->
</Model3DGroup>
</ModelVisual3D.Content>
</ModelVisual3D>
</Viewport3D.Children>
</Viewport3D>
</Window>
<!-- ********************************************************************************************************** -->
Last edited: