Project should take an OBJ file (using pygame, pyopengl, or any other well supported library you may prefer) and convert it to an LDraw format, which is a fairly simple text based format.
OBJ is a common format for 3d objects, but LDraw is less common. It's a text file format description of a LEGO model. The full specifications are here: [login to view URL]
But in reality very little of the spec will be used for this. There will be the header, the lines for parts, and a "step" line for each "level" of the piece.
A line for a piece will need just color information, location information and the piece (one of two possibilities). Other info (rotation and other transformations) won't be used.
Essentially, the conversion should run the following operations on the OBJ file:
Create an array imagining a set of smaller blocks ("plates"). The number of blocks in height is set via command args, and the width and depth of this array are then just as many as they need to be to cover the OBJ object (example below). The ratio for the plates is 0.4x1x1 (HxWxD).
Looping through the array, find each block that intersects with the OBJ object. Keep those blocks and discard the rest, creating essentially an array of binary blocks ("does this block intersect or not?").
Either as a secondary loop, or during the initial one: check the color/texturemap of each area that's inside a given block. Average the color and find the nearest match to a list of "good" colors (standard RGB values) in a passed config file.
Now we have an array of blocks with specified colors. Awesome. Nearly there.
With the array, working from the lowest/bottom level, check each block with the level(s) above it. If there are three in a column that match color, flag the bottom of the three and remove two above it. Do this for each level (so one of these "three blocks" can start at any of the levels). Three LEGO "plates" stacked together make a "brick" (ratio 1.2x1x1 if useful) . At the end of each of these levels, add a "step" line to the LDraw file.
Important note: While I envision this solution as basically "create a three dimensional array and loop through it", if you have a more clever way to solve this, as long as the output file is right, how to get there is not set.
Example:
The command line should then look somewhat like (may vary depending on how you read command args):
> python [login to view URL] --file=[login to view URL] --colors=[login to view URL] --height=100
This would take my '[login to view URL]' file and map it to an array of blocks 100 high (making that array as wide and deep as needed) and colorizing the blocks to match that json file, saving it to a reasonable default like '[login to view URL]'.
This process will have a couple of uses in the end, but the simplest, and easiest to visualize, is to convert an OBJ file into a set of Lego instructions. Three of the shorter "plates" of a Lego block can combine into one "brick", hence that secondary loop through the results. Moving them into a reduced color set allows us to make to available Lego blocks. The end file then becomes a set of Lego instructions to build the OBJ file at whatever height was specified.
I have a .net version of this that completes step 1 (only) of this, making an array of blocks. It's not Python, and only does the beginning loop, but if helpful to visualize one solution to that part of things, it is available here:
Attached:
simple ldr sample file (final file format)
sample obj file with texture mapping as example source files
sample config file
sample color file
Hi ,I am Gang ,software developer in China.
I am a certificated freelancer with over 700 good reviews from my clients.
Relevant Skills and Experience
3D modeling ,OpenGL,
Proposed Milestones
$2061 USD - done
let you visit my reviews so that confirm with me.
Thank you!
Hello, I have read what you exactly need, however I would like to ask you a few questions
Please feel free to ping me anytime so we can have a detailed discussion and finalize our budget and timeline.
Relevant Skills and Experience
Hello, I have read what you exactly need, however I would like to ask you a few questions
Please feel free to ping me anytime so we can have a detailed discussion and finalize our budget and timeline.
Proposed Milestones
$555 USD - placeholder
Hi,
Please Give me one chance to work for you, I have expertise in Graphic design, illustrator,Photoshop,corel draw,Flash designer, Maya, Max, After Effect, 2D & 3D design,modelling,rendering and Animation.
I can create 3D model for you as per your requirement, and also I will sure give you high quality, eye-catchy and fast work.
I have done number of project like this, you can review from my portfolio and also I will show you more once you will select me.
Hope for your very soon reply
Thanks & Regards
Poonam s
Hello,Sir
High-Quality+fast development+good credit+fast communication=My work method!
My first aim is to provide you quality and professional task.
i have developed for 7 years on freelancer.com.
This is my new Account.
I can work fast for the project to meet tight deadlines.
I have a lot of experiences in Python,opengl,webgl for 5+years.
I understand your proposal completely.
I am sure that I will carry out completely with my skills.
and you will be glad with my good quality work.
i have full time for your task and i can communicate with you at any time.
If you reply my request,I am ready for carrying out the task anytime and have enough time.
Let’s resolve this task with together.
Thanks
Regards.
Hey, how’s it going? My name is Mike, I’m a Web Designer & Developer from Boston. I've had a look at your project description and feel that my skills match your requirements perfectly.
Relevant Skills and Experience
Graphic Design, Front End Development, PHP, WordPress
Proposed Milestones
$555 USD - project milestone
I recently did a very similar project which I can share with you.
Hello,
We have accomplished 90% of the project which is similar of your requirement. All we need 10% customization as per your requirement set and specifications. I want to discuss in personal chat in order to explore your needs, which will yield a clear picture of implementation phase.
Prior undertaking project, I want to show demo of the work done previously.
Apart from demo, I will be sharing following documentation which will turn your project into Quality and Successful delivery:
- Technical Project Proposal
- Designs
- Flow chart for this Project
- Execution plan
Thanks
I will do Python 3d file conversion (OBJ file to LDraw)
Relevant Skills and Experience
3D Design, 3D Modelling, Python, Software Development
Proposed Milestones
$555 USD - 10 Days
Hello, I can do this task in order to you make your lego movie
Relevant Skills and Experience
I am an engineer with a lot of expereience at python and other programming langages and I like to work whit virtual 3D objects.
Proposed Milestones
$500 USD - source code of OBJ to LDraw file converter in python
Hi. I can help you! Waiting for your response
Relevant Skills and Experience
HTML5, CSS, Python, Flask, Django, JavaScript, React Native
Stay tuned, I'm is still working on this proposal.