Moo-Ack-Productions / MCprep

Blender python addon to increase workflow for creating minecraft renders and animations
https://theduckcow.com/MCprep
GNU General Public License v3.0
285 stars 24 forks source link

How do I add new sub menus and sub tabs? #50

Closed ghost closed 6 years ago

ghost commented 6 years ago

I'd like to make the add-on more customized for myself, like adding a blocks spawner, an item spawner, an effect spanwer (?), and use them like doing Shift + A or using the tools bar, I tried copying some of the code and edit it but it didn't work..., does someone knows how to correctly create/add a new section?

TheDuckCow commented 6 years ago

Hey there! What you’re trying to do is definitely in my todo list for things I want to add.. But I can’t make any promises on how quickly it will be get there.

My short-term suggestion for you, would be to add the blocks as objects or groups into the mesh swap blend file. Then you can still use shift a and the side panel (side panel even lets you search via text).

If you really want to try to copy the code (go for it!) then, why don’t you create a branch of MCprep, make some hot commits there and then I may be able to help correct the problems you are running into.

Patrick W. Crawford Moo-Ack! Productions www.TheDuckCow.com youtube, twitter, facebook

On Aug 6, 2018, at 22:31, Zophiekat notifications@github.com wrote:

I'd like to make the add-on more customized for myself, like adding a blocks spawner, an item spawner, an effect spanwer (?), and use them like doing Shift + A or using the tools bar, I tried copying some of the code and edit it but it didn't work..., does someone knows how to correctly create/add a new section?

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub, or mute the thread.

ghost commented 6 years ago

General kenobi (jk lol) I tried doing something but it didn't work, I don't know how to code but I'll try again :) also, it would also be cool if you could edit the default nodes on the marerials so you don't have to redo them, is it ok if I can show you the edit I made for "materials.py"? (I have no idea what to do for the tabs)

TheDuckCow commented 6 years ago

Certainly, feel free to share the screenshot here with your edited node layout. I’m also working (and much closer to) an update there which improves emission materials and otherwise upgrades to use the principled shader. This is great time to get other change inputs!

Patrick W. Crawford Moo-Ack! Productions www.TheDuckCow.com youtube, twitter, facebook

On Aug 8, 2018, at 17:25, Zophiekat notifications@github.com wrote:

General kenobi (jk lol) I tried doing something but it didn't work, I don't know how to code but I'll try again :) also, it would also be cool if you could edit the default nodes on the marerials so you don't have to redo them, is it ok if I can show you the edit I made for "materials.py"? (I have no idea what to do for the tabs)

— You are receiving this because you commented. Reply to this email directly, view it on GitHub, or mute the thread.

ghost commented 6 years ago

What a coincidence! my main node on the code is the principled shader, it would be nice if the update supports other textures besides Color but SSS, Roughness, Glossy, Normal, I tried it creating a new material and it looks better than the regular blocks! (I had to create my own textures tho)

stone bricks regular stone bricks principled with maps stone bricks material

and this is the edit of the materials which failed idk why (this is the part I edited)

