Skip to content

Use the newer tangent generator, fixes the shiny sphere template #456

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

Merged
merged 1 commit into from
Jan 22, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,11 @@ public JmePaletteShinySphere() {

private String createBody() {

String body = "/** Illuminated bumpy rock with shiny effect. \n * Uses Texture from jme3-test-data library! Needs light source! */\nSphere sphereMesh = new Sphere(32,32, 2f);\nGeometry shinyGeo = new Geometry(\"Shiny rock\", sphereMesh);\nrock.setTextureMode(Sphere.TextureMode.Projected); // better quality on spheres\nTangentBinormalGenerator.generate(rock); // for lighting effect\nMaterial shinyMat = new Material( assetManager, \"Common/MatDefs/Light/Lighting.j3md\");\nshinyMat.setTexture(\"DiffuseMap\", assetManager.loadTexture(\"Textures/Terrain/Pond/Pond.png\"));\nshinyMat.setTexture(\"NormalMap\", assetManager.loadTexture(\"Textures/Terrain/Pond/Pond_normal.png\"));\n//shinyMat.setTexture(\"GlowMap\", assetManager.loadTexture(\"Textures/glowmap.png\")); // requires glow filter!\nshinyMat.setBoolean(\"UseMaterialColors\",true); // needed for shininess\nshinyMat.setColor(\"Specular\", ColorRGBA.White); // needed for shininess\nshinyMat.setColor(\"Diffuse\", ColorRGBA.White); // needed for shininess\nshinyMat.setFloat(\"Shininess\", 5f); // shininess from 1-128\nshinyGeo.setMaterial(shinyMat);\nrootNode.attachChild(shinyGeo);";
String body = "/** Illuminated bumpy rock with shiny effect. \n * Uses Texture from jme3-test-data library! Needs light source! */\nSphere sphereMesh = new Sphere(32,32, 2f);\nGeometry shinyGeo = new Geometry(\"Shiny rock\", sphereMesh);\nsphereMesh.setTextureMode(Sphere.TextureMode.Projected); // better quality on spheres\nMikktspaceTangentGenerator.generate(shinyGeo); // for lighting effect\nMaterial shinyMat = new Material( assetManager, \"Common/MatDefs/Light/Lighting.j3md\");\nshinyMat.setTexture(\"DiffuseMap\", assetManager.loadTexture(\"Textures/Terrain/Pond/Pond.jpg\"));\nshinyMat.setTexture(\"NormalMap\", assetManager.loadTexture(\"Textures/Terrain/Pond/Pond_normal.png\"));\n//shinyMat.setTexture(\"GlowMap\", assetManager.loadTexture(\"Textures/glowmap.png\")); // requires glow filter!\nshinyMat.setBoolean(\"UseMaterialColors\",true); // needed for shininess\nshinyMat.setColor(\"Specular\", ColorRGBA.White); // needed for shininess\nshinyMat.setColor(\"Diffuse\", ColorRGBA.White); // needed for shininess\nshinyMat.setFloat(\"Shininess\", 5f); // shininess from 1-128\nshinyGeo.setMaterial(shinyMat);\nrootNode.attachChild(shinyGeo);";
return body;
}

@Override
public boolean handleTransfer(JTextComponent targetComponent) {
String body = createBody();
try {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
NewCustomControlVisualPanel1.jTextField1.text=com.mycompany.mygame.MyControl
NewCustomControlVisualPanel1.jLabel1.text=Class Name:
AtlasBatchGeometryVisualPanel1.jTextArea1.text=Note that all the textures of the batched geometry have to fit in the atlas texture, else not all will be added to the atlas. There is no scaling happening!\n\nAlso note that when batching geometry with normal maps you have to make sure the current normal map and color/diffuse map etc. match in size for each geometry. \nE.g. a model with a diffuse map of 256x256 has to use a normal map with 256x256 pixels as well.
GenerateTangentsVisualPanel1.jTextPane1.text=Warning this will likely modify the mesh by adding vertices.\nUse this if your normal map has mirrored parts.
GenerateTangentsVisualPanel1.splitMirrored.text=Split vertices with mirrored UVs
GenerateLODVisualPanel1.jPanel1.border.title=Reduction method
GenerateLODVisualPanel1.jPanel2.border.title=Reduction values
GenerateLODVisualPanel1.jLabel1.text=Type a value for each desired level
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,27 +34,18 @@
import com.jme3.gde.core.sceneexplorer.nodes.AbstractSceneExplorerNode;
import com.jme3.gde.core.sceneexplorer.nodes.JmeGeometry;
import com.jme3.gde.core.sceneexplorer.nodes.actions.AbstractToolAction;
import com.jme3.gde.core.sceneexplorer.nodes.actions.AbstractToolWizardAction;
import com.jme3.gde.core.sceneexplorer.nodes.actions.ToolAction;
import com.jme3.scene.Geometry;
import com.jme3.scene.Mesh;
import com.jme3.scene.VertexBuffer.Type;
import com.jme3.util.TangentBinormalGenerator;
import java.awt.Component;
import java.text.MessageFormat;
import java.util.ArrayList;
import java.util.List;
import javax.swing.JComponent;
import org.openide.DialogDisplayer;
import org.openide.WizardDescriptor;
import org.openide.nodes.Node;
import com.jme3.util.mikktspace.MikktspaceTangentGenerator;

/**
*
* @author normenhansen
*/
@org.openide.util.lookup.ServiceProvider(service = ToolAction.class)
public class GenerateTangentsTool extends AbstractToolWizardAction {
public class GenerateTangentsTool extends AbstractToolAction {

public GenerateTangentsTool() {
name = "Generate Tangents";
Expand All @@ -75,55 +66,18 @@ protected void doUndoTool(AbstractSceneExplorerNode rootNode, Object undoObject)
}
}

@Override
public Class<?> getNodeClass() {
return JmeGeometry.class;
}

@Override
protected Object showWizard(Node node) {
List<WizardDescriptor.Panel<WizardDescriptor>> panels = new ArrayList<WizardDescriptor.Panel<WizardDescriptor>>();
panels.add(new GenerateTangentsWizardPanel1());
for (int i = 0; i < panels.size(); i++) {
Component c = panels.get(i).getComponent();
if (c instanceof JComponent) { // assume Swing components
JComponent jc = (JComponent) c;
jc.putClientProperty(WizardDescriptor.PROP_CONTENT_SELECTED_INDEX, i);
jc.putClientProperty(WizardDescriptor.PROP_AUTO_WIZARD_STYLE, true);
jc.putClientProperty(WizardDescriptor.PROP_CONTENT_DISPLAYED, true);
jc.putClientProperty(WizardDescriptor.PROP_CONTENT_NUMBERED, true);
}
}
WizardDescriptor wiz = new WizardDescriptor(new WizardDescriptor.ArrayIterator<WizardDescriptor>(panels));
// {0} will be replaced by WizardDesriptor.Panel.getComponent().getName()
wiz.setTitleFormat(new MessageFormat("{0}"));
wiz.setTitle("Generate tangents for this model");
if (DialogDisplayer.getDefault().notify(wiz) == WizardDescriptor.FINISH_OPTION) {
// do something
return wiz;
}
return null;
}

@Override
protected Object doApplyTool(AbstractSceneExplorerNode rootNode, Object settings) {
WizardDescriptor wiz = (WizardDescriptor)settings;
protected Object doApplyTool(AbstractSceneExplorerNode rootNode) {
Geometry geom = rootNode.getLookup().lookup(Geometry.class);
boolean splitMirrored = (Boolean)wiz.getProperties().get("splitMirrored");

Mesh mesh = geom.getMesh();
Mesh keptMesh = null;
if (mesh != null) {
if(splitMirrored){
keptMesh = mesh.deepClone();
}
TangentBinormalGenerator.generate(geom, splitMirrored);

}
if(keptMesh == null){
return splitMirrored;
}else{
return keptMesh;
}

MikktspaceTangentGenerator.generate(geom);

return false;
}

}

This file was deleted.

This file was deleted.

This file was deleted.

Loading