Pedrollane

[Software] LDraw2Sunflow a rendering engine for LDraw

Recommended Posts

I wrote a Java application to convert an LDraw model to Sunflow.

Thank you to msx80 for giving me the idea with Blurender

Thank Bublible I use some of your metallics materials in my application.

It is not complete yet but I have tested on several models without problems.

There are still things to optimize and probably bugs.

Currently no progress bar, keep an eye on the console to see the progress of the work. :classic:

Screenshot:

180766Ldraw2Sunflow.png

Only the "render" button not "ipr" saves the image in the same directory as the stage Sunflow. (not true with the latest version)

185736Ldraw2SunflowL.png

In the LDraw tab you can set :

- LDraw path

- Common used texterea is a solution to optimize the final mesh

Examples :

These models comes from here

3063 - Heartlake Flying Club

mini_4116483063HeartlakeFlyingClubsc.png

30210 - Frodo with cooking corner

mini_9761868464FrontEndLoadersc.png

30210 - Frodo with cooking corner

mini_69150630210Frodowithcookingcornersc.png

Download :

Version e - here

Version d - here

Version c - here

Version b - here

Version a - here

Edited by Pedrollane

Share this post


Link to post
Share on other sites

Looks very promising indeed! Will test it later...

+ I am happy you like my work with those special materials and that you actually used them. ;-)

Share this post


Link to post
Share on other sites

I fixed a bug on the pattern display.

Before

After

You can download the new version here

So now it also supports decorations, that is great! :thumbup:

Share this post


Link to post
Share on other sites

Hi, I'm trying to use your tool. Does it require any other applications installed (like Sunflow)?

I'm asking because i get this error:

...
aug 24, 2015 3:26:58 EM com.sunflow.converter.ldrawtosunflow.LdrawConverterMulti2 parseFile
SEVERE: Erreur sur la ligne 0.0 -4.0 0.0
aug 24, 2015 3:26:58 EM com.sunflow.converter.ldrawtosunflow.LdrawConverterMulti2 parseFile
SEVERE: Erreur sur la ligne triangles 144
Exception in thread "AWT-EventQueue-0" java.util.NoSuchElementException
 at java.util.StringTokenizer.nextToken(Unknown Source)
 at com.sunflow.converter.ldrawtosunflow.LdrawConverterMulti2.parseFile(LdrawConverterMulti2.java:259)
 at com.sunflow.converter.ldrawtosunflow.LdrawConverterMulti2.<init>(LdrawConverterMulti2.java:75)
...

I'm running on Win 10 with the LDraw path pointed on the directory that is used by e.g. LDCad.

Edited by reilar

Share this post


Link to post
Share on other sites

Sorry, I don't know how to send you the file. Doesn't seem that I'm allowed to PM you yet. I probably need to write more in the forums:)

...but when I start the application it looks like this in the cmd window:

C:\Users\Reine\Downloads\LDraw2Sunflow_b>java -jar Ldraw2Sunflow.jar
aug 24, 2015 4:07:56 EM java.util.prefs.WindowsPreferences <init>
WARNING: Could not open/create prefs root node Software\JavaSoft\Prefs at root 0x80000002. Windows RegCreateKeyEx(...) returned error code 5.
aug 24, 2015 4:07:56 EM org.ldrawtosunflow.ui.Ldraw2Sunflow <init>
INFO: en_GB

Could it be a problem with localization?

Share this post


Link to post
Share on other sites

C:\Users\Reine\Downloads\LDraw2Sunflow_b>java -jar Ldraw2Sunflow.jar

aug 24, 2015 4:07:56 EM java.util.prefs.WindowsPreferences <init>

WARNING: Could not open/create prefs root node Software\JavaSoft\Prefs at root 0x80000002. Windows RegCreateKeyEx(...) returned error code 5.

You can solve this warning :

  1. Go into your Start Menu and type regedit into the search field.
  2. Navigate to path HKEY_LOCAL_MACHINE\Software\JavaSoft
  3. Right click on the JavaSoft folder and click on New -> Key
  4. Name the new Key Prefs and everything should work.

Direct link to solution

aug 24, 2015 3:26:58 EM com.sunflow.converter.ldrawtosunflow.LdrawConverterMulti2 parseFile
SEVERE: Erreur sur la ligne 0.0 -4.0 0.0
aug 24, 2015 3:26:58 EM com.sunflow.converter.ldrawtosunflow.LdrawConverterMulti2 parseFile
SEVERE: Erreur sur la ligne triangles 144

For this error, without the file difficult to find

Share this post


Link to post
Share on other sites

I have update Ldraw2Sunflow :

  1. When the scene is generated a 3D preview appears, for smaller models. large models only the bounding box appears because I have memory problems.You can use the mouse to turn around the model and the direction arrows to move the camera. When you press ESC or close the window, the last position of the camera is used to generate the Sunflow scene.
  2. IPR and Render buttons save the image
  3. ldraw official and unofficial parts can be in separate directory.

I'm working on Darats' High quality STL files support, for the next version.

Examples :

Space / Ice Planet 2002 / 6983 - Ice Station Odyssey

8704176983IceStationOdysseysc.png

42039 - 24 Hours Race Car / Technic

9323684203924hoursracecarsc.png

Share this post


Link to post
Share on other sites

Hi, just a few notes from my experience trying LDraw2Sunflow on Linux:

First, there’s a '\' used as a file separator in PartFinder.checkLDrawDirectory(). '\' is a normal character in POSIX filesystems. That’s not portable.

Next, LDraw is (almost) case-insensitive for filenames. An LDR file can refer to parts in lowercase, uppercase, or mixedcase (not necessarily the actual case on the filesystem).

The LDraw official parts archive has all its parts filenames in lowercase but some parts refer to others in uppercase (or, some, only with an uppercase .DAT).

E..g. “p/8/stud6.dat” refers to “3-4edge.DAT” and “p/znap1.dat” refers to “1-4EDGE.DAT”. The files in the archive are “3-4edge.dat” and “1-4edge.dat”.

That’s important because POSIX filesystems are actually case-sentive (not the compatible-with-DOS-but-allowing-pretty-case of Windows filesystems).

Finally, does the GSLS version really need to be 1.50? I tried 130 and it seemed to work. (The driver, Mesa, advertises 1.30 for GSLS even if its “core profile” (whatever that means) GSLS is 3.30. So 1.50 is too high for me.)

Share this post


Link to post
Share on other sites

Thank for your feedback SylvainLS

I removed the backslash in PartFinder.checkLDrawDirectory() and check other class it seems ok.

Now i'm look for parts in lowercase.

Shader version don't need to be 150. I have start with version 330 but is too high for my netbook I change to 150.

Now I change to 130 :classic:

I have find the memory leak on preview OpenGL it work now, there are no more big ugly gray and blue box :classic:

You can find the last version here

Share this post


Link to post
Share on other sites

Thank for your feedback SylvainLS

No problem… at least for me :classic:

Now i'm look for parts in lowercase.

Er, that’s not quite right yet. The LDraw library .dat files and directories are in lowercase, the other LDraw files are mixedcase (e.g. LDConfig.ldr) and, above all, other files and directories on the filesystem are mixedcase/case-sensitive.

So, always using toLowerCase on the complete path is not an option. Only the relative path to the LDraw library files should be lowercased (“p”, “parts” and “models” included but not the prefix).

The filepath to the main model, the file to convert, should not be lowercased.

It’s quite a bother, eh? :wink:

In fact, I checked LDView’s code (but other programs should be similar): LDView first look for the all-lowercase filename, then all-uppercase, then the original filename.

Shader version don't need to be 150. I have start with version 330 but is too high for my netbook I change to 150.

Now I change to 130 :classic:

I have find the memory leak on preview OpenGL it work now, there are no more big ugly gray and blue box :classic:

You can find the last version here

Great!

Share this post


Link to post
Share on other sites

Me again! :tongue:

A few little itches with the OpenGL preview:

1. The aspect ratio doesn’t match the render, so it’s difficult to correctly prepare the view.

2. Is there a way to change the center (or shift the model / pan the view)?