`

Function for default cycles materials

def materialsCycles(self, mat):
    # get the texture, but will fail if NoneType
    try:
        imageTex = mat.texture_slots[0].texture.image
    except:
        return
    matGen = util.nameGeneralize(mat.name)
    listData = self.getListDataMats()

    #enable nodes
    mat.use_nodes = True
    nodes = mat.node_tree.nodes
    links = mat.node_tree.links
    nodes.clear()
    nodeTexImage1 = nodes.new('ShaderNodeTexImage')
    nodeTexImage2 = nodes.new('ShaderNodeTexImage')
    nodeTexImage3 = nodes.new('ShaderNodeTexImage')
    nodeTexImage4 = nodes.new('ShaderNodeTexImage')
    nodeNormalMap = nodes.new('ShaderNodeNormalMap')
    nodePrincipled = nodes.new('ShaderNodeBsdfPrincipled')
    nodeTransparent = nodes.new('ShaderNodeBsdfTransparent')
    nodeMixShader = nodes.new('ShaderNodeMixShader')
    nodeOut = nodes.new('ShaderNodeOutputMaterial')

    # set location and connect
    nodeTexImage1.location = (-1800,480)
    nodeTexImage2.location = (-1800,0)
    nodeTexImage3.location = (-1800,-480)
    nodeTexImage4.location = (-1400,-1000)
    nodeNormalMap.location = (-1800,-960)
    nodePrincipled.location = (-840,0)
    nodeTransparent.location = (-860,-160)
    nodeMixShader.location = (-400,0)
    nodeOut.location = (0,0)
    links.new(nodeTexImage1.outputs["Color"],nodePrincipled.inputs[0])
    links.new(nodeTexImage1.outputs["Color"],nodePrincipled.inputs[3])
    links.new(nodeTexImage2.outputs["Color"],nodePrincipled.inputs[1])
    links.new(nodeTexImage3.outputs["Color"],nodePrincipled.inputs[7])
    links.new(nodeTexImage4.outputs["Color"],nodeNormalMap.inputs[2])
    links.new(nodeNormalMap.outputs["Normal"],nodePrincipled.inputs[16])
    links.new(nodePrincipled.outputs["BSDF"],nodeMixShader.inputs[2])
    links.new(nodeTransparent.outputs["BSDF"],nodeMixShader.inputs[1])
    links.new(nodeMixShader.outputs["Shader"],nodeOut.inputs[0])
    nodeTexImage1.image = imageTex
    nodeTexImage2.image = imageTex
    nodeTexImage3.image = imageTex
    nodeTexImage4.image = imageTex
    nodeTexImage1.color_space = 'Color'
    nodeTexImage2.color_space = 'Non-Color Data'
    nodeTexImage3.color_space = 'Non-Color Data'
    nodeTexImage4.color_space = 'Non-Color Data'
    nodeTexImage1.interpolation = 'Closest'
    nodeTexImage2.interpolation = 'Closest'
    nodeTexImage3.interpolation = 'Closest'
    nodeTexImage4.interpolation = 'Linear'

    #set other default values, e.g. the mixes
    nodeNormalMap.inputs[1].default_value = 1
    nodePrincipled.inputs[1].default_value = 0
    nodePrincipled.inputs[4].default_value = 0
    nodePrincipled.inputs[5].default_value = 0.5
    nodePrincipled.inputs[6].default_value = 0
    nodePrincipled.inputs[7].default_value = 0.5
    nodePrincipled.inputs[8].default_value = 0
    nodePrincipled.inputs[9].default_value = 0
    nodePrincipled.inputs[10].default_value = 0
    nodePrincipled.inputs[11].default_value = 0.5
    nodePrincipled.inputs[12].default_value = 0
    nodePrincipled.inputs[13].default_value = 0.03
    nodePrincipled.inputs[14].default_value = 1.45
    nodePrincipled.inputs[15].default_value = 0
    nodeMixShader.inputs[0].default_value = 0.5

    # the above are all default nodes. Now see if in specific lists

perhaps I need to edit another .py file? `

TheDuckCow commented 6 years ago

Great minds think alike :) Yes, the next (or possibly second to next) release will actually fully support arbitrary, valid Minecraft resource packs - which includes packs with extra paths for normal maps and so forth. There aren't a ton out there which utilize these extra maps, but a enough to still be useful by and large. Honestly, I'm just sorry I haven't released it sooner! And nice to see some other animators coding too.

For debugging the code, I don't see an immediate errors off the bat, but a good way to debug yourself is sprinkle "print" statements; e.g. add a line just after #enable nodes like `print("DEBUG - running cycles principled generator"), and then check in the output console window after you press the prep materials button (On windows, view it by going to Window > toggle console; on mac or linux, open blender from a command line window to begin with). If you do see it, then it's running.. but not how you expect. If you don't see it, then it's not even running that code, so something else is going awry.

Finally, just want to call out I also have a dev branch on this repo. Might be interesting for you to check that out, as I have the principled shader code pretty much all implemented there. It's called dev for a reason though.. not everything may be fully working, as this next update involves a refactor of a lot of code and structures.

ghost commented 6 years ago

A dev verison? nice! I didn't knew about this one :D I will be happy to test it and see how it works, I was stressing too much on recreating some of the code so it has the stuff I want but at the back of my head I was thinking "what if there's a new MCprep version soon?" but I kept learning how to do it myself until I hit bedrock and couldn't do anything.

Perhaps I could help with some basic stuff if you would like to, I'll be happy to help!

TheDuckCow commented 6 years ago

Really appreciate the offer! And honestly, having literally anyone helping at all would be great given the limited time I have. Definitely give the dev branch a try, be sure to fully remove the existing MCprep addon, restart blender, then install the new one and let me know how it goes.

TheDuckCow commented 6 years ago

I'm going to close this issue in the meantime, but @Zophiekat definitely check out the latest dev updates if you hadn't before now.

ghost commented 6 years ago

Alright!, I haven't used the dev yet because I had some issues with creating maps 😅