Converting LDraw parts to WPF - Printable Version +- LDraw.org Discussion Forums (https://forums.ldraw.org) +-- Forum: LDraw Programs (https://forums.ldraw.org/forum-7.html) +--- Forum: All Other Programs. (https://forums.ldraw.org/forum-26.html) +--- Thread: Converting LDraw parts to WPF (/thread-23613.html) |
Converting LDraw parts to WPF - Hans de Lang - 2019-08-11 Hi All, I'm trying to convert Ldraw parts to use in a Windows Presentation Foundation program, written with visual basic. Drawing a 4-4disc.dat file for a stud.dat the triangles are CCW that's correct. stud3.dat uses the same disc, so still CCW and so not visible from the bottom. The disc has shift down de y axis. I imagen that when it flips so x,y become -x, -y it would be correct. I use the buildin 4x4 Matrix3d and fill it like the LDraw explanation mentioned. What am I missing? Regards, Hans top.jpg (Size: 9.75 KB / Downloads: 98) bottom.jpg (Size: 13.68 KB / Downloads: 98) RE: Converting LDraw parts to WPF - Lasse Deleuran - 2019-08-11 (2019-08-11, 13:17)Hans de Lang Wrote: Hi All,Did you remember to invert the drawing order for rotations with negative determinants? (ie. Reverse the CCW drawing order if determinant(rotation) < 0) If this is the issue, then I recommend adding this tip to the Culling/clipping page as everyone (including myself twice) have fallen into this. RE: Converting LDraw parts to WPF - Hans de Lang - 2019-08-11 (2019-08-11, 14:06)Lasse Deleuran Wrote: Did you remember to invert the drawing order for rotations with negative determinants? Excellent! That's the trick, now I can see both discs at the top and at the bottom. Thanks! RE: Converting LDraw parts to WPF - Travis Cobbs - 2019-08-12 (2019-08-11, 21:54)Hans de Lang Wrote: Excellent! That's the trick, now I can see both discs at the top and at the bottom. Just so you know, full BFC (back face culling) support requires a lot more than just detecting when a matrix mirrors things. The BFC spec isn't super complicated to understand, but it isn't exactly trivial to implement. Also, some polygons in some parts are intended to be drawn on both sides. So to properly draw all LDraw parts, you have to support that also. (One easy way to do that if you can't have the rendering software draw both sides of polygons is to draw the polygons both ways.) RE: Converting LDraw parts to WPF - Victor Di Rienzo - 2019-08-12 (2019-08-11, 13:17)Hans de Lang Wrote: Hi All,Van you make a tutorial how you make them? RE: Converting LDraw parts to WPF - Hans de Lang - 2019-08-13 (2019-08-12, 3:43)Travis Cobbs Wrote: Just so you know, full BFC (back face culling) support requires a lot more than just detecting when a matrix mirrors things. The BFC spec isn't super complicated to understand, but it isn't exactly trivial to implement. Also, some polygons in some parts are intended to be drawn on both sides. So to properly draw all LDraw parts, you have to support that also. (One easy way to do that if you can't have the rendering software draw both sides of polygons is to draw the polygons both ways.)Thanks for the link on BFC, very helpful, and written in basic! Without all these {{ == << | and so on Drawing both sides was my work around up to no and I also can convert to .obj and that's always visible Doing it as defined is faster and less memory consuming and i'm learning now how to do that! RE: Converting LDraw parts to WPF - Hans de Lang - 2019-08-13 (2019-08-12, 13:09)Victor Di Rienzo Wrote: Van you make a tutorial how you make them?pretty long story i'm afraid What you can do is placing an elementhost on a standard form, connect a grid to that and you can use wpf so form Elementhost Grid Viewport3D Camera ModelVisual3D Model3DGroup Model3D TransFormGroup MaterialGroup MeshData Positions Normals (not given by LDraw but you can leave them out Texturecoordinates ( very useful for stickers ) Triangles ( and that's the CCW and CW choice) Parsing the .dat files is easy. Then calculating the points with the matrixes and put them into the Mesh.positions Thing is WPF works with Y axis up and LDraw with Y-axis down but if you make Y = -Y and Z = - Z then its normal again You can't draw edges in WPF, but I scale my bricks to the real measures of 7.8 x 7.8 mm That give's a small gap between the bricks and shows not as a solid wall Succes! RE: Converting LDraw parts to WPF - Michael Heidemann - 2019-09-14 (2019-08-13, 22:27)Hans de Lang Wrote: pretty long story i'm afraidDo you think you can make a dll out of this that can be used in my visual basic applications as the renderer for ldraw files, so I can show the result in a picture frame and/or window? Currently I use ldview.dll, but that is 32bit and not 64bit. |