Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Previews for matparams #334

Merged
merged 38 commits into from
Sep 12, 2022
Merged

Conversation

neph1
Copy link
Contributor

@neph1 neph1 commented May 16, 2022

This is both preview of shader node outputs, editing them and some general refactoring and fixes made along the way.

I'm afraid this is going to be a big one, so I'm creating a draft in case anyone wants to tag along :)

Edit: I'm unsure as to why it replaces some whole files. Because line endings were wrong?

neph1 added 3 commits May 16, 2022 22:04
AssetManager static hack to load textures in preview...
Updatable floats and colors
Updatable floats and colors
(SDK Core project)
private MatDefBlock matDefStructure;
private TechniqueBlock currentTechnique;
private MaterialDef materialDef;
private static ProjectAssetManager assetManager;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, this was the best I could do at the time. Will try to find a better way

@@ -721,6 +728,9 @@ private void initData(TechniqueBlock technique, ProjectAssetManager manager, Lis

for (MatParamBlock matParamBlock : matDef.getMatParams()) {
ShaderNodeVariable var = new ShaderNodeVariable("", "MatParam", matParamBlock.getName());
if(matParamBlock.getDefaultValue() != null){
Copy link
Contributor Author

@neph1 neph1 May 16, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This allows for the creation of previews for the nodes

break;
case MatParam:
header.setIcon(Icons.mat);
setNameAndTitle("MatParam");
name = "MatParam";
setTitle(outputLabels.get(0).getText());
break;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Separating name and title for single output nodes. It allows for having the param name in the header.

neph1 added 8 commits May 18, 2022 21:12
# Conflicts:
#	jme3-core/src/com/jme3/gde/core/editor/nodes/NodePanel.java
This reverts commit 2d4920e, reversing
changes made to bed7dea.
# Conflicts:
#	jme3-core/src/com/jme3/gde/core/editor/nodes/NodePanel.java
@neph1
Copy link
Contributor Author

neph1 commented May 20, 2022

This PR adds both previews and editors for values for the shader nodes. I'd still like to explore it a bit further and see if i can pass down MatParams all the way to the nodes, that would make some things easier to formalize.

if (evt.getPropertyName().equals("name")) {
if(evt.getSource() instanceof BasePreview && evt.getNewValue() instanceof String){
diagram.updateDefaultValue(evt.getPropertyName(), (String) evt.getNewValue());
} else if (evt.getPropertyName().equals("name")) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This block listens for changes to default values and passes them on.

@neph1
Copy link
Contributor Author

neph1 commented May 25, 2022

I tried breaking out the live updates for materials into its own, but it's too nestled in with the rest.

/**
* The NodePanel is the actual implementation of a Node.
* @author Nehon
*/
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All changes to this class are about making nodes more compact and work better with the preview/editor panels. I made them opaque for that reason

this.loaded = loaded;
}

private class MatStructChangeListener implements PropertyChangeListener {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Moved this to its own class

}
return 0;
}

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Handled by Comparator in ShaderNodesBlock now

@@ -42,6 +42,7 @@
import javax.swing.JList;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JToggleButton;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added a new button for toggling live updates. Should find an icon for that..

@neph1 neph1 marked this pull request as ready for review May 25, 2022 20:00
@neph1 neph1 marked this pull request as draft May 26, 2022 05:47
neph1 added 10 commits May 26, 2022 21:01
# Conflicts:
#	jme3-materialeditor/src/com/jme3/gde/materialdefinition/editor/ShaderNodePanel.java
Conflicts:
	jme3-materialeditor/src/com/jme3/gde/materialdefinition/EditableMatDefFile.java
# Conflicts:
#	jme3-core/src/com/jme3/gde/core/editor/nodes/Diagram.java
#	jme3-materialeditor/src/com/jme3/gde/materialdefinition/EditableMatDefFile.java
#	jme3-materialeditor/src/com/jme3/gde/materialdefinition/editor/Bundle.properties
#	jme3-materialeditor/src/com/jme3/gde/materialdefinition/editor/MatDefEditorToolBar.form
#	jme3-materialeditor/src/com/jme3/gde/materialdefinition/editor/MatDefEditorToolBar.java
#	jme3-materialeditor/src/com/jme3/gde/materialdefinition/editor/ShaderNodeDiagram.java
#	jme3-materialeditor/src/com/jme3/gde/materials/MaterialPreviewRenderer.java
@neph1
Copy link
Contributor Author

neph1 commented Jun 7, 2022

Getting there... This last merge was really messy. Cause: Line endings updated on other PR's but not this one. One more "lesser" pr to go before i'll finish this one up.

@neph1 neph1 marked this pull request as ready for review August 7, 2022 15:05
@neph1
Copy link
Contributor Author

neph1 commented Aug 23, 2022

@neph1
Copy link
Contributor Author

neph1 commented Aug 25, 2022

I think this PR deserves a squash commit.
I'll request an inverse review; Unless someone complains loudly, I'll merge this in a couple of days time.

@neph1 neph1 merged commit 33831b7 into jMonkeyEngine:master Sep 12, 2022
@neph1 neph1 deleted the previews_for_matparams branch May 6, 2023 07:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant