Skip to content
This repository has been archived by the owner on May 18, 2019. It is now read-only.

New feature request: Add "primitive substitution" feature #44

Open
MinnieTheMoocher opened this issue Dec 28, 2013 · 19 comments
Open

New feature request: Add "primitive substitution" feature #44

MinnieTheMoocher opened this issue Dec 28, 2013 · 19 comments

Comments

@MinnieTheMoocher
Copy link

Currently, all primitives are imported as any normal LDRAW file.
This means for example that a 1-4cyli.dat always is a polygon mesh.

There already exists a boolean option to replace all primitives
by their "48ed" (high-res) versions if the user wants that.
That option could be extended to replace all primitives
by their "8ed" (low-res) counterparts if the user really wants that.
However, he most probably will not, as the rendering quality will be just poor.

What would be much, much more interesting would be to add a
"substitute primitives by native 3D objects" value of that substitution option.
If the user sets the option to THAT mode, it should work similarly as it
works in LDView. There, the tool internally has a lookup table for LDRAW primitives.
It knows that a 1-4cyli.dat models a quarter cylinder, and substitutes
a real 3D OpenGL quarter cylinder for it, instead of importing simply the polygon
mesh.

@MinnieTheMoocher
Copy link
Author

Here are screenshots of the tool LDView with the primitives replacement enabled and disabled.
You can see that one picture shows a plain, boring polygon mesh,
and the second picture shows a native OpenGL 3D object, which is much more detailed.

6804-001

6804-002

@le717
Copy link
Owner

le717 commented Dec 28, 2013

Assigned to later date milestone, as this would only happen after the rewrite (v1.2).

@MinnieTheMoocher
Copy link
Author

is fine for me.
adding this feature will make the LDR Importer a heartbreaker.
This substitution is a killer feature.
Without it, you have to stick with boring polygon meshes forever.
With it, your 3D scenes can be rendered smoothly.

@le717
Copy link
Owner

le717 commented Dec 28, 2013

Again, /cc @rioforce

@MinnieTheMoocher
Copy link
Author

FYI, here is a list of all LDRAW primitives. You can see the systematics in there
to see how to substitute the primitives:
http://ldraw.org/library/primref/

You could also contact Travis Cobbs, the author of LDView.
That tool already contains a primitives substitution list.
Maybe you can re-use his list instead of re-inventing it:
http://ldview.sourceforge.net/

@JoshTheDerf
Copy link
Collaborator

You have quite a few good ideas, almost too many to keep up with.

;)

@rioforce
Copy link
Collaborator

Whiled this idea may be good for LDView, it's not right for the LDraw importer. Reconstructing certain primitives would be pointless, because this is an LDraw importer, not something that imports coordinates and reconstructs bricks. If we were going to reconstruct certain bricks, we could just reconstruct all the bricks and then wouldn't have to worry about using the LDraw parts! But that's not logical, because this is an LDraw importer, not a brick constructor. LDraw has different qualities of bricks for a reason, and with a simple function, we could toggle between hi-res, lo-res, and normal-res bricks. :)

@MinnieTheMoocher
Copy link
Author

you misunderstood me.
i was not talking of "reconstruction" of bricks. i think you think of something like LGEO or something,
where whole brick geometry is replaced.

this request only talked about primitives.
that's a small handful of ldraw files, like cylinders, discs, tori.

i was talking about how they are imported.
currently, they get imported as a mesh.
but they could also be imported as a native 3D object (cylinder, disc, torus etc).

this is not at all about "guessing" geometry, or "reconstructing" it from the mesh.
would I have suggested that, then I would have objected the same way you did.
the importer is no math algebra suite which can reconstruct cylinders etc from given meshes.

the task I talk about here is much, much more trivial:
when an ldraw file says "please put a half cylinder of radius 20 here",
the importer currently simply puts the cylinder mesh from ldraw file p/2-4cyli there.
it would be easy, if not trivial, to put a real 3D cyli there.

@rioforce
Copy link
Collaborator

Ah, I understand what you mean now. I think that it's harder than it sounds though. Not sure how that would work with our parser...

@MinnieTheMoocher
Copy link
Author

still very simple. you just need a small table which tells you:
"ah, you want a 2-4cyli scaled by factors x/y/z at location p? fine. i'll put a primitive for you there."

this is not an issue about the file parser.
parsing the file already works well.
this issue is about what to do with the information from the file.
currently always the mesh is used.
the request is, if the option for that is enabled, to replace SOME (just few!) specific meshes
(ie., the primitives) by native 3d objects.
it's something that comes after parsing.

@JoshTheDerf
Copy link
Collaborator

parsing the file already works well.

Um, nope. Take a look at the code and see what I mean. :P

@MinnieTheMoocher
Copy link
Author

what I wanted to say is that you need to separate parsing a file from working with the parsed data.

to mix these 2 steps usually leads immediately to spaghetti code.
the usual implementation in compiler construction is

  1. parse the input
  2. operate on the parsed stuff
    If you start modifying things already during the load, things quickly get messy.
    http://www.amazon.com/Compilers-Principles-Techniques-Tools-2nd/dp/0321486811

@le717
Copy link
Owner

le717 commented Jan 6, 2014

Yes, we are aware of the "spaghetti code". David Pluntze wrote it that way, and fixing it is one of the (if not the) main goal of the rewrite. 😉 Thanks for the resource, though too bad I most likely will not get the chance to read it.

@MinnieTheMoocher
Copy link
Author

if you're studying computer science, you will :)

@rioforce
Copy link
Collaborator

rioforce commented Jan 8, 2014

One Question: Does LDraw already have the primitive models as DAT files in the LDraw directory, or is this an optional thing? If re-building them is just to increase quality, subsurf (or a similar method) would help from within Blender.

@MinnieTheMoocher
Copy link
Author

Your question makes no sense. You are asking if LDRAW contains DAT files for those primitives.
Yes, it does.
But this issue is about REPLACING them by native 3D objects of the renderer,
i.e., using a PERFECT 3D cone instead of the polygonized one from the DAT.

@rioforce
Copy link
Collaborator

rioforce commented May 5, 2014

We added the high and low-quality primitives from LDraw for this reason. Instead of reconstructing meshes, why not just use the new LDraw primitives? This importer is supposed to import LDraw bricks as they are, with maybe some minor cleanup. I don't see a reason to re-construct the bricks when LDraw already has 3 qualities of primitives built in.

If you can show us some code, we may consider it. But until then, I don't think this will get into the script.

@MinnieTheMoocher
Copy link
Author

You again misunderstood me.
DAT files ONLY can contain meshes. NO native cones etc.

This request asks for SUBSTITUTING the mesh DATs with native 3D primitives.

So it makes no sense that you again point me back to DATs.

This request is something totally different.

The feature is available in LDView, and rendering quality dramatically increases
when using it.

I wanted to have the same feature in Blender.

@rioforce
Copy link
Collaborator

rioforce commented May 5, 2014

Depending on your pictures above, ( #44 (comment) ), it makes the mesh more high-poly. "Native cones" are meshes in Blender. So are LDraw models. They all turn into faces and vertices. I don't see the point of replacing them. I thought that's why we added the hi-res primitives, so people could have higher quality bricks. I understand what you want, but the feature just doesn't have a high demand. Maybe this could go into the script re-write.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants