holance on 2.22.0
Fix all the logging issue with … Merge pull request #1812 from h… Merge pull request #1813 from h… (compare)
holance on develop
Fix all the logging issue with … Merge pull request #1812 from h… (compare)
I did ZoomFit
Vector2 center = new Vector2(Convert.ToSingle((xMax + xMin) / 2), Convert.ToSingle((yMax + yMin) / 2));//Center 2D
Vector3 center3D = new Vector3();
DieCreationWindow.ViewPort.UnProjectOnPlane(center, new Vector3(0, 0, 0), DieCreationWindow.ViewPort.Camera.LookDirection.ToVector3(), out center3D);//Find center 3D
DieCreationWindow.ViewPort.ZoomToRectangle(new Rect(new System.Windows.Point(xMin - 5, yMin - 5), new Size(sizeX + 10, sizeY + 10)));
Vector3D lookDirection = DieCreationWindow.ViewPort.Camera.LookDirection;
lookDirection.Normalize();
DieCreationWindow.ViewPort.Camera.LookDirection = lookDirection;
DieCreationWindow.ViewPort.Camera.LookAt(center3D, 0);
after using it then use the zoom to maximize, model vibrates
public MainWindow()
{
InitializeComponent();
Create3DViewPort();
}
private void Create3DViewPort()
{
var hVp3D = new HelixViewport3D{
ShowFrameRate = true,
ShowViewCube = true,
ShowCoordinateSystem = true,
ShowTriangleCountInfo = true
};
var lights = new DefaultLights();
hVp3D.Children.Add(lights);
var meshBuilder = new MeshBuilder();
meshBuilder.AddBox(new Point3D(0, 0, 0.5), 1, 1, 1);
hVp3D.Items.Add(new MeshGeometryVisual3D
{
MeshGeometry = meshBuilder.ToMesh(),
Fill = GetTextMaterial("T")
});
hVp3D.Children.Add(new GridLinesVisual3D
{
Width = 8,
Length = 8,
MajorDistance = 1,
MinorDistance = 1,
Thickness = 0.01
});
h3dContainer.Children.Add(hVp3D);
}
private System.Windows.Media.Brush GetTextMaterial(string text)
{
Bitmap bmp = new Bitmap(64, 64);
RectangleF rectf = new RectangleF(0, 0, bmp.Width, bmp.Height);
Graphics g = Graphics.FromImage(bmp);
g.SmoothingMode = SmoothingMode.AntiAlias;
g.InterpolationMode = InterpolationMode.HighQualityBicubic;
g.PixelOffsetMode = PixelOffsetMode.HighQuality;
g.TextRenderingHint = TextRenderingHint.AntiAliasGridFit;
g.FillRectangle(System.Drawing.Brushes.Green, rectf);
StringFormat format = new StringFormat()
{
Alignment = StringAlignment.Center,
LineAlignment = StringAlignment.Center
};
g.DrawString(text, new Font("Tahoma", 8), System.Drawing.Brushes.Black, rectf, format);
g.Flush();
var bmpImage = Bitmap2BitmapImage(bmp);
var material = MaterialHelper.CreateImageMaterial(bmpImage, 1, true);
var imageBrush = new ImageBrush(bmpImage);
return imageBrush;
}
private BitmapImage Bitmap2BitmapImage(Bitmap bitmap)
{
using (MemoryStream ms = new MemoryStream())
{
bitmap.Save(ms, ImageFormat.Png);
ms.Position = 0;
BitmapImage bi = new BitmapImage();
bi.BeginInit();
bi.StreamSource = ms;
bi.EndInit();
return bi;
}
}
}
Hello,
I try to implement my custom shader technique; In order to get it works, every objects in the scene must be preprocessed in this way: object geometry is split in two part, one part (let's called A) has its own shader, vertex/index buffers, primitivetopology, also the other part (let's called B) has its own shader, buffers.
Now, to apply this technique correctly, I have to render A first and the B in this order. This must be done for every objects so, for example, if I have 3 objects in scene I have to render: A1 B1 A2 B2 A3 B3.
How could manage this in Helix? I think about create two nodes (one for A and one for B) and append both as child of an "empty" parent-Object node