LDraw.org Discussion Forums

Full Version: "Wrapping" Tool
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Before I start my own rudimentary coding, I thingk I better ask.

I am looking for a tool that allows me to wrap Stickers around a certain shape, e.g. the Santa Fe front sticker, some Panels etc.
If those stickers are made from the scanned sheet itself some distortion will occur, proper rotation of the destination part will reduce these effects when using SlicerPro.

Howver with Stickers "around the corner", like the Santa Fe one, the result is too distorted. The output gets streched too much to be visually pleasing.

Now I though of doing a small script that "bends" the sticker along the edges that the parts provide. For the Santa Fe thsi would be the outer surface of the 6005.dat

The question is if somebody has already done such a tool or which tool can do this?


Have you tried removing the sticker from the part and then scanning it?

Also, if you plan on using POV-Ray, then a distorted image might actually be what you want. If you project the scanned image onto the 3D part, then the result may look like the real thing.
he wants to do the other way around. Create a plain Sticker (from a Sticker Sheet) and add it to a bent surface. Actually it results in a heavy deformed pattern, when it is bent too much. So we need something that will bent the sticker automatically without stretching it.

My basic idea would be:
1. get the edge coordinates
2. move this edge 0.25 LDU to the outside (this must be calculated as a simple movement doesn't work here)
3. rotate the pattern until it is planar with the most outside edge
4. break the pattern at the line, where the edge line is bent for the first time
5. rotate the rest of the pattern until it is planar with the next edge
6. break the pattern at the line, where the edge from step 5. is bent.
7. redo steps 4, 5 and 6 until all areas of the pattern are bent correctly.
8. create the outside border of the sticker (90° to the pattern sides)
9. create the underside (maybe as a cutout of the part where the sticker should be applied)

No such tool exist AFAIK - and it would be useful. In the past I used the cut/rotate/move solution using simsplitter and MLCad, but it's tedious at best!

And if you are in the mood of heavy coding, think of the more general problem of patterned foldable canvas such as tepee!

Quote:For the Santa Fe thsi would be the outer surface of the 6005.dat
Don't forget sticker thickness Wink
That are exactly the steps as I wrote them down :-)
The problem with my mood for heavy coding is the output, it will be in VB... but I will try it. ...and look into something more efficient language in the future...

I won't forget the 0,25 LDU!

PS: that could be a feature for Nils' Part Editor :-)
Adapting to C or C++ should be possible afterwards... ;-)
Gerald Lasser Wrote:Now I though of doing a small script that "bends" the sticker along the edges that the parts provide. For the Santa Fe thsi would be the outer surface of the 6005.datGerald

Here's the $10,000 question: what will your program do if the sticker cannot be placed on the part without a wrinkle or bend?

For the case where you'd want to apply a sticker (e.g. a rectangular sticker around a curved top surface or curved arch top) there exists a good 'wrap' to make this happen.

But what about a part like 86500.dat (Dome 4x4 Smooth)? A sticker on the top would in real life be a wrinkled mess; the planar sticker can't cover the top well.

Or what about the front of the Maersk engine? There is a sticker covering a series of cheese slopes. In real life it works pretty well, but a computer program might be fooled by the small vertical edge of the cheese slope which interrupts the implied smooth surface.

The problem with coding this (as I see it) is that LDraw does not provide -guarantees- about the connectivity of a mesh. Even for a case that can work right (e.g. 6192.dat Brick 2x4 with curved top) the file format does not guarantee that the top smooth surface can be identified as continuous without gaps. There may even be small caps that must be covered with rounding due to problems with part authoring and rounding in the matrices of the primitives.

If I had to code this I think I would (I suppose) look at something like this:


Least Conformal Squares is one of the common ways that 3-d programs provide texture maps to arbitrary surfaces. I -think- that if the surface is good for stickering (e.g our curved tops) the UV map should have no distortion. The nice thing about an algorithm like this is that, if the sticker can't lay perfectly flat, it gets it as close as it can, so you don't have to deal with total algorithm failures due to rounding errors.

