I have been trying to achieve a simple 3D engine in VB.NET and it's visually pretty good.
(Except i still need to add a Z-Buffer or Painter's algorithm to properly show concave shapes)
My problem is when it come to a model with a large amount of triangles(such as the monkey) the fps drop significantly to where is slightly freezes as it's rotating.
I figured my rotate function creating a new mesh every time might be too much to ask for:
So I instead made a function to fetch Vertices in a mesh and rotate them directly but that was even slower.vb.net Code:
Public Function Rotate_X(ByVal Angle As Single) As Mesh Dim Sin_T As Double = Math.Sin(Angle * Math.PI / 180) Dim Cos_T As Double = Math.Cos(Angle * Math.PI / 180) Dim MSH As New Mesh For Each Triangle As TriFace In arr_Faces Dim TF As TriFace = Triangle.Clone For Each Vertex As PVector In TF.Vertices Dim Y As Double = Vertex.Y Dim Z As Double = Vertex.Z Vertex.Y = CSng(Y * Cos_T - Z * Sin_T) Vertex.Z = CSng(Z * Cos_T + Y * Sin_T) Next MSH.AddFace(TF) Next Return MSH End Function
When it comes to models with a smaller amount of face everything runs smoothly though.
I'm using the fillpath method in in paint event; Should I switch to a bitmap and make my own raster function instead using setpixel ?
vb.net Code:
Dim new_Points() As Point = {New Point(PTriangle.Vertex_A.X, PTriangle.Vertex_A.Y), New Point(PTriangle.Vertex_B.X, PTriangle.Vertex_B.Y), New Point(PTriangle.Vertex_C.X, PTriangle.Vertex_C.Y)} Dim TrianglePath As New Drawing2D.GraphicsPath(Drawing2D.FillMode.Alternate) TrianglePath.AddLines(new_Points) TrianglePath.CloseFigure() Dim MyBrush As New Drawing.SolidBrush(TriColor) GFX.FillPath(MyBrush, TrianglePath)
Or do I just need to use a language with access to the graphics card at this point ?
I'm kind of lost ... thnx in advance for suggestions.




Reply With Quote
