Drawing to 3D render

The cab arrived late. The inside was in as bad of shape as the outside which was concerning, and it didn’t appear that it had been cleaned in months. The green tree air-freshener hanging from the rearview mirror was either exhausted of its scent or not strong enough to overcome the other odors emitting from the cab. The correct decision, in this case, was to get the hell out of it and to call another cab, but she was late and didn’t have a choice.

Hi,
If I got it right, this is what I understand you want to do:
You have a .dxf file, which seems to be AutoCAD’s way of storing 2D and 3D drawings several years ago.
You want to render that with some images on the background.
I apologize if this is not what you wanted. You might want to explain in detail.

I do not know how someone might be able to automate this, because I assume each image is going to be different.

But doing this can be done easily in blender if you have only a few images:

  1. Install blender if you don’t have.
  2. Install the .dxf importer-exporter addon from within blender.
  3. Import the the .dxf you have.
  4. Import the image as a backdrop and click render.
    Simply googling these steps will let you know how to do it.

But the image you obtain might not be very realistic. That requires a bit more work.
See World Environment if you want.

Screenshots are easy to make.

from direct.showbase.ShowBase import ShowBase

class Demo(ShowBase):

    def __init__(self):
        ShowBase.__init__(self)

        sample = loader.loadModel("panda")
        sample.reparentTo(render)
        sample.set_pos(0, 50, 0)
        
        base.graphicsEngine.renderFrame()
        base.win.saveScreenshot("1.png")
        
demo = Demo()
demo.run()
1 Like

Hi @briaian87b

Yes, see here

You would have to add this line at the beginning of the script:

loadPrcFileData("", "load-file-type p3assimp")

By default panda3d can only load .egg and .bam files (AFAIK). This snippet enables all formats supported by assimp.

Yes, as stated above you can export it to any format supported by assimp and load it on panda3d.

So, summing up all these you would have something like:

from direct.showbase.ShowBase import ShowBase
from panda3d.core import loadPrcFileData
loadPrcFileData("", "window-type offscreen" ) # Spawn an offscreen buffer
loadPrcFileData("", "audio-library-name null" ) # Prevent ALSA errors
loadPrcFileData("", "load-file-type p3assimp") # Load using assimp
base = ShowBase()
for file in folder:
    sample = loader.loadModel(file)
    sample.reparentTo(render)
    sample.set_pos(0, 50, 0)
    base.graphicsEngine.renderFrame()
    base.screenshot(namePrefix='screenshot', defaultFilename=1, source=None, imageComment="")
    sample.destroy()

In fact, Assimp is used by default. The Confauto.prc file contains a string generated by the build system.

# If we built with Assimp support, we can enable the Assimp loader,
# which allows us to load many model formats natively.

load-file-type p3assimp