Once you have a "UV" map (a 2-d mapping of the sticker's X and Y space) over the part, you can then, for each triangle in the 3-d mesh, locate its place over the sticker, cut out a series of sub-triangles in the sticker, and place them in 3-d space. Because each triangle in the real 3-d part is (by definition :-) planar, applying the set of planar sticker sub-triangles doesn't require anything complicated.

Uh, I hope this isn't too discouraging. Unfortunately wrapping planar labels around arbitrary 3-d surfaces is complicated. Perhaps there could be some way to simplify the problem, e.g. have the user specify the cross-section of the curved surface the sticker will be placed on, then apply it. This would let you work from mathematical input data that is much more suited for your purpose than "triangle soup".

I'd just work on the simple case of planer surfaces, open the code, and either get back to the hard cases later or let someone else give it a whirl.
Thanks for your thoughts! I really do not want to touch surfaces bent in two directions. Of all the LEGO stickers I have thought of and I check right now (e.g. Wedge 52031) that ight seem to be bent slightly in two directions are actuall not. These surfaces are planar.

I came across the problemfirst when projecting a circle onto a bent surface, e.g the new Artic Logo onto the Curved Slope 15068. The "normal" projection distorts the logo, however if you rotate the slope in a better porition the projection issue is not that apparent. Another thing is how LEGO prints them, positions them etc.

The real issue comes with something like the Santa Fe. But for this case the edge line of the front part is enough to do the job. And even if I have to extract it manually from multiple part as it is a STAMP case (as the MAERSK Engine)

I will try something along this path, "bending" a sticker along a given line. For sure there is manual work involved as well, but for a start I think I will be fine with this low-fi approach first.

Gerald Lasser Wrote:I will try something along this path, "bending" a sticker along a given line. For sure there is manual work involved as well, but for a start I think I will be fine with this low-fi approach first.

I think that's a good approach. You can still get the exact result you want pretty easily, the algorithm will be 1,000,000 times easier to code, and most importantly, you can write an algorithm that works 100% of the time and is not fooled by floating point rounding errors, non-planar meshes, and other crazy things. :-)

(It is this "long tail" of bugs and weirdness that makes general purpose mesh algorithms in floating point so scary...)

Gerald Lasser Wrote:PS: that could be a feature for Nils' Part Editor :-)

I will take this on my list, but I do not include this feature in the first release.
It is possible to do the 2D to 3D projection with my LDPatternCreator (LPC).
This process is difficult.
You have to create a template file with defined projections, like this:

1 0 0 0
0 1 0 0
0 0 1 0
0 0 0 1
{60 48; 60 -48; -60 -48; -60 48} {2 96 10; 2 0 10; 2 0 130; 2 96 130}

{60 48; 60 -48; -60 -48; -60 48} {2 96 10; 2 0 10; 2 0 130; 2 96 130}
defines the projection
Interesting... I must dig deeper into this!

[edit] got it to work!!! more later...
I looked into the templates of LDPC, the good thing there is I can use it to slice it first with the CUT command in the template. The problem is if the planes are approaching 90° compared to the initial orientation.

What was not very clear to me was if I have a facetted surface, how to define the orientation and coordinates of the different surfaces, but looking at your example, I will give that a try as well.

so {60 48; 60 -48; -60 -48; -60 48} I understand is a quad. but what does {2 96 10; 2 0 10; 2 0 130; 2 96 130} define?
I ever thought, that the result will be stretched or deformed after doing this.

No, take the slope parts: you project from top, but create a non-stretched pattern.
Good to know :-)
I made the "Diver's Computer Pattern" with this method, but I never used it for a multi-facetted surface (like a Curved Slope) as I did not know how to prepare a template for such a surface.
Quote:so {60 48; 60 -48; -60 -48; -60 48} I understand is a quad. but what does {2 96 10; 2 0 10; 2 0 130; 2 96 130} define?
The first part defines the area in LPC plane (quad) that will be mapped it 3D world on the quad whose coordinated are given in the second part.

I just created a template for a 6005 sticker, here is the method I used.
- Create the top surface of formed sticker, using front surface of 6005 part (file 6005StickerTemplateBase.dat)
- Inline every primitives and leave only required lines (file 6005StickerTemplate.dat)
- Launch LPC, and File -> import from dat -> project on XY front -> import projection data -> select 6005StickerTemplate.dat
- We now see the shape of sticker, with quads forming the curve getting flatter and flatter (and more and more useless...) as we approach top of curve. Thansform this imported projection data into a template: File -> projection data->template (the green lines turn light brown.
- This creates a template file, named _New_Template_1.txt (number may change if you repeat this process!). This file is located in C:\Documents and Settings\Philo\Application Data\Nils Schmidt\LDPatternCreator\template (exact location depends on Windows version).
- We are now going to transform this template to make all quads equal, with the right height, so that we can use a flat image of sticker to draw pattern. This is the painful, tedious and error prone step that would need to be automated with a script... A bit of trigonometry gives the height of each quad (5.265 ldu).
- Using this information, we change height of the quads drawn on screen by LPC
-10 48
-10 40
10 40
10 48
10 34.74738
10 40
-10 40
-10 34.74738
10 29.5833
10 34.74738
-10 34.74738
-10 29.5833
-10 48
-10 40
10 40
10 48
10 34.735
10 40
-10 40
-10 34.735
10 29.47
10 34.735
-10 34.735
-10 29.47
The first rectangle, base of part, is not part of curve and is unchanged, the second has its height slightly modified, the third has its base moved to compensate brevious quad changed, and its height changed to 5.265, and so on.
- In the same spirit, we change the planar to 3D transformation lines:
{-10 48; -10 40; 10 40; 10 48} {10 48 -50.25; 10 40 -50.25; -10 40 -50.25; -10 48 -50.25}
{10 34.747375; 10 40; -10 40; -10 34.747375} {-10 34.747375 -49.90385; -10 40 -50.25; 10 40 -50.25; 10 34.747375 -49.90385}
{10 29.5833; 10 34.747375; -10 34.747375; -10 29.5833} {-10 29.5833 -48.877475; -10 34.747375 -49.90385; 10 34.747375 -49.90385; 10 29.5833 -48.877475}
is changed to
{-10 48; -10 40; 10 40; 10 48} {10 48 -50.25; 10 40 -50.25; -10 40 -50.25; -10 48 -50.25}
{10 34.735; 10 40; -10 40; -10 34.735} {-10 34.747375 -49.90385; -10 40 -50.25; 10 40 -50.25; 10 34.747375 -49.90385}
{10 29.47; 10 34.735; -10 34.735; -10 29.47} {-10 29.5833 -48.877475; -10 34.747375 -49.90385; 10 34.747375 -49.90385; 10 29.5833 -48.877475}
- When this lengthy process is done, we save file as 6005_Sticker_Template.txtt in the template folder. Phew!
- We can now start again LPC and load this new template. All the quads of the curve now have the same height! Here is the LPC file of a quick test.

The image below shows LPC screen and resulting sticker.
Wow! [Lifts hat] That's an amazing work you have done! Thanks!

Did a quick try on the Santa Fe Logo and it looks promising!
[Image: santafe-a_out11.png]
...aaand here's the front part of the sticker! A bit of bleeding can be see although it is .25 LDU from each surface. I hoep this goes away with the completed box!

[Image: 100208.png]
As there is an ever growing number of stickers to be applied on curved surfaces, like the Speed Champions etc, I made a small Excel-Tool (as a proof of concept) that creates does the LDPC template creation for me.

I think I should take it up as a programming exercise for my first C++ program :-) right now everything is still possible with formulas in the cells.

How does it work:
-> You feed it the surface where the sticker shall be applied to
note: currently to work it needs quads and the vertices in an order like this
A ---- D
| |
B -----C
-> the thickness is set to 0.25 LDU
-> you get the template data a few columns to the right...
-> The result can be pasted (with replacing "*" by a <CR>) into a template file

I still need to think of a way to hand over a proper reference point to easily apply the sticker in the CAD programs

And I need to add the box shape for the sticker.

I do some screenshots in the evening and open a new post including the spreadsheet
Could you please copy this to the website and spoil it with more picture?

Thx, w.