0
$\begingroup$

I'm creating an application that generates lenses based on a prescription, and places those lenses into frames so that the user can get a feel for how the lenses might look. The problem I'm facing is that I'm unable to consistently place lenses into frames at the correct location/rotation. This is because:

  1. Each frame has different geometry i.e. some are flatter, some are angled, circular, etc
  2. Each lens has different geometry, based on the prescription, and then the cut out that's made to fit into the specified frame.

What I have at the moment is a set transformation for each frame that the lenses just copy, which only works for a small range of prescriptions.

Examples:

Lenses are too far back

Lenses are too far back

Not rotated properly

enter image description hereenter image description here

Location is ok, but the curvature causes it to no connect

enter image description here

I'm aware that my lens generation algorithm isn't perfect and makes it harder (can be seen in the last pic) but at the moment I need to focus on the lens placement and consider the generation to be a block box.

Some solutions I've thought of:

  1. Shrinkwrap the lens onto a preset shape. Would probably look ok but takes away from the whole point of the application by deforming the lens.
  2. Create a set of anchor points on the frames, a corresponding number of anchor points on the lenses, and then "anchor" the corresponding anchor points on the frame and lens. While I can create the anchor points on the frames beforehand and use it as a present, I'm not sure how I would create the anchor points on the lenses algorithmically. I'm also not sure what a good criterion would be for where I would create the anchor points, nor how many. I'm also not sure how I could ensure that anchoring one pair of points doesn't disconnect a previously anchored pair.
  3. Go with solution 2, but use a minimizer to find the best rotation/location of the lens relative to the frame. I'd still need to define anchor points, giving me the same problems as number 2, but I'd have a minimizer instead of a weird algorithm trying to match all the points. I feel like this would work the best, but I'm not sure how I would create the minimizer or the anchor points.
$\endgroup$
3
  • $\begingroup$ Certainly a puzzle to solve. I think your talking about a python script. One small part of this would be the use of the knife_project(), after you visually align the lens to the frame (i.e. the frame would project and cut new vertices, edges, into the lens. Perhaps also copy-location and copy-rotation constraints to align the two components. For lens thickness, perhaps the "Solidify" modifier. $\endgroup$
    – james_t
    Commented Apr 5 at 20:58
  • $\begingroup$ Have you tried converting part of you object to a curve ( glasses) and wrapping a curve (lens) to the object blender.stackexchange.com/questions/258459/… or blender.stackexchange.com/questions/277240/… $\endgroup$
    – Rick T
    Commented Apr 6 at 5:27
  • $\begingroup$ Thank you for the, input but both these solutions involve deforming the mesh which I'm not allowed to do $\endgroup$
    – Omar Farag
    Commented Apr 6 at 19:55

0

You must log in to answer this question.

Browse other questions tagged .