Click or drag to resize
AB4D logo

ObjModelVisual3DPreserveScaleAspectRatio Property

Gets or sets a Boolean that specifies if the 3D model is scaled so its aspect ratio is preserved (the ratio between width, height and depth of the object).

Namespace: Ab3d.Visuals
Assembly: Ab3d.PowerToys (in Ab3d.PowerToys.dll) Version: 11.2.9104.2045
Syntax
C#
public bool PreserveScaleAspectRatio { get; set; }

Property Value

Boolean
Remarks

The size of the shown object is controlled by the SizeX, SizeY, SizeZ and PreserveScaleAspectRatio properties.

By default all the SizeX, SizeY and SizeZ are set to -1. This means that the original size of the object is used. But if the SizeX is set to let's say 100, the object would be scaled so its SizeX would be 100.

If PreserveScaleAspectRatio is true (default), than the aspect ratio of the 3D model is preserved. This means that the model is stretched to one side mode than to the other - the scale is evenly set to all the axis. This also means that if all SizeX, SizeY and SizeZ are defined, the object will be scaled so it will not exceed and of the specified sizes.

If PreserveScaleAspectRatio is false, than the aspect ration of the 3D model will not be preserved. In this case the SizeX, SizeY and SizeZ will be applied so the object will be exactly the size of the specified sizes.

Example

The following example shown a 3D model from ab3d.obj file. The model's center is positioned at (-250, 0, 0) and its size is set so its SizeX is 80. Note that by default the PreserveScaleAspectRatio is set to true.

XAML
<ObjModelVisual3D:ObjModelVisual3D Source="/Resources/ab3d.obj" 
                   SizeX="80"
                   Position="0 40 0" PositionType="Center"/>

The following code shows the same mode, but this time it is custom sized:

XAML
<ObjModelVisual3D:ObjModelVisual3D Source="/Resources/ab3d.obj" 
                   SizeX="50" SizeY="30" SizeZ="40"
                   PreserveScaleAspectRatio="False"
                   Position="0 40 0" PositionType="Center"/>
See Also