3. It’s certainly a matter of taste but the mouse controls are reversed in regard to others 3D viewers I’m used to (Leocad, LDView and LDD among them :laugh: ). I’m used to the “drag the model” metaphor, not the “move the camera” one.

Also, OpenGL preview is okay (the colors are a bit off: light bley looks lavender-ish) but I get “GRAVE: Shader compile error :” (no more info on the line).

Share this post


Link to post
Share on other sites

I'm working on Darats' High quality STL files support, for the next version.

Really nice renders.

I would like to know how you can implement support for my LGEO parts library.

As it is Povray code, using many boolean operations, especially for patterned parts, I don't really understand how you can do that.

Same for studs, how can you do that.

Then, I'm currently rewriting the entire library using "mesh2" povray meshes instead of "mesh" ones. It's a very long process and I can't tell when it will be over, but I'm regularly updating the package (without notification). This is transparent for PovRay users but it might give you issues if your writing some compatibility code.

Maybe we could get in touch to talk about it.

Share this post


Link to post
Share on other sites

I have question about the SunFlow part: what version of SF did you used? Cos version 0.72 has problems with glasses being too dark - if you managed to solve it can you tell us how? I am asking because another project using SF named BlueRender for LDD using modified v0.72 suffer from that problem whereas your renders seem to have their glasses OK (although I managed to solved it partly).

BTW render of #6973 looks fantastic to me, almost real! :thumbup:

Edited by bublible

Share this post


Link to post
Share on other sites

I used a modified version of Bluerender Sunflow version.

I have checkout this version : https://bitbucket.or...8967?at=default

I made changes in some classes :

BoundingIntervalHierarchy ->I've change a 2 lines in subdivide function because of infinite loop some times.

SCParser -> I added a noinstance=true where type equals generic-mesh

Instance -> I removed return false when matrice determinant is null.

AccelerationStructureFactory -> I used UniformGrid in place of BoundingIntervalHierarchy when primitive is null.

Share this post


Link to post
Share on other sites

I used a modified version of Bluerender Sunflow version.

I have checkout this version : https://bitbucket.or...8967?at=default

I made changes in some classes :

BoundingIntervalHierarchy ->I've change a 2 lines in subdivide function because of infinite loop some times.

SCParser -> I added a noinstance=true where type equals generic-mesh

Instance -> I removed return false when matrice determinant is null.

AccelerationStructureFactory -> I used UniformGrid in place of BoundingIntervalHierarchy when primitive is null.

So it means you are basically using "our" SF version for BlueRender, hm, interesting - could you, please, provide your modified src/final sunflow.jar for SF so I can test it here to see if your changes have any significance to the glass problem?

Edited by bublible

Share this post


Link to post
Share on other sites

The sunflow modified sources are here

Thanx a lot - I will test it later today and then let you know what was the result of it.

Share this post


Link to post
Share on other sites

Two pictures

First without Darats parts :

83600539472sc.png

Second with Darats parts (and no binoculars :angry: I don't know where they are) :

4508413947sc.png

Look arms, hands, shovel, motor grid.

it's not yet available but soon :wink:

Share this post


Link to post
Share on other sites

Thanx a lot - I will test it later today and then let you know what was the result of it.

TESTED - unfortunately there is no advantage/improvement in glass rendering over original BlueRender's version...I used latest BR v0.004 with replaced sunflow.jar (with the one built from your SF src you provided above) and the final result - used with BR - is really bad (you probably changed some stuff that is badly needed by BlueRender I guess) - msx80's Orca model a little bit MODded by me :grin: :

This is result from your SF:

orca1.jpg

This one is ORIGINAL BlueRender's materials & SF (v0.004)

orca2.jpg

...and finally this one is result of my own materials & SF MOD:

orca3.jpg

So as you can see glass material is basically the same quality with your and original BR SF although when I saw your #6973 render I thought it is much more improved over the original one (maybe there is something else in your other src code elsewhere?), but as of now my MOD is the way to go at least deffinitely for me cos compared to original one it looks really like a plastic trans glass wheres the original is too dark and dull.

Anyway thank you for your kindness providing your src for testing - appriciated! :wink:

Edited by bublible

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Recently Browsing   0 members

    No registered users viewing this page.