iwgeric 10 years ago
commit 92b33ddc9e
  1. 36
      common.gradle
  2. 3
      gradle.properties
  3. 3
      jme3-bullet/src/common/java/com/jme3/bullet/control/CharacterControl.java
  4. 18
      sdk/ant-jme/src/com/jme/ant/FixWikiLinks.java
  5. 9
      sdk/ant-jme/src/com/jme/ant/LoadWikiImages.java
  6. BIN
      sdk/ant-lib/ant-jme.jar
  7. 6
      sdk/branding/core/core.jar/org/netbeans/core/startup/Bundle.properties
  8. 2
      sdk/jme3-assetpack-support/src/com/jme3/gde/assetpack/browser/nodes/AssetPackBrowserFolder.java
  9. 2
      sdk/jme3-assetpack-support/src/com/jme3/gde/assetpack/browser/nodes/AssetPackBrowserItem.java
  10. 11
      sdk/jme3-core/src/com/jme3/gde/core/assets/nodes/AssetNode.java
  11. 11
      sdk/jme3-core/src/com/jme3/gde/core/codeless/CodelessProjectWizardAction.java
  12. 6
      sdk/jme3-core/src/com/jme3/gde/core/errorreport/RendererInfoAction.java
  13. 5
      sdk/jme3-core/src/com/jme3/gde/core/filters/FilterExplorerTopComponent.java
  14. 46
      sdk/jme3-core/src/com/jme3/gde/core/layer.xml
  15. 2
      sdk/jme3-documentation/build.xml
  16. BIN
      sdk/jme3-documentation/src/com/jme3/gde/docs/jme3/advanced/1.jpg
  17. BIN
      sdk/jme3-documentation/src/com/jme3/gde/docs/jme3/advanced/2.jpg
  18. BIN
      sdk/jme3-documentation/src/com/jme3/gde/docs/jme3/advanced/220px-trefoil_knot_arb.png
  19. BIN
      sdk/jme3-documentation/src/com/jme3/gde/docs/jme3/advanced/3.jpg
  20. 22
      sdk/jme3-documentation/src/com/jme3/gde/docs/jme3/advanced/3d_models.html
  21. BIN
      sdk/jme3-documentation/src/com/jme3/gde/docs/jme3/advanced/4.jpg
  22. BIN
      sdk/jme3-documentation/src/com/jme3/gde/docs/jme3/advanced/5.jpg
  23. BIN
      sdk/jme3-documentation/src/com/jme3/gde/docs/jme3/advanced/6.jpg
  24. 85
      sdk/jme3-documentation/src/com/jme3/gde/docs/jme3/advanced/animation.html
  25. 64
      sdk/jme3-documentation/src/com/jme3/gde/docs/jme3/advanced/application_states.html
  26. 27
      sdk/jme3-documentation/src/com/jme3/gde/docs/jme3/advanced/appstatesdemo.html
  27. 69
      sdk/jme3-documentation/src/com/jme3/gde/docs/jme3/advanced/asset_manager.html
  28. 71
      sdk/jme3-documentation/src/com/jme3/gde/docs/jme3/advanced/audio.html
  29. 42
      sdk/jme3-documentation/src/com/jme3/gde/docs/jme3/advanced/audio_environment_presets.html
  30. 56
      sdk/jme3-documentation/src/com/jme3/gde/docs/jme3/advanced/bloom_and_glow.html
  31. 22
      sdk/jme3-documentation/src/com/jme3/gde/docs/jme3/advanced/bullet_multithreading.html
  32. BIN
      sdk/jme3-documentation/src/com/jme3/gde/docs/jme3/advanced/butterfly-particle-emitter.png
  33. 33
      sdk/jme3-documentation/src/com/jme3/gde/docs/jme3/advanced/camera.html
  34. 67
      sdk/jme3-documentation/src/com/jme3/gde/docs/jme3/advanced/capture_audio_video_to_a_file.html
  35. 99
      sdk/jme3-documentation/src/com/jme3/gde/docs/jme3/advanced/cinematics.html
  36. 44
      sdk/jme3-documentation/src/com/jme3/gde/docs/jme3/advanced/collision_and_intersection.html
  37. 70
      sdk/jme3-documentation/src/com/jme3/gde/docs/jme3/advanced/combo_moves.html
  38. 48
      sdk/jme3-documentation/src/com/jme3/gde/docs/jme3/advanced/custom_controls.html
  39. 132
      sdk/jme3-documentation/src/com/jme3/gde/docs/jme3/advanced/custom_meshes.html
  40. BIN
      sdk/jme3-documentation/src/com/jme3/gde/docs/jme3/advanced/debug-shapes.png
  41. 70
      sdk/jme3-documentation/src/com/jme3/gde/docs/jme3/advanced/debugging.html
  42. BIN
      sdk/jme3-documentation/src/com/jme3/gde/docs/jme3/advanced/dof-blur.png
  43. 137
      sdk/jme3-documentation/src/com/jme3/gde/docs/jme3/advanced/effects_overview.html
  44. BIN
      sdk/jme3-documentation/src/com/jme3/gde/docs/jme3/advanced/elephant-pointlights.png
  45. 48
      sdk/jme3-documentation/src/com/jme3/gde/docs/jme3/advanced/endless_terraingrid.html
  46. BIN
      sdk/jme3-documentation/src/com/jme3/gde/docs/jme3/advanced/explosion-5.png
  47. 9
      sdk/jme3-documentation/src/com/jme3/gde/docs/jme3/advanced/fade.html
  48. 41
      sdk/jme3-documentation/src/com/jme3/gde/docs/jme3/advanced/headless_server.html
  49. 57
      sdk/jme3-documentation/src/com/jme3/gde/docs/jme3/advanced/hinges_and_joints.html
  50. BIN
      sdk/jme3-documentation/src/com/jme3/gde/docs/jme3/advanced/house-directionallight.png
  51. 77
      sdk/jme3-documentation/src/com/jme3/gde/docs/jme3/advanced/hud.html
  52. 79
      sdk/jme3-documentation/src/com/jme3/gde/docs/jme3/advanced/input_handling.html
  53. 73
      sdk/jme3-documentation/src/com/jme3/gde/docs/jme3/advanced/j3m_material_files.html
  54. 83
      sdk/jme3-documentation/src/com/jme3/gde/docs/jme3/advanced/jme3_shaders.html
  55. BIN
      sdk/jme3-documentation/src/com/jme3/gde/docs/jme3/advanced/light-scattering-filter.png
  56. BIN
      sdk/jme3-documentation/src/com/jme3/gde/docs/jme3/advanced/light-sources.png
  57. 66
      sdk/jme3-documentation/src/com/jme3/gde/docs/jme3/advanced/light_and_shadow.html
  58. 39
      sdk/jme3-documentation/src/com/jme3/gde/docs/jme3/advanced/loading_screen.html
  59. 56
      sdk/jme3-documentation/src/com/jme3/gde/docs/jme3/advanced/localization.html
  60. 29
      sdk/jme3-documentation/src/com/jme3/gde/docs/jme3/advanced/logging.html
  61. 30
      sdk/jme3-documentation/src/com/jme3/gde/docs/jme3/advanced/making_the_camera_follow_a_character.html
  62. 58
      sdk/jme3-documentation/src/com/jme3/gde/docs/jme3/advanced/material_definitions.html
  63. 247
      sdk/jme3-documentation/src/com/jme3/gde/docs/jme3/advanced/materials_overview.html
  64. 38
      sdk/jme3-documentation/src/com/jme3/gde/docs/jme3/advanced/mesh.html
  65. 109
      sdk/jme3-documentation/src/com/jme3/gde/docs/jme3/advanced/monkey_zone.html
  66. 20
      sdk/jme3-documentation/src/com/jme3/gde/docs/jme3/advanced/motionpath.html
  67. 35
      sdk/jme3-documentation/src/com/jme3/gde/docs/jme3/advanced/mouse_picking.html
  68. 54
      sdk/jme3-documentation/src/com/jme3/gde/docs/jme3/advanced/multiple_camera_views.html
  69. 63
      sdk/jme3-documentation/src/com/jme3/gde/docs/jme3/advanced/multithreading.html
  70. 131
      sdk/jme3-documentation/src/com/jme3/gde/docs/jme3/advanced/networking.html
  71. BIN
      sdk/jme3-documentation/src/com/jme3/gde/docs/jme3/advanced/nifty-gui-13.png
  72. BIN
      sdk/jme3-documentation/src/com/jme3/gde/docs/jme3/advanced/nifty-gui-example.png
  73. BIN
      sdk/jme3-documentation/src/com/jme3/gde/docs/jme3/advanced/nifty-gui.png
  74. BIN
      sdk/jme3-documentation/src/com/jme3/gde/docs/jme3/advanced/nifty-screen-layer-panel.png
  75. 55
      sdk/jme3-documentation/src/com/jme3/gde/docs/jme3/advanced/nifty_gui.html
  76. 177
      sdk/jme3-documentation/src/com/jme3/gde/docs/jme3/advanced/nifty_gui_java_interaction.html
  77. 109
      sdk/jme3-documentation/src/com/jme3/gde/docs/jme3/advanced/nifty_gui_java_layout.html
  78. 47
      sdk/jme3-documentation/src/com/jme3/gde/docs/jme3/advanced/nifty_gui_overlay.html
  79. 13
      sdk/jme3-documentation/src/com/jme3/gde/docs/jme3/advanced/nifty_gui_popup_menu.html
  80. 42
      sdk/jme3-documentation/src/com/jme3/gde/docs/jme3/advanced/nifty_gui_projection.html
  81. 129
      sdk/jme3-documentation/src/com/jme3/gde/docs/jme3/advanced/nifty_gui_scenarios.html
  82. 196
      sdk/jme3-documentation/src/com/jme3/gde/docs/jme3/advanced/nifty_gui_xml_layout.html
  83. BIN
      sdk/jme3-documentation/src/com/jme3/gde/docs/jme3/advanced/nurbs_3-d_surface.png
  84. 14
      sdk/jme3-documentation/src/com/jme3/gde/docs/jme3/advanced/ogrecompatibility.html
  85. 42
      sdk/jme3-documentation/src/com/jme3/gde/docs/jme3/advanced/open_game_finder.html
  86. BIN
      sdk/jme3-documentation/src/com/jme3/gde/docs/jme3/advanced/otoglow.png
  87. BIN
      sdk/jme3-documentation/src/com/jme3/gde/docs/jme3/advanced/otonobloom.png
  88. BIN
      sdk/jme3-documentation/src/com/jme3/gde/docs/jme3/advanced/particle.png
  89. 80
      sdk/jme3-documentation/src/com/jme3/gde/docs/jme3/advanced/particle_emitters.html
  90. 177
      sdk/jme3-documentation/src/com/jme3/gde/docs/jme3/advanced/physics.html
  91. 54
      sdk/jme3-documentation/src/com/jme3/gde/docs/jme3/advanced/physics_listeners.html
  92. 57
      sdk/jme3-documentation/src/com/jme3/gde/docs/jme3/advanced/post-processor_water.html
  93. 53
      sdk/jme3-documentation/src/com/jme3/gde/docs/jme3/advanced/ragdoll.html
  94. 12
      sdk/jme3-documentation/src/com/jme3/gde/docs/jme3/advanced/read_graphic_card_capabilites.html
  95. 23
      sdk/jme3-documentation/src/com/jme3/gde/docs/jme3/advanced/remote-controlling_the_camera.html
  96. 61
      sdk/jme3-documentation/src/com/jme3/gde/docs/jme3/advanced/save_and_load.html
  97. 9
      sdk/jme3-documentation/src/com/jme3/gde/docs/jme3/advanced/screenshots.html
  98. BIN
      sdk/jme3-documentation/src/com/jme3/gde/docs/jme3/advanced/shaderblow_glass.jpg
  99. BIN
      sdk/jme3-documentation/src/com/jme3/gde/docs/jme3/advanced/shaderblow_light1.jpg
  100. BIN
      sdk/jme3-documentation/src/com/jme3/gde/docs/jme3/advanced/shaderblow_light2.jpg
  101. Some files were not shown because too many files have changed in this diff Show More

@ -5,9 +5,6 @@
apply plugin: 'java'
apply plugin: 'maven'
//String jmeVersion = '3.0.10'
//String jmeVersion = rootProject.version;
String mavenGroupId = 'com.jme3'
String mavenVersion = jmeVersion + '-' + jmeVersionTag //'-SNAPSHOT'
@ -19,9 +16,6 @@ repositories {
maven{
url "http://nifty-gui.sourceforge.net/nifty-maven-repo"
}
// You may define additional repositories, or even remove "mavenCentral()".
// Read more about repositories here:
// http://www.gradle.org/docs/current/userguide/dependency_management.html#sec:repositories
}
dependencies {
@ -34,21 +28,17 @@ String mavenArtifactId = name
group = mavenGroupId
version = mavenVersion
//jar.doFirst{
// manifest {
// attributes('Manifest-Version' : '1.0',
// 'Created-By' : vendor,
// 'Specification-Title' : appName,
// 'Specification-Version' : version,
// 'Specification-Vendor' : vendor,
// 'Implementation-Title' : appName,
// 'Implementation-Version' : version,
// 'Implementation-Vendor' : vendor,
// 'Main-Class' : getProperty('mainClass'),
// 'Class-Path' : configurations.compile.collect { 'lib/' + it.getName() }.join(' ')
// )
// }
//}
javadoc {
failOnError = false
options.memberLevel = org.gradle.external.javadoc.JavadocMemberLevel.PROTECTED
options.docTitle = "jMonkeyEngine ${jmeMainVersion} ${project.name} Javadoc"
options.windowTitle = "jMonkeyEngine ${jmeMainVersion} ${project.name} Javadoc"
options.header = "<b>jMonkeyEngine ${jmeMainVersion} ${project.name}</b>"
options.author = "true"
options.use = "true"
//disable doclint for JDK8, more quiet output
options.addStringOption('Xdoclint:none', '-quiet')
}
task sourcesJar(type: Jar, dependsOn: classes, description: 'Creates a jar from the source files.') {
classifier = 'sources'
@ -63,7 +53,9 @@ task javadocJar(type: Jar, dependsOn: javadoc, description: 'Creates a jar from
artifacts {
archives jar
archives sourcesJar
// archives javadocJar
if(buildJavaDoc == "true"){
archives javadocJar
}
}
configure(install.repositories.mavenInstaller) {

@ -5,6 +5,9 @@ jmeMainVersion = 3.1
# Version addition pre-alpha-svn, Stable, Beta
jmeVersionTag = snapshot-github
# specify if JavaDoc should be built
buildJavaDoc = true
# specify if SDK and Native libraries get built
buildSdkProject = true
buildNativeProjects = false

@ -47,10 +47,9 @@ import com.jme3.scene.control.Control;
import java.io.IOException;
/**
* @deprecated in favor of <code>BetterCharacterControl</code>
* You might want to try <code>BetterCharacterControl</code> as well.
* @author normenhansen
*/
@Deprecated
public class CharacterControl extends PhysicsCharacter implements PhysicsControl {
protected Spatial spatial;

@ -31,16 +31,16 @@ public class FixWikiLinks extends Task {
String line = rdr.readLine();
while (line != null) {
//internal links
line = line.replaceAll("wiki/doku\\.php/([^>]*):([^>]*):([^>]*):([^>]*)\\?do=export_xhtmlbody", helpPath + "$1/$2/$3/$4.html");
line = line.replaceAll("wiki/doku\\.php/([^>]*):([^>]*):([^>]*)\\?do=export_xhtmlbody", helpPath + "$1/$2/$3.html");
line = line.replaceAll("wiki/doku\\.php/([^>]*):([^>]*)\\?do=export_xhtmlbody", helpPath + "$1/$2.html");
line = line.replaceAll("wiki/doku\\.php/([^>]*)\\?do=export_xhtmlbody", helpPath + "$1.html");
line = line.replaceAll("doku\\.php/([^>]*):([^>]*):([^>]*):([^>]*)\\?do=export_xhtmlbody", helpPath + "$1/$2/$3/$4.html");
line = line.replaceAll("doku\\.php/([^>]*):([^>]*):([^>]*)\\?do=export_xhtmlbody", helpPath + "$1/$2/$3.html");
line = line.replaceAll("doku\\.php/([^>]*):([^>]*)\\?do=export_xhtmlbody", helpPath + "$1/$2.html");
line = line.replaceAll("doku\\.php/([^>]*)\\?do=export_xhtmlbody", helpPath + "$1.html");
//images
line = line.replaceAll("/wiki/lib/exe/fetch\\.php/([^>]*):([^>]*):([^>]*):([^>]*)\"", "nbdocs:/" + helpPath + "$1/$2/$3/$4\"");
line = line.replaceAll("/wiki/lib/exe/fetch\\.php/([^>]*):([^>]*):([^>]*)\"", "nbdocs:/" + helpPath + "$1/$2/$3\"");
line = line.replaceAll("/wiki/lib/exe/fetch\\.php/([^>]*):([^>]*)\"", "nbdocs:/" + helpPath + "$1/$2\"");
line = line.replaceAll("/wiki/lib/exe/fetch\\.php/([^>]*)\"", "nbdocs:/" + helpPath + "$1\"");
// line = line.replaceAll("/wiki/lib/exe/fetch\\.php?([^>]*)\"", "nbdocs:/" + helpPath + "external/$1\"").replaceAll("[_[^\\w\\däüö:ÄÜÖ\\/\\+\\-\\. ]]", "_");
line = line.replaceAll("/lib/exe/fetch\\.php/([^>]*):([^>]*):([^>]*):([^>]*)\"", "nbdocs:/" + helpPath + "$1/$2/$3/$4\"");
line = line.replaceAll("/lib/exe/fetch\\.php/([^>]*):([^>]*):([^>]*)\"", "nbdocs:/" + helpPath + "$1/$2/$3\"");
line = line.replaceAll("/lib/exe/fetch\\.php/([^>]*):([^>]*)\"", "nbdocs:/" + helpPath + "$1/$2\"");
line = line.replaceAll("/lib/exe/fetch\\.php/([^>]*)\"", "nbdocs:/" + helpPath + "$1\"");
// line = line.replaceAll("/lib/exe/fetch\\.php?([^>]*)\"", "nbdocs:/" + helpPath + "external/$1\"").replaceAll("[_[^\\w\\däüö:ÄÜÖ\\/\\+\\-\\. ]]", "_");
line = line.replaceAll("<a href=([^>]*)><img src=\"([^\"]*)\"([^>]*)></a>", "<img src=\"$2\">");
line = line.replaceAll("<img src=\"([^>]*)\\?([^>]*)\">", "<img src=\"$1\">");

@ -37,11 +37,12 @@ public class LoadWikiImages extends Task {
int endIdx = line.indexOf("\"", idx + 10);
if (endIdx >= 0) {
String link = line.substring(idx + 10, endIdx);
int wikidx = link.indexOf("/wiki/lib/exe/fetch.php/");
//int extidx = link.indexOf("/wiki/lib/exe/fetch.php?");
link = link.replace("&amp;", "&");
int wikidx = link.indexOf("/lib/exe/fetch.php/");
//int extidx = link.indexOf("/lib/exe/fetch.php?");
int extidx = -1;
if (wikidx >= 0) {
String name = link.replaceAll("/wiki/lib/exe/fetch\\.php/", "");
String name = link.replaceAll("/lib/exe/fetch\\.php/", "");
int markIdx = name.indexOf("?");
if (markIdx >= 0) {
name = name.substring(0, markIdx);
@ -75,7 +76,7 @@ public class LoadWikiImages extends Task {
}
}
} else if (extidx >= 0) {
String name = link.replaceAll("/wiki/lib/exe/fetch\\.php\\?([^>]*);media=([^>]*)\"", "");
String name = link.replaceAll("/lib/exe/fetch\\.php\\?([^>]*);media=([^>]*)\"", "");
int markIdx = name.indexOf("?");
if (markIdx >= 0) {
name = name.substring(0, markIdx);

Binary file not shown.

@ -4,6 +4,6 @@ currentVersion=jMonkeyEngine SDK 3.1-snapshot-github
LBL_splash_window_title=Starting jMonkeyEngine SDK
SPLASH_HEIGHT=350
SPLASH_WIDTH=500
SplashProgressBarBounds=0,344,500,6
SplashRunningTextBounds=3,330,497,12
SplashRunningTextFontSize=12
SplashProgressBarBounds=0,347,500,6
SplashRunningTextBounds=3,335,497,12
SplashRunningTextFontSize=10

@ -19,7 +19,7 @@ import org.w3c.dom.Element;
*/
public class AssetPackBrowserFolder extends AbstractNode {
Image icon = ImageUtilities.loadImage("/com/jme3/gde/assetpack/icons/assets.gif");
Image icon = ImageUtilities.loadImage("com/jme3/gde/assetpack/icons/assets.gif");
Project proj;
public AssetPackBrowserFolder(Element[] elem, Project lib, String[] categories, String[] tags) {

@ -63,7 +63,7 @@ public class AssetPackBrowserItem extends AbstractNode {
private void setImage() {
try {
String add = item.getAttribute("type");
icon = ImageUtilities.loadImage("/com/jme3/gde/assetpack/icons/" + add + ".gif");
icon = ImageUtilities.loadImage("com/jme3/gde/assetpack/icons/" + add + ".gif");
} catch (Exception e) {
}
}

@ -48,12 +48,21 @@ public class AssetNode extends FilterNode {
private Node node;
public AssetNode(ProjectAssetManager manager, Node node) {
super(node, new AssetChildren(manager, node), createLookupProxy(manager, node));
super(node, isFile(node) ? Children.LEAF : new AssetChildren(manager, node), createLookupProxy(manager, node));
this.node = node;
enableDelegation(DELEGATE_GET_ACTIONS);
enableDelegation(DELEGATE_GET_CONTEXT_ACTIONS);
}
public static boolean isFile(Node node) {
DataObject obj = null;
obj = node.getLookup().lookup(DataObject.class);
if (obj != null) {
return !obj.getPrimaryFile().isFolder();
}
return false;
}
public static Lookup createLookupProxy(ProjectAssetManager manager, Node node) {
//TODO: This is causing the most silly exception for the most silly problem
// due to the most silly warning in netbeans platform

@ -47,6 +47,9 @@ import org.netbeans.api.project.ProjectManager;
import org.netbeans.api.project.ui.OpenProjects;
import org.openide.DialogDisplayer;
import org.openide.WizardDescriptor;
import org.openide.awt.ActionID;
import org.openide.awt.ActionReference;
import org.openide.awt.ActionRegistration;
import org.openide.filesystems.FileLock;
import org.openide.filesystems.FileObject;
import org.openide.filesystems.FileUtil;
@ -54,9 +57,13 @@ import org.openide.util.Exceptions;
import org.openide.util.HelpCtx;
import org.openide.util.actions.CallableSystemAction;
// An example action demonstrating how the wizard could be called from within
// your code. You can copy-paste the code below wherever you need.
@SuppressWarnings({"unchecked", "rawtypes"})
@ActionID(id = "com.jme3.gde.core.codeless.CodelessProjectWizardAction", category = "CodelessProjects")
@ActionRegistration(iconBase = "com/jme3/gde/core/assets/actions/jme-logo.png",
displayName = "#CTL_Codeless_Project",
lazy = false,
iconInMenu = true)
@ActionReference(path = "Menu/File/Import", name = "CodelessProject", position = 0)
public final class CodelessProjectWizardAction extends CallableSystemAction {
private static final Logger logger = Logger.getLogger(CodelessProjectWizardAction.class.getName());

@ -34,7 +34,13 @@ package com.jme3.gde.core.errorreport;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JFrame;
import org.openide.awt.ActionID;
import org.openide.awt.ActionReference;
import org.openide.awt.ActionRegistration;
@ActionID(id = "com.jme3.gde.core.errorreport.RendererInfoAction", category = "jMonkeyPlatform")
@ActionRegistration(displayName = "#CTL_RendererInfoAction", iconInMenu = true)
@ActionReference(path = "Menu/Help", position = 1225)
public final class RendererInfoAction implements ActionListener {
RendererInfo info;

@ -51,6 +51,7 @@ import org.openide.explorer.view.BeanTreeView;
import org.openide.nodes.Node;
import org.openide.util.HelpCtx;
import org.openide.util.NbBundle;
import org.openide.util.actions.SystemAction;
import org.openide.windows.TopComponent;
import org.openide.windows.WindowManager;
@ -84,8 +85,8 @@ public final class FilterExplorerTopComponent extends TopComponent implements Ex
setToolTipText(NbBundle.getMessage(FilterExplorerTopComponent.class, "HINT_FilterExplorerTopComponent"));
ActionMap map = getActionMap();
map.put("delete", ExplorerUtils.actionDelete(explorerManager, true));
map.put("moveup", new MoveUpAction());
map.put("movedown", new MoveDownAction());
map.put("moveup", SystemAction.get(MoveUpAction.class));
map.put("movedown", SystemAction.get(MoveDownAction.class));
associateLookup(ExplorerUtils.createLookup(explorerManager, map));
}

@ -2,26 +2,6 @@
<!DOCTYPE filesystem PUBLIC "-//NetBeans//DTD Filesystem 1.2//EN" "http://www.netbeans.org/dtds/filesystem-1_2.dtd">
<filesystem>
<folder name="Actions">
<folder name="CodelessProjects">
<file name="com-jme3-gde-core-codeless-CodelessProjectWizardAction.instance">
<attr name="delegate" methodvalue="org.openide.awt.Actions.inject"/>
<attr name="displayName" bundlevalue="com.jme3.gde.core.codeless.Bundle#CTL_Codeless_Project"/>
<attr name="iconBase" stringvalue="com/jme3/gde/core/assets/actions/jme-logo.png"/>
<attr name="injectable" stringvalue="com.jme3.gde.core.codeless.CodelessProjectWizardAction"/>
<attr name="noIconInMenu" boolvalue="false"/>
</file>
</folder>
<folder name="SceneComposer">
<file name="com-jme3-gde-core-sceneviewer-actions-SwitchFrontViewAcction.instance_hidden"/>
<file name="com-jme3-gde-core-sceneviewer-actions-SwitchFrontViewAction.instance">
<attr name="iconBase" stringvalue="com/jme3/gde/core/sceneviewer/actions/32_bit.png"/>
<attr name="instanceCreate" methodvalue="org.openide.awt.Actions.alwaysEnabled"/>
<attr name="instanceCreate" methodvalue="org.openide.awt.Actions.alwaysEnabled"/>
<attr name="noIconInMenu" boolvalue="false"/>
</file>
<file name="com-jme3-gde-core-sceneviewer-actions-SwitchFrontViewAction.instance"/>
<file name="com-jme3-gde-core-sceneviewer-actions-SwitchToFrontViewAction.instance_hidden"/>
</folder>
<folder name="jMonkeyPlatform">
<file name="com-jme3-gde-core-assets-actions-OpenModel.instance">
<attr name="delegate" methodvalue="org.openide.awt.Actions.inject"/>
@ -43,12 +23,6 @@
<attr name="selectionType" stringvalue="ANY"/>
<attr name="type" stringvalue="com.jme3.gde.core.assets.SpatialAssetDataObject"/>
</file>
<file name="com-jme3-gde-core-errorreport-RendererInfoAction.instance">
<attr name="delegate" newvalue="com.jme3.gde.core.errorreport.RendererInfoAction"/>
<attr name="displayName" bundlevalue="com.jme3.gde.core.errorreport.Bundle#CTL_RendererInfoAction"/>
<attr name="instanceCreate" methodvalue="org.openide.awt.Actions.alwaysEnabled"/>
<attr name="noIconInMenu" boolvalue="false"/>
</file>
</folder>
<folder name="Window">
<file name="com-jme3-gde-core-sceneexplorer-SceneExplorerAction.instance">
@ -76,24 +50,16 @@
</folder>
<folder name="File">
<folder name="Import">
<file name="CodelessProject.shadow">
<attr name="originalFile" stringvalue="Actions/CodelessProjects/com-jme3-gde-core-codeless-CodelessProjectWizardAction.instance"/>
<attr name="position" intvalue="0"/>
</file>
<file name="org-netbeans-modules-projectimport-eclipse-core-ImportProjectAction.shadow_hidden"/>
<file name="org-netbeans-modules-projectimport-eclipse-core-ResynchronizeEclipseAction.shadow_hidden"/>
</folder>
</folder>
<folder name="Help">
<file name="com-jme3-gde-core-errorreport-RendererInfoAction.shadow">
<attr name="originalFile" stringvalue="Actions/jMonkeyPlatform/com-jme3-gde-core-errorreport-RendererInfoAction.instance"/>
<attr name="position" intvalue="1225"/>
</file>
<file name="jmewiki.url" url="jmewiki.url">
<attr name="SystemFileSystem.localizingBundle" stringvalue="com.jme3.gde.core.Bundle"/>
<attr name="displayName" bundlevalue="com.jme3.gde.core.Bundle#Menu/Help/jmewiki.url"/>
<attr name="position" intvalue="200"/>
</file>
<file name="help-main.xml" url="help-main.xml">
<attr name="SystemFileSystem.localizingBundle" stringvalue="com.jme3.gde.core.Bundle"/>
<attr name="displayName" bundlevalue="com.jme3.gde.core.Bundle#Menu/Help/help-main.xml"/>
<attr name="position" intvalue="100"/>
</file>
@ -181,14 +147,6 @@
<file name="org-netbeans-modules-java-helpset.xml_hidden"/>
</folder>
</folder>
<folder name="Menu">
<folder name="File">
<folder name="Import">
<file name="org-netbeans-modules-projectimport-eclipse-core-ImportProjectAction.shadow_hidden"/>
<file name="org-netbeans-modules-projectimport-eclipse-core-ResynchronizeEclipseAction.shadow_hidden"/>
</folder>
</folder>
</folder>
<folder name="Windows2">
<folder name="Components">
<file name="SceneExplorerTopComponent.settings" url="SceneExplorerTopComponentSettings.xml"/>

@ -45,7 +45,7 @@
<!-- download images from page (custom task) -->
<loadwikiimages file="src/${javahelp_path}/${page_path}.html"
target="src/${javahelp_path}/"
host="http://jmonkeyengine.org"/>
host="http://wiki.jmonkeyengine.org"/>
<!-- fix links in wiki (custom task) -->
<fixwikilinks file="src/${javahelp_path}/${page_path}.html"
helppath="${javahelp_path}/"/>

Binary file not shown.

Before

Width:  |  Height:  |  Size: 27 KiB

After

Width:  |  Height:  |  Size: 177 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 24 KiB

After

Width:  |  Height:  |  Size: 151 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.1 KiB

After

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 29 KiB

After

Width:  |  Height:  |  Size: 189 KiB

@ -1,23 +1,21 @@
<h1><a>Models and Scenes</a></h1>
<h1>Models and Scenes</h1>
<div>
<p>
Like <a href="/com/jme3/gde/docs/jme3/advanced/shape.html">Shape</a>s, 3D models are also made up of <a href="/com/jme3/gde/docs/jme3/advanced/mesh.html">Mesh</a>es, but models are more complex than Shapes. While Shapes are built into jME3, you typically create models in external 3D Mesh Editors.
</p>
</div>
<!-- EDIT1 SECTION "Models and Scenes" [1-226] -->
<h2><a>Using Models and Scenes with jME3</a></h2>
<h2>Using Models and Scenes with jME3</h2>
<div>
<p>
To use 3D models in a jME3 application:
</p>
<ol>
<li><div> Export the 3D model in Ogre <acronym title="Extensible Markup Language">XML</acronym> or Wavefront OBJ format. Export Scenes as Ogre DotScene format.</div>
<li><div> Export the 3D model in Ogre XML or Wavefront OBJ format. Export Scenes as Ogre DotScene format.</div>
</li>
<li><div> Save the files into a subdirectory of your jME3 project&#039;s <code>assets</code> directory.</div>
</li>
@ -25,17 +23,16 @@ To use 3D models in a jME3 application:
&quot;Models/MonkeyHead/MonkeyHead.mesh.xml&quot; &#41;;</pre>
</div>
</li>
<li><div> (For the release build:) Use the jMonkeyEngine <acronym title="Software Development Kit">SDK</acronym> to convert models to .j3o format. You don&#039;t need this step as long you still develop and test the aplication within the jMonkeyEngine <acronym title="Software Development Kit">SDK</acronym>.</div>
<li><div> (For the release build:) Use the jMonkeyEngine SDK to convert models to .j3o format. You don&#039;t need this step as long you still develop and test the aplication within the jMonkeyEngine SDK.</div>
</li>
</ol>
</div>
<!-- EDIT2 SECTION "Using Models and Scenes with jME3" [227-901] -->
<h2><a>Creating Models and Scenes</a></h2>
<h2>Creating Models and Scenes</h2>
<div>
<p>
To create 3D models and scenes, you need a 3D Mesh Editor such as <object classid="java:org.netbeans.modules.javahelp.BrowserDisplayer"><param name="content" value="http://www.blender.org/"><param name="text" value="<html><u>Blender</u></html>"><param name="textColor" value="blue"></object>, with an OgreXML Exporter plugin.
</p>
@ -45,7 +42,6 @@ To create 3D models and scenes, you need a 3D Mesh Editor such as <object classi
<p>
3D model editors are third-party products, so please consult their documentation for instructions how to use them. Here is an example workflow for Blender users:
</p>
<ul>
<li><div> <a href="/com/jme3/gde/docs/jme3/external/blender.html">Creating jME3 compatible 3D models in Blender</a></div>
@ -53,13 +49,12 @@ To create 3D models and scenes, you need a 3D Mesh Editor such as <object classi
</ul>
<p>
To export your models as Ogre <acronym title="Extensible Markup Language">XML</acronym> meshes with materials:
To export your models as Ogre XML meshes with materials:
</p>
<ol>
<li><div> Open the menu File &gt; Export &gt; OgreXML Exporter to open the exporter dialog.</div>
</li>
<li><div> In the Export Materials field: Give the material the same name as the model. For example, the model <code>something.mesh.xml</code> goes with <code>something.material</code>, plus (optionally) <code>something.skeleton.xml</code>, and some <acronym title="Joint Photographics Experts Group">JPG</acronym> files.</div>
<li><div> In the Export Materials field: Give the material the same name as the model. For example, the model <code>something.mesh.xml</code> goes with <code>something.material</code>, plus (optionally) <code>something.skeleton.xml</code>, and some JPG files.</div>
</li>
<li><div> In the Export Meshes field: Select a target subdirectory of your <code>assets/Models/</code> directory. E.g. <code>assets/Models/something/</code>.</div>
</li>
@ -82,10 +77,9 @@ To export your models as Ogre <acronym title="Extensible Markup Language">XML</a
</ol>
<p>
You can now use the <a href="/com/jme3/gde/docs/sdk.html">jMonkeyEngine SDK</a> to <a href="/com/jme3/gde/docs/sdk/model_loader_and_viewer.html">load and view models</a>. You can <a href="/com/jme3/gde/docs/sdk/scene_composer.html">create scenes</a> from them and write code that loads them into your application.
</p>
</div>
<!-- EDIT3 SECTION "Creating Models and Scenes" [902-] -->
<p><em><a href="http://hub.jmonkeyengine.org/wiki/doku.php/jme3:advanced:3d_models?do=export_xhtmlbody">view online version</a></em></p>
<p><em><a href="http://wiki.jmonkeyengine.org/doku.php/jme3:advanced:3d_models?do=export_xhtmlbody">view online version</a></em></p>

Binary file not shown.

Before

Width:  |  Height:  |  Size: 26 KiB

After

Width:  |  Height:  |  Size: 158 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 25 KiB

After

Width:  |  Height:  |  Size: 196 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 23 KiB

After

Width:  |  Height:  |  Size: 162 KiB

@ -1,24 +1,22 @@
<h1><a>Animation in jME3</a></h1>
<h1>Animation in jME3</h1>
<div>
<p>
In 3D games, you do not only load static 3D models, you also want to be able to trigger animations in the model from the Java code.
</p>
</div>
<!-- EDIT1 SECTION "Animation in jME3" [1-167] -->
<h2><a>Requirements</a></h2>
<h2>Requirements</h2>
<div>
<p>
JME3 only loads and plays animated models, it does not create them.
</p>
<p>
What is required for an animated model? (<a href="/com/jme3/gde/docs/jme3/terminology#animation.html">See also: Animation terminology</a>)
What is required for an animated model? (<a href="/com/jme3/gde/docs/jme3/terminology.html#animation">See also: Animation terminology</a>)
</p>
<ol>
<li><div> For each model, you have to segment the model into a skeleton (<strong>bone rigging</strong>). </div>
@ -32,7 +30,6 @@ What is required for an animated model? (<a href="/com/jme3/gde/docs/jme3/termin
</ol>
<p>
Unless you download free models, or buy them from a 3D artist, you must create your animated models in an <strong>external mesh editor</strong> (for example, Blender) yourself.
</p>
<ul>
@ -51,7 +48,6 @@ Unless you download free models, or buy them from a 3D artist, you must create y
</ul>
<p>
What is required in your JME3-based Java class?
</p>
<ul>
@ -63,7 +59,7 @@ What is required in your JME3-based Java class?
</div>
<!-- EDIT2 SECTION "Requirements" [168-2038] -->
<h2><a>Code Samples</a></h2>
<h2>Code Samples</h2>
<div>
<ul>
<li><div> <object classid="java:org.netbeans.modules.javahelp.BrowserDisplayer"><param name="content" value="http://code.google.com/p/jmonkeyengine/source/browse/trunk/engine/src/test/jme3test/model/anim/TestSpatialAnim.java"><param name="text" value="<html><u>TestSpatialAnim.java</u></html>"><param name="textColor" value="blue"></object></div>
@ -82,16 +78,15 @@ What is required in your JME3-based Java class?
</div>
<!-- EDIT3 SECTION "Code Samples" [2039-2947] -->
<h2><a>Controlling Animations</a></h2>
<h2>Controlling Animations</h2>
<div>
</div>
<!-- EDIT4 SECTION "Controlling Animations" [2948-2983] -->
<h3><a>The Animation Control</a></h3>
<h3>The Animation Control</h3>
<div>
<p>
Create one <code>com.jme3.animation.AnimControl</code> object in your JME3 application for each animated model that you want to control. You have to register each animated model to one of these Animation Controls. The control object gives you access to the available animation sequences in the model.
</p>
<pre> AnimControl playerControl; // you need one Control per model
@ -101,16 +96,15 @@ Create one <code>com.jme3.animation.AnimControl</code> object in your JME3 appli
</div>
<!-- EDIT5 SECTION "The Animation Control" [2984-3623] -->
<h3><a>Animation Channels</a></h3>
<h3>Animation Channels</h3>
<div>
<p>
An Animation Control has several Animation Channels (<code>com.jme3.animation.AnimChannel</code>). Each channel can play one animation sequence at a time.
</p>
<p>
There often are situations where you want to run several animation sequences at the same time, e.g. &quot;shooting while walking&quot; or &quot;boxing while jumping&quot;. In this case, you create several channels, assign an animation to each, and play them in parallel.
There often are situations where you want to run several animation sequences at the same time, e.g. “shooting while walking” or “boxing while jumping”. In this case, you create several channels, assign an animation to each, and play them in parallel.
</p>
<pre> AnimChannel channel_walk = playerControl.createChannel&#40;&#41;;
AnimChannel channel_jump = playerControl.createChannel&#40;&#41;;
@ -122,18 +116,18 @@ To reset a Control, call <code>control.clearChannels();</code>
</div>
<!-- EDIT6 SECTION "Animation Channels" [3624-4257] -->
<h2><a>Animation Control Properties</a></h2>
<h2>Animation Control Properties</h2>
<div>
<p>
The following information is available for an AnimControl.
</p>
<div><table>
<thead>
<tr>
<th>AnimControl Property</th><th>Usage</th>
</tr>
</thead>
<tr>
<td>createChannel()</td><td>Returns a new channel, controlling all bones by default.</td>
</tr>
@ -153,9 +147,11 @@ clearListeners() </td><td>Adds or removes listeners to receive animation related
</tr>
</table></div>
<!-- EDIT8 TABLE [4360-4829] --><div><table>
<thead>
<tr>
<th>AnimControl Property</th><th>Usage</th>
</tr>
</thead>
<tr>
<td>setAnimations(aniHashMap)</td><td>Sets the animations that this AnimControl is capable of playing. The animations must be compatible with the skeleton given in the constructor.</td>
</tr>
@ -167,16 +163,18 @@ removeAnim(boneAnim)</td><td>Adds or removes an animation from this Control.</td
<td>getAnimationNames()</td><td>A String Collection of names of all animations that this Control can play for this model.</td>
</tr>
<tr>
<td>getAnim(&quot;anim&quot;)</td><td>Retrieve an animation from the list of animations.</td>
<td>getAnim(“anim”)</td><td>Retrieve an animation from the list of animations.</td>
</tr>
<tr>
<td>getAnimationLength(&quot;anim&quot;)</td><td>Returns the length of the given named animation in seconds</td>
<td>getAnimationLength(“anim”)</td><td>Returns the length of the given named animation in seconds</td>
</tr>
</table></div>
<!-- EDIT9 TABLE [4831-5391] --><div><table>
<thead>
<tr>
<th>AnimControl Property</th><th>Usage</th>
</tr>
</thead>
<tr>
<td>getSkeleton()</td><td>The Skeleton object controlled by this Control.</td>
</tr>
@ -184,24 +182,24 @@ removeAnim(boneAnim)</td><td>Adds or removes an animation from this Control.</td
<td>getTargets()</td><td>The Skin objects controlled by this Control, as Mesh array.</td>
</tr>
<tr>
<td>getAttachmentsNode(&quot;bone&quot;)</td><td>Returns the attachment node of a bone. Attach models and effects to this node to make them follow this bone&#039;s motions.</td>
<td>getAttachmentsNode(“bone”)</td><td>Returns the attachment node of a bone. Attach models and effects to this node to make them follow this bone&#039;s motions.</td>
</tr>
</table></div>
<!-- EDIT10 TABLE [5393-5708] -->
</div>
<!-- EDIT7 SECTION "Animation Control Properties" [4258-5710] -->
<h2><a>Animation Channel Properties</a></h2>
<h2>Animation Channel Properties</h2>
<div>
<p>
The following properties are set per AnimChannel.
</p>
<div><table>
<thead>
<tr>
<th>AnimChannel Property</th><th>Usage</th>
</tr>
</thead>
<tr>
<td>setLoopMode(LoopMode.Loop); </td><td> From now on, the animation on this channel will repeat from the beginning when it ends. </td>
</tr>
@ -220,14 +218,14 @@ The following properties are set per AnimChannel.
</table></div>
<!-- EDIT12 TABLE [5804-6428] -->
<p>
The following information is available for a channel.
</p>
<div><table>
<thead>
<tr>
<th>AnimChannel Property</th><th>Usage</th>
</tr>
</thead>
<tr>
<td>getAnimationName()</td><td>The name of the animation playing on this channel. Returns <code>null</code> when no animation is playing.</td>
</tr>
@ -246,64 +244,62 @@ The following information is available for a channel.
</table></div>
<!-- EDIT13 TABLE [6485-7118] -->
<p>
Use the following methods to add or remove individual bones to an AnimChannel. This is useful when you play two animations in parallel on two channels, and each controls a subset of the bones (e.g. one the arms, and the other the legs).
</p>
<div><table>
<thead>
<tr>
<th>AnimChannel Methods</th><th>Usage</th>
</tr>
</thead>
<tr>
<td>addAllBones()</td><td>Add all the bones of the model&#039;s skeleton to be influenced by this animation channel. (default)</td>
</tr>
<tr>
<td>addBone(&quot;bone1&quot;) <br/>
<td>addBone(“bone1”) <br/>
addBone(bone1)</td><td>Add a single bone to be influenced by this animation channel.</td>
</tr>
<tr>
<td>addToRootBone(&quot;bone1&quot;) <br/>
<td>addToRootBone(“bone1”) <br/>
addToRootBone(bone1) </td><td>Add a series of bones to be influenced by this animation channel: Add all bones, starting from the given bone, to the root bone.</td>
</tr>
<tr>
<td>addFromRootBone(&quot;bone1&quot;) <br/>
<td>addFromRootBone(“bone1”) <br/>
addFromRootBone(bone1) </td><td>Add a series of bones to be influenced by this animation channel: Add all bones, starting from the given root bone, going towards the children bones.</td>
</tr>
</table></div>
<!-- EDIT14 TABLE [7358-7979] -->
</div>
<!-- EDIT11 SECTION "Animation Channel Properties" [5711-7981] -->
<h2><a>Playing Animations</a></h2>
<h2>Playing Animations</h2>
<div>
<p>
Animations are played by channel. <strong>Note:</strong> Whether the animation channel plays continuously or only once, depends on the Loop properties you have set.
</p>
<div><table>
<thead>
<tr>
<th>Channel Method</th><th>Usage</th>
</tr>
</thead>
<tr>
<td>channel_walk.setAnim(&quot;Walk&quot;,0.50f); </td><td> Start the animation named &quot;Walk&quot; on channel channel_walk. <br/>
<td>channel_walk.setAnim(“Walk”,0.50f); </td><td> Start the animation named “Walk” on channel channel_walk. <br/>
The float value specifies the time how long the animation should overlap with the previous one on this channel. If set to 0f, then no blending will occur and the new animation will be applied instantly.</td>
</tr>
</table></div>
<!-- EDIT16 TABLE [8167-8493] -->
<p>
<strong>Tip:</strong> Use the AnimEventLister below to react at the end or start of an animation cycle.
</p>
</div>
<!-- EDIT15 SECTION "Playing Animations" [7982-8586] -->
<h3><a>Usage Example</a></h3>
<h3>Usage Example</h3>
<div>
<p>
In this short example, we define the space key to trigger playing the &quot;Walk&quot; animation on channel2.
In this short example, we define the space key to trigger playing the “Walk” animation on channel2.
</p>
<pre> public void simpleInitApp&#40;&#41; &#123;
...
@ -312,7 +308,7 @@ In this short example, we define the space key to trigger playing the &quot;Walk
...
&#125;
&nbsp;
private ActionListener actionListener = new ActionListener&#40;&#41; &#123;
private ActionListener&#40;&#41; &#123;
public void onAction&#40;String name, boolean keyPressed, float tpf&#41; &#123;
if &#40;name.equals&#40;&quot;Walk&quot;&#41; &amp;&amp; !keyPressed&#41; &#123;
if &#40;!channel2.getAnimationName&#40;&#41;.equals&#40;&quot;Walk&quot;&#41;&#41; &#123;
@ -325,11 +321,10 @@ In this short example, we define the space key to trigger playing the &quot;Walk
</div>
<!-- EDIT17 SECTION "Usage Example" [8587-9276] -->
<h2><a>Animation Event Listener</a></h2>
<h2>Animation Event Listener</h2>
<div>
<p>
A jME3 application that contains animations can implement the <code>com.jme3.animation.AnimEventListener</code> interface.
</p>
<pre>public class HelloAnimation extends SimpleApplication
@ -341,11 +336,10 @@ This optional Listener enables you to respond to animation start and end events,
</div>
<!-- EDIT18 SECTION "Animation Event Listener" [9277-9680] -->
<h3><a>Responding to Animation End</a></h3>
<h3>Responding to Animation End</h3>
<div>
<p>
The onAnimCycleDone() event is invoked when an animation cycle has ended. For non-looping animations, this event is invoked when the animation is finished playing. For looping animations, this event is invoked each time the animation loop is restarted.
</p>
@ -370,11 +364,10 @@ You have access to the following objects:
</div>
<!-- EDIT19 SECTION "Responding to Animation End" [9681-10471] -->
<h3><a>Responding to Animation Start</a></h3>
<h3>Responding to Animation Start</h3>
<div>
<p>
The onAnimChange() event is invoked every time before an animation is set by the user to be played on a given channel (<code>channel.setAnim()</code>).
</p>
@ -399,4 +392,4 @@ You have access to the following objects
</div>
<!-- EDIT20 SECTION "Responding to Animation Start" [10472-] -->
<p><em><a href="http://hub.jmonkeyengine.org/wiki/doku.php/jme3:advanced:animation?do=export_xhtmlbody">view online version</a></em></p>
<p><em><a href="http://wiki.jmonkeyengine.org/doku.php/jme3:advanced:animation?do=export_xhtmlbody">view online version</a></em></p>

@ -1,24 +1,22 @@
<h1><a>Application States</a></h1>
<h1>Application States</h1>
<div>
<p>
The <code>com.jme3.app.state.AppState</code> class is a customizable jME3 interface that allows you to control the global game logic, the overall game mechanics. (To control the behaviour of a Spatial, see <a href="/com/jme3/gde/docs/jme3/advanced/custom_controls.html">Custom Controls</a> instead. Controls and AppStates can be used together.)
</p>
</div>
<!-- EDIT1 SECTION "Application States" [1-322] -->
<h2><a>Overview</a></h2>
<h2>Overview</h2>
<div>
</div>
<!-- EDIT2 SECTION "Overview" [323-344] -->
<h3><a>Use Case Examples</a></h3>
<h3>Use Case Examples</h3>
<div>
<p>
There are situations during your game development where you think:
</p>
<ul>
@ -26,22 +24,21 @@ There are situations during your game development where you think:
</li>
<li><div> I have the in-game scene, and a character editor, and a Captain&#039;s Quarters screen. Can I group a set of nodes and behaviours, and swap them in and out in one step?</div>
</li>
<li><div> When I pause the game, I want the character&#039;s &quot;idle&quot; animation to continue, but all other loops and game events should stop. How do I define what happens when the game is paused/unpaused? </div>
<li><div> When I pause the game, I want the character&#039;s “idle” animation to continue, but all other loops and game events should stop. How do I define what happens when the game is paused/unpaused? </div>
</li>
<li><div> I have a conditional block that takes up a lot of space in my simpleUpdate() loop. Can I wrap up this block of code, and switch it on and off in one step?</div>
</li>
<li><div> Can I package everything that belongs in-game, and everything that belongs to the menu screen, and switch between these two &quot;big states&quot; in one step? </div>
<li><div> Can I package everything that belongs in-game, and everything that belongs to the menu screen, and switch between these two “big states” in one step? </div>
</li>
</ul>
<p>
You can! This is what AppStates are there for. An AppState class is subset of (or an extension to) your application. Every AppState class has access to all fields in your main application (AssetManager, ViewPort, StateManager, InputManager, RootNode, GuiNode, etc) and hooks into the main update loop. An AppState can contain:
</p>
<ul>
<li><div> a subset of class fields, functions, methods (game state data and accessors), </div>
</li>
<li><div> a subset of <acronym title="Graphical User Interface">GUI</acronym> elements and their listeners, </div>
<li><div> a subset of <abbr title="Graphical User Interface">GUI</abbr> elements and their listeners, </div>
</li>
<li><div> a subset of input handlers and mappings, </div>
</li>
@ -51,17 +48,16 @@ You can! This is what AppStates are there for. An AppState class is subset of (o
</li>
<li><div> a subset of other AppStates and Controls</div>
</li>
<li><div> ??? or combinations thereof. </div>
<li><div> or combinations thereof. </div>
</li>
</ul>
</div>
<!-- EDIT3 SECTION "Use Case Examples" [345-2032] -->
<h3><a>Supported Features</a></h3>
<h3>Supported Features</h3>
<div>
<p>
Each AppState lets you define what happens to it in the following situations:
</p>
<ul>
@ -73,25 +69,23 @@ The AppState executes its own simpleInitApp() method when it is attached, so to
<li><div> <strong>While the AppState is running/paused:</strong> You can poll isEnabled() to define paused and unpaused game behaviour in the update() loop. In update(), you poll and modify the game state, modify the scene graph, and trigger events. Test if <code>!isEnabled()</code>, and write code that skips the running sections of this AppState&#039;s <code>update()</code> loop. <br/>
Each AppState has its own update loop, which hooks into the main simpleUpdate() loop (callback). </div>
</li>
<li><div> <strong>The AppState has been disabled (paused):</strong> This toggles a boolean isEnabled() to false. Here you switch all objects to their specific &quot;paused&quot; behaviour. </div>
<li><div> <strong>The AppState has been disabled (paused):</strong> This toggles a boolean isEnabled() to false. Here you switch all objects to their specific “paused” behaviour. </div>
</li>
<li><div> <strong>The AppState is cleaned up:</strong> Here you decide what happens when the AppState is detached. Save this AppState&#039;s game state, unregister Controls and InputHandlers, detach related AppStates, detach nodes from the rootNode, etc.</div>
</li>
</ul>
<p>
<p><div>Tip: AppStates are extremely handy to swap out, or pause/unpause whole sets of other AppStates. For example, an InGameState (loads in-game <acronym title="Graphical User Interface">GUI</acronym>, activates click-to-shoot input mappings, inits game content, starts game loop) versus MainScreenState (stops game loop, saves and detaches game content, switches to menu screen <acronym title="Graphical User Interface">GUI</acronym>, switches to click-to-select input mappings).
<p><div>Tip: AppStates are extremely handy to swap out, or pause/unpause whole sets of other AppStates. For example, an InGameState (loads in-game <abbr title="Graphical User Interface">GUI</abbr>, activates click-to-shoot input mappings, inits game content, starts game loop) versus MainScreenState (stops game loop, saves and detaches game content, switches to menu screen <abbr title="Graphical User Interface">GUI</abbr>, switches to click-to-select input mappings).
</div></p>
</p>
</div>
<!-- EDIT4 SECTION "Supported Features" [2033-3761] -->
<h3><a>Usage</a></h3>
<h3>Usage</h3>
<div>
<p>
To implement game logic:
</p>
<ol>
@ -114,17 +108,15 @@ To implement game logic:
</ol>
<p>
When you add several AppStates to one Application and activate them, their initialize() methods and update() loops are executed in the order in which the AppStates were added to the AppStateManager.
</p>
</div>
<!-- EDIT5 SECTION "Usage" [3762-4620] -->
<h3><a>Code Samples</a></h3>
<h3>Code Samples</h3>
<div>
<p>
JME3 comes with a BulletAppState that implements Physical behaviour (using the jBullet library). You, for example, could write an Artificial Intelligence AppState to control all your enemy units. Existing examples in the code base include:
</p>
<ul>
@ -140,18 +132,18 @@ JME3 comes with a BulletAppState that implements Physical behaviour (using the j
</div>
<!-- EDIT6 SECTION "Code Samples" [4621-5401] -->
<h2><a>AppState</a></h2>
<h2>AppState</h2>
<div>
<p>
The AppState interface lets you initialize sets of objects, and hook a set of continously executing code into the main loop.
</p>
<div><table>
<thead>
<tr>
<th>AppState Method</th><th>Usage</th>
</tr>
</thead>
<tr>
<td>initialize(asm,app)</td><td>When this AppState is added to the game, the RenderThread initializes the AppState and then calls this method. You can modify the scene graph from here (e.g. attach nodes). To get access to the main app, call: <pre>super.initialize&#40;stateManager, app&#41;;
this.app = &#40;SimpleApplication&#41; app;</pre>
@ -187,17 +179,15 @@ stateDetached(asm)</td><td>The AppState knows when it is attached to, or detache
<!-- EDIT8 TABLE [5550-7112] -->
</div>
<!-- EDIT7 SECTION "AppState" [5402-7113] -->
<h2><a>AbstractAppState</a></h2>
<h2>AbstractAppState</h2>
<div>
<p>
The AbstractAppState class already implements some common methods (<code>isInitialized(), setActive(), isActive()</code>) and makes creation of custom AppStates a bit easier. We recommend you extend AbstractAppState and override the remaining AppState methods: <code>initialize(), setEnabled(), cleanup()</code>.
</p>
<p>
Definition:
</p>
<pre>public class MyAppState extends AbstractAppState &#123;
&nbsp;
@ -250,28 +240,27 @@ Definition:
</div>
<!-- EDIT9 SECTION "AbstractAppState" [7114-9286] -->
<h2><a>Pausing and Unpausing</a></h2>
<h2>Pausing and Unpausing</h2>
<div>
<p>
You define what an AppState does when Paused or Unpaused, in the <code>setEnabled()</code> and <code>update()</code> methods. Call <code>myState.setEnabled(false)</code> on all states that you want to pause. Call <code>myState.setEnabled(true)</code> on all states that you want to unpause.
</p>
</div>
<!-- EDIT10 SECTION "Pausing and Unpausing" [9287-9577] -->
<h2><a>AppStateManager</a></h2>
<h2>AppStateManager</h2>
<div>
<p>
The com.jme3.app.state.AppStateManager holds the list of AppStates for an application. AppStateManager ensures that active AppStates can modify the scene graph, and that the update() loops of active AppStates is executed. There is one AppStateManager per application. You typically attach several AppStates to one AppStateManager, but the same state can only be attached once.
</p>
<div><table>
<thead>
<tr>
<th>AppStateManager Method</th><th>Usage</th>
</tr>
</thead>
<tr>
<td>hasState(myState)</td><td>Is AppState object &#039;myState&#039; attached?</td>
</tr>
@ -281,9 +270,7 @@ The com.jme3.app.state.AppStateManager holds the list of AppStates for an applic
</table></div>
<!-- EDIT12 TABLE [9985-10195] -->
<p>
The AppStateManager&#039;s <code>render(), postRender(), cleanup()</code> methods are internal, ignore them, users never call them directly.
</p>
<ul>
<li><div> If a detached AppState is attached then initialize() will be called on the following render pass.</div>
@ -300,32 +287,29 @@ The AppStateManager&#039;s <code>render(), postRender(), cleanup()</code> method
</div>
<!-- EDIT11 SECTION "AppStateManager" [9578-10961] -->
<h2><a>Best Practices</a></h2>
<h2>Best Practices</h2>
<div>
</div>
<!-- EDIT13 SECTION "Best Practices" [10962-10989] -->
<h3><a>Communication Among AppStates</a></h3>
<h3>Communication Among AppStates</h3>
<div>
<p>
You can only access other AppStates (read from and write to them) from certain places: From a Control&#039;s update() method, from an AppState&#039;s update() method, and from the SimpleApplication&#039;s simpleUpdate() loop. Don&#039;t mess with the AppState from other places, because from other methods you have no control over the order of modifications; the game can go out of sync because you can&#039;t know when (during which half-finished step of another state change) your modification will be performed.
</p>
<p>
You can use custom accessors to get data from AppStates, to set data in AppStates, or to trigger methods in AppStates.
</p>
<pre>this.app.getStateManager&#40;&#41;.getState&#40;MyAppState.class&#41;.doSomeCustomStuffInThisState&#40;&#41;;</pre>
</div>
<!-- EDIT14 SECTION "Communication Among AppStates" [10990-11745] -->
<h3><a>Initialize Familiar Class Fields</a></h3>
<h3>Initialize Familiar Class Fields</h3>
<div>
<p>
To access class fields of the SimpleApplication the way you are used to, initialize them to local variables, as shown in the following AppState template:
</p>
<pre>private SimpleApplication app;
@ -352,4 +336,4 @@ public class MyAppState extends AbstractAppState &#123;
</div>
<!-- EDIT15 SECTION "Initialize Familiar Class Fields" [11746-] -->
<p><em><a href="http://hub.jmonkeyengine.org/wiki/doku.php/jme3:advanced:application_states?do=export_xhtmlbody">view online version</a></em></p>
<p><em><a href="http://wiki.jmonkeyengine.org/doku.php/jme3:advanced:application_states?do=export_xhtmlbody">view online version</a></em></p>

@ -1,19 +1,17 @@
<h1><a>Simple AppStates Demo</a></h1>
<h1>Simple AppStates Demo</h1>
<div>
<p>
<p><div>
THIS DEMO IS OUT OF DATE AND NEEDS CORRECTING
</div></p>
</p>
</div>
<!-- EDIT1 SECTION "Simple AppStates Demo" [1-108] -->
<h1><a>THIS DEMO IS OUT OF DATE AND NEEDS CORRECTING FOR NOW PLEASE SEE</a></h1>
<h1>THIS DEMO IS OUT OF DATE AND NEEDS CORRECTING FOR NOW PLEASE SEE</h1>
<div>
<p>
@ -21,7 +19,7 @@ THIS DEMO IS OUT OF DATE AND NEEDS CORRECTING
</p>
<p>
Note: this tutorial needs to be fixed and is currently not correct. One should almost never override stateDetached and stateAttached??? and should certainly never do anything scene related in them.
Note: this tutorial needs to be fixed and is currently not correct. One should almost never override stateDetached and stateAttached and should certainly never do anything scene related in them.
</p>
<p>
@ -30,12 +28,11 @@ This demo is a simple example of how you use AppStates to toggle between a Start
<p>
There are four files, Main.java, GameRunningState.java, StartScreenState.java, SettingsScreenState.java.
</p>
</div>
<!-- EDIT2 SECTION "THIS DEMO IS OUT OF DATE AND NEEDS CORRECTING FOR NOW PLEASE SEE" [109-793] -->
<h2><a>Main.java</a></h2>
<h2>Main.java</h2>
<div>
<pre>package chapter04.appstatedemo;
&nbsp;
@ -94,7 +91,7 @@ public class Main extends SimpleApplication &#123;
inputManager.addListener&#40;actionListener, new String&#91;&#93;&#123;&quot;Toggle Settings&quot;&#125;&#41;;
&#125;
&nbsp;
private ActionListener actionListener = new ActionListener&#40;&#41; &#123;
private ActionListener&#40;&#41; &#123;
public void onAction&#40;String name, boolean isPressed, float tpf&#41; &#123;
System.out.println&#40;&quot;key&quot; + name&#41;;
if &#40;name.equals&#40;&quot;Game Pause Unpause&quot;&#41; &amp;&amp; !isPressed&#41; &#123;
@ -131,7 +128,7 @@ public class Main extends SimpleApplication &#123;
</div>
<!-- EDIT3 SECTION "Main.java" [794-4202] -->
<h2><a>GameRunningState.java</a></h2>
<h2>GameRunningState.java</h2>
<div>
<pre>package chapter04.appstatedemo;
&nbsp;
@ -178,7 +175,7 @@ public class GameRunningState extends AbstractAppState &#123;
/** Load this scene */
viewPort.setBackgroundColor&#40;backgroundColor&#41;;
&nbsp;
Box mesh = new Box&#40;Vector3f.ZERO, 1, 1, 1&#41;;
Box&#40;Vector3f.ZERO, 1, 1, 1&#41;;
Geometry geom = new Geometry&#40;&quot;Box&quot;, mesh&#41;;
Material mat = new Material&#40;assetManager,
&quot;Common/MatDefs/Misc/Unshaded.j3md&quot;&#41;;
@ -223,7 +220,7 @@ public class GameRunningState extends AbstractAppState &#123;
</div>
<!-- EDIT4 SECTION "GameRunningState.java" [4203-7170] -->
<h2><a>SettingsScreenState.java</a></h2>
<h2>SettingsScreenState.java</h2>
<div>
<pre>package chapter04.appstatedemo;
&nbsp;
@ -270,7 +267,7 @@ public class SettingsScreenState extends AbstractAppState &#123;
/** Load this scene */
viewPort.setBackgroundColor&#40;backgroundColor&#41;;
&nbsp;
Box mesh = new Box&#40;new Vector3f&#40;-1, -1, 0&#41;, .5f, .5f, .5f&#41;;
Box&#40;new Vector3f&#40;-1, -1, 0&#41;, .5f, .5f, .5f&#41;;
Geometry geom = new Geometry&#40;&quot;Box&quot;, mesh&#41;;
Material mat = new Material&#40;assetManager,
&quot;Common/MatDefs/Misc/Unshaded.j3md&quot;&#41;;
@ -312,7 +309,7 @@ public class SettingsScreenState extends AbstractAppState &#123;
</div>
<!-- EDIT5 SECTION "SettingsScreenState.java" [7171-9985] -->
<h2><a>StartScreenState.java</a></h2>
<h2>StartScreenState.java</h2>
<div>
<pre>package chapter04.appstatedemo;
&nbsp;
@ -359,7 +356,7 @@ public StartScreenState&#40;SimpleApplication app&#41;&#123;
/** Init this scene */
viewPort.setBackgroundColor&#40;backgroundColor&#41;;
&nbsp;
Box mesh = new Box&#40;new Vector3f&#40;-1,1,0&#41;, .5f,.5f,.5f&#41;;
Box&#40;new Vector3f&#40;-1,1,0&#41;, .5f,.5f,.5f&#41;;
Geometry geom = new Geometry&#40;&quot;Box&quot;, mesh&#41;;
Material mat = new Material&#40;assetManager,
&quot;Common/MatDefs/Misc/Unshaded.j3md&quot;&#41;;
@ -401,4 +398,4 @@ public StartScreenState&#40;SimpleApplication app&#41;&#123;
</div>
<!-- EDIT6 SECTION "StartScreenState.java" [9986-] -->
<p><em><a href="http://hub.jmonkeyengine.org/wiki/doku.php/jme3:advanced:appstatesdemo?do=export_xhtmlbody">view online version</a></em></p>
<p><em><a href="http://wiki.jmonkeyengine.org/doku.php/jme3:advanced:appstatesdemo?do=export_xhtmlbody">view online version</a></em></p>

@ -1,9 +1,8 @@
<h1><a>AssetManager</a></h1>
<h1>AssetManager</h1>
<div>
<p>
By assets we mean multi-media files, such as 3D models, materials, textures, scenes, custom shaders, music and sound files, and custom fonts. JME3 has an integrated asset manager that helps you keep your project assets organized. Think of the asset manager as the filesystem of your game, independent of the actual deployment platform. By default, store your assets in the <code>MyGame/assets/ </code> directory of your project.
</p>
@ -21,13 +20,12 @@ For example, the same textures are not uploaded to the graphics card multiple ti
</ul>
<p>
Advanced users can write a custom build and packaging script, and can register custom paths to the AssetManager, but this is up to you then.
</p>
</div>
<h4><a>Context</a></h4>
<h4>Context</h4>
<div>
<pre>jMonkeyProjects/MyGame/assets/ # You store assets in subfolders here! &lt;------
jMonkeyProjects/MyGame/build/ # SDK generates built classes here (*)
@ -44,11 +42,10 @@ See also <a href="/com/jme3/gde/docs/jme3/intermediate/best_practices.html">Best
</div>
<!-- EDIT1 SECTION "AssetManager" [1-1702] -->
<h2><a>Usage</a></h2>
<h2>Usage</h2>
<div>
<p>
The <code>assetManager</code> object is an com.jme3.asset.AssetManager instance that every com.jme3.app.Application can access. It maintains a root that also includes your project&#039;s classpath by default, so you can load any asset that&#039;s on the classpath, that is, the top level of your project directory.
</p>
@ -63,7 +60,7 @@ Here is an example how you load assets using the AssetManager. This lines loads
new AssetKey&#40;&quot;Common/Materials/RedColor.j3m&quot;&#41;&#41;;</pre>
<p>
This Material is &quot;somewhere&quot; in the jME3 JAR; the default Asset Manager is configured to handle a <code>Common/???</code> path correctly, so you don&#039;t have to specify the whole path when referring to built-in assets (such as default Materials).
This Material is “somewhere” in the jME3 JAR; the default Asset Manager is configured to handle a <code>Common/</code> path correctly, so you don&#039;t have to specify the whole path when referring to built-in assets (such as default Materials).
</p>
<p>
@ -72,16 +69,15 @@ Additionally, you can configure the Asset Manager and add any path to its root.
</div>
<!-- EDIT2 SECTION "Usage" [1703-2860] -->
<h2><a>Asset Directory</a></h2>
<h2>Asset Directory</h2>
<div>
<p>
By default, jME3 searches for models in a directory named <code>assets</code>.
</p>
<p>
<p><div>In Java projects created with the jMonkeyEngine <acronym title="Software Development Kit">SDK</acronym>, an <code>assets</code> folder is created by default in your project directory. If you are using any other IDE, or the command line, you simply create an <code>assets</code> directory manually (see the Codeless Project tip below).
<p><div>In Java projects created with the jMonkeyEngine SDK, an <code>assets</code> folder is created by default in your project directory. If you are using any other IDE, or the command line, you simply create an <code>assets</code> directory manually (see the Codeless Project tip below).
</div></p>
</p>
@ -104,7 +100,7 @@ These subdirectories are just the most common examples.
</p>
<p>
<p><div>You can rename/delete/add (sub)directories inside the <code>assets</code> directory in any way you like. Note however that there is no automatic refactoring for asset paths in the <acronym title="Software Development Kit">SDK</acronym>, so if you modify them late in the development process, you have to refactor all paths manually.
<p><div>You can rename/delete/add (sub)directories inside the <code>assets</code> directory in any way you like. Note however that there is no automatic refactoring for asset paths in the SDK, so if you modify them late in the development process, you have to refactor all paths manually.
</div></p>
</p>
@ -120,39 +116,33 @@ After the conversion, you move the .j3o file into the <code>assets/Models/</code
</div>
<!-- EDIT3 SECTION "Asset Directory" [2861-5290] -->
<h2><a>Example Code: Loading Assets</a></h2>
<h2>Example Code: Loading Assets</h2>
<div>
<p>
Creating a material instance with the definition &quot;Unshaded.j3md&quot;:
Creating a material instance with the definition “Unshaded.j3md”:
</p>
<pre>Material mat_brick = new Material&#40;
assetManager, &quot;Common/MatDefs/Misc/Unshaded.j3md&quot;&#41;;</pre>
<p>
Applying a texture to the material:
</p>
<pre>mat_brick.setTexture&#40;&quot;ColorMap&quot;,
assetManager.loadTexture&#40;&quot;Textures/Terrain/BrickWall/BrickWall.jpg&quot;&#41;&#41;;</pre>
<p>
Loading a font:
</p>
<pre>guiFont = assetManager.loadFont&#40;&quot;Interface/Fonts/Default.fnt&quot;&#41;;</pre>
<p>
Loading a model:
</p>
<pre>Spatial ninja = assetManager.loadModel&#40;&quot;Models/Ninja/Ninja.mesh.xml&quot;&#41;;</pre>
<p>
Loading a scene from an Ogre3D dotScene file stored inside a zip:
</p>
<pre>assetManager.registerLocator&#40;&quot;town.zip&quot;, ZipLocator.class&#41;;
Spatial scene = assetManager.loadModel&#40;&quot;main.scene&quot;&#41;;
@ -171,18 +161,20 @@ jME3 also offers a ClasspathLocator, ZipLocator, FileLocator, HttpZipLocator, an
</p>
<p>
<p><div>The custom build script does not automatically include all ZIP files in the executable build. See &quot;Cannot Locate Resource&quot; solution below.
<p><div>The custom build script does not automatically include all ZIP files in the executable build. See “Cannot Locate Resource” solution below.
</div></p>
</p>
</div>
<!-- EDIT4 SECTION "Example Code: Loading Assets" [5291-6763] -->
<h2><a>Common AssetManager Tasks</a></h2>
<h2>Common AssetManager Tasks</h2>
<div>
<div><table>
<thead>
<tr>
<th> Task? </th><th> Solution! </th>
</tr>
</thead>
<tr>
<td> Load a model with materials </td><td> Use the asset manager&#039;s <code>loadModel()</code> method and attach the Spatial to the rootNode. <pre>Spatial elephant = assetManager.loadModel&#40;&quot;Models/Elephant/Elephant.mesh.xml&quot;&#41;;
rootNode.attachChild&#40;elephant&#41;;</pre>
@ -206,16 +198,15 @@ rootNode.attachChild&#40;scene&#41;;</pre>
<!-- EDIT6 TABLE [6803-7731] -->
</div>
<!-- EDIT5 SECTION "Common AssetManager Tasks" [6764-7732] -->
<h2><a>NullPointerException: Cannot locate resource?</a></h2>
<h2>NullPointerException: Cannot locate resource?</h2>
<div>
<p>
<strong>Problem:</strong>
</p>
<p>
My game runs fine when I run it right from the jMonkeyEngine <acronym title="Software Development Kit">SDK</acronym>. But when I run the stand-alone executables (.jar, .jnlp .exe, .app), a DesktopAssetManager error message occurs in the console, and it quits?
My game runs fine when I run it right from the jMonkeyEngine SDK. But when I run the stand-alone executables (.jar, .jnlp .exe, .app), a DesktopAssetManager error message occurs in the console, and it quits?
</p>
<pre>com.jme3.asset.DesktopAssetManager loadAsset
WARNING: Cannot locate resource: Scenes/town/main.scene
@ -228,7 +219,7 @@ java.lang.NullPointerException</pre>
</p>
<p>
If you use the default build script, <strong>original models and scenes (.mesh.xml, .obj, .blend, .zip), are excluded</strong> from the distribution automatically. A stand-alone executable includes converted <strong>.j3o files</strong> (models and scenes) only. The default build script makes sure to bundle existing .j3o files in the distribution, but you need to remember to convert the models (from mesh.xml???&gt;.j3o, or .obj???&gt;.j3o, etc) yourself.
If you use the default build script, <strong>original models and scenes (.mesh.xml, .obj, .blend, .zip), are excluded</strong> from the distribution automatically. A stand-alone executable includes converted <strong>.j3o files</strong> (models and scenes) only. The default build script makes sure to bundle existing .j3o files in the distribution, but you need to remember to convert the models (from mesh.xml&gt;.j3o, or .obj–&gt;.j3o, etc) yourself.
</p>
<p>
@ -236,16 +227,16 @@ If you use the default build script, <strong>original models and scenes (.mesh.x
</p>
<p>
Before building the executable, you must use the jMonkeyEngine <acronym title="Software Development Kit">SDK</acronym>&#039;s context menu action to <a href="/com/jme3/gde/docs/sdk/model_loader_and_viewer.html">convert 3D models to .j3o binary format</a>.
Before building the executable, you must use the jMonkeyEngine SDK&#039;s context menu action to <a href="/com/jme3/gde/docs/sdk/model_loader_and_viewer.html">convert 3D models to .j3o binary format</a>.
</p>
<ol>
<li><div> Save your original models (.mesh.xml, .scene, .blend, or .obj files, plus textures) into <code>assets/Textures/</code>. (!)</div>
</li>
<li><div> Open the jME3 project in the jMonkeyEngine <acronym title="Software Development Kit">SDK</acronym>.</div>
<li><div> Open the jME3 project in the jMonkeyEngine SDK.</div>
</li>
<li><div> Browse to the <code>assets</code> directory in the Projects window. </div>
</li>
<li><div> Right-click an original model in <code>assets/Textures/</code>, and choose &quot;Convert to JME3 binary&quot;.</div>
<li><div> Right-click an original model in <code>assets/Textures/</code>, and choose “Convert to JME3 binary”.</div>
</li>
<li><div> The converted file appears in the same directory as the original file. It has the same name and a <code>.j3o</code> suffix. </div>
</li>
@ -256,7 +247,6 @@ Before building the executable, you must use the jMonkeyEngine <acronym title="S
</ol>
<p>
This ensures that the model&#039;s Texture paths keep working between your 3D mesh editor and JME3.
</p>
@ -267,16 +257,15 @@ This ensures that the model&#039;s Texture paths keep working between your 3D me
</div>
<!-- EDIT7 SECTION "NullPointerException: Cannot locate resource?" [7733-9809] -->
<h2><a>Asset Handling For Other IDEs: Codeless Projects</a></h2>
<h2>Asset Handling For Other IDEs: Codeless Projects</h2>
<div>
<p>
<strong>Problem:</strong>
</p>
<p>
I use another IDE than jMonkeyEngine <acronym title="Software Development Kit">SDK</acronym> for coding (Eclipse, IntelliJ, text editor). Where is my <code>asset</code> folder and .j3o converter?
I use another IDE than jMonkeyEngine SDK for coding (Eclipse, IntelliJ, text editor). Where is my <code>asset</code> folder and .j3o converter?
</p>
<p>
@ -284,8 +273,7 @@ I use another IDE than jMonkeyEngine <acronym title="Software Development Kit">S
</p>
<p>
You can code in any IDE, but you must create a so-called codeless project in the jMonkeyEngine <acronym title="Software Development Kit">SDK</acronym> to maintain assets. <strong>A code-less jMonkeyEngine project does not meddle with your sources or custom build scripts.</strong> You merely use it to convert models to .j3o binaries.
You can code in any IDE, but you must create a so-called codeless project in the jMonkeyEngine SDK to maintain assets. <strong>A code-less jMonkeyEngine project does not meddle with your sources or custom build scripts.</strong> You merely use it to convert models to .j3o binaries.
</p>
<ol>
<li><div> Create your (Eclipse or whatever) project as you like.</div>
@ -293,28 +281,27 @@ You can code in any IDE, but you must create a so-called codeless project in the
<li><div> Create a directory in your project folder and name it, for example, <code>assets</code>. <br/>
Store your assets there as described above.</div>
</li>
<li><div> Download and install the jMonkeyEngine <acronym title="Software Development Kit">SDK</acronym>.</div>
<li><div> Download and install the jMonkeyEngine SDK.</div>
</li>
<li><div> In the <acronym title="Software Development Kit">SDK</acronym>, go to File ??? Import Projects ??? External Project Assets.</div>
<li><div> In the SDK, go to File → Import Projects → External Project Assets.</div>
</li>
<li><div> Select your (Eclipse or whatever) project and your assets folder in the Import Wizard.</div>
</li>
<li><div> You can now open this (Eclipse or whatever) project in the jMonkeyEngine <acronym title="Software Development Kit">SDK</acronym>. <br/>
<li><div> You can now open this (Eclipse or whatever) project in the jMonkeyEngine SDK. <br/>
Convert assets as described above.</div>
</li>
</ol>
<p>
<p><div>If you don&#039;t use the <acronym title="Software Development Kit">SDK</acronym> for some reason, you can still convert models to j3o format: Load any model in Ogre3D or Wavefront format with the AssetManager.loadModel() as a spatial. Then save the spatial as j3o file using <a href="/com/jme3/gde/docs/jme3/advanced/save_and_load.html">BinaryExporter</a>.
<p><div>If you don&#039;t use the SDK for some reason, you can still convert models to j3o format: Load any model in Ogre3D or Wavefront format with the AssetManager.loadModel() as a spatial. Then save the spatial as j3o file using <a href="/com/jme3/gde/docs/jme3/advanced/save_and_load.html">BinaryExporter</a>.
</div></p>
</p>
<p>
<p><div>Use file version control and let team members check out the project. Your developers open the project in Eclipse (etc) as they are used to. Additionally to their graphic tools, ask your graphic designers to install the jMonkeyEngine <acronym title="Software Development Kit">SDK</acronym>, and to check out the codeless project that you just prepared. This makes it easy for non-coding team member to browse and preview game assets, to arrange scenes, and to convert files. At the same time, non-coders don&#039;t accidentally mess with code, and developers don&#039;t accidentally mess with assets. :)
<p><div>Use file version control and let team members check out the project. Your developers open the project in Eclipse (etc) as they are used to. Additionally to their graphic tools, ask your graphic designers to install the jMonkeyEngine SDK, and to check out the codeless project that you just prepared. This makes it easy for non-coding team member to browse and preview game assets, to arrange scenes, and to convert files. At the same time, non-coders don&#039;t accidentally mess with code, and developers don&#039;t accidentally mess with assets. :)
</div></p>
</p>
</div>
<!-- EDIT8 SECTION "Asset Handling For Other IDEs: Codeless Projects" [9810-] -->
<p><em><a href="http://hub.jmonkeyengine.org/wiki/doku.php/jme3:advanced:asset_manager?do=export_xhtmlbody">view online version</a></em></p>
<p><em><a href="http://wiki.jmonkeyengine.org/doku.php/jme3:advanced:asset_manager?do=export_xhtmlbody">view online version</a></em></p>

@ -1,15 +1,14 @@
<h1><a>Audio in jME3</a></h1>
<h1>Audio in jME3</h1>
<div>
<p>
Place audio files in the <code>assets/Sound/</code> directory of your project. jME3 supports Ogg Vorbis audio compression (.ogg) and uncompressed PCM Wave (.wav) formats. You can use for example <object classid="java:org.netbeans.modules.javahelp.BrowserDisplayer"><param name="content" value="http://audacity.sourceforge.net/"><param name="text" value="<html><u>Audacity</u></html>"><param name="textColor" value="blue"></object> to convert from other formats.
</p>
</div>
<!-- EDIT1 SECTION "Audio in jME3" [1-293] -->
<h2><a>Audio Terminology</a></h2>
<h2>Audio Terminology</h2>
<div>
<ul>
<li><div> <strong>Streaming:</strong> There are two ways to load audio data: Short audio files are to be stored entirely in memory (prebuffered), while long audio files, such as music, are streamed from the hard drive as it is played.</div>
@ -23,13 +22,11 @@ You cannot loop streamed sounds.</div>
</div>
<!-- EDIT2 SECTION "Audio Terminology" [294-891] -->
<h2><a>Creating Audio Nodes: Streamed or Buffered</a></h2>
<h2>Creating Audio Nodes: Streamed or Buffered</h2>
<div>
<p>
The main jME audio class to look at is <code>com.jme3.audio.AudioNode</code>. When creating a new audio node you need to declare whether how you want to load this sound:
</p>
<ul>
<li><div> <strong>Buffered:</strong> By default, a new audio node is buffered. This means jME3 loads the whole file into memory before playing. Use this for short sounds. You create a buffered sound by setting the boolean to false, or using no boolean at all: <pre>AudioNode boom = new AudioNode&#40;assetManager, &quot;Sound/boom.wav&quot;&#41;;
@ -43,12 +40,14 @@ AudioNode boom = new AudioNode&#40;assetManager, &quot;Sound/boom.wav&quot;, fal
</div>
<!-- EDIT3 SECTION "Creating Audio Nodes: Streamed or Buffered" [892-1839] -->
<h2><a>Getting AudioNode Properties</a></h2>
<h2>Getting AudioNode Properties</h2>
<div>
<div><table>
<thead>
<tr>
<th>AudioNode Method</th><th>Usage</th>
</tr>
</thead>
<tr>
<td>getStatus()</td><td>Returns either AudioSource.Status.Playing, AudioSource.Status.Stopped, or AudioSource.Status.Paused. </td>
</tr>
@ -66,12 +65,14 @@ Note: There are other obvious getters to poll the status of all corresponding se
</div>
<!-- EDIT4 SECTION "Getting AudioNode Properties" [1840-2192] -->
<h2><a>Setting AudioNode Properties</a></h2>
<h2>Setting AudioNode Properties</h2>
<div>
<div><table>
<thead>
<tr>
<th>AudioNode Method</th><th>Usage</th>
</tr>
</thead>
<tr>
<td>setTimeOffset(0.5f)</td><td>Play the sound starting at a 0.5 second offset from the beginning. Default is 0.</td>
</tr>
@ -94,12 +95,14 @@ Note: There are other obvious getters to poll the status of all corresponding se
<!-- EDIT7 TABLE [2235-3364] -->
</div>
<!-- EDIT6 SECTION "Setting AudioNode Properties" [2193-3365] -->
<h3><a>Looping &amp; Ambient Sounds</a></h3>
<h3>Looping &amp; Ambient Sounds</h3>
<div>
<div><table>
<thead>
<tr>
<th>AudioNode Method</th><th>Usage</th>
</tr>
</thead>
<tr>
<td>setPositional(false) <br/>
setDirectional(false)</td><td>All 3D effects switched off. This sound is global and plays in headspace (it appears to come from everywhere). Good for environmental ambient sounds and background music.</td>
@ -112,58 +115,59 @@ setDirectional(false)</td><td>All 3D effects switched off. This sound is global
<!-- EDIT9 TABLE [3402-3883] -->
</div>
<!-- EDIT8 SECTION "Looping & Ambient Sounds" [3366-3884] -->
<h3><a>Positional 3D Sounds</a></h3>
<h3>Positional 3D Sounds</h3>
<div>
<div><table>
<thead>
<tr>
<th>AudioNode Method</th><th>Usage</th>
</tr>
</thead>
<tr>
<td>setPositional(true) <br/>
setLocalTranslation(???)</td><td>Activates 3D audio: The sound appears to come from a certain position, where it is loudest. Position the AudioNode in the 3D scene, or move it with mobile players or NPCs.</td>
setLocalTranslation()</td><td>Activates 3D audio: The sound appears to come from a certain position, where it is loudest. Position the AudioNode in the 3D scene, or move it with mobile players or NPCs.</td>
</tr>
<tr>
<td>setReverbEnabled(true)</td><td>Reverb is a 3D echo effect that only makes sense with positional AudioNodes. Use Audio Environments to make scenes sound as if they were &quot;outdoors&quot;, or &quot;indoors&quot; in a large or small room, etc. The reverb effect is defined by the <code>com.jme3.audio.Environment</code> that the <code>audioRenderer</code> is in. See &quot;Setting Audio Environment Properties&quot; below. </td>
<td>setReverbEnabled(true)</td><td>Reverb is a 3D echo effect that only makes sense with positional AudioNodes. Use Audio Environments to make scenes sound as if they were “outdoors”, or “indoors” in a large or small room, etc. The reverb effect is defined by the <code>com.jme3.audio.Environment</code> that the <code>audioRenderer</code> is in. See “Setting Audio Environment Properties” below. </td>
</tr>
</table></div>
<!-- EDIT11 TABLE [3917-4533] -->
<p>
<p><div>Positional 3D sounds require an <code>AudioListener</code> object in the scene (representing the player&#039;s ears).
</div></p>
</p>
</div>
<!-- EDIT10 SECTION "Positional 3D Sounds" [3885-4662] -->
<h3><a>Directional 3D Sounds</a></h3>
<h3>Directional 3D Sounds</h3>
<div>
<div><table>
<thead>
<tr>
<th>AudioNode Method</th><th>Usage</th>
</tr>
</thead>
<tr>
<td>setDirectional(true) <br/>
setDirection(???) </td><td>Activates 3D audio: This sound can only be heard from a certain direction. Specify the direction and angle in the 3D scene if you have setDirectional() true. Use this to restrict noises that should not be heard, for example, through a wall.</td>
setDirection() </td><td>Activates 3D audio: This sound can only be heard from a certain direction. Specify the direction and angle in the 3D scene if you have setDirectional() true. Use this to restrict noises that should not be heard, for example, through a wall.</td>
</tr>
<tr>
<td>setInnerAngle() <br/>
setOuterAngle()</td><td>Set the angle in degrees for the directional audio. The angle is relative to the direction. Note: By default, both angles are 360?? and the sound can be heard from all directions!</td>
setOuterAngle()</td><td>Set the angle in degrees for the directional audio. The angle is relative to the direction. Note: By default, both angles are 360° and the sound can be heard from all directions!</td>
</tr>
</table></div>
<!-- EDIT13 TABLE [4696-5223] -->
<p>
<p><div>Directional 3D sounds require an AudioListener object in the scene (representing the player&#039;s ears).
</div></p>
</p>
</div>
<!-- EDIT12 SECTION "Directional 3D Sounds" [4663-5350] -->
<h2><a>Play, Pause, Stop</a></h2>
<h2>Play, Pause, Stop</h2>
<div>
<p>
You play, pause, and stop a node called myAudioNode by using the respective of the following three methods:
</p>
<pre>myAudioNode.play&#40;&#41;;</pre>
@ -181,11 +185,10 @@ You can also start playing instances of an AudioNode. Use the <code>playInstance
</div>
<!-- EDIT14 SECTION "Play, Pause, Stop" [5351-6055] -->
<h2><a>The Audio Listener</a></h2>
<h2>The Audio Listener</h2>
<div>
<p>
The default AudioListener object <code>listener</code> in <code>SimpleApplication</code> is the user&#039;s ear in the scene. If you use 3D audio (positional or directional sounds), you must move the AudioListener with the player: For example, for a first-person player, you move the listener with the camera. For a third-person player, you move the listener with the player avatar Geometry.
</p>
<pre> @Override
@ -197,18 +200,18 @@ The default AudioListener object <code>listener</code> in <code>SimpleApplicatio
</div>
<!-- EDIT15 SECTION "The Audio Listener" [6056-6692] -->
<h2><a>Setting Audio Environment Properties</a></h2>
<h2>Setting Audio Environment Properties</h2>
<div>
<p>
Optionally, You can choose from the following environmental presets from <code>com.jme3.audio.Environment</code>. This presets influence subtle echo effects (reverb) that evoke associations of different environments in your users. That is, it makes you scene sound &quot;indoors&quot; or &quot;outdoors&quot; etc. You use Audio Environments together with <code>setReverbEnabled(true)</code> on positional AudioNodes (see above).
Optionally, You can choose from the following environmental presets from <code>com.jme3.audio.Environment</code>. This presets influence subtle echo effects (reverb) that evoke associations of different environments in your users. That is, it makes you scene sound “indoors” or “outdoors” etc. You use Audio Environments together with <code>setReverbEnabled(true)</code> on positional AudioNodes (see above).
</p>
<div><table>
<thead>
<tr>
<th>Environment</th><th>density</th><th>diffusion</th><th>gain</th><th>gainHf</th><th>decayTime</th><th>decayHf</th><th>reflGain</th><th>reflDelay</th><th>lateGain</th><th>lateDelay</th>
</tr>
</thead>
<tr>
<td>Garage </td><td>1.00f</td><td>1.0f</td><td>1.0f</td><td>1.00f</td><td>0.90f</td><td>0.5f</td><td>0.751f</td><td>0.0039f</td><td>0.661f</td><td>0.0137f</td>
</tr>
@ -228,7 +231,7 @@ Optionally, You can choose from the following environmental presets from <code>c
<!-- EDIT17 TABLE [7135-7624] --><ol>
<li><div> Activate a Environment preset</div>
<ul>
<li><div> Either use a default, e.g. make you scene sounds like a dungeon environment: <pre>audioRenderer.setEnvironment&#40;new Environment&#40;Environment.Dungeon&#41;&#41;;</pre>
<li><div> Either use a default, e.g. make you scene sounds like a dungeon environment: <pre>audioRenderer.setEnvironment&#40;new Environment.Dungeon&#41;&#41;;</pre>
</div>
</li>
<li><div> Or activate <a href="/com/jme3/gde/docs/jme3/advanced/audio_environment_presets.html">custom environment settings</a> in the Environment constructor:<pre>audioRenderer.setEnvironment&#40;
@ -245,25 +248,23 @@ footstepsAudio.setReverbEnabled&#40;true&#41;;</pre>
</ol>
<p>
<p><div>A sound engineer can create a custom <code>com.???jme3.???audio.Environment</code> object and specify custom environment values such as density, diffusion, gain, decay, delay??? You can find many <a href="/com/jme3/gde/docs/jme3/advanced/audio_environment_presets.html">examples of custom audio environment presets</a> here.
<p><div>A sound engineer can create a custom <code>com.jme3.audio.Environment</code> object and specify custom environment values such as density, diffusion, gain, decay, delay… You can find many <a href="/com/jme3/gde/docs/jme3/advanced/audio_environment_presets.html">examples of custom audio environment presets</a> here.
</div></p>
</p>
<p>
Advanced users find more info about OpenAL and its features here: <object classid="java:org.netbeans.modules.javahelp.BrowserDisplayer"><param name="content" value="http://connect.creativelabs.com/openal/Documentation/OpenAL%201.1%20Specification.pdf"><param name="text" value="<html><u>OpenAL 1.1 Specification</u></html>"><param name="textColor" value="blue"></object>.
Advanced users find more info about OpenAL and its features here: <object classid="java:org.netbeans.modules.javahelp.BrowserDisplayer"><param name="content" value="http://web.archive.org/web/20130327063429/http://connect.creativelabs.com/openal/Documentation/OpenAL_Programmers_Guide.pdf"><param name="text" value="<html><u>OpenAL 1.1 Specification</u></html>"><param name="textColor" value="blue"></object>.
</p>
<p>
<p><div>It depends on the hardware whether audio effects are supported (if not, you get the message <code>OpenAL EFX not available! Audio effects won&#039;t work.</code>)
</div></p>
</p>
<div><span>
<a href="/wiki/doku.php/tag:sound?do=showtag&amp;tag=tag%3Asound">sound</a>,
<a href="/wiki/doku.php/tag:documentation?do=showtag&amp;tag=tag%3Adocumentation">documentation</a>,
<a href="/wiki/doku.php/tag:environment?do=showtag&amp;tag=tag%3Aenvironment">environment</a>
</span></div>
<p>
<a href="nbdocs:/com/jme3/gde/docs/jme3:advanced/tag_sound_documentation_environment">tag_sound_documentation_environment</a>
</p>
</div>
<!-- EDIT16 SECTION "Setting Audio Environment Properties" [6693-] -->
<p><em><a href="http://hub.jmonkeyengine.org/wiki/doku.php/jme3:advanced:audio?do=export_xhtmlbody">view online version</a></em></p>
<p><em><a href="http://wiki.jmonkeyengine.org/doku.php/jme3:advanced:audio?do=export_xhtmlbody">view online version</a></em></p>

@ -1,17 +1,15 @@
<h1><a>Audio Environment Presets</a></h1>
<h1>Audio Environment Presets</h1>
<div>
<p>
Use these presets together with <a href="/com/jme3/gde/docs/jme3/advanced/audio.html">Audio</a> Nodes to create different &quot;moods&quot; for sounds. Environment effects make your audio sound as if the listener were in various places that have different types of echoes.
Use these presets together with <a href="/com/jme3/gde/docs/jme3/advanced/audio.html">Audio</a> Nodes to create different “moods” for sounds. Environment effects make your audio sound as if the listener were in various places that have different types of echoes.
</p>
<p>
Usage:
</p>
<pre>Environment Generic = new Environment&#40;
<pre>Environment&#40;
new float&#91;&#93;&#123; 0, 7.5f, 1f, -1000, -100, 0, 1.49f, 0.83f, 1f, -2602,
0.007f, 0f, 0f, 0f, 200, 0.011f, 0f, 0f, 0f, 0.250f,
0f, 0.250f, 0f, -5f, 5000f, 250f, 0f, 0x3f&#125; &#41;;
@ -19,7 +17,7 @@ audioRenderer.setEnvironment&#40;myEnvironment&#41;;</pre>
</div>
<!-- EDIT1 SECTION "Audio Environment Presets" [1-568] -->
<h2><a>Castle</a></h2>
<h2>Castle</h2>
<div>
<pre>CastleSmallRoom = new Environment &#40; new float&#91;&#93;&#123; 26, 8.3f, 0.890f, -1000, -800, -2000, 1.22f, 0.83f, 0.31f, -100, 0.022f, 0f, 0f, 0f, 600, 0.011f, 0f, 0f, 0f, 0.138f, 0.080f, 0.250f, 0f, -5f, 5168.6f, 139.5f, 0f, 0x20&#125; &#41;;
CastleShortPassage = new Environment &#40; new float&#91;&#93;&#123; 26, 8.3f, 0.890f, -1000, -1000, -2000, 2.32f, 0.83f, 0.31f, -100, 0.007f, 0f, 0f, 0f, 200, 0.023f, 0f, 0f, 0f, 0.138f, 0.080f, 0.250f, 0f, -5f, 5168.6f, 139.5f, 0f, 0x20&#125; &#41;;
@ -33,7 +31,7 @@ CastleAlcove = new Environment &#40; new float&#91;&#93;&#123; 26, 8.3f, 0
</div>
<!-- EDIT2 SECTION "Castle" [569-2630] -->
<h2><a>Warehouse, Factory</a></h2>
<h2>Warehouse, Factory</h2>
<div>
<pre>FactoryAlcove = new Environment &#40; new float&#91;&#93;&#123; 26, 1.8f, 0.590f, -1200, -200, -600, 3.14f, 0.65f, 1.31f, 300, 0.010f, 0f, 0f, 0f, 000, 0.038f, 0f, 0f, 0f, 0.114f, 0.100f, 0.250f, 0f, -5f, 3762.6f, 362.5f, 0f, 0x20&#125; &#41;;
FactoryShortpassage = new Environment &#40; new float&#91;&#93;&#123; 26, 1.8f, 0.640f, -1200, -200, -600, 2.53f, 0.65f, 1.31f, 0, 0.010f, 0f, 0f, 0f, 200, 0.038f, 0f, 0f, 0f, 0.135f, 0.230f, 0.250f, 0f, -5f, 3762.6f, 362.5f, 0f, 0x20&#125; &#41; &#41;;
@ -47,7 +45,7 @@ FactorySmallroom = new Environment &#40; new float&#91;&#93;&#123; 26, 1.8f,
</div>
<!-- EDIT3 SECTION "Warehouse, Factory" [2631-4706] -->
<h2><a>Ice Palace</a></h2>
<h2>Ice Palace</h2>
<div>
<pre>IcepalaceAlcove = new Environment &#40; new float&#91;&#93;&#123; 26, 2.7f, 0.840f, -1000, -500, -1100, 2.76f, 1.46f, 0.28f, 100, 0.010f, 0f, 0f, 0f, -100, 0.030f, 0f, 0f, 0f, 0.161f, 0.090f, 0.250f, 0f, -5f, 12428.5f, 99.6f, 0f, 0x20&#125; &#41;;
IcepalaceShortpassage = new Environment &#40; new float&#91;&#93;&#123; 26, 2.7f, 0.750f, -1000, -500, -1100, 1.79f, 1.46f, 0.28f, -600, 0.010f, 0f, 0f, 0f, 100, 0.019f, 0f, 0f, 0f, 0.177f, 0.090f, 0.250f, 0f, -5f, 12428.5f, 99.6f, 0f, 0x20&#125; &#41; &#41;;
@ -61,7 +59,7 @@ IcepalaceSmallroom = new Environment &#40; new float&#91;&#93;&#123; 26, 2.7f
</div>
<!-- EDIT4 SECTION "Ice Palace" [4707-6805] -->
<h2><a>Space Station</a></h2>
<h2>Space Station</h2>
<div>
<pre>SpacestationAlcove = new Environment &#40; new float&#91;&#93;&#123; 26, 1.5f, 0.780f, -1000, -300, -100, 1.16f, 0.81f, 0.55f, 300, 0.007f, 0f, 0f, 0f, 000, 0.018f, 0f, 0f, 0f, 0.192f, 0.210f, 0.250f, 0f, -5f, 3316.1f, 458.2f, 0f, 0x20&#125; &#41;;
SpacestationMediumroom = new Environment &#40; new float&#91;&#93;&#123; 26, 1.5f, 0.750f, -1000, -400, -100, 3.01f, 0.50f, 0.55f, -800, 0.034f, 0f, 0f, 0f, 100, 0.035f, 0f, 0f, 0f, 0.209f, 0.310f, 0.250f, 0f, -5f, 3316.1f, 458.2f, 0f, 0x20&#125; &#41;;
@ -74,7 +72,7 @@ SpacestationSmallroom = new Environment &#40; new float&#91;&#93;&#123; 26, 1
</div>
<!-- EDIT5 SECTION "Space Station" [6806-8687] -->
<h2><a>Wooden Hut or Ship</a></h2>
<h2>Wooden Hut or Ship</h2>
<div>
<pre>WoodenAlcove = new Environment &#40; new float&#91;&#93;&#123; 26, 7.5f, 1f, -1000, -1800, -1000, 1.22f, 0.62f, 0.91f, 100, 0.012f, 0f, 0f, 0f, -300, 0.024f, 0f, 0f, 0f, 0.250f, 0f, 0.250f, 0f, -5f, 4705f, 99.6f, 0f, 0x3f&#125; &#41;;
WoodenShortpassage = new Environment &#40; new float&#91;&#93;&#123; 26, 7.5f, 1f, -1000, -1800, -1000, 1.75f, 0.50f, 0.87f, -100, 0.012f, 0f, 0f, 0f, -400, 0.024f, 0f, 0f, 0f, 0.250f, 0f, 0.250f, 0f, -5f, 4705f, 99.6f, 0f, 0x3f&#125; &#41;;
@ -88,7 +86,7 @@ WoodenCourtyard = new Environment &#40; new float&#91;&#93;&#123; 26, 7.5
</div>
<!-- EDIT6 SECTION "Wooden Hut or Ship" [8688-10715] -->
<h2><a>Sport</a></h2>
<h2>Sport</h2>
<div>
<pre>SportEmptystadium = new Environment &#40; new float&#91;&#93;&#123; 26, 7.2f, 1f, -1000, -700, -200, 6.26f, 0.51f, 1.10f, -2400, 0.183f, 0f, 0f, 0f, -800, 0.038f, 0f, 0f, 0f, 0.250f, 0f, 0.250f, 0f, -5f, 5000f, 250f, 0f, 0x20&#125; &#41;;
SportSquashcourt = new Environment &#40; new float&#91;&#93;&#123; 26, 7.5f, 0.750f, -1000, -1000, -200, 2.22f, 0.91f, 1.16f, -700, 0.007f, 0f, 0f, 0f, -200, 0.011f, 0f, 0f, 0f, 0.126f, 0.190f, 0.250f, 0f, -5f, 7176.9f, 211.2f, 0f, 0x20&#125; &#41;;
@ -99,7 +97,7 @@ SportFullstadium = new Environment &#40; new float&#91;&#93;&#123; 26, 7.2
</div>
<!-- EDIT7 SECTION "Sport" [10716-12105] -->
<h2><a>Pipes</a></h2>
<h2>Pipes</h2>
<div>
<pre>Sewerpipe = new Environment &#40; new float&#91;&#93;&#123; 21, 1.7f, 0.800f, -1000, -1000, 0, 2.81f, 0.14f, 1f, 429, 0.014f, 0f, 0f, 0f, 1023, 0.021f, 0f, 0f, 0f, 0.250f, 0f, 0.250f, 0f, -5f, 5000f, 250f, 0f, 0x3f&#125; &#41;;
PipeSmall = new Environment &#40; new float&#91;&#93;&#123; 26, 50.3f, 1f, -1000, -900, -1300, 5.04f, 0.10f, 0.10f, -600, 0.032f, 0f, 0f, 0f, 800, 0.015f, 0f, 0f, 0f, 0.250f, 0f, 0.250f, 0f, -5f, 2854.4f, 20f, 0f, 0x3f&#125; &#41;;
@ -109,7 +107,7 @@ PipeResonant = new Environment &#40; new float&#91;&#93;&#123; 26, 1.3f, 0.910f,
</div>
<!-- EDIT8 SECTION "Pipes" [12106-13186] -->
<h2><a>Moods</a></h2>
<h2>Moods</h2>
<div>
<pre>Heaven = new Environment &#40; new float&#91;&#93;&#123; 26, 19.6f, 0.940f, -1000, -200, -700, 5.04f, 1.12f, 0.56f, -1230, 0.020f, 0f, 0f, 0f, 200, 0.029f, 0f, 0f, 0f, 0.250f, 0.080f, 2.742f, 0.050f, -2f, 5000f, 250f, 0f, 0x3f&#125; &#41;;
Hell = new Environment &#40; new float&#91;&#93;&#123; 26, 100f, 0.570f, -1000, -900, -700, 3.57f, 0.49f, 2f, -10000, 0.020f, 0f, 0f, 0f, 300, 0.030f, 0f, 0f, 0f, 0.110f, 0.040f, 2.109f, 0.520f, -5f, 5000f, 139.5f, 0f, 0x40&#125; &#41;;
@ -120,7 +118,7 @@ Psychotic = new Environment &#40; new float&#91;&#93;&#123; 25, 1f, 0.500f, -100
</div>
<!-- EDIT9 SECTION "Moods" [13187-14458] -->
<h2><a>Car Racing</a></h2>
<h2>Car Racing</h2>
<div>
<pre>DrivingCommentator = new Environment &#40; new float&#91;&#93;&#123; 26, 3f, 0f, 1000, -500, -600, 2.42f, 0.88f, 0.68f, -1400, 0.093f, 0f, 0f, 0f, -1200, 0.017f, 0f, 0f, 0f, 0.250f, 1f, 0.250f, 0f, -10f, 5000f, 250f, 0f, 0x20&#125; &#41;;
DrivingPitgarage = new Environment &#40; new float&#91;&#93;&#123; 26, 1.9f, 0.590f, -1000, -300, -500, 1.72f, 0.93f, 0.87f, -500, 0f, 0f, 0f, 0f, 200, 0.016f, 0f, 0f, 0f, 0.250f, 0.110f, 0.250f, 0f, -5f, 5000f, 250f, 0f, 0x0&#125; &#41;;
@ -133,7 +131,7 @@ DrivingTunnel = new Environment &#40; new float&#91;&#93;&#123; 26, 3.1
</div>
<!-- EDIT10 SECTION "Car Racing" [14459-16253] -->
<h2><a>City</a></h2>
<h2>City</h2>
<div>
<pre>CityIndoors = new Environment &#40; new float&#91;&#93;&#123; 16, 7.5f, 0.500f, -1000, -800, 0, 1.49f, 0.67f, 1f, -2273, 0.007f, 0f, 0f, 0f, -1691, 0.011f, 0f, 0f, 0f, 0.250f, 0f, 0.250f, 0f, -5f, 5000f, 250f, 0f, 0x3f&#125; &#41;;
CityStreets = new Environment &#40; new float&#91;&#93;&#123; 26, 3f, 0.780f, -1000, -300, -100, 1.79f, 1.12f, 0.91f, -1100, 0.046f, 0f, 0f, 0f, -1400, 0.028f, 0f, 0f, 0f, 0.250f, 0.200f, 0.250f, 0f, -5f, 5000f, 250f, 0f, 0x20&#125; &#41;;
@ -145,7 +143,7 @@ CityAbandoned = new Environment &#40; new float&#91;&#93;&#123; 26, 3f, 0.690f,
</div>
<!-- EDIT11 SECTION "City" [16254-17801] -->
<h2><a>Small Indoor Rooms</a></h2>
<h2>Small Indoor Rooms</h2>
<div>
<pre>Room = new Environment &#40; new float&#91;&#93;&#123; 2, 1.9f, 1f, -1000, -454, 0, 0.40f, 0.83f, 1f, -1646, 0.002f, 0f, 0f, 0f, 53, 0.003f, 0f, 0f, 0f, 0.250f, 0f, 0.250f, 0f, -5f, 5000f, 250f, 0f, 0x3f&#125; &#41;;
Bathroom = new Environment &#40; new float&#91;&#93;&#123; 3, 1.4f, 1f, -1000, -1200, 0, 1.49f, 0.54f, 1f, -370, 0.007f, 0f, 0f, 0f, 1030, 0.011f, 0f, 0f, 0f, 0.250f, 0f, 0.250f, 0f, -5f, 5000f, 250f, 0f, 0x3f&#125; &#41;;
@ -155,7 +153,7 @@ Stoneroom = new Environment &#40; new float&#91;&#93;&#123; 5, 11.6f, 1f, -10
</div>
<!-- EDIT12 SECTION "Small Indoor Rooms" [17802-18853] -->
<h2><a>Medium-Sized Indoor Rooms</a></h2>
<h2>Medium-Sized Indoor Rooms</h2>
<div>
<pre>Workshop = new Environment &#40; new float&#91;&#93;&#123; 26, 1.9f, 1f, -1000, -1700, -800, 0.76f, 1f, 1f, 0, 0.012f, 0f, 0f, 0f, 100, 0.012f, 0f, 0f, 0f, 0.250f, 0f, 0.250f, 0f, -5f, 5000f, 250f, 0f, 0x0&#125; &#41;;
Schoolroom = new Environment &#40; new float&#91;&#93;&#123; 26, 1.86f, 0.690f, -1000, -400, -600, 0.98f, 0.45f, 0.18f, 300, 0.017f, 0f, 0f, 0f, 300, 0.015f, 0f, 0f, 0f, 0.095f, 0.140f, 0.250f, 0f, -5f, 7176.9f, 211.2f, 0f, 0x20&#125; &#41;;
@ -167,7 +165,7 @@ Chapel = new Environment &#40; new float&#91;&#93;&#123; 26, 19.6f, 0.840f
</div>
<!-- EDIT13 SECTION "Medium-Sized Indoor Rooms" [18854-20400] -->
<h2><a>Large Indoor Rooms</a></h2>
<h2>Large Indoor Rooms</h2>
<div>
<pre>Auditorium = new Environment &#40; new float&#91;&#93;&#123; 6, 21.6f, 1f, -1000, -476, 0, 4.32f, 0.59f, 1f, -789, 0.020f, 0f, 0f, 0f, -289, 0.030f, 0f, 0f, 0f, 0.250f, 0f, 0.250f, 0f, -5f, 5000f, 250f, 0f, 0x3f&#125; &#41;;
Concerthall = new Environment &#40; new float&#91;&#93;&#123; 7, 19.6f, 1f, -1000, -500, 0, 3.92f, 0.70f, 1f, -1230, 0.020f, 0f, 0f, 0f, -02, 0.029f, 0f, 0f, 0f, 0.250f, 0f, 0.250f, 0f, -5f, 5000f, 250f, 0f, 0x3f&#125; &#41;;
@ -179,7 +177,7 @@ DomeSaintPauls = new Environment &#40; new float&#91;&#93;&#123; 26, 50.3f, 0.87
</div>
<!-- EDIT14 SECTION "Large Indoor Rooms" [20401-21901] -->
<h2><a>Hallways, Alleys</a></h2>
<h2>Hallways, Alleys</h2>
<div>
<pre>Carpettedhallway = new Environment &#40; new float&#91;&#93;&#123; 11, 1.9f, 1f, -1000, -4000, 0, 0.30f, 0.10f, 1f, -1831, 0.002f, 0f, 0f, 0f, -1630, 0.030f, 0f, 0f, 0f, 0.250f, 0f, 0.250f, 0f, -5f, 5000f, 250f, 0f, 0x3f&#125; &#41;;
Hallway = new Environment &#40; new float&#91;&#93;&#123; 12, 1.8f, 1f, -1000, -300, 0, 1.49f, 0.59f, 1f, -1219, 0.007f, 0f, 0f, 0f, 441, 0.011f, 0f, 0f, 0f, 0.250f, 0f, 0.250f, 0f, -5f, 5000f, 250f, 0f, 0x3f&#125; &#41;;
@ -188,7 +186,7 @@ Alley = new Environment &#40; new float&#91;&#93;&#123; 14, 7.5f, 0.3
</div>
<!-- EDIT15 SECTION "Hallways, Alleys" [21902-22779] -->
<h2><a>Outdoors</a></h2>
<h2>Outdoors</h2>
<div>
<pre>Backyard = new Environment &#40; new float&#91;&#93;&#123; 26, 80.3f, 0.450f, -1000, -1200, -600, 1.12f, 0.34f, 0.46f, -700, 0.069f, 0f, 0f, -0f, -300, 0.023f, 0f, 0f, 0f, 0.218f, 0.340f, 0.250f, 0f, -5f, 4399.1f, 242.9f, 0f, 0x0&#125; &#41;;
Plain = new Environment &#40; new float&#91;&#93;&#123; 19, 42.5f, 0.210f, -1000, -2000, 0, 1.49f, 0.50f, 1f, -2466, 0.179f, 0f, 0f, 0f, -1926, 0.100f, 0f, 0f, 0f, 0.250f, 1f, 0.250f, 0f, -5f, 5000f, 250f, 0f, 0x3f&#125; &#41;;
@ -203,11 +201,11 @@ Parkinglot = new Environment &#40; new float&#91;&#93;&#123; 20, 8.3f, 1f, -1
</div>
<!-- EDIT16 SECTION "Outdoors" [22780-24957] -->
<h2><a>Water</a></h2>
<h2>Water</h2>
<div>
<pre>Underwater = new Environment &#40; new float&#91;&#93;&#123; 22, 1.8f, 1f, -1000, -4000, 0, 1.49f, 0.10f, 1f, -449, 0.007f, 0f, 0f, 0f, 1700, 0.011f, 0f, 0f, 0f, 0.250f, 0f, 1.180f, 0.348f, -5f, 5000f, 250f, 0f, 0x3f&#125; &#41;;
Smallwaterroom = new Environment &#40; new float&#91;&#93;&#123; 26, 36.2f, 0.700f, -1000, -698, 0, 1.51f, 1.25f, 1.14f, -100, 0.020f, 0f, 0f, 0f, 300, 0.030f, 0f, 0f, 0f, 0.179f, 0.150f, 0.895f, 0.190f, -7f, 5000f, 250f, 0f, 0x0&#125; &#41;;</pre>
</div>
<!-- EDIT17 SECTION "Water" [24958-] -->
<p><em><a href="http://hub.jmonkeyengine.org/wiki/doku.php/jme3:advanced:audio_environment_presets?do=export_xhtmlbody">view online version</a></em></p>
<p><em><a href="http://wiki.jmonkeyengine.org/doku.php/jme3:advanced:audio_environment_presets?do=export_xhtmlbody">view online version</a></em></p>

@ -1,9 +1,8 @@
<h1><a>Bloom and Glow</a></h1>
<h1>Bloom and Glow</h1>
<div>
<p>
Bloom is a popular shader effect in 3D games industry. It usually consist in displaying a glowing halo around light sources or bright areas of a scene.
In practice, the bright areas are extracted from the rendered scene, blurred and finally added up to the render.
</p>
@ -16,7 +15,7 @@ Those images gives an idea of what bloom does. The left image has no bloom effec
</div>
<!-- EDIT1 SECTION "Bloom and Glow" [1-484] -->
<h1><a>Bloom Usage</a></h1>
<h1>Bloom Usage</h1>
<div>
<ol>
<li><div> Create a FilterPostProcessor</div>
@ -34,12 +33,14 @@ Those images gives an idea of what bloom does. The left image has no bloom effec
viewPort.addProcessor&#40;fpp&#41;;</pre>
<p>
Here are the parameters that you can tweak :
Here are the parameters that you can tweak :
</p>
<div><table>
<thead>
<tr>
<th> Parameter </th><th> Method </th><th> Default </th><th> Description </th>
</tr>
</thead>
<tr>
<td> blur scale </td><td> <code>setBlurScale(float)</code> </td><td>1.5f </td><td> the scale of the bloom effect, but be careful, high values does artifacts </td>
</tr>
@ -53,30 +54,27 @@ Here are the parameters that you can tweak :
<td> bloom intensity </td><td> <code>setBloomIntensity(float)</code> </td><td>2.0f </td><td> the resulting bloom value is multiplied by this intensity </td>
</tr>
</table></div>
<!-- EDIT3 TABLE [865-1454] -->
<!-- EDIT3 TABLE [864-1454] -->
<p>
You&#039;ll probably need to adjust those parameters depending on your scene.
</p>
</div>
<!-- EDIT2 SECTION "Bloom Usage" [485-1529] -->
<h1><a>Bloom with a glow map</a></h1>
<h1>Bloom with a glow map</h1>
<div>
<p>
Sometimes, you want to have more control over what glows and does not glow.
The bloom filter supports a glow map or a glow color.
</p>
</div>
<h5><a>Creating a glow-map</a></h5>
<h5>Creating a glow-map</h5>
<div>
<p>
Let&#039;s take the hover tank example bundled with JME3 test data.<br/>
Here you can see the diffuse map of the tank, and the associated glow map that only contains the parts of the texture that will glow and their glowing color: <br/>
@ -88,7 +86,6 @@ Here you can see the diffuse map of the tank, and the associated glow map that o
<p>
Glow maps work with Lighting.j3md, Particles.j3md and SolidColor.j3md material definitions.
The tank material looks like this :
</p>
<pre>Material My Material : Common/MatDefs/Light/Lighting.j3md {
MaterialParameters {
@ -105,13 +102,12 @@ The tank material looks like this :
}</pre>
<p>
The glow map is defined here : <strong>GlowMap : Models/HoverTank/tank_glow_map_highres.png</strong>
</p>
</div>
<h5><a>Usage</a></h5>
<h5>Usage</h5>
<div>
<ol>
<li><div> Create a FilterPostProcessor</div>
@ -136,18 +132,17 @@ Here is the result : <br/>
</div>
<!-- EDIT4 SECTION "Bloom with a glow map" [1530-3231] -->
<h1><a>Bloom with a glow color</a></h1>
<h1>Bloom with a glow color</h1>
<div>
<p>
Sometimes you need an entire object to glow, not just parts of it.
In this case you&#039;ll need to use the glow color parameter.
</p>
</div>
<h5><a>Usage</a></h5>
<h5>Usage</h5>
<div>
<ol>
<li><div> Create a material for your object and set the GlowColor parameter</div>
@ -178,33 +173,30 @@ Here is the result on Oto&#039;s plasma ball (before and after) : <br/>
</div>
<!-- EDIT5 SECTION "Bloom with a glow color" [3232-4239] -->
<h1><a>Hints and tricks</a></h1>
<h1>Hints and tricks</h1>
<div>
</div>
<h5><a>Increasing the blur range and reducing fps cost</a></h5>
<h5>Increasing the blur range and reducing fps cost</h5>
<div>
<p>
The glow render is sampled on a texture that has the same dimensions as the viewport.
You can reduce the size of the bloom sampling just by using the setDownSamplingFactor method like this : <br/>
</p>
<pre> BloomFilter bloom=new BloomFilter&#40;&#41;;
bloom.setDownSamplingFactor&#40;2.0f&#41;; </pre>
<p>
In this example the sampling size is divided by 4 (width/2,height/2), resulting in less work to blur the scene.
The resulting texture is then up sampled to the screen size using hardware bilinear filtering. this results in a wider blur range.
</p>
</div>
<h5><a>Using classic bloom combined with a glow map</a></h5>
<h5>Using classic bloom combined with a glow map</h5>
<div>
<p>
@ -219,11 +211,10 @@ However, note that both effects will share the same values of attribute, and som
</div>
<h5><a>Making your home brewed material definition support Glow</a></h5>
<h5>Making your home brewed material definition support Glow</h5>
<div>
<p>
Let&#039;s say you have made a custom material on your own, and that you want it to support glow maps and glow color.
In your material definition you need to add those lines in the MaterialParameters section :
</p>
@ -239,7 +230,6 @@ In your material definition you need to add those lines in the MaterialParameter
<p>
Then add the following technique :
</p>
<pre> Technique Glow {
@ -264,27 +254,23 @@ Then you can use this material with the BloomFilter
</div>
<h5><a>Make a glowing object stop to glow</a></h5>
<h5>Make a glowing object stop to glow</h5>
<div>
<p>
If you are using a glow map, remove the texture from the material.
</p>
<pre>material.clearTextureParam(&quot;GlowMap&quot;);</pre>
<p>
If you are using a glow color, set it to black
</p>
<pre>material.setColor(&quot;GlowColor&quot;,ColorRGBA.Black);</pre>
<div><span>
<a href="/wiki/doku.php/tag:documentation?do=showtag&amp;tag=tag%3Adocumentation">documentation</a>,
<a href="/wiki/doku.php/tag:effect?do=showtag&amp;tag=tag%3Aeffect">effect</a>,
<a href="/wiki/doku.php/tag:light?do=showtag&amp;tag=tag%3Alight">light</a>
</span></div>
<p>
<a href="nbdocs:/com/jme3/gde/docs/jme3:advanced/tag_documentation_effect_light">tag_documentation_effect_light</a>
</p>
</div>
<!-- EDIT6 SECTION "Hints and tricks" [4240-] -->
<p><em><a href="http://hub.jmonkeyengine.org/wiki/doku.php/jme3:advanced:bloom_and_glow?do=export_xhtmlbody">view online version</a></em></p>
<p><em><a href="http://wiki.jmonkeyengine.org/doku.php/jme3:advanced:bloom_and_glow?do=export_xhtmlbody">view online version</a></em></p>

@ -1,24 +1,22 @@
<h1><a>Multithreading Bullet Physics in jme3</a></h1>
<h1>Multithreading Bullet Physics in jme3</h1>
<div>
</div>
<!-- EDIT1 SECTION "Multithreading Bullet Physics in jme3" [1-53] -->
<h2><a>Introduction</a></h2>
<h2>Introduction</h2>
<div>
<p>
Since bullet is not (yet) multithreaded or GPU accelerated, the jME3 implementation allows to run each physics space on a separate thread that is executed in parallel to rendering.
</p>
</div>
<!-- EDIT2 SECTION "Introduction" [54-261] -->
<h2><a>How is it handled in jme3 and bullet?</a></h2>
<h2>How is it handled in jme3 and bullet?</h2>
<div>
<p>
A SimpleApplication with a BulletAppState allows setting the threading type via
</p>
<pre>setThreadingType(ThreadingType type);</pre>
@ -38,9 +36,11 @@ stateManager.attach&#40;bulletAppState&#41;;</pre>
Now the physics update happens in parallel to render(), that is, after the user&#039;s changes in the update() call have been applied. During update() the physics update loop pauses. This way the loop logic is still maintained: the user can set and change values in physics and scenegraph objects before render() and physicsUpdate() are called in parallel. This allows you to use physics methods in update() as if it was single-threaded.
</p>
<div><table>
<thead>
<tr>
<th>PARALLEL</th><th>SEQUENTIAL</th>
</tr>
</thead>
<tr>
<td>1. update(), 2. render() and physics update().</td><td>1. update(), 2. render(), 3. physics update(). </td>
</tr>
@ -50,16 +50,14 @@ Now the physics update happens in parallel to render(), that is, after the user&
</table></div>
<!-- EDIT4 TABLE [1202-1424] -->
<p>
<p><div>You can add more physics spaces by using multiple PARALLEL bulletAppStates. You would do that if you have sets physical objects that never collide (for example, underground bolders and flying cannon balls above ground), so you put those into separate physics spaces, which improves performances (less collisions to check!).
</div></p>
</p>
<div><span>
<a href="/wiki/doku.php/tag:documentation?do=showtag&amp;tag=tag%3Adocumentation">documentation</a>,
<a href="/wiki/doku.php/tag:physics?do=showtag&amp;tag=tag%3Aphysics">physics</a>,
<a href="/wiki/doku.php/tag:threading?do=showtag&amp;tag=tag%3Athreading">threading</a>
</span></div>
<p>
<a href="nbdocs:/com/jme3/gde/docs/jme3:advanced/tag_documentation_physics_threading">tag_documentation_physics_threading</a>
</p>
</div>
<!-- EDIT3 SECTION "How is it handled in jme3 and bullet?" [262-] -->
<p><em><a href="http://hub.jmonkeyengine.org/wiki/doku.php/jme3:advanced:bullet_multithreading?do=export_xhtmlbody">view online version</a></em></p>
<p><em><a href="http://wiki.jmonkeyengine.org/doku.php/jme3:advanced:bullet_multithreading?do=export_xhtmlbody">view online version</a></em></p>

Binary file not shown.

Before

Width:  |  Height:  |  Size: 10 KiB

After

Width:  |  Height:  |  Size: 94 KiB

@ -1,19 +1,17 @@
<h1><a>The jME3 Camera</a></h1>
<h1>The jME3 Camera</h1>
<div>
<p>
Note that by default, the mouse pointer is invisible, and the mouse is set up to control the camera rotation.
</p>
</div>
<!-- EDIT1 SECTION "The jME3 Camera" [1-142] -->
<h2><a>Default Camera</a></h2>
<h2>Default Camera</h2>
<div>
<p>
The default com.jme3.renderer.Camera object is <code>cam</code> in com.jme3.app.Application.
</p>
@ -25,7 +23,7 @@ The camera object is created with the following defaults:
</li>
<li><div> Frustum Perspective:</div>
<ul>
<li><div> Frame of view angle of 45?? along the Y axis</div>
<li><div> Frame of view angle of 45° along the Y axis</div>
</li>
<li><div> Aspect ratio of width divided by height</div>
</li>
@ -41,9 +39,11 @@ The camera object is created with the following defaults:
</li>
</ul>
<div><table>
<thead>
<tr>
<th>Method</th><th>Usage</th>
</tr>
</thead>
<tr>
<td>cam.getLocation(), setLocation()</td><td>The camera position</td>
</tr>
@ -94,20 +94,21 @@ The camera object is created with the following defaults:
</div>
<!-- EDIT2 SECTION "Default Camera" [143-2035] -->
<h2><a>FlyBy Camera</a></h2>
<h2>FlyBy Camera</h2>
<div>
<p>
The <code>flyCam</code> class field gives you access to an AppState that extends the default camera in <code>com.jme3.app.SimpleApplication</code> with more features. The input manager of the <code>com.jme3.input.FlyByCamera</code> AppState is preconfigured to respond to the WASD keys for walking forwards and backwards, and strafing to the sides; move the mouse to rotate the camera (&quot;Mouse Look&quot;), scroll the mouse wheel for zooming in or out. The QZ keys raise or lower the camera vertically.
The <code>flyCam</code> class field gives you access to an AppState that extends the default camera in <code>com.jme3.app.SimpleApplication</code> with more features. The input manager of the <code>com.jme3.input.FlyByCamera</code> AppState is preconfigured to respond to the WASD keys for walking forwards and backwards, and strafing to the sides; move the mouse to rotate the camera (“Mouse Look”), scroll the mouse wheel for zooming in or out. The QZ keys raise or lower the camera vertically.
</p>
<pre>Q W up forw
A S D --&gt; left back right
Z down </pre>
<div><table>
<thead>
<tr>
<th>Method</th><th>Usage</th>
</tr>
</thead>
<tr>
<td>flyCam.setEnabled(true);</td><td>Activate the flyby cam</td>
</tr>
@ -123,25 +124,25 @@ Z down </pre>
</table></div>
<!-- EDIT5 TABLE [2634-3016] -->
<p>
The FlyByCamera is active by default, but you can change all these defaults for your game.
</p>
</div>
<!-- EDIT4 SECTION "FlyBy Camera" [2036-3109] -->
<h2><a>Chase Camera</a></h2>
<h2>Chase Camera</h2>
<div>
<p>
jME3 also supports an optional Chase Cam that can follow a moving target Spatial (<code>com.jme3.input.ChaseCamera</code>). When you use the chase cam, the player clicks and hold the mouse button to rotate the camera around the camera target. You can use a chase cam if you need the mouse pointer visible in your game.
</p>
<pre>flyCam.setEnabled&#40;false&#41;;
ChaseCamera chaseCam = new ChaseCamera&#40;cam, target, inputManager&#41;;</pre>
<div><table>
<thead>
<tr>
<th>Method</th><th>Usage</th>
</tr>
</thead>
<tr>
<td>chaseCam.setSmoothMotion(true);</td><td>Interpolates a smoother acceleration/deceleration when the camera moves.</td>
</tr>
@ -176,11 +177,11 @@ ChaseCamera chaseCam = new ChaseCamera&#40;cam, target, inputManager&#41;;</pre>
<td>chaseCam.setDefaultHorizontalRotation(-FastMath.PI/2);</td><td>The default horizontal rotation angle of the camera around the target at the start of the application.</td>
</tr>
</table></div>
<!-- EDIT7 TABLE [3561-5033] --><div><span>
<a href="/wiki/doku.php/tag:camera?do=showtag&amp;tag=tag%3Acamera">camera</a>,
<a href="/wiki/doku.php/tag:documentation?do=showtag&amp;tag=tag%3Adocumentation">documentation</a>
</span></div>
<!-- EDIT7 TABLE [3561-5033] -->
<p>
<a href="nbdocs:/com/jme3/gde/docs/jme3:advanced/tag_camera_documentation">tag_camera_documentation</a>
</p>
</div>
<!-- EDIT6 SECTION "Chase Camera" [3110-] -->
<p><em><a href="http://hub.jmonkeyengine.org/wiki/doku.php/jme3:advanced:camera?do=export_xhtmlbody">view online version</a></em></p>
<p><em><a href="http://wiki.jmonkeyengine.org/doku.php/jme3:advanced:camera?do=export_xhtmlbody">view online version</a></em></p>

@ -1,9 +1,8 @@
<h1><a>Capture Audio/Video to a File</a></h1>
<h1>Capture Audio/Video to a File</h1>
<div>
<p>
So you&#039;ve made your cool new JMonkeyEngine3 game and you want to
create a demo video to show off your hard work. Or maybe you want to
make a cutscene for your game using the physics and characters in the
@ -22,11 +21,10 @@ feature to record high-quality game trailers!
</div>
<!-- EDIT1 SECTION "Capture Audio/Video to a File" [1-658] -->
<h2><a>Simple Way</a></h2>
<h2>Simple Way</h2>
<div>
<p>
First off, if all you need is to record video at 30fps with no sound, then look
no further than jMonkeyEngine 3&#039;s built in <code>VideoRecorderAppState</code>
class.
@ -55,15 +53,14 @@ That&#039;s all!
</div>
<!-- EDIT2 SECTION "Simple Way" [659-1362] -->
<h2><a>Advanced Way</a></h2>
<h2>Advanced Way</h2>
<div>
<p>
<p><div>This way of A/V recording is still in development.
It works for all of jMonkeyEngine&#039;s test cases.
If you experience any problems or
if something isn&#039;t clear, please <object classid="java:org.netbeans.modules.javahelp.BrowserDisplayer"><param name="content" value="http://jmonkeyengine.org/members/bortreb/"><param name="text" value="<html><u>let me know</u></html>"><param name="textColor" value="blue"></object>. ??? bortreb
if something isn&#039;t clear, please <object classid="java:org.netbeans.modules.javahelp.BrowserDisplayer"><param name="content" value="http://jmonkeyengine.org/members/bortreb/"><param name="text" value="<html><u>let me know</u></html>"><param name="textColor" value="blue"></object>. bortreb
</div></p>
</p>
@ -131,20 +128,20 @@ video frames to it will fail, and nothing will be written.
</p>
<p>
2.) If the filename ends in &quot;.avi&quot; then the frames will be encoded as
2.) If the filename ends in “.avi” then the frames will be encoded as
a RAW stream inside an AVI 1.0 container. The resulting file
will be quite large and you will probably want to re-encode it to
your preferred container/codec format. Be advised that some
video payers cannot process AVI with a RAW stream, and that AVI
1.0 files generated by this method that exceed 2.0GB are invalid
according to the AVI 1.0 <acronym title="specification">spec</acronym> (but many programs can still deal
according to the AVI 1.0 <abbr title="specification">spec</abbr> (but many programs can still deal
with them.) Thanks to
<object classid="java:org.netbeans.modules.javahelp.BrowserDisplayer"><param name="content" value="http://www.randelshofer.ch/blog/2008/08/writing-avi-videos-in-pure-java/"><param name="text" value="<html><u>Werner Randelshofer</u></html>"><param name="textColor" value="blue"></object>
for his excellent work which made the AVI file writer option possible.
</p>
<p>
3.) Any non-directory file ending in anything other than &quot;.avi&quot; will
3.) Any non-directory file ending in anything other than “.avi” will
be processed through Xuggle. Xuggle provides the option to use
many codecs/containers, but you will have to install it on your
system yourself in order to use this option. Please visit
@ -158,11 +155,10 @@ a file.
</div>
<!-- EDIT3 SECTION "Advanced Way" [1363-4555] -->
<h3><a>Basic Example</a></h3>
<h3>Basic Example</h3>
<div>
<p>
Here is a complete example showing how to capture both audio and video
from one of jMonkeyEngine3&#039;s advanced demo applications.
</p>
@ -186,9 +182,9 @@ import com.jme3.app.SimpleApplication;
&nbsp;
public class Basic &#123;
&nbsp;
public static void main&#40;String&#91;&#93; ignore&#41; throws IOException&#123;
File video = File.createTempFile&#40;&quot;JME-water-video&quot;, &quot;.avi&quot;&#41;;
File audio = File.createTempFile&#40;&quot;JME-water-audio&quot;, &quot;.wav&quot;&#41;;
public static void main&#40;IOException&#123;
File.createTempFile&#40;&quot;JME-water-video&quot;, &quot;.avi&quot;&#41;;
File.createTempFile&#40;&quot;JME-water-audio&quot;, &quot;.wav&quot;&#41;;
&nbsp;
SimpleApplication app = new TestPostWater&#40;&#41;;
app.setTimer&#40;new IsoTimer&#40;60&#41;&#41;;
@ -206,11 +202,10 @@ public class Basic &#123;
</div>
<!-- EDIT4 SECTION "Basic Example" [4556-5688] -->
<h3><a>How it works</a></h3>
<h3>How it works</h3>
<div>
<p>
A standard JME3 application that extends <code>SimpleApplication</code> or
<code>Application</code> tries as hard as it can to keep in sync with
<em>user-time</em>. If a ball is rolling at 1 game-mile per game-hour in the
@ -247,11 +242,10 @@ would be useless.
</div>
<!-- EDIT5 SECTION "How it works" [5689-7327] -->
<h3><a>Advanced Example</a></h3>
<h3>Advanced Example</h3>
<div>
<p>
The package from aurellem.com was made for AI research and can do more
than just record a single stream of audio and video. You can use it
to:
@ -584,49 +578,24 @@ public class Advanced extends SimpleApplication &#123;
&#125;</pre>
<p>
<!--[if !IE]> -->
<object class="media" width="400" height="350" type="application/x-shockwave-flash" data="/wiki/lib/exe/fetch.php?hash=568504&amp;media=http%3A%2F%2Fwww.youtube.com%2Fv%2FoCEfK0yhDrY%3F.swf" >
<!-- <![endif]-->
<!--[if IE]>
<object class="media" width="400" height="350" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" >
<param name="movie" value="/wiki/lib/exe/fetch.php?hash=568504&amp;media=http%3A%2F%2Fwww.youtube.com%2Fv%2FoCEfK0yhDrY%3F.swf" />
<!--><!-- -->
<param name="quality" value="high" />
The <object classid="java:org.netbeans.modules.javahelp.BrowserDisplayer"><param name="content" value="http://www.adobe.com/products/flashplayer/"><param name="text" value="<html><u>Adobe Flash Plugin</u></html>"><param name="textColor" value="blue"></object> is needed to display this content.
</object>
<!-- <![endif]-->
<a href="/lib/exe/fetch.php?tok=b1b225&amp;media=http%3A%2F%2Fwww.youtube.com%2Fv%2FoCEfK0yhDrY%3F.swf">oCEfK0yhDrY?.swf</a>
</p>
</div>
<!-- EDIT6 SECTION "Advanced Example" [7328-17233] -->
<h3><a>Using Advanced features to Record from more than one perspective at once</a></h3>
<h3>Using Advanced features to Record from more than one perspective at once</h3>
<div>
<p>
<!--[if !IE]> -->
<object class="media" width="400" height="350" type="application/x-shockwave-flash" data="/wiki/lib/exe/fetch.php?hash=6921c2&amp;media=http%3A%2F%2Fwww.youtube.com%2Fv%2FWIJt9aRGusc%3F.swf" >
<!-- <![endif]-->
<!--[if IE]>
<object class="media" width="400" height="350" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" >
<param name="movie" value="/wiki/lib/exe/fetch.php?hash=6921c2&amp;media=http%3A%2F%2Fwww.youtube.com%2Fv%2FWIJt9aRGusc%3F.swf" />
<!--><!-- -->
<param name="quality" value="high" />
The <object classid="java:org.netbeans.modules.javahelp.BrowserDisplayer"><param name="content" value="http://www.adobe.com/products/flashplayer/"><param name="text" value="<html><u>Adobe Flash Plugin</u></html>"><param name="textColor" value="blue"></object> is needed to display this content.
</object>
<!-- <![endif]-->
<a href="/lib/exe/fetch.php?tok=8afd69&amp;media=http%3A%2F%2Fwww.youtube.com%2Fv%2FWIJt9aRGusc%3F.swf">WIJt9aRGusc?.swf</a>
</p>
</div>
<!-- EDIT7 SECTION "Using Advanced features to Record from more than one perspective at once" [17234-17375] -->
<h2><a>More Information</a></h2>
<h2>More Information</h2>
<div>
<p>
This is the old page showing the first version of this idea
<object classid="java:org.netbeans.modules.javahelp.BrowserDisplayer"><param name="content" value="http://aurellem.org/cortex/html/capture-video.html"><param name="text" value="<html><u>http://aurellem.org/cortex/html/capture-video.html</u></html>"><param name="textColor" value="blue"></object>
</p>
@ -654,4 +623,4 @@ listeners can be found here.
</div>
<!-- EDIT8 SECTION "More Information" [17376-] -->
<p><em><a href="http://hub.jmonkeyengine.org/wiki/doku.php/jme3:advanced:capture_audio_video_to_a_file?do=export_xhtmlbody">view online version</a></em></p>
<p><em><a href="http://wiki.jmonkeyengine.org/doku.php/jme3:advanced:capture_audio_video_to_a_file?do=export_xhtmlbody">view online version</a></em></p>

@ -1,10 +1,9 @@
<h1><a>JME3 Cinematics</a></h1>
<h1>JME3 Cinematics</h1>
<div>
<p>
JME3 cinematics (com.jme.cinematic) allow you to remote control nodes and cameras in a 3D game: You can script and and play cinematic scenes. You can use cinematics to create <object classid="java:org.netbeans.modules.javahelp.BrowserDisplayer"><param name="content" value="http://en.wikipedia.org/wiki/Cutscene"><param name="text" value="<html><u>cutscenes</u></html>"><param name="textColor" value="blue"></object> and movies/trailers for your game. Another good use case is efficient &quot;destruction physics&quot;: Playing back prerecorded flying pieces of debris for demolitions is much faster than calculating them with live physics.
JME3 cinematics (com.jme.cinematic) allow you to remote control nodes and cameras in a 3D game: You can script and and play cinematic scenes. You can use cinematics to create <object classid="java:org.netbeans.modules.javahelp.BrowserDisplayer"><param name="content" value="http://en.wikipedia.org/wiki/Cutscene"><param name="text" value="<html><u>cutscenes</u></html>"><param name="textColor" value="blue"></object> and movies/trailers for your game. Another good use case is efficient “destruction physics”: Playing back prerecorded flying pieces of debris for demolitions is much faster than calculating them with live physics.
</p>
<p>
@ -29,7 +28,7 @@ This Node can be the rootNode, or a Node that is attached to the rootNode. </div
</div>
<!-- EDIT1 SECTION "JME3 Cinematics" [1-1103] -->
<h2><a>Sample Code</a></h2>
<h2>Sample Code</h2>
<div>
<ul>
<li><div> <object classid="java:org.netbeans.modules.javahelp.BrowserDisplayer"><param name="content" value="http://code.google.com/p/jmonkeyengine/source/browse/trunk/engine/src/test/jme3test/animation/TestCinematic.java"><param name="text" value="<html><u>TestCinematic.java</u></html>"><param name="textColor" value="blue"></object></div>
@ -38,11 +37,10 @@ This Node can be the rootNode, or a Node that is attached to the rootNode. </div
</div>
<!-- EDIT2 SECTION "Sample Code" [1104-1270] -->
<h2><a>How to Use a Cinematic</a></h2>
<h2>How to Use a Cinematic</h2>
<div>
<p>
A Cinematic is like a movie script for a node.
</p>
<pre>Cinematic cinematic = new Cinematic&#40;sceneNode, duration&#41;;
@ -76,9 +74,11 @@ stateManager.attach&#40;cinematic&#41;;</pre>
</li>
</ol>
<div><table>
<thead>
<tr>
<th>Method</th><th>Usage</th>
</tr>
</thead>
<tr>
<td>cinematic.play()</td><td>Starts playing the cinematic from the start, or from where it was paused.</td>
</tr>
@ -92,22 +92,22 @@ stateManager.attach&#40;cinematic&#41;;</pre>
<!-- EDIT4 TABLE [2362-2574] -->
</div>
<!-- EDIT3 SECTION "How to Use a Cinematic" [1271-2574] -->
<h2><a>Events(CinematicEvents)</a></h2>
<h2>Events(CinematicEvents)</h2>
<div>
<p>
Just like a movie script consists of lines with instructions to the actors, each Cinematic consists of a series of events.
</p>
<p>
Here is the list of available CinematicEvents that you use as events. Each track remote-controls scene objects in a different way:
</p>
<div><table>
<thead>
<tr>
<th>Events(CinematicEvents)</th><th>Description</th>
</tr>
</thead>
<tr>
<td>MotionEvent</td><td>Use a MotionEvent to move a Spatial non-linearly over time. A MotionEvent is based on a list of waypoints in a MotionPath. The curve goes through each waypoint, and you can adjust the tension of the curve to modify the roundedness of the path. This is the motion interpolation you are going to use in most cases. </td>
</tr>
@ -115,7 +115,7 @@ Here is the list of available CinematicEvents that you use as events. Each track
<td>SoundEvent</td><td>Use a SoundEvent to play a <a href="/com/jme3/gde/docs/jme3/advanced/audio.html">sound</a> at a given time for the given duration.</td>
</tr>
<tr>
<td>GuiEvent</td><td>Displays a <a href="/com/jme3/gde/docs/jme3/advanced/nifty_gui.html">Nifty GUI</a> at a given time for the given duration. Use it to display subtitles or HUD elements. Bind the Nifty <acronym title="Graphical User Interface">GUI</acronym> <acronym title="Extensible Markup Language">XML</acronym> to the cinematic using <code>cinematic.bindUi(&quot;path/to/nifty/file.xml&quot;);</code></td>
<td>GuiEvent</td><td>Displays a <a href="/com/jme3/gde/docs/jme3/advanced/nifty_gui.html">Nifty GUI</a> at a given time for the given duration. Use it to display subtitles or HUD elements. Bind the Nifty <abbr title="Graphical User Interface">GUI</abbr> XML to the cinematic using <code>cinematic.bindUi(“path/to/nifty/file.xml”);</code></td>
</tr>
<tr>
<td>AnimationEvent</td><td>Use this to start playing a model <a href="/com/jme3/gde/docs/jme3/advanced/animation.html">animation</a> at a given time (a character walking animation for example)</td>
@ -123,20 +123,16 @@ Here is the list of available CinematicEvents that you use as events. Each track
</table></div>
<!-- EDIT6 TABLE [2868-3669] -->
<p>
Of course one can make is own event implementation, by extending the AbstractCinematicEvent.
You can add custom events by extending AbstractCinematicEvent.
</p>
</div>
<!-- EDIT5 SECTION "Events(CinematicEvents)" [2575-3763] -->
<h3><a>MotionEvent</a></h3>
<!-- EDIT5 SECTION "Events(CinematicEvents)" [2575-3733] -->
<h3>MotionEvent</h3>
<div>
<p>
A MotionEvent moves a Spatial along a complex path.
</p>
<pre>MotionEvent events= new MotionEvent &#40;thingNode, path&#41;;</pre>
@ -151,7 +147,6 @@ Details of the constructor:
</ul>
<p>
To create a MotionEvent, do the following:
</p>
<ol>
@ -165,9 +160,11 @@ To create a MotionEvent, do the following:
</li>
</ol>
<div><table>
<thead>
<tr>
<th>MotionEvent configuration method</th><th>Usage</th>
</tr>
</thead>
<tr>
<td>event.setLoopMode(LoopMode.Loop)</td><td>Sets whether the animation along this path should loop (LoopMode.Loop) or play only once (LoopMode.DontLoop).</td>
</tr>
@ -193,30 +190,26 @@ To create a MotionEvent, do the following:
<td>event.setRotation(quaternion)</td><td>Sets the rotation. Use together with <code>MotionEvent.Direction.Rotation</code> or <code>MotionEvent.Direction.PathAndRotation</code>.</td>
</tr>
</table></div>
<!-- EDIT8 TABLE [4249-5658] -->
<!-- EDIT8 TABLE [4219-5628] -->
<p>
<strong>Tip:</strong> Most likely you remote-control more than one object in your scene. Give the events and paths useful names such as <code>dragonEvent</code>, <code>dragonPath</code>, <code>heroEvent</code>, <code>heroPath</code>, etc.
</p>
</div>
<!-- EDIT7 SECTION "MotionEvent" [3764-5853] -->
<h3><a>SoundEvent</a></h3>
<!-- EDIT7 SECTION "MotionEvent" [3734-5823] -->
<h3>SoundEvent</h3>
<div>
<p>
A SoundEventplays a sound as part of the cinematic.
</p>
<pre>SoundEvent&#40; audioPath, isStream, duration, loopMode &#41;</pre>
<p>
Details of the constructor:
</p>
<ul>
<li><div> <code>audioPath</code> is the path to an audio file as String, e.g. &quot;Sounds/mySound.wav&quot;.</div>
<li><div> <code>audioPath</code> is the path to an audio file as String, e.g. “Sounds/mySound.wav”.</div>
</li>
<li><div> <code>isStream</code> toggles between streaming and buffering. Set to true to stream long audio file, set to false to play short buffered sounds.</div>
</li>
@ -227,21 +220,17 @@ Details of the constructor:
</ul>
</div>
<!-- EDIT9 SECTION "SoundEvent" [5854-6384] -->
<h3><a>GuiEvent</a></h3>
<!-- EDIT9 SECTION "SoundEvent" [5824-6354] -->
<h3>GuiEvent</h3>
<div>
<p>
A GuiEventshows or hide a NiftyGUI as part of a cinematic.
</p>
<pre>GuiEvent&#40; screen, duration, loopMode &#41;</pre>
<p>
You must use this together with bindUI() to specify the Nifty <acronym title="Graphical User Interface">GUI</acronym> <acronym title="Extensible Markup Language">XML</acronym> file that you want to load:
You must use this together with bindUI() to specify the Nifty <abbr title="Graphical User Interface">GUI</abbr> XML file that you want to load:
</p>
<pre>cinematic.bindUi&#40;&quot;Interface/subtitle.xml&quot;&#41;;</pre>
@ -249,7 +238,7 @@ You must use this together with bindUI() to specify the Nifty <acronym title="Gr
Details of the constructor:
</p>
<ul>
<li><div> <code>screen</code> is the name of the Nifty <acronym title="Graphical User Interface">GUI</acronym> screen to load, as String. </div>
<li><div> <code>screen</code> is the name of the Nifty <abbr title="Graphical User Interface">GUI</abbr> screen to load, as String. </div>
</li>
<li><div> <code>duration</code> is the time that it should take to play.</div>
</li>
@ -258,19 +247,16 @@ Details of the constructor:
</ul>
</div>
<!-- EDIT10 SECTION "GuiEvent" [6385-6912] -->
<h3><a>AnimationEvent</a></h3>
<!-- EDIT10 SECTION "GuiEvent" [6355-6882] -->
<h3>AnimationEvent</h3>
<div>
<p>
An AnimationEvent triggers an animation as part of a cinematic.
</p>
<pre>AnimationEvent&#40; thingNode, animationName, duration, loopMode &#41;</pre>
<p>
Details of the constructor:
</p>
<ul>
@ -285,26 +271,22 @@ Details of the constructor:
</ul>
</div>
<!-- EDIT11 SECTION "AnimationEvent" [6913-7425] -->
<h3><a>Camera Management</a></h3>
<!-- EDIT11 SECTION "AnimationEvent" [6883-7395] -->
<h3>Camera Management</h3>
<div>
<p>
There is a built in system for camera switching in Cinematics. It based on CameraNode, and the cinematic just enable the given CameraNode control at a given time.
</p>
<p>
First you have to bind a camera to the cinematic with a unique name. You&#039;ll be provided with a CameraNode
</p>
<pre> CameraNode camNode = cinematic.bindCamera&#40;&quot;topView&quot;, cam&#41;;</pre>
<p>
then you can do whatever you want with this camera node : place it so that you have a the camera angle you&#039;d like, attach it to a motion event to have some camera scrolling, attach control of your own that give it whatever behavior you&#039;d like.
In the above example, I want it to be a top view of the scene looking at the world origin.
</p>
<pre> //set its position
camNode.setLocalTranslation&#40;new Vector3f&#40;0, 50, 0&#41;&#41;;
@ -313,32 +295,30 @@ In the above example, I want it to be a top view of the scene looking at the wor
<p>
Then i just have to schedule its activation in the cinematic. I want it to get activated 3 seconds after the start of the cinematic so I just have to do
</p>
<pre> cinematic.activateCamera&#40;3,???topView???&#41;;</pre>
<pre> cinematic.activateCamera&#40;3,”topView”&#41;;</pre>
</div>
<!-- EDIT12 SECTION "Camera Management" [7426-8538] -->
<h3><a>Customizations</a></h3>
<!-- EDIT12 SECTION "Camera Management" [7396-8508] -->
<h3>Customizations</h3>
<div>
<p>
You can extend individual CinematicEvents. The <object classid="java:org.netbeans.modules.javahelp.BrowserDisplayer"><param name="content" value="http://code.google.com/p/jmonkeyengine/source/browse/trunk/engine/src/test/jme3test/animation/SubtitleTrack.java"><param name="text" value="<html><u>SubtitleTrack.java example</u></html>"><param name="textColor" value="blue"></object> shows how to extend a GuiTrack to script subtitles. See how the subtitles are used in the <object classid="java:org.netbeans.modules.javahelp.BrowserDisplayer"><param name="content" value="http://code.google.com/p/jmonkeyengine/source/browse/trunk/engine/src/test/jme3test/animation/TestCinematic.java"><param name="text" value="<html><u>TestCinematic.java example</u></html>"><param name="textColor" value="blue"></object>.
</p>
<p>
You can also create new CinematicEvent by extending <object classid="java:org.netbeans.modules.javahelp.BrowserDisplayer"><param name="content" value="http://code.google.com/p/jmonkeyengine/source/browse/trunk/engine/src/core/com/jme3/cinematic/events/AbstractCinematicEvent.java"><param name="text" value="<html><u>AbstractCinematicEvent</u></html>"><param name="textColor" value="blue"></object>. An AbstractCinematicEvent implements the CinematicEvent interface and provides duration, time, speed, etc??? management. Look at the <object classid="java:org.netbeans.modules.javahelp.BrowserDisplayer"><param name="content" value="http://code.google.com/p/jmonkeyengine/source/browse/trunk/engine/src/test/jme3test/animation/TestCinematic.java"><param name="text" value="<html><u>TestCinematic.java example</u></html>"><param name="textColor" value="blue"></object> is to use this for a custom fadeIn/fadeOut effect in combination with a com.jme3.post.filters.FadeFilter.
You can also create new CinematicEvent by extending <object classid="java:org.netbeans.modules.javahelp.BrowserDisplayer"><param name="content" value="http://code.google.com/p/jmonkeyengine/source/browse/trunk/engine/src/core/com/jme3/cinematic/events/AbstractCinematicEvent.java"><param name="text" value="<html><u>AbstractCinematicEvent</u></html>"><param name="textColor" value="blue"></object>. An AbstractCinematicEvent implements the CinematicEvent interface and provides duration, time, speed, etc management. Look at the <object classid="java:org.netbeans.modules.javahelp.BrowserDisplayer"><param name="content" value="http://code.google.com/p/jmonkeyengine/source/browse/trunk/engine/src/test/jme3test/animation/TestCinematic.java"><param name="text" value="<html><u>TestCinematic.java example</u></html>"><param name="textColor" value="blue"></object> is to use this for a custom fadeIn/fadeOut effect in combination with a com.jme3.post.filters.FadeFilter.
</p>
</div>
<!-- EDIT13 SECTION "Customizations" [8539-9584] -->
<h2><a>Interacting with Cinematics</a></h2>
<!-- EDIT13 SECTION "Customizations" [8509-9554] -->
<h2>Interacting with Cinematics</h2>
<div>
</div>
<!-- EDIT14 SECTION "Interacting with Cinematics" [9585-9625] -->
<h3><a>CinematicEventListener</a></h3>
<!-- EDIT14 SECTION "Interacting with Cinematics" [9555-9595] -->
<h3>CinematicEventListener</h3>
<div>
<pre>CinematicEventListener cel = new CinematicEventListener&#40;&#41; &#123;
public void onPlay&#40;CinematicEvent cinematic&#41; &#123;
@ -359,15 +339,14 @@ You can also create new CinematicEvent by extending <object classid="java:org.ne
cinematic.addListener&#40;cel&#41;;</pre>
</div>
<!-- EDIT15 SECTION "CinematicEventListener" [9626-10121] -->
<h3><a>Physics Interaction</a></h3>
<!-- EDIT15 SECTION "CinematicEventListener" [9596-10091] -->
<h3>Physics Interaction</h3>
<div>
<p>
Upcoming.
</p>
</div>
<!-- EDIT16 SECTION "Physics Interaction" [10122-] -->
<p><em><a href="http://hub.jmonkeyengine.org/wiki/doku.php/jme3:advanced:cinematics?do=export_xhtmlbody">view online version</a></em></p>
<!-- EDIT16 SECTION "Physics Interaction" [10092-] -->
<p><em><a href="http://wiki.jmonkeyengine.org/doku.php/jme3:advanced:cinematics?do=export_xhtmlbody">view online version</a></em></p>

@ -1,9 +1,8 @@
<h1><a>Collision and Intersection</a></h1>
<h1>Collision and Intersection</h1>
<div>
<p>
The term collision can be used to refer to <a href="/com/jme3/gde/docs/jme3/advanced/physics_listeners.html">physical interactions</a> (where <a href="/com/jme3/gde/docs/jme3/advanced/physics.html">physical objects</a> collide, push and bump off one another), and also to non-physical <em>intersections</em> in 3D space. This article is about the non-physical (mathematical) collisions.
</p>
@ -12,16 +11,15 @@ Non-physical collision detection is interesting because it uses less computing r
</p>
<p>
<strong>Example:</strong> One example for an optimization is a physical vehicle&#039;s wheels. You could make the wheels fully physical disks, and have jME calculate every tiny force ??? sounds very accurate? It&#039;s total overkill and too slow for a racing game. A more performant solution is to cast four invisible rays down from the vehicle and calculate the intersections with the floor. These non-physical wheels require (in the simplest case) only four calculations per tick to achieve an effect that players can hardly distinguish from the real thing.
<strong>Example:</strong> One example for an optimization is a physical vehicle&#039;s wheels. You could make the wheels fully physical disks, and have jME calculate every tiny force sounds very accurate? It&#039;s total overkill and too slow for a racing game. A more performant solution is to cast four invisible rays down from the vehicle and calculate the intersections with the floor. These non-physical wheels require (in the simplest case) only four calculations per tick to achieve an effect that players can hardly distinguish from the real thing.
</p>
</div>
<!-- EDIT1 SECTION "Collision and Intersection" [1-1432] -->
<h2><a>Collidable</a></h2>
<h2>Collidable</h2>
<div>
<p>
The interface com.jme3.collision.Collidable declares one method that returns how many collisions were found between two Collidables: <code>collideWith(Collidable other, CollisionResults results)</code>.
</p>
<ul>
@ -32,9 +30,11 @@ Note that jME counts <em>all</em> collisions, this means a ray intersecting a bo
</li>
</ul>
<div><table>
<thead>
<tr>
<th>CollisionResults Method</th><th>Usage</th>
</tr>
</thead>
<tr>
<td>size() </td><td>Returns the number of CollisionResult objects.</td>
</tr>
@ -53,9 +53,11 @@ Note that jME counts <em>all</em> collisions, this means a ray intersecting a bo
A CollisionResult object contains information about the second party of the collision event.
</p>
<div><table>
<thead>
<tr>
<th>CollisionResult Method</th><th>Usage</th>
</tr>
</thead>
<tr>
<td>getContactPoint()</td><td>Returns the contact point coordinate on the second party, as Vector3f.</td>
</tr>
@ -78,11 +80,10 @@ A CollisionResult object contains information about the second party of the coll
<!-- EDIT4 TABLE [2497-3030] -->
</div>
<!-- EDIT2 SECTION "Collidable" [1433-3031] -->
<h3><a>Code Sample</a></h3>
<h3>Code Sample</h3>
<div>
<p>
Assume you have two collidables a and b and want to detect collisions between them. The collision parties can be Geometries, Nodes with Geometries attached (including the rootNode), Planes, Quads, Lines, or Rays. An important restriction is that you can only collide geometry vs bounding volumes or rays. (This means for example that a must be of Type Node or Geometry and b respectively of Type BoundingBox, BoundingSphere or Ray.)
</p>
@ -129,16 +130,14 @@ You can also loop over all results and trigger different reactions depending on
<p>
Knowing the distance of the collisions is useful for example when you intersect Lines and Rays with other objects.
</p>
</div>
<!-- EDIT5 SECTION "Code Sample" [3032-5570] -->
<h2><a>Bounding Volumes</a></h2>
<h2>Bounding Volumes</h2>
<div>
<p>
A <code>com.jme3.bounding.BoundingVolume</code> is an interface for dealing with containment of a collection of points. All BoundingVolumes are <code>Collidable</code> and are used as optimization to calculate non-physical collisions more quickly: It&#039;s always faster to calculate an intersection between simple shapes like spheres and boxes than between complex shapes like models.
</p>
@ -147,12 +146,12 @@ jME3 computes bounding volumes for all objects. These bounding volumes are later
</p>
<p>
All fast-paced action and shooter games use BoundingVolumes as an optimization. Wrap all complex models into simpler shapes ??? in the end, you get equally useful collision detection results, but faster. <object classid="java:org.netbeans.modules.javahelp.BrowserDisplayer"><param name="content" value="http://en.wikipedia.org/wiki/Bounding_volume"><param name="text" value="<html><u>More about bounding volumes...</u></html>"><param name="textColor" value="blue"></object>
All fast-paced action and shooter games use BoundingVolumes as an optimization. Wrap all complex models into simpler shapes in the end, you get equally useful collision detection results, but faster. <object classid="java:org.netbeans.modules.javahelp.BrowserDisplayer"><param name="content" value="http://en.wikipedia.org/wiki/Bounding_volume"><param name="text" value="<html><u>More about bounding volumes...</u></html>"><param name="textColor" value="blue"></object>
</p>
<p>
Supported types:
<img src="/wiki/lib/exe/fetch.php">
<img src="/lib/exe/fetch.php">
</p>
<ul>
<li><div> Type.AABB = Axis-aligned bounding box, that means it doesn&#039;t rotate, which makes it less precise. A <code>com.jme3.bounding.BoundingBox</code> is an axis-aligned cuboid used as a container for a group of vertices of a piece of geometry. A BoundingBox has a center and extents from that center along the x, y and z axis. This is the default bounding volume, since it is fairly fast to generate and gives better accuracy than the bounding sphere.</div>
@ -161,52 +160,46 @@ Supported types:
</li>
<li><div> Type.OBB = Oriented bounding box. This bounding box is more precise because it can rotate with its content, but is computationally more expensive. (Currently not supported.)</div>
</li>
<li><div> Type.Capsule = Cylinder with rounded ends, also called &quot;swept sphere&quot;. Typically used for mobile characters. (Currently not supported.)</div>
<li><div> Type.Capsule = Cylinder with rounded ends, also called “swept sphere”. Typically used for mobile characters. (Currently not supported.)</div>
</li>
</ul>
<p>
<p><div>Note: If you are looking for bounding volumes for physical objects, use <a href="/com/jme3/gde/docs/jme3/advanced/physics.html">CollisionShapes</a>.
</div></p>
</p>
</div>
<!-- EDIT6 SECTION "Bounding Volumes" [5571-7614] -->
<h3><a>Usage</a></h3>
<h3>Usage</h3>
<div>
<p>
For example you can use Bounding Volumes on custom meshes, or complex non-physical shapes.
</p>
<pre>mesh.setBound&#40;new BoundingSphere&#40;&#41;&#41;;
mesh.updateBound&#40;&#41;;</pre>
</div>
<!-- EDIT7 SECTION "Usage" [7615-7796] -->
<h2><a>Mesh and Scene Graph Collision</a></h2>
<h2>Mesh and Scene Graph Collision</h2>
<div>
<p>
One of the supported <code>Collidable</code>s are meshes and scene graph objects. To execute a collision detection query against a scene graph, use <code>Spatial.collideWith()</code>. This will traverse the scene graph and return any mesh collisions that were detected. Note that the first collision against a particular scene graph may take a long time, this is because a special data structure called <object classid="java:org.netbeans.modules.javahelp.BrowserDisplayer"><param name="content" value="http://en.wikipedia.org/wiki/Bounding_interval_hierarchy"><param name="text" value="<html><u>|Bounding Interval Hierarchy (BIH)</u></html>"><param name="textColor" value="blue"></object> needs to be generated for the meshes. At a later point, the mesh could change and the BIH tree would become out of date, in that case, call <object classid="java:org.netbeans.modules.javahelp.BrowserDisplayer"><param name="content" value="http://jmonkeyengine.org/javadoc/com/jme3/scene/Mesh.html#createCollisionData()"><param name="text" value="<html><u>Mesh.createCollisionData()</u></html>"><param name="textColor" value="blue"></object> on the changed mesh to update the BIH tree.
</p>
</div>
<!-- EDIT8 SECTION "Mesh and Scene Graph Collision" [7797-8617] -->
<h2><a>Intersection</a></h2>
<h2>Intersection</h2>
<div>
<p>
A <code>com.jme3.math.Ray</code> is an infinite line with a beginning, a direction, and no end; whereas a <code>com.jme3.math.Line</code> is an infinite line with only a direction (no beginning, no end).
</p>
<p>
Rays are used to perform line-of-sight calculations. This means you can detect what users were &quot;aiming at&quot; when they clicked or pressed a key. You can also use this to detect whether game characters can see something (or someone) or not.
Rays are used to perform line-of-sight calculations. This means you can detect what users were “aiming at” when they clicked or pressed a key. You can also use this to detect whether game characters can see something (or someone) or not.
</p>
<ul>
<li><div> <strong>Click to select:</strong> You can determine what a user has clicked by casting a ray from the camera forward in the direction of the camera. Now identify the closest collision of the ray with the rootNode, and you have the clicked object.</div>
@ -216,8 +209,7 @@ Rays are used to perform line-of-sight calculations. This means you can detect w
</ul>
<p>
<p><div>These simple but powerful ray-surface intersection tests are called Ray Casting. As opposed to the more advanced Ray Tracing technique, Ray Casting does not follow the ray&#039;s reflection after the first hit ??? the ray just goes straight on.
<p><div>These simple but powerful ray-surface intersection tests are called Ray Casting. As opposed to the more advanced Ray Tracing technique, Ray Casting does not follow the ray&#039;s reflection after the first hit – the ray just goes straight on.
</div></p>
</p>
@ -238,4 +230,4 @@ TODO:
</div>
<!-- EDIT9 SECTION "Intersection" [8618-] -->
<p><em><a href="http://hub.jmonkeyengine.org/wiki/doku.php/jme3:advanced:collision_and_intersection?do=export_xhtmlbody">view online version</a></em></p>
<p><em><a href="http://wiki.jmonkeyengine.org/doku.php/jme3:advanced:collision_and_intersection?do=export_xhtmlbody">view online version</a></em></p>

@ -1,5 +1,5 @@
<h1><a>Combo Moves</a></h1>
<h1>Combo Moves</h1>
<div>
<p>
@ -7,7 +7,7 @@ The ComboMoves class allows you to define combinations of inputs that trigger sp
</p>
<p>
Combos are usually a series of inputs, in a fixed order: For example a keyboard combo can look like: &quot;press Down, then Down+Right together, then Right&quot;.
Combos are usually a series of inputs, in a fixed order: For example a keyboard combo can look like: “press Down, then Down+Right together, then Right”.
</p>
<p>
@ -25,30 +25,28 @@ Usage:
</ol>
<p>
Copy the two classes ComboMoveExecution.java and ComboMove.java into your application and adjust them to your package paths.
</p>
</div>
<!-- EDIT1 SECTION "Combo Moves" [1-824] -->
<h2><a>Example Code</a></h2>
<h2>Example Code</h2>
<div>
<ul>
<li><div> <object classid="java:org.netbeans.modules.javahelp.BrowserDisplayer"><param name="content" value="http://code.google.com/p/jmonkeyengine/source/browse/trunk/engine/src/test/jme3test/input/combomoves/TestComboMoves.java"><param name="text" value="<html><u>TestComboMoves.java</u></html>"><param name="textColor" value="blue"></object></div>
</li>
<li><div> <object classid="java:org.netbeans.modules.javahelp.BrowserDisplayer"><param name="content" value="http://code.google.com/p/jmonkeyengine/source/browse/trunk/engine/src/test/jme3test/input/combomoves/ComboMoveExecution.java"><param name="text" value="<html><u>ComboMoveExecution.java</u></html>"><param name="textColor" value="blue"></object> ??? required</div>
<li><div> <object classid="java:org.netbeans.modules.javahelp.BrowserDisplayer"><param name="content" value="http://code.google.com/p/jmonkeyengine/source/browse/trunk/engine/src/test/jme3test/input/combomoves/ComboMoveExecution.java"><param name="text" value="<html><u>ComboMoveExecution.java</u></html>"><param name="textColor" value="blue"></object> required</div>
</li>
<li><div> <object classid="java:org.netbeans.modules.javahelp.BrowserDisplayer"><param name="content" value="http://code.google.com/p/jmonkeyengine/source/browse/trunk/engine/src/test/jme3test/input/combomoves/ComboMove.java"><param name="text" value="<html><u>ComboMove.java</u></html>"><param name="textColor" value="blue"></object> ??? required</div>
<li><div> <object classid="java:org.netbeans.modules.javahelp.BrowserDisplayer"><param name="content" value="http://code.google.com/p/jmonkeyengine/source/browse/trunk/engine/src/test/jme3test/input/combomoves/ComboMove.java"><param name="text" value="<html><u>ComboMove.java</u></html>"><param name="textColor" value="blue"></object> required</div>
</li>
</ul>
</div>
<!-- EDIT2 SECTION "Example Code" [825-1321] -->
<h2><a>Create Input Triggers</a></h2>
<h2>Create Input Triggers</h2>
<div>
<p>
First you <a href="/com/jme3/gde/docs/jme3/advanced/input_handling.html">define your game&#039;s inputs</a> as you usually do: Implement the com.jme3.input.controls.ActionListener interface for your class, and add triggers mappings such as com.jme3.input.controls.KeyTrigger and com.jme3.input.KeyInput.
</p>
@ -65,16 +63,15 @@ inputManager.addListener&#40;this, &quot;Left&quot;, &quot;Right&quot;, &quot;Up
</div>
<!-- EDIT3 SECTION "Create Input Triggers" [1322-2092] -->
<h2><a>Define Combos</a></h2>
<h2>Define Combos</h2>
<div>
<p>
For each of your combo moves, you specify the series of inputs that will trigger it. The order in which you define them is the order the player has to press them for the step to be recorded. When all steps have been recorded, the combo is triggered.
</p>
<p>
The following example shows how a fireball combo move is triggered by pressing the navigation keys for &quot;down, down+right, right&quot;, in this order.
The following example shows how a fireball combo move is triggered by pressing the navigation keys for “down, down+right, right”, in this order.
</p>
<pre>ComboMove fireball = new ComboMove&#40;&quot;Fireball&quot;&#41;;
fireball.press&#40;&quot;Down&quot;&#41;.notPress&#40;&quot;Right&quot;&#41;.done&#40;&#41;;
@ -90,37 +87,37 @@ Also create a ComboMoveExecution object for each ComboMove. You need it later to
</div>
<!-- EDIT4 SECTION "Define Combos" [2093-3001] -->
<h3><a>ComboMove Class Methods</a></h3>
<h3>ComboMove Class Methods</h3>
<div>
<p>
Use the following ComboMove methods to specify the combo:
</p>
<div><table>
<thead>
<tr>
<th>ComboMove Method</th><th>Description</th>
</tr>
</thead>
<tr>
<td>press(&quot;A&quot;).done(); <br/>
press(&quot;A&quot;,&quot;B&quot;).done();</td><td>Combo step is recorded if A is entered. <br/>
<td>press(“A”).done(); <br/>
press(“A”,“B”).done();</td><td>Combo step is recorded if A is entered. <br/>
Combo step is recorded if A and B are entered simultaneously.</td>
</tr>
<tr>
<td>notPress(&quot;A&quot;).done(); <br/>
notPress(&quot;A&quot;,&quot;B&quot;).done();</td><td>Combo step is recorded if A is released. <br/>
<td>notPress(“A”).done(); <br/>
notPress(“A”,“B”).done();</td><td>Combo step is recorded if A is released. <br/>
Combo step is recorded if A and B are both released.</td>
</tr>
<tr>
<td>press(&quot;A&quot;).notPress(&quot;B&quot;).done();</td><td>Combo step is recorded if A is entered, and not B</td>
<td>press(“A”).notPress(“B”).done();</td><td>Combo step is recorded if A is entered, and not B</td>
</tr>
<tr>
<td>press(&quot;A&quot;).notPress(&quot;B&quot;).timeElapsed(0.11f).done();</td><td>Combo step is recorded a certain time after A and not B is entered. <br/>
etc, etc ???</td>
<td>press(“A”).notPress(“B”).timeElapsed(0.11f).done();</td><td>Combo step is recorded a certain time after A and not B is entered. <br/>
etc, etc </td>
</tr>
<tr>
<td>setPriority(0.5f);</td><td>If there is an ambiguity, a high-priority combo will trigger instead of a low-priority combo. This prevents that a similar looking combo step &quot;hijacks&quot; another Combo. Use only once per ComboMove.</td>
<td>setPriority(0.5f);</td><td>If there is an ambiguity, a high-priority combo will trigger instead of a low-priority combo. This prevents that a similar looking combo step “hijacks” another Combo. Use only once per ComboMove.</td>
</tr>
<tr>
<td>setUseFinalState(false); <br/>
@ -131,18 +128,18 @@ True: This is the final state, do not chain combo steps. (?)</td>
</table></div>
<!-- EDIT6 TABLE [3096-4090] -->
<p>
The <code>press()</code> and <code>notPress()</code> methods accept sets of Input Triggers, e.g. <code>fireball.press(&quot;A&quot;,&quot;B&quot;,&quot;C&quot;).done()</code>.
The <code>press()</code> and <code>notPress()</code> methods accept sets of Input Triggers, e.g. <code>fireball.press(“A”,“B”,“C”).done()</code>.
</p>
<p>
The following getters give you more information about the game state:
</p>
<div><table>
<thead>
<tr>
<th>ComboMove Method</th><th>Usage</th>
</tr>
</thead>
<tr>
<td>getCastTime()</td><td>Returns the time since the last step has been recorded. (?)</td>
</tr>
@ -156,11 +153,10 @@ The following getters give you more information about the game state:
<!-- EDIT7 TABLE [4283-4489] -->
</div>
<!-- EDIT5 SECTION "ComboMove Class Methods" [3002-4490] -->
<h2><a>Detect Combos in ActionListener</a></h2>
<h2>Detect Combos in ActionListener</h2>
<div>
<p>
Now that you have specified the combo steps, you want to detect them. You do that in the onAction() method that you get from the ActionListener interface.
</p>
@ -215,11 +211,10 @@ public void onAction&#40;String name, boolean isPressed, float tpf&#41; &#123;
</div>
<!-- EDIT8 SECTION "Detect Combos in ActionListener" [4491-6314] -->
<h2><a>Execute Combos in the Update Loop</a></h2>
<h2>Execute Combos in the Update Loop</h2>
<div>
<p>
Now that you have detected the current move, you want to execute it. You do that in the update loop.
</p>
<pre>@Override
@ -245,26 +240,23 @@ Test <code>currentMove.getMoveName()</code> and proceed to call methods that imp
</div>
<!-- EDIT9 SECTION "Execute Combos in the Update Loop" [6315-7152] -->
<h2><a>Why Combos?</a></h2>
<h2>Why Combos?</h2>
<div>
<p>
Depending on the game genre, the designer can reward the players&#039; intrinsical or extrinsical skills:
</p>
<ul>
<li><div> (intrinsical:) RPGs typically calculate the success of an attack from the character&#039;s in-game training level: The player plays the role of a character whose skill level is defined in numbers. RPGs typically do not offer any Combos.</div>
</li>
<li><div> (extrinsical:) Sport and fighter games typically choose to reward the player&#039;s &quot;manual&quot; skills: The success of a special move solely depends on the player&#039;s own dexterity. These games typically offer optional Combos.</div>
<li><div> (extrinsical:) Sport and fighter games typically choose to reward the player&#039;s “manual” skills: The success of a special move solely depends on the player&#039;s own dexterity. These games typically offer optional Combos.</div>
</li>
</ul>
<div><span>
<a href="/wiki/doku.php/tag:keyinput?do=showtag&amp;tag=tag%3Akeyinput">keyinput</a>,
<a href="/wiki/doku.php/tag:input?do=showtag&amp;tag=tag%3Ainput">input</a>,
<a href="/wiki/doku.php/tag:documentation?do=showtag&amp;tag=tag%3Adocumentation">documentation</a>
</span></div>
<p>
<a href="nbdocs:/com/jme3/gde/docs/jme3:advanced/tag_keyinput_input_documentation">tag_keyinput_input_documentation</a>
</p>
</div>
<!-- EDIT10 SECTION "Why Combos?" [7153-] -->
<p><em><a href="http://hub.jmonkeyengine.org/wiki/doku.php/jme3:advanced:combo_moves?do=export_xhtmlbody">view online version</a></em></p>
<p><em><a href="http://wiki.jmonkeyengine.org/doku.php/jme3:advanced:combo_moves?do=export_xhtmlbody">view online version</a></em></p>

@ -1,13 +1,13 @@
<h1><a>Custom Controls</a></h1>
<h1>Custom Controls</h1>
<div>
<p>
A <code>com.jme3.scene.control.Control</code> is a customizable jME3 interface that allows you to cleanly steer the behaviour of game entities (Spatials), such as artificially intelligent behaviour in NPCs, traps, automatic alarms and doors, animals and pets, self-steering vehicles or platforms ??? anything that moves and interacts. Several instances of custom Controls together implement the behaviours of a type of Spatial.
A <code>com.jme3.scene.control.Control</code> is a customizable jME3 interface that allows you to cleanly steer the behaviour of game entities (Spatials), such as artificially intelligent behaviour in NPCs, traps, automatic alarms and doors, animals and pets, self-steering vehicles or platforms anything that moves and interacts. Several instances of custom Controls together implement the behaviours of a type of Spatial.
</p>
<p>
To control global game behaviour see <a href="/com/jme3/gde/docs/jme3/advanced/application_states.html">Application States</a> ??? you often use AppStates and Control together.
To control global game behaviour see <a href="/com/jme3/gde/docs/jme3/advanced/application_states.html">Application States</a> you often use AppStates and Control together.
</p>
<ul>
<li><div> <object classid="java:org.netbeans.modules.javahelp.BrowserDisplayer"><param name="content" value="http://www.youtube.com/watch?v=MNDiZ9YHIpM"><param name="text" value="<html><u>Quick video introduction to Custom Controls</u></html>"><param name="textColor" value="blue"></object></div>
@ -15,7 +15,6 @@ To control global game behaviour see <a href="/com/jme3/gde/docs/jme3/advanced/a
</ul>
<p>
To control the behaviour of spatials:
</p>
<ol>
@ -38,17 +37,15 @@ For example, one NPC can be controlled by a PhysicsControl instance and an AICon
</ol>
<p>
To implement game logic for a type of spatial, you will either extend AbstractControl (most common case), or implement the Control interface, as explained in this article.
</p>
</div>
<!-- EDIT1 SECTION "Custom Controls" [1-1746] -->
<h2><a>Usage</a></h2>
<h2>Usage</h2>
<div>
<p>
Use <span><a href="/com/jme3/gde/docs/jme3/advanced/custom_controls.html">Controls</a></span> to implement the <em>behaviour of types of game entities</em>.
</p>
<ul>
@ -67,11 +64,10 @@ Use <span><a href="/com/jme3/gde/docs/jme3/advanced/custom_controls.html">Contro
</ul>
<p>
Examples: You can write
</p>
<ul>
<li><div> A WalkerNavControl, SwimmerNavControl, FlyerNavControl??? that defines how a type of NPC finds their way around. All NPCs can walk, some can fly, others can swim, and some can all three, etc.</div>
<li><div> A WalkerNavControl, SwimmerNavControl, FlyerNavControl that defines how a type of NPC finds their way around. All NPCs can walk, some can fly, others can swim, and some can all three, etc.</div>
</li>
<li><div> A PlayerNavControl that is steered by user-configurable keyboard and mouse input.</div>
</li>
@ -81,22 +77,20 @@ Examples: You can write
</li>
<li><div> An IdleBehaviourControl that remote-controls NPC behaviour in neutral situations. </div>
</li>
<li><div> A DestructionControl that automatically replaces a structure with an appropriate piece of debris after collision with a projectile??? </div>
<li><div> A DestructionControl that automatically replaces a structure with an appropriate piece of debris after collision with a projectile </div>
</li>
</ul>
<p>
The possibilities are endless. <img src="/wiki/lib/images/smileys/icon_smile.gif" class="middle" alt=":-)" />
The possibilities are endless. <img src="/lib/images/smileys/icon_smile.gif" class="icon" alt=":-)" />
</p>
</div>
<!-- EDIT2 SECTION "Usage" [1747-3214] -->
<h2><a>Example Code</a></h2>
<h2>Example Code</h2>
<div>
<p>
Other examples include the built-in RigidBodyControl in JME&#039;s physics integration, the built-in TerrainLODControl that updates the terrain&#039;s level of detail depending on the viewer&#039;s perspective, etc.
</p>
@ -116,11 +110,10 @@ Existing examples in the code base include:
</div>
<!-- EDIT3 SECTION "Example Code" [3215-4499] -->
<h2><a>AbstractControl Class</a></h2>
<h2>AbstractControl Class</h2>
<div>
<p>
<p><div>The most common way to create a Control is to create a class that extends AbstractControl.
</div></p>
</p>
@ -141,7 +134,6 @@ For example, you disable your IdleBehaviourControl when you enable your Defensiv
</ul>
<p>
Usage: Your custom subclass implements the three methods <code>controlUpdate()</code>, <code>controlRender()</code>, <code>setSpatial()</code>, and <code>cloneForSpatial()</code> as shown here:
</p>
<pre>public class MyControl extends AbstractControl implements Savable, Cloneable &#123;
@ -222,11 +214,10 @@ See also:
</div>
<!-- EDIT4 SECTION "AbstractControl Class" [4500-7583] -->
<h2><a>The Control Interface</a></h2>
<h2>The Control Interface</h2>
<div>
<p>
<p><div>In the less common case that you want to create a Control that also extends another class, create a custom interface that extends jME3&#039;s Control interface. Your class can become a Control by implementing the Control interface, and at the same time extending another class.
</div></p>
</p>
@ -246,19 +237,15 @@ The AssetManager also uses this method if the same spatial is loaded twice. You
</ul>
<p>
Usage example:
1. Create a custom control interface
</p>
<pre>public interface MyControlInterface extends Control &#123;
public void setSomething&#40;int x&#41;; // optionally, add custom methods
&#125;</pre>
<p>
2. Create custom Controls implementing your Control interface.
</p>
<pre>public class MyControl extends MyCustomClass implements MyControlInterface &#123;
&nbsp;
@ -329,14 +316,12 @@ Usage example:
</div>
<!-- EDIT5 SECTION "The Control Interface" [7584-10841] -->
<h2><a>Best Practices</a></h2>
<h2>Best Practices</h2>
<div>
<p>
<strong>Tip:</strong> Use the getControl() accessor to get Control objects from Spatials. No need to pass around lots of object references.
Here an example from the <object classid="java:org.netbeans.modules.javahelp.BrowserDisplayer"><param name="content" value="http://code.google.com/p/monkeyzone/"><param name="text" value="<html><u>MonkeyZone</u></html>"><param name="textColor" value="blue"></object> code:
</p>
<pre>public class CharacterAnimControl implements Control &#123;
...
@ -349,9 +334,7 @@ Here an example from the <object classid="java:org.netbeans.modules.javahelp.Bro
&#125;</pre>
<p>
<strong>Tip:</strong> You can create custom Control interfaces so a set of different Controls provide the same methods and can be accessed with the interface class type.
</p>
<pre>public interface ManualControl extends Control &#123;
public void steerX&#40;float value&#41;;
@ -363,22 +346,17 @@ Here an example from the <object classid="java:org.netbeans.modules.javahelp.Bro
&#125;</pre>
<p>
Then you create custom sub-Controls and implement the methods accordingly to the context:
</p>
<pre>public class ManualVehicleControl extends ManualControl &#123;...&#125;</pre>
<p>
and
</p>
<pre>public class ManualCharacterControl extends ManualControl &#123;...&#125;</pre>
<p>
Then add the appropriate controls to spatials:
</p>
<pre>characterSpatial.addControl&#40;new ManualCharacterControl&#40;&#41;&#41;;
...
@ -386,13 +364,11 @@ vehicleSpatial.addControl&#40;new ManualVehicleControl&#40;&#41;&#41;;
...</pre>
<p>
<strong>Tip:</strong> Use the getControl() method on a Spatial to get a specific Control object, and activate its behaviour!
</p>
<pre>ManualControl c = mySpatial.getControl&#40;ManualControl.class&#41;;
c.steerX&#40;steerX&#41;;</pre>
</div>
<!-- EDIT6 SECTION "Best Practices" [10842-] -->
<p><em><a href="http://hub.jmonkeyengine.org/wiki/doku.php/jme3:advanced:custom_controls?do=export_xhtmlbody">view online version</a></em></p>
<p><em><a href="http://wiki.jmonkeyengine.org/doku.php/jme3:advanced:custom_controls?do=export_xhtmlbody">view online version</a></em></p>

@ -1,15 +1,14 @@
<h1><a>Custom Mesh Shapes</a></h1>
<h1>Custom Mesh Shapes</h1>
<div>
<p>
<img src="/wiki/lib/exe/fetch.php">
<img src="/lib/exe/fetch.php">
Use the Mesh class to create custom shapes that go beyond Quad, Box, Cylinder, and Sphere, even procedural shapes are possible. Thank you to KayTrance for providing the sample code!
</p>
<p>
<strong>Note:</strong> In this tutorial, we (re)create a very simple rectangular mesh (a quad), and we have a look at different ways of coloring it. Coding a custom quad may not be very useful because it&#039;s exactly the same as the built-in <code>com.jme3.scene.shape.Quad</code>. We chose a simple quad to teach you how to build any shape out of triangles, without the distractions of more complex shapes.
</p>
<ul>
<li><div> Full code sample: <object classid="java:org.netbeans.modules.javahelp.BrowserDisplayer"><param name="content" value="http://jmonkeyengine.googlecode.com/svn/branches/stable-alpha4/engine/src/test/jme3test/model/shape/TestCustomMesh.java"><param name="text" value="<html><u>TestCustomMesh.java</u></html>"><param name="textColor" value="blue"></object></div>
@ -18,11 +17,10 @@ Use the Mesh class to create custom shapes that go beyond Quad, Box, Cylinder, a
</div>
<!-- EDIT1 SECTION "Custom Mesh Shapes" [1-834] -->
<h2><a>Polygon Meshes</a></h2>
<h2>Polygon Meshes</h2>
<div>
<p>
Polygon <a href="/com/jme3/gde/docs/jme3/advanced/mesh.html">mesh</a>es are made up of triangles. The corners of the triangles are called vertices. When ever you create any new shape, you break it down into triangles.
</p>
@ -35,17 +33,16 @@ The important thing is that you have to specify the vertices of each triangle in
</p>
<p>
Sounds harder than it is ??? let&#039;s create a simple custom mesh, a quad.
Sounds harder than it is let&#039;s create a simple custom mesh, a quad.
</p>
</div>
<!-- EDIT2 SECTION "Polygon Meshes" [835-1518] -->
<h2><a>Creating a Quad Mesh</a></h2>
<h2>Creating a Quad Mesh</h2>
<div>
<p>
In this tutorial we want to create a 3x3 Quad. The quad has four vertices, and is made up of two triangles. In our example, we decide that the bottom left corner is at 0/0/0 and the top right is at 3/3/0.
In this tutorial we want to create a 3&times;3 Quad. The quad has four vertices, and is made up of two triangles. In our example, we decide that the bottom left corner is at 0/0/0 and the top right is at 3/3/0.
</p>
<pre>0,3,0--3,3,0
| \ |
@ -57,13 +54,11 @@ In this tutorial we want to create a 3x3 Quad. The quad has four vertices, and i
</div>
<!-- EDIT3 SECTION "Creating a Quad Mesh" [1519-1864] -->
<h3><a>The Mesh Object</a></h3>
<h3>The Mesh Object</h3>
<div>
<p>
The base class for creating meshes is <code>com.jme3.scene.Mesh</code>.
</p>
<pre>Mesh mesh = new Mesh&#40;&#41;;</pre>
@ -73,13 +68,11 @@ Tip: If you create your own Mesh-based class (<code>public class MyMesh extends
</div>
<!-- EDIT4 SECTION "The Mesh Object" [1865-2157] -->
<h3><a>Vertex Coordinates</a></h3>
<h3>Vertex Coordinates</h3>
<div>
<p>
To define your own shape, determine the shape&#039;s <strong>vertex coordinates</strong> in 3D space. Store the list of corner positions in an <code>com.jme3.math.Vector3f</code> array. For a Quad, we need four vertices: Bottom left, bottom right, top left, top right. We name the array <code>vertices[]</code>.
</p>
<pre>Vector3f &#91;&#93; vertices = new Vector3f&#91;4&#93;;
vertices&#91;0&#93; = new Vector3f&#40;0,0,0&#41;;
@ -89,12 +82,11 @@ vertices&#91;3&#93; = new Vector3f&#40;3,3,0&#41;;</pre>
</div>
<!-- EDIT5 SECTION "Vertex Coordinates" [2158-2664] -->
<h3><a>Texture Coordinates</a></h3>
<h3>Texture Coordinates</h3>
<div>
<p>
Next, we define the Quad&#039;s 2D <strong>texture coordinates</strong> for each vertex, in the same order as the vertices: Bottom left, bottom right, top left, top right. We name this Vector2f array <code>texCoord[]</code>
</p>
<pre>Vector2f&#91;&#93; texCoord = new Vector2f&#91;4&#93;;
texCoord&#91;0&#93; = new Vector2f&#40;0,0&#41;;
@ -103,13 +95,12 @@ texCoord&#91;2&#93; = new Vector2f&#40;0,1&#41;;
texCoord&#91;3&#93; = new Vector2f&#40;1,1&#41;;</pre>
<p>
This syntax means, when you apply a texture to this mesh, the texture will fill the quad from corner to corner at 100% percent size. Especially when you stitch together a larger mesh, you use this to tell the renderer whether, and how exactly, you want to cover the whole mesh. E.g. if you use .5f or 2f as texture coordinates instead of 1f, textures will be stretched or shrunk accordingly.
</p>
</div>
<!-- EDIT6 SECTION "Texture Coordinates" [2665-3475] -->
<h3><a>Connecting the Dots</a></h3>
<h3>Connecting the Dots</h3>
<div>
<p>
@ -118,12 +109,10 @@ Next we turn these unrelated coordinates into <strong>triangles</strong>: We def
<p>
Remember that you must specify the vertices counter-clockwise.
</p>
<pre>int &#91;&#93; indexes = &#123; 2,0,1, 1,3,2 &#125;;</pre>
<p>
This syntax means:
</p>
<ul>
@ -140,18 +129,17 @@ This syntax means:
0--1\1</pre>
<p>
If the shape is more complex, it has more triangles, and therefor also more vertices/indices. Just continue expanding the list by adding groups of three indices for each triangle. (For example a three-triangle &quot;house&quot; shape has 5 vertices/indices and you&#039;d specify three groups: <code>int [] indexes = { 2,0,1, 1,3,2, 2,3,4 };</code>.)
If the shape is more complex, it has more triangles, and therefor also more vertices/indices. Just continue expanding the list by adding groups of three indices for each triangle. (For example a three-triangle “house” shape has 5 vertices/indices and you&#039;d specify three groups: <code>int [] indexes = { 2,0,1, 1,3,2, 2,3,4 };</code>.)
</p>
<p>
<p><div>If you get the order wrong (clockwise) for some of the triangles, then these triangles face backwards. If the <a href="/com/jme3/gde/docs/jme3/advanced/spatial.html">Spatial</a>&#039;s material uses the default <code>FaceCullMode.Back</code> (see &quot;face culling&quot;), the broken triangles appear as holes in the rendered mesh. You need to identify and fix them in your code.
<p><div>If you get the order wrong (clockwise) for some of the triangles, then these triangles face backwards. If the <a href="/com/jme3/gde/docs/jme3/advanced/spatial.html">Spatial</a>&#039;s material uses the default <code>FaceCullMode.Back</code> (see “face culling”), the broken triangles appear as holes in the rendered mesh. You need to identify and fix them in your code.
</div></p>
</p>
</div>
<!-- EDIT7 SECTION "Connecting the Dots" [3476-4947] -->
<h3><a>Setting the Mesh Buffer</a></h3>
<h3>Setting the Mesh Buffer</h3>
<div>
<p>
@ -181,18 +169,16 @@ mesh.setBuffer&#40;Type.Index, 3, BufferUtils.createIntBuffer&#40;indexes&#41
mesh.updateBound&#40;&#41;;</pre>
<p>
Our Mesh is ready! Now we want to see it.
</p>
</div>
<!-- EDIT8 SECTION "Setting the Mesh Buffer" [4948-6071] -->
<h2><a>Using the Mesh in a Scene</a></h2>
<!-- EDIT8 SECTION "Setting the Mesh Buffer" [4948-6073] -->
<h2>Using the Mesh in a Scene</h2>
<div>
<p>
We create a <code>com.jme3.scene.Geometry</code> from our <code>mesh</code>, apply a simple color material to it, and attach it to the rootNode to make it appear in the scene.
We create a <code>com.jme3.scene.Geometry</code> and <code>com.jme3.material.Material</code>from our <code>mesh</code>, apply a simple color material to it, and attach it to the rootNode to make it appear in the scene.
</p>
<pre>Geometry geo = new Geometry&#40;&quot;OurMesh&quot;, mesh&#41;; // using our custom mesh object
Material mat = new Material&#40;assetManager,
@ -202,33 +188,58 @@ geo.setMaterial&#40;mat&#41;;
rootNode.attachChild&#40;geo&#41;;</pre>
<p>
Library for assetManager?
Ta-daa!
</p>
</div>
<!-- EDIT9 SECTION "Using the Mesh in a Scene" [6072-6547] -->
<h2><a>Dynamic Meshes</a></h2>
<!-- EDIT9 SECTION "Using the Mesh in a Scene" [6074-6610] -->
<h2>Using a Quad instead</h2>
<div>
<p>
We created a quad Mesh it can be replace by a Quad such as :
</p>
<pre>Quad quad = new Quad&#40;1,1&#41;; // replace the definition of Vertex and Textures Coordinates plus indexes
Geometry geo = new Geometry&#40;&quot;OurQuad&quot;, quad&#41;; // using Quad object
Material mat = new Material&#40;assetManager,
&quot;Common/MatDefs/Misc/Unshaded.j3md&quot;&#41;;
mat.setColor&#40;&quot;Color&quot;, ColorRGBA.Blue&#41;;
geo.setMaterial&#40;mat&#41;;
rootNode.attachChild&#40;geo&#41;;</pre>
<p>
If you want to change the Textures Coordinates, in order to change the scale of the texture, use :
</p>
<pre>Quad quad = new Quad&#40;1,1&#41;;
quad.scaleTextureCoordinates&#40;new Vector2f&#40;width , height&#41;&#41;;</pre>
</div>
<!-- EDIT10 SECTION "Using a Quad instead" [6611-7273] -->
<h2>Dynamic Meshes</h2>
<div>
<p>
If you are modifying a mesh dynamically in a way which changes the model&#039;s bounds, you need to update it:
</p>
<ol>
<li><div> Call <code>updateBounds()</code> on the mesh object, and then </div>
<li><div> Call <code>updateBound()</code> on the mesh object, and then </div>
</li>
<li><div> call <code>updateModelBound()</code> on the Geometry object containing the mesh. </div>
</li>
</ol>
<p>
The updateModelBounds() method warns you about not usually needing to use it, but that can be ignored in this special case.
The updateModelBound() method warns you about not usually needing to use it, but that can be ignored in this special case.
</p>
<p>
<em>N.B.: This does not work on TerrainQuad. Please use the TerrainQuad.adjustHeight() function to edit the TerrainQuad mesh instead. Additionally, if you want to use collisions on them afterwards, you need to call TerrainPatch.getMesh().createCollisionData(); to update the collision data, else it will collide with what seems to be the old mesh. </em>
</p>
</div>
<!-- EDIT10 SECTION "Dynamic Meshes" [6548-6942] -->
<h2><a>Optional Mesh Features</a></h2>
<!-- EDIT11 SECTION "Dynamic Meshes" [7274-8018] -->
<h2>Optional Mesh Features</h2>
<div>
<p>
@ -236,8 +247,8 @@ There are more vertex buffers in a Mesh than the three shown above. For an overv
</p>
</div>
<!-- EDIT11 SECTION "Optional Mesh Features" [6943-7082] -->
<h3><a>Example: Vertex Colors</a></h3>
<!-- EDIT12 SECTION "Optional Mesh Features" [8019-8158] -->
<h3>Example: Vertex Colors</h3>
<div>
<p>
@ -271,7 +282,6 @@ You create a float array color buffer:
</ul>
<p>
Loop over the colorArray buffer to quickly set some RGBA value for each vertex. As usual, RGBA color values range from 0.0f to 1.0f. <strong>Note that the color values in this example are arbitrarily chosen.</strong> It&#039;s just a quick loop to give every vertex a different RGBA value (a purplish gray, purple, a greenish gray, green, see screenshot), without writing too much code. For your own mesh, you&#039;d assign meaningful values for the color buffer depending on which color you want your mesh to have.
</p>
<pre>// note: the red and green values are arbitray in this example
@ -288,23 +298,20 @@ for&#40;int i = 0; i &lt; 4; i++&#41;&#123;
<p>
Next, set the color buffer. An RGBA color value contains four float components, thus the parameter <code>4</code>.
</p>
<pre>mesh.setBuffer&#40;Type.Color, 4, colorArray&#41;;
geo.setMaterial&#40;matVC&#41;;</pre>
<p>
When you run this code, you see a gradient color extending from each vertex.
</p>
</div>
<!-- EDIT12 SECTION "Example: Vertex Colors" [7083-9361] -->
<h3><a>Example: Using Meshes With Lighting.j3md</a></h3>
<!-- EDIT13 SECTION "Example: Vertex Colors" [8159-10437] -->
<h3>Example: Using Meshes With Lighting.j3md</h3>
<div>
<p>
The previous examples used the mesh together with the <code>Unshaded.j3md</code> material. If you want to use the mesh with a Phong illuminated material (such as <code>Lighting.j3md</code>), the mesh must include information about its Normals. (Normal Vectors encode in which direction a mesh polygon is facing, which is important for calculating light and shadow!)
</p>
<pre>float&#91;&#93; normals = new float&#91;12&#93;;
@ -320,12 +327,11 @@ If the mesh is more complex or rounded, calculate cross products of neighbouring
</p>
</div>
<!-- EDIT13 SECTION "Example: Using Meshes With Lighting.j3md" [9362-10288] -->
<h3><a>Example: Point Mode</a></h3>
<!-- EDIT14 SECTION "Example: Using Meshes With Lighting.j3md" [10438-11364] -->
<h3>Example: Point Mode</h3>
<div>
<p>
Additionally to coloring the faces as just described, you can hide the faces and show only the vertices as colored corner points.
</p>
<pre>Geometry coloredMesh = new Geometry &#40;&quot;ColoredMesh&quot;, cMesh&#41;;
@ -340,22 +346,20 @@ rootNode.attachChild&#40;points&#41;;
rootNode.attachChild&#40;geo&#41;;</pre>
<p>
This will result in a 10 px dot being rendered for each of the four vertices. The dot has the vertex color you specified above. The Quad&#039;s faces are not rendered at all in this mode. You can use this to visualize a special debugging or editing mode in your game.
</p>
</div>
<!-- EDIT14 SECTION "Example: Point Mode" [10289-11022] -->
<h2><a>Debugging Tip: Culling</a></h2>
<!-- EDIT15 SECTION "Example: Point Mode" [11365-12098] -->
<h2>Debugging Tip: Culling</h2>
<div>
<p>
By default, jME3 optimizes a mesh by &quot;backface culling&quot;, this means not drawing the inside. It determines the side of a triangle by the order of the vertices: The frontface is the face where the vertices are specified counter-clockwise.
By default, jME3 optimizes a mesh by “backface culling”, this means not drawing the inside. It determines the side of a triangle by the order of the vertices: The frontface is the face where the vertices are specified counter-clockwise.
</p>
<p>
This means for you that, by default, your custom mesh is invisible when seen from &quot;behind&quot; or from the inside. This may not be a problem, typically this is even intended, because it&#039;s faster. The player will not look at the inside of most things anyway. For example, if your custom mesh is a closed polyhedron, or a flat wallpaper-like object, then rendering the backfaces (the inside of the pillar, the back of the painting, etc) would indeed be a waste of resources.
This means for you that, by default, your custom mesh is invisible when seen from “behind” or from the inside. This may not be a problem, typically this is even intended, because it&#039;s faster. The player will not look at the inside of most things anyway. For example, if your custom mesh is a closed polyhedron, or a flat wallpaper-like object, then rendering the backfaces (the inside of the pillar, the back of the painting, etc) would indeed be a waste of resources.
</p>
<p>
@ -373,22 +377,18 @@ In case however that your usecase requires the backfaces be visible, you have tw
<p>
See also:
</p>
<ul>
<li><div> <a href="/com/jme3/gde/docs/jme3/advanced/spatial.html">Spatial</a> ??? contains more info about how to debug custom meshes (that do not render as expected) by changing the default culling behaviour.</div>
<li><div> <a href="/com/jme3/gde/docs/jme3/advanced/spatial.html">Spatial</a> contains more info about how to debug custom meshes (that do not render as expected) by changing the default culling behaviour.</div>
</li>
<li><div> <a href="/com/jme3/gde/docs/jme3/advanced/mesh.html">Mesh</a> ??? more details about advanced Mesh properties</div>
<li><div> <a href="/com/jme3/gde/docs/jme3/advanced/mesh.html">Mesh</a> more details about advanced Mesh properties</div>
</li>
</ul>
<div><span>
<a href="/wiki/doku.php/tag:spatial?do=showtag&amp;tag=tag%3Aspatial">spatial</a>,
<a href="/wiki/doku.php/tag:node?do=showtag&amp;tag=tag%3Anode">node</a>,
<a href="/wiki/doku.php/tag:mesh?do=showtag&amp;tag=tag%3Amesh">mesh</a>,
<a href="/wiki/doku.php/tag:geometry?do=showtag&amp;tag=tag%3Ageometry">geometry</a>,
<a href="/wiki/doku.php/tag:scenegraph?do=showtag&amp;tag=tag%3Ascenegraph">scenegraph</a>
</span></div>
<p>
<a href="nbdocs:/com/jme3/gde/docs/jme3:advanced/tag_spatial_node_mesh_geometry_scenegraph">tag_spatial_node_mesh_geometry_scenegraph</a>
</p>
</div>
<!-- EDIT15 SECTION "Debugging Tip: Culling" [11023-] -->
<p><em><a href="http://hub.jmonkeyengine.org/wiki/doku.php/jme3:advanced:custom_meshes?do=export_xhtmlbody">view online version</a></em></p>
<!-- EDIT16 SECTION "Debugging Tip: Culling" [12099-] -->
<p><em><a href="http://wiki.jmonkeyengine.org/doku.php/jme3:advanced:custom_meshes?do=export_xhtmlbody">view online version</a></em></p>

Binary file not shown.

Before

Width:  |  Height:  |  Size: 27 KiB

After

Width:  |  Height:  |  Size: 28 KiB

@ -1,18 +1,17 @@
<h1><a>Debugging</a></h1>
<h1>Debugging</h1>
<div>
<p>
When you deal with complex game engine features like animations or physics it is handy to get feedback from the engine how it interpreted the current state. Is the physical object&#039;s collision shape really where you think it is? Is the skeleton of the animated character moving like you think it should? This document shows you how to activate visual debug aides.
</p>
<p>
What if you just want to quickly write code that loads models and brings them in their start position? You may not want to hunt for a sample model, convert it, add lights, and load materials. Instead you use &quot;hasslefree&quot; simple shapes, and a &quot;hasslefree&quot; unshaded material or wireframe: No model, no light source, no materials are needed to see them in your test scene.
What if you just want to quickly write code that loads models and brings them in their start position? You may not want to hunt for a sample model, convert it, add lights, and load materials. Instead you use “hasslefree” simple shapes, and a “hasslefree” unshaded material or wireframe: No model, no light source, no materials are needed to see them in your test scene.
</p>
<p>
If you ever have problems with objects appearing in the wrong spot, with the wrong scale, or wrong orientation, simply attach debug shapes to your scene to have a point of reference in 3D space ??? just like a giant ruler. If your code positions the debug shapes correctly, but models remain invisible when you apply the same code to them, you know that the problem must be either the model (where is its origin coordinate?), or the light (too dark? too bright? missing?), or the model&#039;s material (missing?) ??? and not the positioning code.
If you ever have problems with objects appearing in the wrong spot, with the wrong scale, or wrong orientation, simply attach debug shapes to your scene to have a point of reference in 3D space just like a giant ruler. If your code positions the debug shapes correctly, but models remain invisible when you apply the same code to them, you know that the problem must be either the model (where is its origin coordinate?), or the light (too dark? too bright? missing?), or the model&#039;s material (missing?) and not the positioning code.
</p>
<p>
@ -25,17 +24,16 @@ Here are some different debug shapes:
</div>
<!-- EDIT1 SECTION "Debugging" [1-1389] -->
<h2><a>Debug Shapes</a></h2>
<h2>Debug Shapes</h2>
<div>
</div>
<!-- EDIT2 SECTION "Debug Shapes" [1390-1415] -->
<h3><a>Coordinate Axes</a></h3>
<h3>Coordinate Axes</h3>
<div>
<p>
The coordinate axes (com.jme3.scene.debug.Arrow) help you see the cardinal directions (X,Y,Z) from their center point. Scale the arrows to use them as a &quot;ruler&quot; for a certain length.
The coordinate axes (com.jme3.scene.debug.Arrow) help you see the cardinal directions (X,Y,Z) from their center point. Scale the arrows to use them as a “ruler” for a certain length.
</p>
<pre>private void attachCoordinateAxes&#40;Vector3f pos&#41;&#123;
Arrow arrow = new Arrow&#40;Vector3f.UNIT_X&#41;;
@ -63,14 +61,13 @@ private Geometry putShape&#40;Mesh shape, ColorRGBA color&#41;&#123;
</div>
<!-- EDIT3 SECTION "Coordinate Axes" [1416-2483] -->
<h3><a>Wireframe Grid</a></h3>
<h3>Wireframe Grid</h3>
<div>
<p>
Use a wireframe grid (com.jme3.scene.debug.Grid) as a ruler or simple floor.
</p>
<pre>private void attachGrid&#40;Vector3f pos, float size, ColorRGBA color&#41;&#123;
<pre>private Geometry attachGrid&#40;Vector3f pos, float size, ColorRGBA color&#41;&#123;
Geometry g = new Geometry&#40;&quot;wireframe grid&quot;, new Grid&#40;size, size, 0.2f&#41; &#41;;
Material mat = new Material&#40;assetManager, &quot;Common/MatDefs/Misc/Unshaded.j3md&quot;&#41;;
mat.getAdditionalRenderState&#40;&#41;.setWireframe&#40;true&#41;;
@ -82,15 +79,14 @@ Use a wireframe grid (com.jme3.scene.debug.Grid) as a ruler or simple floor.
&#125;</pre>
</div>
<!-- EDIT4 SECTION "Wireframe Grid" [2484-3005] -->
<h3><a>Wireframe Cube</a></h3>
<!-- EDIT4 SECTION "Wireframe Grid" [2484-3009] -->
<h3>Wireframe Cube</h3>
<div>
<p>
Use a wireframe cube (com.jme3.scene.debug.WireBox) as a stand-in object to see whether your code scales, positions, or orients, loaded models right.
</p>
<pre>public void attachWireBox&#40;Vector3f pos, float size, ColorRGBA color&#41;&#123;
<pre>public Geometry attachWireBox&#40;Vector3f pos, float size, ColorRGBA color&#41;&#123;
Geometry g = new Geometry&#40;&quot;wireframe cube&quot;, new WireBox&#40;size, size, size&#41;&#41;;
Material mat = new Material&#40;assetManager, &quot;Common/MatDefs/Misc/Unshaded.j3md&quot;&#41;;
mat.getAdditionalRenderState&#40;&#41;.setWireframe&#40;true&#41;;
@ -102,15 +98,14 @@ Use a wireframe cube (com.jme3.scene.debug.WireBox) as a stand-in object to see
&#125;</pre>
</div>
<!-- EDIT5 SECTION "Wireframe Cube" [3006-3611] -->
<h3><a>Wireframe Sphere</a></h3>
<!-- EDIT5 SECTION "Wireframe Cube" [3010-3619] -->
<h3>Wireframe Sphere</h3>
<div>
<p>
Use a wireframe sphere (com.jme3.scene.debug.WireSphere) as a stand-in object to see whether your code scales, positions, or orients, loaded models right.
</p>
<pre>private void attachWireSphere&#40;Vector3f pos, float size, ColorRGBA color&#41;&#123;
<pre>private Geometry attachWireSphere&#40;Vector3f pos, float size, ColorRGBA color&#41;&#123;
Geometry g = new Geometry&#40;&quot;wireframe sphere&quot;, new WireSphere&#40;size&#41;&#41;;
Material mat = new Material&#40;assetManager, &quot;Common/MatDefs/Misc/Unshaded.j3md&quot;&#41;;
mat.getAdditionalRenderState&#40;&#41;.setWireframe&#40;true&#41;;
@ -122,12 +117,11 @@ Use a wireframe sphere (com.jme3.scene.debug.WireSphere) as a stand-in object to
&#125;</pre>
</div>
<!-- EDIT6 SECTION "Wireframe Sphere" [3612-4220] -->
<h2><a>Wireframe for Physics</a></h2>
<!-- EDIT6 SECTION "Wireframe Sphere" [3620-4232] -->
<h2>Wireframe for Physics</h2>
<div>
<p>
You can display a wireframe of the (usually invisible) collision shape around all physical objects. Use this for debugging when analyzing unexpected behaviour. Does not work with DETACHED physics, please switch to PARALLEL or SEQUENTIAL for debugging.
</p>
<pre>physicsSpace.enableDebug&#40;assetManager&#41;;</pre>
@ -149,12 +143,11 @@ With debugging enabled, colors are used to indicate various types of physical ob
</ul>
</div>
<!-- EDIT7 SECTION "Wireframe for Physics" [4221-4913] -->
<h2><a>Wireframe for Animations</a></h2>
<!-- EDIT7 SECTION "Wireframe for Physics" [4233-4925] -->
<h2>Wireframe for Animations</h2>
<div>
<p>
Making the skeleton visible inside animated models can be handy for debugging animations. The <code>control</code> object is an AnimControl, <code>player</code> is the loaded model.
</p>
<pre> SkeletonDebugger skeletonDebug =
@ -166,25 +159,23 @@ Making the skeleton visible inside animated models can be handy for debugging an
player.attachChild&#40;skeletonDebug&#41;;</pre>
</div>
<!-- EDIT8 SECTION "Wireframe for Animations" [4914-5505] -->
<h2><a>Example: Toggle Wireframe on Model</a></h2>
<!-- EDIT8 SECTION "Wireframe for Animations" [4926-5517] -->
<h2>Example: Toggle Wireframe on Model</h2>
<div>
<p>
We assume that you have loaded a model with a material <code>mat</code>.
</p>
<p>
Then you can add a switch to toggle the model&#039;s wireframe on and off, like this:
</p>
<ol>
<li><div> Create a key input trigger that switches between the two materials: E.g. we toggle when the T key is pressed: <pre> inputManager.addMapping&#40;&quot;toggle wireframe&quot;, new KeyTrigger&#40;KeyInput.KEY_T&#41;&#41;;
inputManager.addListener&#40;actionListener, &quot;toggle wireframe&quot;&#41;;</pre>
</div>
</li>
<li><div> Now add the toggle action to the action listener <pre> private ActionListener actionListener = new ActionListener&#40;&#41; &#123;
<li><div> Now add the toggle action to the action listener <pre> private ActionListener&#40;&#41; &#123;
@Override
public void onAction&#40;String name, boolean pressed, float tpf&#41; &#123;
// toggle wireframe
@ -197,7 +188,7 @@ Then you can add a switch to toggle the model&#039;s wireframe on and off, like
&#125;;</pre>
</div>
</li>
<li><div> Alternatively you could traverse over the whole scene and toggle for all Geometry objects in there if you don&#039;t want to create a new SceneProcessor <pre> private ActionListener actionListener = new ActionListener&#40;&#41; &#123;
<li><div> Alternatively you could traverse over the whole scene and toggle for all Geometry objects in there if you don&#039;t want to create a new SceneProcessor <pre> private ActionListener&#40;&#41; &#123;
boolean wireframe = false;
&nbsp;
@Override
@ -224,12 +215,11 @@ TIP :: To set the line width of wireframe display, use mesh.setLineWidth(lineWid
</p>
</div>
<!-- EDIT9 SECTION "Example: Toggle Wireframe on Model" [5506-7396] -->
<h2><a>Example: Toggle Wireframe on the scene</a></h2>
<!-- EDIT9 SECTION "Example: Toggle Wireframe on Model" [5518-7408] -->
<h2>Example: Toggle Wireframe on the scene</h2>
<div>
<p>
To display the wireframe of the entire scene instead on one material at a time, first create the following Scene Processor
</p>
<pre>public class WireProcessor implements SceneProcessor &#123;
@ -273,19 +263,19 @@ To display the wireframe of the entire scene instead on one material at a time,
&#125;</pre>
<p>
Then attach the scene processor to the <acronym title="Graphical User Interface">GUI</acronym> Viewport.
Then attach the scene processor to the <abbr title="Graphical User Interface">GUI</abbr> Viewport.
</p>
<pre>getViewPort&#40;&#41;.addProcessor&#40;new WireProcessor&#40;&#41;&#41;;</pre>
</div>
<!-- EDIT10 SECTION "Example: Toggle Wireframe on the scene" [7397-8770] -->
<h2><a>See also</a></h2>
<!-- EDIT10 SECTION "Example: Toggle Wireframe on the scene" [7409-8782] -->
<h2>See also</h2>
<div>
<ul>
<li><div> <a href="/com/jme3/gde/docs/jme3/advanced/spatial.html">Spatial</a> ??? if you can&#039;t see certain spatials, you can modify the culling behaviour to identify problems (such as inside-out custom meshes)</div>
<li><div> <a href="/com/jme3/gde/docs/jme3/advanced/spatial.html">Spatial</a> if you can&#039;t see certain spatials, you can modify the culling behaviour to identify problems (such as inside-out custom meshes)</div>
</li>
</ul>
</div>
<!-- EDIT11 SECTION "See also" [8771-] -->
<p><em><a href="http://hub.jmonkeyengine.org/wiki/doku.php/jme3:advanced:debugging?do=export_xhtmlbody">view online version</a></em></p>
<!-- EDIT11 SECTION "See also" [8783-] -->
<p><em><a href="http://wiki.jmonkeyengine.org/doku.php/jme3:advanced:debugging?do=export_xhtmlbody">view online version</a></em></p>

Binary file not shown.

Before

Width:  |  Height:  |  Size: 26 KiB

After

Width:  |  Height:  |  Size: 631 KiB

@ -1,15 +1,14 @@
<h1><a>jME3 Special Effects Overview</a></h1>
<h1>jME3 Special Effects Overview</h1>
<div>
<p>
jME3 supports several types of special effects: Post-Processor Filters, SceneProcessors, and Particle Emitters (also known as particle systems). This list contains screenshots and links to sample code that demonstrates how to add the effect to a scene.
</p>
</div>
<!-- EDIT1 SECTION "jME3 Special Effects Overview" [1-299] -->
<h2><a>Sample Code</a></h2>
<h2>Sample Code</h2>
<div>
<ul>
<li><div> There is one <code>com.jme3.effect.ParticleEmitter</code> class for all Particle Systems. </div>
@ -22,7 +21,7 @@ jME3 supports several types of special effects: Post-Processor Filters, ScenePro
</div>
<!-- EDIT2 SECTION "Sample Code" [300-768] -->
<h3><a>Particle Emitter</a></h3>
<h3>Particle Emitter</h3>
<div>
<pre>public class MyGame extends SimpleApplication &#123;
public void simpleInitApp&#40;&#41; &#123;
@ -38,7 +37,7 @@ jME3 supports several types of special effects: Post-Processor Filters, ScenePro
</div>
<!-- EDIT3 SECTION "Particle Emitter" [769-1298] -->
<h3><a>Scene Processor</a></h3>
<h3>Scene Processor</h3>
<div>
<pre>public class MyGame extends SimpleApplication &#123;
private BasicShadowRenderer bsr;
@ -51,7 +50,7 @@ jME3 supports several types of special effects: Post-Processor Filters, ScenePro
</div>
<!-- EDIT4 SECTION "Scene Processor" [1299-1674] -->
<h3><a>Post-Processor Filter</a></h3>
<h3>Post-Processor Filter</h3>
<div>
<pre>public class MyGame extends SimpleApplication &#123;
private FilterPostProcessor fpp; // one FilterPostProcessor per app
@ -67,11 +66,10 @@ jME3 supports several types of special effects: Post-Processor Filters, ScenePro
</div>
<!-- EDIT5 SECTION "Post-Processor Filter" [1675-2201] -->
<h2><a>Water</a></h2>
<h2>Water</h2>
<div>
<p>
<img src="nbdocs:/com/jme3/gde/docs/jme3/advanced/water-post.png"><img src="nbdocs:/com/jme3/gde/docs/jme3/advanced/water.png">
The jMonkeyEngine&#039;s <a href="/com/jme3/gde/docs/jme3/advanced/water.html">&quot;SeaMonkey&quot; WaterFilter</a> simulates ocean waves, foam, including cool underwater caustics.
Use the SimpleWaterProcessor (SceneProcessor) for small, limited bodies of water, such as puddles, drinking troughs, pools, fountains.
@ -81,9 +79,9 @@ Use the SimpleWaterProcessor (SceneProcessor) for small, limited bodies of water
See also the <object classid="java:org.netbeans.modules.javahelp.BrowserDisplayer"><param name="content" value="http://jmonkeyengine.org/2011/01/15/new-advanced-water-effect-for-jmonkeyengine-3"><param name="text" value="<html><u>Rendering Water as Post-Process Effect</u></html>"><param name="textColor" value="blue"></object> announcement with video.
</p>
<ul>
<li><div> <object classid="java:org.netbeans.modules.javahelp.BrowserDisplayer"><param name="content" value="http://code.google.com/p/jmonkeyengine/source/browse/trunk/engine/src/test/jme3test/water/TestSceneWater.java"><param name="text" value="<html><u>jme3/src/test/jme3test/water/TestSceneWater.java</u></html>"><param name="textColor" value="blue"></object> ??? SimpleWaterProcessor (SceneProcessor)</div>
<li><div> <object classid="java:org.netbeans.modules.javahelp.BrowserDisplayer"><param name="content" value="http://code.google.com/p/jmonkeyengine/source/browse/trunk/engine/src/test/jme3test/water/TestSceneWater.java"><param name="text" value="<html><u>jme3/src/test/jme3test/water/TestSceneWater.java</u></html>"><param name="textColor" value="blue"></object> SimpleWaterProcessor (SceneProcessor)</div>
</li>
<li><div> <object classid="java:org.netbeans.modules.javahelp.BrowserDisplayer"><param name="content" value="http://code.google.com/p/jmonkeyengine/source/browse/trunk/engine/src/test/jme3test/water/TestSimpleWater.java"><param name="text" value="<html><u>jme3/src/test/jme3test/water/TestSimpleWater.java</u></html>"><param name="textColor" value="blue"></object> ??? SimpleWaterProcessor (SceneProcessor)</div>
<li><div> <object classid="java:org.netbeans.modules.javahelp.BrowserDisplayer"><param name="content" value="http://code.google.com/p/jmonkeyengine/source/browse/trunk/engine/src/test/jme3test/water/TestSimpleWater.java"><param name="text" value="<html><u>jme3/src/test/jme3test/water/TestSimpleWater.java</u></html>"><param name="textColor" value="blue"></object> SimpleWaterProcessor (SceneProcessor)</div>
</li>
</ul>
@ -91,52 +89,51 @@ See also the <object classid="java:org.netbeans.modules.javahelp.BrowserDisplaye
<img src="nbdocs:/com/jme3/gde/docs/jme3/advanced/water-reflection-muddy.png"><img src="nbdocs:/com/jme3/gde/docs/jme3/advanced/underwater2.jpg">
</p>
<ul>
<li><div> <object classid="java:org.netbeans.modules.javahelp.BrowserDisplayer"><param name="content" value="http://code.google.com/p/jmonkeyengine/source/browse/trunk/engine/src/test/jme3test/water/TestPostWater.java"><param name="text" value="<html><u>jme3/src/test/jme3test/water/TestPostWater.java</u></html>"><param name="textColor" value="blue"></object> ??? WaterFilter</div>
<li><div> <object classid="java:org.netbeans.modules.javahelp.BrowserDisplayer"><param name="content" value="http://code.google.com/p/jmonkeyengine/source/browse/trunk/engine/src/test/jme3test/water/TestPostWater.java"><param name="text" value="<html><u>jme3/src/test/jme3test/water/TestPostWater.java</u></html>"><param name="textColor" value="blue"></object> WaterFilter</div>
</li>
<li><div> <object classid="java:org.netbeans.modules.javahelp.BrowserDisplayer"><param name="content" value="http://code.google.com/p/jmonkeyengine/source/browse/trunk/engine/src/test/jme3test/water/TestPostWaterLake.java"><param name="text" value="<html><u>jme3/src/test/jme3test/water/TestPostWaterLake.java</u></html>"><param name="textColor" value="blue"></object> ??? WaterFilter</div>
<li><div> <object classid="java:org.netbeans.modules.javahelp.BrowserDisplayer"><param name="content" value="http://code.google.com/p/jmonkeyengine/source/browse/trunk/engine/src/test/jme3test/water/TestPostWaterLake.java"><param name="text" value="<html><u>jme3/src/test/jme3test/water/TestPostWaterLake.java</u></html>"><param name="textColor" value="blue"></object> WaterFilter</div>
</li>
</ul>
</div>
<!-- EDIT6 SECTION "Water" [2202-3620] -->
<h2><a>Environment Effects</a></h2>
<h2>Environment Effects</h2>
<div>
</div>
<!-- EDIT7 SECTION "Environment Effects" [3621-3653] -->
<h3><a>Depth of Field Blur</a></h3>
<h3>Depth of Field Blur</h3>
<div>
<p>
<img src="nbdocs:/com/jme3/gde/docs/jme3/advanced/dof-blur.png"><img src="nbdocs:/com/jme3/gde/docs/jme3/advanced/light-scattering-filter.png">
</p>
<ul>
<li><div> <object classid="java:org.netbeans.modules.javahelp.BrowserDisplayer"><param name="content" value="http://code.google.com/p/jmonkeyengine/source/browse/trunk/engine/src/test/jme3test/post/TestDepthOfField.java"><param name="text" value="<html><u>jme3/src/test/jme3test/post/TestDepthOfField.java</u></html>"><param name="textColor" value="blue"></object> ??? DepthOfFieldFilter</div>
<li><div> <object classid="java:org.netbeans.modules.javahelp.BrowserDisplayer"><param name="content" value="http://code.google.com/p/jmonkeyengine/source/browse/trunk/engine/src/test/jme3test/post/TestDepthOfField.java"><param name="text" value="<html><u>jme3/src/test/jme3test/post/TestDepthOfField.java</u></html>"><param name="textColor" value="blue"></object> DepthOfFieldFilter</div>
</li>
</ul>
</div>
<!-- EDIT8 SECTION "Depth of Field Blur" [3654-3972] -->
<h3><a>Fog</a></h3>
<h3>Fog</h3>
<div>
<ul>
<li><div> <object classid="java:org.netbeans.modules.javahelp.BrowserDisplayer"><param name="content" value="http://code.google.com/p/jmonkeyengine/source/browse/trunk/engine/src/test/jme3test/post/TestFog.java"><param name="text" value="<html><u>jme3/src/test/jme3test/post/TestFog.java</u></html>"><param name="textColor" value="blue"></object> ??? FogFilter</div>
<li><div> <object classid="java:org.netbeans.modules.javahelp.BrowserDisplayer"><param name="content" value="http://code.google.com/p/jmonkeyengine/source/browse/trunk/engine/src/test/jme3test/post/TestFog.java"><param name="text" value="<html><u>jme3/src/test/jme3test/post/TestFog.java</u></html>"><param name="textColor" value="blue"></object> FogFilter</div>
</li>
</ul>
</div>
<!-- EDIT9 SECTION "Fog" [3973-4152] -->
<h3><a>Light Scattering</a></h3>
<h3>Light Scattering</h3>
<div>
<ul>
<li><div> <object classid="java:org.netbeans.modules.javahelp.BrowserDisplayer"><param name="content" value="http://code.google.com/p/jmonkeyengine/source/browse/trunk/engine/src/test/jme3test/post/TestLightScattering.java"><param name="text" value="<html><u>jme3/src/test/jme3test/post/TestLightScattering.java</u></html>"><param name="textColor" value="blue"></object> ??? LightScatteringFilter</div>
<li><div> <object classid="java:org.netbeans.modules.javahelp.BrowserDisplayer"><param name="content" value="http://code.google.com/p/jmonkeyengine/source/browse/trunk/engine/src/test/jme3test/post/TestLightScattering.java"><param name="text" value="<html><u>jme3/src/test/jme3test/post/TestLightScattering.java</u></html>"><param name="textColor" value="blue"></object> LightScatteringFilter</div>
</li>
</ul>
</div>
<!-- EDIT10 SECTION "Light Scattering" [4153-4381] -->
<h3><a>Vegetation</a></h3>
<h3>Vegetation</h3>
<div>
<ul>
<li><div> Contribution: <a href="/com/jme3/gde/docs/jme3/contributions/vegetationsystem/grass.html">Grass System</a></div>
@ -147,7 +144,7 @@ See also the <object classid="java:org.netbeans.modules.javahelp.BrowserDisplaye
</div>
<!-- EDIT11 SECTION "Vegetation" [4382-4619] -->
<h2><a>Light and Shadows</a></h2>
<h2>Light and Shadows</h2>
<div>
<p>
@ -156,47 +153,46 @@ See also the <object classid="java:org.netbeans.modules.javahelp.BrowserDisplaye
</div>
<!-- EDIT12 SECTION "Light and Shadows" [4620-4743] -->
<h3><a>Bloom and Glow</a></h3>
<h3>Bloom and Glow</h3>
<div>
<ul>
<li><div> <object classid="java:org.netbeans.modules.javahelp.BrowserDisplayer"><param name="content" value="http://code.google.com/p/jmonkeyengine/source/browse/trunk/engine/src/test/jme3test/post/TestBloom.java"><param name="text" value="<html><u>jme3/src/test/jme3test/post/TestBloom.java</u></html>"><param name="textColor" value="blue"></object></div>
</li>
<li><div> More details: <a href="/com/jme3/gde/docs/jme3/advanced/bloom_and_glow.html">Bloom and Glow</a> ??? BloomFilter</div>
<li><div> More details: <a href="/com/jme3/gde/docs/jme3/advanced/bloom_and_glow.html">Bloom and Glow</a> BloomFilter</div>
</li>
</ul>
</div>
<!-- EDIT13 SECTION "Bloom and Glow" [4744-4990] -->
<h3><a>Light</a></h3>
<h3>Light</h3>
<div>
<ul>
<li><div> <object classid="java:org.netbeans.modules.javahelp.BrowserDisplayer"><param name="content" value="http://code.google.com/p/jmonkeyengine/source/browse/trunk/engine/src/test/jme3test/light/TestSimpleLighting.java"><param name="text" value="<html><u>jme3/src/test/jme3test/light/TestSimpleLighting.java</u></html>"><param name="textColor" value="blue"></object> ??? DirectionalLight, PointLight</div>
<li><div> <object classid="java:org.netbeans.modules.javahelp.BrowserDisplayer"><param name="content" value="http://code.google.com/p/jmonkeyengine/source/browse/trunk/engine/src/test/jme3test/light/TestSimpleLighting.java"><param name="text" value="<html><u>jme3/src/test/jme3test/light/TestSimpleLighting.java</u></html>"><param name="textColor" value="blue"></object> DirectionalLight, PointLight</div>
</li>
<li><div> <object classid="java:org.netbeans.modules.javahelp.BrowserDisplayer"><param name="content" value="http://code.google.com/p/jmonkeyengine/source/browse/trunk/engine/src/test/jme3test/light/TestLightRadius.java"><param name="text" value="<html><u>jme3/src/test/jme3test/light/TestLightRadius.java</u></html>"><param name="textColor" value="blue"></object> ??? DirectionalLight, PointLight</div>
<li><div> <object classid="java:org.netbeans.modules.javahelp.BrowserDisplayer"><param name="content" value="http://code.google.com/p/jmonkeyengine/source/browse/trunk/engine/src/test/jme3test/light/TestLightRadius.java"><param name="text" value="<html><u>jme3/src/test/jme3test/light/TestLightRadius.java</u></html>"><param name="textColor" value="blue"></object> DirectionalLight, PointLight</div>
</li>
<li><div> <object classid="java:org.netbeans.modules.javahelp.BrowserDisplayer"><param name="content" value="http://code.google.com/p/jmonkeyengine/source/browse/trunk/engine/src/test/jme3test/light/TestManyLights.java"><param name="text" value="<html><u>jme3/src/test/jme3test/light/TestManyLights.java</u></html>"><param name="textColor" value="blue"></object> ??? .j3o scene</div>
<li><div> <object classid="java:org.netbeans.modules.javahelp.BrowserDisplayer"><param name="content" value="http://code.google.com/p/jmonkeyengine/source/browse/trunk/engine/src/test/jme3test/light/TestManyLights.java"><param name="text" value="<html><u>jme3/src/test/jme3test/light/TestManyLights.java</u></html>"><param name="textColor" value="blue"></object> .j3o scene</div>
</li>
<li><div> More details: <a href="/com/jme3/gde/docs/jme3/advanced/light_and_shadow.html">Light and Shadow</a></div>
</li>
</ul>
<p>
<img src="nbdocs:/com/jme3/gde/docs/jme3/advanced/shadow.png"><img src="nbdocs:/com/jme3/gde/docs/jme3/advanced/light-sources.png">
</p>
</div>
<!-- EDIT14 SECTION "Light" [4991-5735] -->
<h3><a>Shadow</a></h3>
<h3>Shadow</h3>
<div>
<ul>
<li><div> <object classid="java:org.netbeans.modules.javahelp.BrowserDisplayer"><param name="content" value="http://code.google.com/p/jmonkeyengine/source/browse/trunk/engine/src/test/jme3test/light/TestShadow.java"><param name="text" value="<html><u>jme3/src/test/jme3test/light/TestShadow.java</u></html>"><param name="textColor" value="blue"></object> ??? BasicShadowRenderer (SceneProcessor)</div>
<li><div> <object classid="java:org.netbeans.modules.javahelp.BrowserDisplayer"><param name="content" value="http://code.google.com/p/jmonkeyengine/source/browse/trunk/engine/src/test/jme3test/light/TestShadow.java"><param name="text" value="<html><u>jme3/src/test/jme3test/light/TestShadow.java</u></html>"><param name="textColor" value="blue"></object> BasicShadowRenderer (SceneProcessor)</div>
</li>
<li><div> <object classid="java:org.netbeans.modules.javahelp.BrowserDisplayer"><param name="content" value="http://code.google.com/p/jmonkeyengine/source/browse/trunk/engine/src/test/jme3test/light/TestPssmShadow.java"><param name="text" value="<html><u>jme3/src/test/jme3test/light/TestPssmShadow.java</u></html>"><param name="textColor" value="blue"></object> ??? PssmShadowRenderer (SceneProcessor), also known as Parallel-Split Shadow Mapping (PSSM).</div>
<li><div> <object classid="java:org.netbeans.modules.javahelp.BrowserDisplayer"><param name="content" value="http://code.google.com/p/jmonkeyengine/source/browse/trunk/engine/src/test/jme3test/light/TestPssmShadow.java"><param name="text" value="<html><u>jme3/src/test/jme3test/light/TestPssmShadow.java</u></html>"><param name="textColor" value="blue"></object> PssmShadowRenderer (SceneProcessor), also known as Parallel-Split Shadow Mapping (PSSM).</div>
</li>
<li><div> <object classid="java:org.netbeans.modules.javahelp.BrowserDisplayer"><param name="content" value="http://code.google.com/p/jmonkeyengine/source/browse/trunk/engine/src/test/jme3test/post/TestSSAO.java"><param name="text" value="<html><u>jme3/src/test/jme3test/post/TestSSAO.java</u></html>"><param name="textColor" value="blue"></object>, <object classid="java:org.netbeans.modules.javahelp.BrowserDisplayer"><param name="content" value="http://code.google.com/p/jmonkeyengine/source/browse/trunk/engine/src/test/jme3test/post/TestSSAO2.java"><param name="text" value="<html><u>jme3/src/test/jme3test/post/TestSSAO2.java</u></html>"><param name="textColor" value="blue"></object> ??? SSAOFilter, also known as Screen-Space Ambient Occlusion shadows (SSOA).</div>
<li><div> <object classid="java:org.netbeans.modules.javahelp.BrowserDisplayer"><param name="content" value="http://code.google.com/p/jmonkeyengine/source/browse/trunk/engine/src/test/jme3test/post/TestSSAO.java"><param name="text" value="<html><u>jme3/src/test/jme3test/post/TestSSAO.java</u></html>"><param name="textColor" value="blue"></object>, <object classid="java:org.netbeans.modules.javahelp.BrowserDisplayer"><param name="content" value="http://code.google.com/p/jmonkeyengine/source/browse/trunk/engine/src/test/jme3test/post/TestSSAO2.java"><param name="text" value="<html><u>jme3/src/test/jme3test/post/TestSSAO2.java</u></html>"><param name="textColor" value="blue"></object> SSAOFilter, also known as Screen-Space Ambient Occlusion shadows (SSOA).</div>
</li>
<li><div> <object classid="java:org.netbeans.modules.javahelp.BrowserDisplayer"><param name="content" value="http://code.google.com/p/jmonkeyengine/source/browse/trunk/engine/src/test/jme3test/post/TestTransparentSSAO.java"><param name="text" value="<html><u>jme3/src/test/jme3test/post/TestTransparentSSAO.java</u></html>"><param name="textColor" value="blue"></object> ??? SSAOFilter, also known as Screen-Space Ambient Occlusion shadows (SSOA), plus transparancy</div>
<li><div> <object classid="java:org.netbeans.modules.javahelp.BrowserDisplayer"><param name="content" value="http://code.google.com/p/jmonkeyengine/source/browse/trunk/engine/src/test/jme3test/post/TestTransparentSSAO.java"><param name="text" value="<html><u>jme3/src/test/jme3test/post/TestTransparentSSAO.java</u></html>"><param name="textColor" value="blue"></object> SSAOFilter, also known as Screen-Space Ambient Occlusion shadows (SSOA), plus transparancy</div>
</li>
<li><div> More details: <a href="/com/jme3/gde/docs/jme3/advanced/light_and_shadow.html">Light and Shadow</a></div>
</li>
@ -204,42 +200,39 @@ See also the <object classid="java:org.netbeans.modules.javahelp.BrowserDisplaye
</div>
<!-- EDIT15 SECTION "Shadow" [5736-6917] -->
<h2><a>Special: Glass, Metal, Dissolve, Toon</a></h2>
<h2>Special: Glass, Metal, Dissolve, Toon</h2>
<div>
<p>
<img src="nbdocs:/com/jme3/gde/docs/jme3/advanced/toon-dino.png">
</p>
</div>
<!-- EDIT16 SECTION "Special: Glass, Metal, Dissolve, Toon" [6918-7010] -->
<h3><a>Toon Effect</a></h3>
<h3>Toon Effect</h3>
<div>
<ul>
<li><div> <object classid="java:org.netbeans.modules.javahelp.BrowserDisplayer"><param name="content" value="http://code.google.com/p/jmonkeyengine/source/browse/trunk/engine/src/test/jme3test/post/TestCartoonEdge.java"><param name="text" value="<html><u>jme3/src/test/jme3test/post/TestCartoonEdge.java</u></html>"><param name="textColor" value="blue"></object> ??? CartoonEdgeFilter</div>
<li><div> <object classid="java:org.netbeans.modules.javahelp.BrowserDisplayer"><param name="content" value="http://code.google.com/p/jmonkeyengine/source/browse/trunk/engine/src/test/jme3test/post/TestCartoonEdge.java"><param name="text" value="<html><u>jme3/src/test/jme3test/post/TestCartoonEdge.java</u></html>"><param name="textColor" value="blue"></object> CartoonEdgeFilter</div>
</li>
<li><div> <object classid="java:org.netbeans.modules.javahelp.BrowserDisplayer"><param name="content" value="http://code.google.com/p/jmonkeyengine/source/browse/trunk/engine/src/test/jme3test/post/TestTransparentCartoonEdge.java"><param name="text" value="<html><u>jme3/src/test/jme3test/post/TestTransparentCartoonEdge.java</u></html>"><param name="textColor" value="blue"></object> ??? CartoonEdgeFilter</div>
<li><div> <object classid="java:org.netbeans.modules.javahelp.BrowserDisplayer"><param name="content" value="http://code.google.com/p/jmonkeyengine/source/browse/trunk/engine/src/test/jme3test/post/TestTransparentCartoonEdge.java"><param name="text" value="<html><u>jme3/src/test/jme3test/post/TestTransparentCartoonEdge.java</u></html>"><param name="textColor" value="blue"></object> CartoonEdgeFilter</div>
</li>
</ul>
</div>
<!-- EDIT17 SECTION "Toon Effect" [7011-7431] -->
<h3><a>Fade in / Fade out</a></h3>
<h3>Fade in / Fade out</h3>
<div>
<ul>
<li><div> <a href="/com/jme3/gde/docs/jme3/advanced/fade.html">Fade</a> ??? FadeFilter</div>
<li><div> <a href="/com/jme3/gde/docs/jme3/advanced/fade.html">Fade</a> FadeFilter</div>
</li>
</ul>
</div>
<!-- EDIT18 SECTION "Fade in / Fade out" [7432-7503] -->
<h3><a>User Contributed</a></h3>
<h3>User Contributed</h3>
<div>
<p>
<img src="nbdocs:/com/jme3/gde/docs/jme3/advanced/shaderblow_light1.jpg"><img src="nbdocs:/com/jme3/gde/docs/jme3/advanced/shaderblow_glass.jpg"><img src="nbdocs:/com/jme3/gde/docs/jme3/advanced/shaderblow_matcap.jpg"><img src="nbdocs:/com/jme3/gde/docs/jme3/advanced/shaderblow_light2.jpg">
</p>
@ -247,64 +240,61 @@ See also the <object classid="java:org.netbeans.modules.javahelp.BrowserDisplaye
<a href="/com/jme3/gde/docs/sdk/plugin/shaderblow.html">ShaderBlow - GLSL Shader Library</a>
</p>
<ul>
<li><div> LightBlow Shader ??? blend material texture maps</div>
<li><div> LightBlow Shader blend material texture maps</div>
</li>
<li><div> FakeParticleBlow Shader ??? jet, fire effect</div>
<li><div> FakeParticleBlow Shader jet, fire effect</div>
</li>
<li><div> ToonBlow Shader ??? Toon Shading, toon edges </div>
<li><div> ToonBlow Shader Toon Shading, toon edges </div>
</li>
<li><div> Dissolve Shader ??? Scifi teleportation/dissolve effect</div>
<li><div> Dissolve Shader Scifi teleportation/dissolve effect</div>
</li>
<li><div> MatCap Shader ??? Gold, metals, glass, toons???!</div>
<li><div> MatCap Shader – Gold, metals, glass, toons…!</div>
</li>
<li><div> Glass Shader ??? Glass</div>
<li><div> Glass Shader Glass</div>
</li>
<li><div> Force Shield Shader ??? Scifi impact-on-force-field effect</div>
<li><div> Force Shield Shader Scifi impact-on-force-field effect</div>
</li>
<li><div> SimpleSprite Shader ??? Animated textures</div>
<li><div> SimpleSprite Shader Animated textures</div>
</li>
<li><div> SimpleSpriteParticle Shader ??? Sprite library</div>
<li><div> SimpleSpriteParticle Shader Sprite library</div>
</li>
<li><div> MovingTexture Shader ??? Animated cloud/mist texture</div>
<li><div> MovingTexture Shader Animated cloud/mist texture</div>
</li>
<li><div> SoftParticles Shader ??? Fire, clouds, smoke etc</div>
<li><div> SoftParticles Shader Fire, clouds, smoke etc</div>
</li>
<li><div> Displace Shader ??? Deformation effect: Ripple, wave, pulse, swell!</div>
<li><div> Displace Shader Deformation effect: Ripple, wave, pulse, swell!</div>
</li>
</ul>
<p>
Thanks for your awesome contributions! Keep them coming!
</p>
</div>
<!-- EDIT19 SECTION "User Contributed" [7504-8465] -->
<h2><a>Particle Emitters: Explosions, Fire, Smoke</a></h2>
<h2>Particle Emitters: Explosions, Fire, Smoke</h2>
<div>
<p>
<img src="nbdocs:/com/jme3/gde/docs/jme3/advanced/explosion-5.png"><img src="nbdocs:/com/jme3/gde/docs/jme3/advanced/particle.png">
<a href="/com/jme3/gde/docs/jme3/advanced/particle_emitters.html">Particle emitter effects</a> are highly configurable and can have any texture. They can simulate smoke, dust, leaves, meteors, snowflakes, mosquitos, fire, explosions, clusters, embers, sparks???
<a href="/com/jme3/gde/docs/jme3/advanced/particle_emitters.html">Particle emitter effects</a> are highly configurable and can have any texture. They can simulate smoke, dust, leaves, meteors, snowflakes, mosquitos, fire, explosions, clusters, embers, sparks
</p>
<ul>
<li><div> <object classid="java:org.netbeans.modules.javahelp.BrowserDisplayer"><param name="content" value="http://code.google.com/p/jmonkeyengine/source/browse/trunk/engine/src/test/jme3test/effect/TestExplosionEffect.java"><param name="text" value="<html><u>jme3/src/test/jme3test/effect/TestExplosionEffect.java</u></html>"><param name="textColor" value="blue"></object> ??? debris, flame, flash, shockwave, smoke, sparks</div>
<li><div> <object classid="java:org.netbeans.modules.javahelp.BrowserDisplayer"><param name="content" value="http://code.google.com/p/jmonkeyengine/source/browse/trunk/engine/src/test/jme3test/effect/TestExplosionEffect.java"><param name="text" value="<html><u>jme3/src/test/jme3test/effect/TestExplosionEffect.java</u></html>"><param name="textColor" value="blue"></object> debris, flame, flash, shockwave, smoke, sparks</div>
</li>
<li><div> <object classid="java:org.netbeans.modules.javahelp.BrowserDisplayer"><param name="content" value="http://code.google.com/p/jmonkeyengine/source/browse/trunk/engine/src/test/jme3test/effect/TestPointSprite.java"><param name="text" value="<html><u>jme3/src/test/jme3test/effect/TestPointSprite.java</u></html>"><param name="textColor" value="blue"></object> ??? cluster of points </div>
<li><div> <object classid="java:org.netbeans.modules.javahelp.BrowserDisplayer"><param name="content" value="http://code.google.com/p/jmonkeyengine/source/browse/trunk/engine/src/test/jme3test/effect/TestPointSprite.java"><param name="text" value="<html><u>jme3/src/test/jme3test/effect/TestPointSprite.java</u></html>"><param name="textColor" value="blue"></object> cluster of points </div>
</li>
<li><div> <object classid="java:org.netbeans.modules.javahelp.BrowserDisplayer"><param name="content" value="http://code.google.com/p/jmonkeyengine/source/browse/trunk/engine/src/test/jme3test/effect/TestMovingParticle.java"><param name="text" value="<html><u>jme3/src/test/jme3test/effect/TestMovingParticle.java</u></html>"><param name="textColor" value="blue"></object> ??? dust, smoke</div>
<li><div> <object classid="java:org.netbeans.modules.javahelp.BrowserDisplayer"><param name="content" value="http://code.google.com/p/jmonkeyengine/source/browse/trunk/engine/src/test/jme3test/effect/TestMovingParticle.java"><param name="text" value="<html><u>jme3/src/test/jme3test/effect/TestMovingParticle.java</u></html>"><param name="textColor" value="blue"></object> dust, smoke</div>
</li>
</ul>
<hr />
</div>
<!-- EDIT20 SECTION "Particle Emitters: Explosions, Fire, Smoke" [8466-9440] -->
<h3><a>Creating your own Filters</a></h3>
<h3>Creating your own Filters</h3>
<div>
<p>
Here is an extract taken from @nehon in the forum thread (<object classid="java:org.netbeans.modules.javahelp.BrowserDisplayer"><param name="content" value="http://hub.jmonkeyengine.org/forum/topic/how-exactly-do-filters-work/"><param name="text" value="<html><u>http://hub.jmonkeyengine.org/forum/topic/how-exactly-do-filters-work/</u></html>"><param name="textColor" value="blue"></object>)
</p>
@ -325,7 +315,7 @@ Those methods are optional in a filter, they are only there if you want to hook
</p>
<p>
The material variable is here for convenience. You have a getMaterial method that returns the material that???s gonna be used to render the full screen quad. It just happened that in every implementation I had a material attribute in all my sub-classes, so I just put it back in the abstract class. Most of the time getMaterial returns this attribute.
The material variable is here for convenience. You have a getMaterial method that returns the material thats gonna be used to render the full screen quad. It just happened that in every implementation I had a material attribute in all my sub-classes, so I just put it back in the abstract class. Most of the time getMaterial returns this attribute.
</p>
<p>
@ -336,7 +326,7 @@ You assume well about the SSAO filer, the normal of the scene are rendered to a
<p>
Passes : these are filters in filters in a way. First they are a convenient way to initialize a FrameBuffer and the associated textures it needs, then you can use them for what ever you want.
For example, a Pass can be (as in the SSAO filter) an extra render of the scene with a forced technique, and you have to handle the render yourself in the postQueue method.
It can be a post pass to do after the main filter has been rendered to screen (for example an additional blur pass used in SSAO again). You have a list of passes called postRenderPass in the Filter abstract class. If you add a pass to this list, it???ll be automatically rendered by the FilterPostProcessor during the filter chain.
It can be a post pass to do after the main filter has been rendered to screen (for example an additional blur pass used in SSAO again). You have a list of passes called postRenderPass in the Filter abstract class. If you add a pass to this list, itll be automatically rendered by the FilterPostProcessor during the filter chain.
</p>
<p>
@ -345,7 +335,6 @@ The bloom Filter does an intensive use of passes.
<p>
Filters in a nutshell.
</p>
<hr />
@ -360,13 +349,11 @@ See also:
<li><div> <object classid="java:org.netbeans.modules.javahelp.BrowserDisplayer"><param name="content" value="http://www.smashingmagazine.com/2008/08/07/50-photoshop-tutorials-for-sky-and-space-effects/"><param name="text" value="<html><u>Photoshop Tutorial for Sky and space effects (article)</u></html>"><param name="textColor" value="blue"></object></div>
</li>
</ul>
<div><span>
<a href="/wiki/doku.php/tag:documentation?do=showtag&amp;tag=tag%3Adocumentation">documentation</a>,
<a href="/wiki/doku.php/tag:effect?do=showtag&amp;tag=tag%3Aeffect">effect</a>,
<a href="/wiki/doku.php/tag:light?do=showtag&amp;tag=tag%3Alight">light</a>,
<a href="/wiki/doku.php/tag:water?do=showtag&amp;tag=tag%3Awater">water</a>
</span></div>
<p>
<a href="nbdocs:/com/jme3/gde/docs/jme3:advanced/tag_documentation_effect_light_water">tag_documentation_effect_light_water</a>
</p>
</div>
<!-- EDIT21 SECTION "Creating your own Filters" [9441-] -->
<p><em><a href="http://hub.jmonkeyengine.org/wiki/doku.php/jme3:advanced:effects_overview?do=export_xhtmlbody">view online version</a></em></p>
<p><em><a href="http://wiki.jmonkeyengine.org/doku.php/jme3:advanced:effects_overview?do=export_xhtmlbody">view online version</a></em></p>

Binary file not shown.

Before

Width:  |  Height:  |  Size: 54 KiB

After

Width:  |  Height:  |  Size: 169 KiB

@ -1,17 +1,25 @@
<h1><a>Endless Terrain</a></h1>
<h1>Endless Terrain</h1>
<div>
<p>
TerrainGrid is an extension built on top of the TerraMonkey tools like TerrainQuad and HeightMap, that provides &quot;infinite&quot; Terrain paging routines. <br/>
<p><div>Deprecated. Look at <object classid="java:org.netbeans.modules.javahelp.BrowserDisplayer"><param name="content" value="http://hub.jmonkeyengine.org/forum/topic/design-question-terrain/#post-262072"><param name="text" value="<html><u>http://hub.jmonkeyengine.org/forum/topic/design-question-terrain/#post-262072</u></html>"><param name="textColor" value="blue"></object> instead
</div></p>
</p>
Thanks to G??bor (@anthyon) and Brent (@sploreg) for this contribution!
<p>
TerrainGrid is DEPRECATED.
</p>
<p>
TerrainGrid is an extension built on top of the TerraMonkey tools like TerrainQuad and HeightMap, that provides “infinite” Terrain paging routines. <br/>
Thanks to Gábor (@anthyon) and Brent (@sploreg) for this contribution!
</p>
</div>
<!-- EDIT1 SECTION "Endless Terrain" [1-254] -->
<h2><a>Sample Code</a></h2>
<!-- EDIT1 SECTION "Endless Terrain" [1-484] -->
<h2>Sample Code</h2>
<div>
<p>
@ -27,8 +35,8 @@ The classes with source code can be found in the org.jme3.terrain.geomipmapping
</ul>
</div>
<!-- EDIT2 SECTION "Sample Code" [255-1134] -->
<h2><a>Specification</a></h2>
<!-- EDIT2 SECTION "Sample Code" [485-1364] -->
<h2>Specification</h2>
<div>
<p>
@ -50,27 +58,25 @@ TerrainGrid is made up of the TerrainGrid class, and the HeightMapGrid and Terra
<p>
<br/>
Multiple listeners can be added to the TerrainGrid, they will be called in the order of addition, so it???s possible to have multiple changes to the material before completing the load of the tile.
Multiple listeners can be added to the TerrainGrid, they will be called in the order of addition, so its possible to have multiple changes to the material before completing the load of the tile.
<br/>
HeightMapGrid adds the possibility of loading terrain tiles on demand instead of having a simple height array. There???s no predefined way of how to store these tiles, it only takes care of loading one HeightMap object at given location at a time.
HeightMapGrid adds the possibility of loading terrain tiles on demand instead of having a simple height array. There’s no predefined way of how to store these tiles, it only takes care of loading one HeightMap object at given location at a time.
</p>
</div>
<!-- EDIT3 SECTION "Specification" [1135-2425] -->
<h2><a>Motivation</a></h2>
<!-- EDIT3 SECTION "Specification" [1365-2655] -->
<h2>Motivation</h2>
<div>
<p>
<img src="nbdocs:/com/jme3/gde/docs/wp-uploads/2011/06/grid-tiles.jpg">
After playing around with the terrain in jME3, soon comes the requirement of having larger explorable lands. Increasing the size of one TerrainQuad leads to more memory usage, while it will still be easy to reach the worlds boundaries. That???s why TerrainGrid was designed. It extends the TerraindQuad class and uses 4 HeightMaps (dark blue) as the four sub-quad. This means that a terrain of size 513 will use tiles of 257. Also an LRUCache is built into the terrain package, so surrounding tiles (green) can be pre-cached on a different thread, lowering the loading time. The quads are updated as the camera approaches the boundary of the light blue section.
After playing around with the terrain in jME3, soon comes the requirement of having larger explorable lands. Increasing the size of one TerrainQuad leads to more memory usage, while it will still be easy to reach the worlds boundaries. That’s why TerrainGrid was designed. It extends the TerraindQuad class and uses 4 HeightMaps (dark blue) as the four sub-quad. This means that a terrain of size 513 will use tiles of 257. Also an LRUCache is built into the terrain package, so surrounding tiles (green) can be pre-cached on a different thread, lowering the loading time. The quads are updated as the camera approaches the boundary of the light blue section.
</p>
</div>
<!-- EDIT4 SECTION "Motivation" [2426-3157] -->
<h2><a>Rationale</a></h2>
<!-- EDIT4 SECTION "Motivation" [2656-3387] -->
<h2>Rationale</h2>
<div>
<p>
@ -80,13 +86,13 @@ There exist also two basic HeightMapGrid implementations:
<ul>
<li><div> ImageBasedHeightMapGrid: uses a sequentially numbered, 16 bit grayscale heightmaps. The physical filename of these files can be generated through the Namer interface. When a tile cannot be found by the assetManager, an empty (all-zero) heightmap is created, and a warning is added to the log.</div>
</li>
<li><div> FractalHeightMapGrid: uses a noise library to create a landscape on the fly. The shape of the terrain can be controlled by the various parameters and postfilters of the fractals. With the help of this grid implementation there???s no limitation ??? above of floating point precision limits ??? how far the camera can get. The tiles generated this way can be cached to the filesystem, for later modification. The FractalHeightMapGrid will always load from cache if a tile exists there!</div>
<li><div> FractalHeightMapGrid: uses a noise library to create a landscape on the fly. The shape of the terrain can be controlled by the various parameters and postfilters of the fractals. With the help of this grid implementation there’s no limitation – above of floating point precision limits – how far the camera can get. The tiles generated this way can be cached to the filesystem, for later modification. The FractalHeightMapGrid will always load from cache if a tile exists there!</div>
</li>
</ul>
</div>
<!-- EDIT5 SECTION "Rationale" [3158-4368] -->
<h2><a>Usage</a></h2>
<!-- EDIT5 SECTION "Rationale" [3388-4598] -->
<h2>Usage</h2>
<div>
<ol>
<li><div> instantiate a TerrainGrid object</div>
@ -112,5 +118,5 @@ Further information about terrain and TerrainQuad can be found in the wiki at:
</ul>
</div>
<!-- EDIT6 SECTION "Usage" [4369-] -->
<p><em><a href="http://hub.jmonkeyengine.org/wiki/doku.php/jme3:advanced:endless_terraingrid?do=export_xhtmlbody">view online version</a></em></p>
<!-- EDIT6 SECTION "Usage" [4599-] -->
<p><em><a href="http://wiki.jmonkeyengine.org/doku.php/jme3:advanced:endless_terraingrid?do=export_xhtmlbody">view online version</a></em></p>

Binary file not shown.

Before

Width:  |  Height:  |  Size: 17 KiB

After

Width:  |  Height:  |  Size: 207 KiB

@ -1,16 +1,15 @@
<h1><a>Fade-in / Fade-out Effect</a></h1>
<h1>Fade-in / Fade-out Effect</h1>
<div>
<p>
You can use a fade in/fade out effect to make smooth transitions, for example between game levels. The effect fades in from black to the initialized scene, or fades out from the scene to black.
The effect uses com.jme3.post.FilterPostProcessor and com.jme3.post.filters.FadeFilter.
</p>
</div>
<!-- EDIT1 SECTION "Fade-in / Fade-out Effect" [1-320] -->
<h2><a>Setting up</a></h2>
<h2>Setting up</h2>
<div>
<ol>
<li><div> Create one FilterPostProcessor object per application.</div>
@ -37,7 +36,7 @@ public void simpleInitApp&#40;&#41; &#123;
</div>
<!-- EDIT2 SECTION "Setting up" [321-965] -->
<h2><a>Fading in and out</a></h2>
<h2>Fading in and out</h2>
<div>
<p>
@ -47,4 +46,4 @@ You can also change the fade duration using <code>fade.setDuration()</code>.
</div>
<!-- EDIT3 SECTION "Fading in and out" [966-] -->
<p><em><a href="http://hub.jmonkeyengine.org/wiki/doku.php/jme3:advanced:fade?do=export_xhtmlbody">view online version</a></em></p>
<p><em><a href="http://wiki.jmonkeyengine.org/doku.php/jme3:advanced:fade?do=export_xhtmlbody">view online version</a></em></p>

@ -1,9 +1,8 @@
<h1><a>jME3 Headless Server</a></h1>
<h1>jME3 Headless Server</h1>
<div>
<p>
When adding multiplayer to your game, you may find that your server needs to know about game state (e.g. where are players, objects? Was that a direct hit? etc.) You can code all this up yourself, but there&#039;s an easier way.
</p>
@ -13,31 +12,29 @@ It&#039;s very easy to change your current (client) game to function as a server
</div>
<!-- EDIT1 SECTION "jME3 Headless Server" [1-348] -->
<h2><a>What Does Headless Mean?</a></h2>
<h2>What Does Headless Mean?</h2>
<div>
<p>
A headless server???
A headless server…
</p>
<ul>
<li><div> does not display any output ??? no window opens, no audio plays, no graphics are rendered.</div>
<li><div> does not display any output no window opens, no audio plays, no graphics are rendered.</div>
</li>
<li><div> ignores all input ??? no input handling.</div>
<li><div> ignores all input no input handling.</div>
</li>
<li><div> keeps game state ??? you can attach to, transform, and save the rootNode, although the scene is not displayed.</div>
<li><div> keeps game state you can attach to, transform, and save the rootNode, although the scene is not displayed.</div>
</li>
<li><div> calls the <code>simpleUpdate()</code> loop ??? you can run tests and trigger events as usual.</div>
<li><div> calls the <code>simpleUpdate()</code> loop you can run tests and trigger events as usual.</div>
</li>
</ul>
</div>
<!-- EDIT2 SECTION "What Does Headless Mean?" [349-748] -->
<h2><a>Client Code</a></h2>
<h2>Client Code</h2>
<div>
<p>
First, let&#039;s take a look at the default way of creating a new game (in its simplest form):
</p>
<pre>public static void main&#40;String&#91;&#93; args&#41; &#123;
@ -47,11 +44,10 @@ First, let&#039;s take a look at the default way of creating a new game (in its
</div>
<!-- EDIT3 SECTION "Client Code" [749-975] -->
<h2><a>Headless Server Code</a></h2>
<h2>Headless Server Code</h2>
<div>
<p>
Now, with a simple change you can start your game in Headless mode. This means that all input and audio/visual output will be ignored. That&#039;s a good thing for a server.
</p>
<pre>import com.jme3.system.JmeContext;
@ -64,16 +60,14 @@ public static void main&#40;String&#91;&#93; args&#41; &#123;
</div>
<!-- EDIT4 SECTION "Headless Server Code" [976-1390] -->
<h2><a>Next steps</a></h2>
<h2>Next steps</h2>
<div>
<p>
Okay, so you can now start your game in a headless &#039;server mode&#039;, where to go from here?
</p>
<ul>
<li><div> Parse <code>String[] args</code> from the <code>main</code>-method to enable server mode on demand (e.g. start your server like <code>java -jar mygame.jar ???server</code>.</div>
<li><div> Parse <code>String[] args</code> from the <code>main</code>-method to enable server mode on demand (e.g. start your server like <code>java -jar mygame.jar server</code>.</div>
</li>
<li><div> Integrate <a href="/com/jme3/gde/docs/jme3/advanced/networking.html">SpiderMonkey</a>, to provide game updates to the server over a network.</div>
</li>
@ -82,14 +76,11 @@ Okay, so you can now start your game in a headless &#039;server mode&#039;, wher
<li><div> Add decent <a href="/com/jme3/gde/docs/jme3/advanced/logging.html">logging</a> so your server actually makes sense.</div>
</li>
</ul>
<div><span>
<a href="/wiki/doku.php/tag:server?do=showtag&amp;tag=tag%3Aserver">server</a>,
<a href="/wiki/doku.php/tag:spidermonkey?do=showtag&amp;tag=tag%3Aspidermonkey">spidermonkey</a>,
<a href="/wiki/doku.php/tag:headless?do=showtag&amp;tag=tag%3Aheadless">headless</a>,
<a href="/wiki/doku.php/tag:network?do=showtag&amp;tag=tag%3Anetwork">network</a>,
<a href="/wiki/doku.php/tag:documentation?do=showtag&amp;tag=tag%3Adocumentation">documentation</a>
</span></div>
<p>
<a href="nbdocs:/com/jme3/gde/docs/jme3:advanced/tag_server_spidermonkey_headless_network_documentation">tag_server_spidermonkey_headless_network_documentation</a>
</p>
</div>
<!-- EDIT5 SECTION "Next steps" [1391-] -->
<p><em><a href="http://hub.jmonkeyengine.org/wiki/doku.php/jme3:advanced:headless_server?do=export_xhtmlbody">view online version</a></em></p>
<p><em><a href="http://wiki.jmonkeyengine.org/doku.php/jme3:advanced:headless_server?do=export_xhtmlbody">view online version</a></em></p>

@ -1,9 +1,8 @@
<h1><a>Physical Hinges and Joints</a></h1>
<h1>Physical Hinges and Joints</h1>
<div>
<p>
The jMonkeyEngine3 has built-in support for <object classid="java:org.netbeans.modules.javahelp.BrowserDisplayer"><param name="content" value="http://jbullet.advel.cz"><param name="text" value="<html><u>jBullet physics</u></html>"><param name="textColor" value="blue"></object> via the <code>com.jme3.bullet</code> package.
</p>
@ -17,7 +16,7 @@ In this example, we will create a pendulum. The joint is the (invisible) connect
</div>
<!-- EDIT1 SECTION "Physical Hinges and Joints" [1-692] -->
<h2><a>Sample Code</a></h2>
<h2>Sample Code</h2>
<div>
<ul>
<li><div> <object classid="java:org.netbeans.modules.javahelp.BrowserDisplayer"><param name="content" value="http://code.google.com/p/jmonkeyengine/source/browse/trunk/engine/src/test/jme3test/bullet/TestPhysicsHingeJoint.java"><param name="text" value="<html><u>TestPhysicsHingeJoint.java</u></html>"><param name="textColor" value="blue"></object></div>
@ -26,7 +25,7 @@ In this example, we will create a pendulum. The joint is the (invisible) connect
</div>
<!-- EDIT2 SECTION "Sample Code" [693-871] -->
<h2><a>Overview of this Physics Application</a></h2>
<h2>Overview of this Physics Application</h2>
<div>
<ol>
<li><div> Create a SimpleApplication with a <a href="/com/jme3/gde/docs/jme3/advanced/physics.html">BulletAppState</a> </div>
@ -37,13 +36,13 @@ In this example, we will create a pendulum. The joint is the (invisible) connect
</li>
<li><div> For the pendulum, we use a Spatial with a PhysicsControl, and we apply physical forces to them.</div>
<ul>
<li><div> The parts of the &quot;pendulum&quot; are Physics Control&#039;ed Spatials with Collision Shapes. </div>
<li><div> The parts of the “pendulum” are Physics Control&#039;ed Spatials with Collision Shapes. </div>
</li>
<li><div> We create a fixed <code>hookNode</code> and a dynamic <code>pendulumNode</code>. </div>
</li>
</ul>
</li>
<li><div> We can &quot;crank the handle&quot; and rotate the joint like a hinge, or we can let loose and expose the joints freely to gravity. </div>
<li><div> We can “crank the handle” and rotate the joint like a hinge, or we can let loose and expose the joints freely to gravity. </div>
<ul>
<li><div> For physical forces we will use the method <code>joint.enableMotor();</code></div>
</li>
@ -53,11 +52,10 @@ In this example, we will create a pendulum. The joint is the (invisible) connect
</div>
<!-- EDIT3 SECTION "Overview of this Physics Application" [872-1519] -->
<h2><a>Creating a Fixed Node</a></h2>
<h2>Creating a Fixed Node</h2>
<div>
<p>
The hookNode is the fixed point from which the pendulum hangs. It has no mass.
</p>
<pre>Node hookNode=PhysicsTestHelper.createPhysicsTestNode&#40;
@ -73,11 +71,10 @@ For a rope bridge, there would be two fixed nodes where the bridge is attached t
</div>
<!-- EDIT4 SECTION "Creating a Fixed Node" [1520-2039] -->
<h2><a>Creating a Dynamic Node</a></h2>
<h2>Creating a Dynamic Node</h2>
<div>
<p>
The pendulumNode is the dynamic part of the construction. It has a mass.
</p>
<pre>Node pendulumNode=PhysicsTestHelper.createPhysicsTestNode&#40;
@ -92,16 +89,15 @@ For a rope bridge, each set of planks would be one dynamic node.
</div>
<!-- EDIT5 SECTION "Creating a Dynamic Node" [2040-2537] -->
<h2><a>Understanding DOF, Joints, and Hinges</a></h2>
<h2>Understanding DOF, Joints, and Hinges</h2>
<div>
<p>
A PhysicsHingeJoint is an invisible connection between two nodes ??? here between the pendulum body and the hook. Why are hinges and joints represented by the same class? Hinges and joints have something in common: They constrain the <em>mechanical degree of freedom</em> (DOF) of another object.
A PhysicsHingeJoint is an invisible connection between two nodes – here between the pendulum body and the hook. Why are hinges and joints represented by the same class? Hinges and joints have something in common: They constrain the <em>mechanical degree of freedom</em> (DOF) of another object.
</p>
<p>
Consider a free falling, &quot;unchained&quot; object in physical 3D space: It has 6 DOFs:
Consider a free falling, “unchained” object in physical 3D space: It has 6 DOFs:
</p>
<ul>
<li><div> It translates along 3 axes</div>
@ -111,7 +107,6 @@ Consider a free falling, &quot;unchained&quot; object in physical 3D space: It h
</ul>
<p>
Now consider some examples of objects with joints:
</p>
<ul>
@ -124,18 +119,16 @@ Now consider some examples of objects with joints:
</ul>
<p>
You&#039;ll understand that, when creating any type of joint, it is important to correctly specify the DOFs that the joint restricts, and the DOFs that the joint allows. For the typical DOF of a <a href="/com/jme3/gde/docs/jme3/advanced/ragdoll.html">ragDoll</a> character&#039;s limbs, jME even offers a special joint, <code>ConeJoint</code>.
</p>
</div>
<!-- EDIT6 SECTION "Understanding DOF, Joints, and Hinges" [2538-3728] -->
<h2><a>Creating the Joint</a></h2>
<h2>Creating the Joint</h2>
<div>
<p>
You create the HingeJoint after you have created the nodes that are to be chained together. In the code snippet you see that the HingeJoint constructor requires the two node objects. You also have to specify axes and pivots ??? they are the degrees of freedom that you just heard about.
You create the HingeJoint after you have created the nodes that are to be chained together. In the code snippet you see that the HingeJoint constructor requires the two node objects. You also have to specify axes and pivots – they are the degrees of freedom that you just heard about.
</p>
<pre>private HingeJoint joint;
...
@ -152,7 +145,6 @@ You create the HingeJoint after you have created the nodes that are to be chaine
Vector3f.UNIT_Z &#41;; // DoF Axis of B (Z axis)</pre>
<p>
The pivot point&#039;s position will be at <code>(0,0,0)</code> in the global 3D space. In A&#039;s local space that is at <code>(0,0,0)</code> and in B&#039;s local space (remember B&#039;s position was set to <code>(0,-1,0)</code>) that is at <code>(0,1,0)</code>.
</p>
@ -160,15 +152,15 @@ The pivot point&#039;s position will be at <code>(0,0,0)</code> in the global 3D
Specify the following parameters for each joint:
</p>
<ul>
<li><div> PhysicsControl A and B ??? the two nodes that are to be joined</div>
<li><div> PhysicsControl A and B the two nodes that are to be joined</div>
</li>
<li><div> Vector3f pivot A and pivot B ??? coordinates of the attachment point relative to A and B</div>
<li><div> Vector3f pivot A and pivot B coordinates of the attachment point relative to A and B</div>
<ul>
<li><div> The points typically lie on the surface of the PhysicsControl&#039;s Spatials, rarely in the middle.</div>
</li>
</ul>
</li>
<li><div> Vector3f axisA and axisB ??? around which axes each node is allowed to spin.</div>
<li><div> Vector3f axisA and axisB around which axes each node is allowed to spin.</div>
<ul>
<li><div> In our example, we constrain the pendulum to swing only along the Z axis.</div>
</li>
@ -177,7 +169,6 @@ Specify the following parameters for each joint:
</ul>
<p>
Remember to add all joint objects to the physicsSpace, just like you would do with any physical objects.
</p>
<pre>bulletAppState.getPhysicsSpace&#40;&#41;.add&#40;joint&#41;;</pre>
@ -188,12 +179,11 @@ Remember to add all joint objects to the physicsSpace, just like you would do wi
</div>
<!-- EDIT7 SECTION "Creating the Joint" [3729-5628] -->
<h2><a>Apply Physical Forces</a></h2>
<h2>Apply Physical Forces</h2>
<div>
<p>
You can apply forces to dynamic nodes (the ones that have a mass), and see how other joined (&quot;chained&quot;) objects are dragged along.
You can apply forces to dynamic nodes (the ones that have a mass), and see how other joined (“chained”) objects are dragged along.
</p>
<p>
@ -219,17 +209,14 @@ joint.enableMotor&#40;true, -1, .1f&#41;;</pre>
</ol>
<p>
When you disable the motor, the chained nodes are exposed to gravity again:
</p>
<pre>joint.enableMotor&#40;false, 0, 0&#41;;</pre>
<div><span>
<a href="/wiki/doku.php/tag:documentation?do=showtag&amp;tag=tag%3Adocumentation">documentation</a>,
<a href="/wiki/doku.php/tag:physics?do=showtag&amp;tag=tag%3Aphysics">physics</a>,
<a href="/wiki/doku.php/tag:joint?do=showtag&amp;tag=tag%3Ajoint">joint</a>
</span></div>
<p>
<a href="nbdocs:/com/jme3/gde/docs/jme3:advanced/tag_documentation_physics_joint">tag_documentation_physics_joint</a>
</p>
</div>
<!-- EDIT8 SECTION "Apply Physical Forces" [5629-] -->
<p><em><a href="http://hub.jmonkeyengine.org/wiki/doku.php/jme3:advanced:hinges_and_joints?do=export_xhtmlbody">view online version</a></em></p>
<p><em><a href="http://wiki.jmonkeyengine.org/doku.php/jme3:advanced:hinges_and_joints?do=export_xhtmlbody">view online version</a></em></p>

Binary file not shown.

Before

Width:  |  Height:  |  Size: 97 KiB

After

Width:  |  Height:  |  Size: 216 KiB

@ -1,10 +1,9 @@
<h1><a>Head-Up Display (HUD)</a></h1>
<h1>Head-Up Display (HUD)</h1>
<div>
<p>
<img src="/wiki/lib/exe/fetch.php">
<img src="/lib/exe/fetch.php">
</p>
<p>
@ -15,48 +14,46 @@ A HUD (Head-Up Display) is part of a game&#039;s visual user interface. It&#039;
HUDs are used to supply players with essential information about the game state.
</p>
<ul>
<li><div> Status: Score, minimap, points, stealth mode, ???</div>
<li><div> Status: Score, minimap, points, stealth mode, </div>
</li>
<li><div> Resources: Ammunition, lives/health, time, ???</div>
<li><div> Resources: Ammunition, lives/health, time, </div>
</li>
<li><div> Vehicle instruments: Cockpit, speedometer, ???</div>
<li><div> Vehicle instruments: Cockpit, speedometer, </div>
</li>
<li><div> Navigational aides: Crosshairs, mouse pointer or hand, ???</div>
<li><div> Navigational aides: Crosshairs, mouse pointer or hand, </div>
</li>
</ul>
<p>
You have two options how to create HUDs.
</p>
<div><table>
<thead>
<tr>
<th>Option</th><th>Pros</th><th>Cons</th>
</tr>
</thead>
<tr>
<th>Attach elements to default guiNode:</th><td>Easy to learn. jMonkeyEngine built-in <acronym title="Application Programming Interface">API</acronym> for attaching plain images and bitmap text.</td><td>Only basic features. <br/>
<th>Attach elements to default guiNode:</th><td>Easy to learn. jMonkeyEngine built-in <abbr title="Application Programming Interface">API</abbr> for attaching plain images and bitmap text.</td><td>Only basic features. <br/>
You will have to write custom controls / buttons / effects if you need them.</td>
</tr>
<tr>
<th>Use advanced <a href="/com/jme3/gde/docs/jme3/advanced/nifty_gui.html">Nifty GUI</a> integration:</th><td>Full-featured interactive user interface. <br/>
Includes buttons, effects, controls. <br/>
Supports <acronym title="Extensible Markup Language">XML</acronym> and Java layouts.</td><td>Steeper learning curve.</td>
Supports XML and Java layouts.</td><td>Steeper learning curve.</td>
</tr>
</table></div>
<!-- EDIT2 TABLE [834-1259] -->
<p>
Using the <acronym title="Graphical User Interface">GUI</acronym> Node is the default approach in jme3 to create simple HUDs. If you just quickly want to display a line of text, or a simple icon on the screen, use the no-frills <acronym title="Graphical User Interface">GUI</acronym> Node, it&#039;s easier.
Using the <abbr title="Graphical User Interface">GUI</abbr> Node is the default approach in jme3 to create simple HUDs. If you just quickly want to display a line of text, or a simple icon on the screen, use the no-frills <abbr title="Graphical User Interface">GUI</abbr> Node, it&#039;s easier.
</p>
</div>
<!-- EDIT1 SECTION "Head-Up Display (HUD)" [1-1460] -->
<h2><a>Simple HUD: GUI Node</a></h2>
<h2>Simple HUD: GUI Node</h2>
<div>
<p>
You already know the <code>rootNode</code> that holds the 3-dimensional scene graph. jME3 also offers a 2-dimension (orthogonal) node, the <code>guiNode</code>.
</p>
@ -64,7 +61,7 @@ You already know the <code>rootNode</code> that holds the 3-dimensional scene gr
This is how you use the guiNode for HUDs:
</p>
<ul>
<li><div> Create a <acronym title="Graphical User Interface">GUI</acronym> element: a BitmapText or Picture object.</div>
<li><div> Create a <abbr title="Graphical User Interface">GUI</abbr> element: a BitmapText or Picture object.</div>
</li>
<li><div> Attach the element to the guiNode. </div>
</li>
@ -77,7 +74,7 @@ The BitmapTexts and Pictures appear as 2 dimensional element on the screen.
</p>
<p>
<p><div>By default, the guiNode has some scene graph statistics attached. To clear the guiNode before you attach your own <acronym title="Graphical User Interface">GUI</acronym> elements, use the following methods:
<p><div>By default, the guiNode has some scene graph statistics attached. To clear the guiNode before you attach your own <abbr title="Graphical User Interface">GUI</abbr> elements, use the following methods:
</p>
<pre>setDisplayStatView&#40;false&#41;; setDisplayFps&#40;false&#41;;</pre>
@ -88,11 +85,10 @@ The BitmapTexts and Pictures appear as 2 dimensional element on the screen.
</div>
<!-- EDIT3 SECTION "Simple HUD: GUI Node" [1461-2189] -->
<h3><a>Displaying Pictures in the HUD</a></h3>
<h3>Displaying Pictures in the HUD</h3>
<div>
<p>
A simple image can be displayed using <code>com.jme3.ui.Picture</code>.
</p>
<pre>Picture pic = new Picture&#40;&quot;HUD Picture&quot;&#41;;
@ -108,11 +104,10 @@ When you set the last boolean in setImage() to true, the alpha channel of your i
</div>
<!-- EDIT4 SECTION "Displaying Pictures in the HUD" [2190-2714] -->
<h3><a>Displaying Text in the HUD</a></h3>
<h3>Displaying Text in the HUD</h3>
<div>
<p>
You use <code>com.jme3.font.BitmapText</code> to display text on the screen.
</p>
<pre>BitmapText hudText = new BitmapText&#40;guiFont, false&#41;;
@ -130,12 +125,12 @@ hudText = new BitmapText(myFont, false);</pre>
</div>
<!-- EDIT5 SECTION "Displaying Text in the HUD" [2715-3562] -->
<h3><a>Positioning HUD Elements</a></h3>
<h3>Positioning HUD Elements</h3>
<div>
<ul>
<li><div> When positioning <acronym title="Graphical User Interface">GUI</acronym> text and images in 2D, the <strong>bottom left corner</strong> of the screen is <code>(0f,0f)</code>, and the <strong>top right corner</strong> is at <code>(settings.getWidth(),settings.getHeight())</code>.</div>
<li><div> When positioning <abbr title="Graphical User Interface">GUI</abbr> text and images in 2D, the <strong>bottom left corner</strong> of the screen is <code>(0f,0f)</code>, and the <strong>top right corner</strong> is at <code>(settings.getWidth(),settings.getHeight())</code>.</div>
</li>
<li><div> If you have several 2D elements in the <acronym title="Graphical User Interface">GUI</acronym> bucket that overlap, define their depth order by specifing a Z value. For example use <code>pic.move(x, y, -1)</code> to move the picture to the background, or <code>hudText.setLocalTranslation(x,y,1)</code> to move text to the foreground.</div>
<li><div> If you have several 2D elements in the <abbr title="Graphical User Interface">GUI</abbr> bucket that overlap, define their depth order by specifing a Z value. For example use <code>pic.move(x, y, -1)</code> to move the picture to the background, or <code>hudText.setLocalTranslation(x,y,1)</code> to move text to the foreground.</div>
</li>
<li><div> Size and length values in the orthogonal render queue are treated like pixels. A 20*20-wu big quad is rendered 20 pixels wide.</div>
</li>
@ -143,26 +138,24 @@ hudText = new BitmapText(myFont, false);</pre>
</div>
<!-- EDIT6 SECTION "Positioning HUD Elements" [3563-4187] -->
<h3><a>Displaying Geometries in the HUD</a></h3>
<h3>Displaying Geometries in the HUD</h3>
<div>
<p>
It is technically possible to attach Quads and 3D Geometries to the HUD. They show up as flat, static <acronym title="Graphical User Interface">GUI</acronym> elements. The size unit for the guiNode is pixels, not world units. If you attach a Geometry that uses a lit Material, you must add a light to the guiNode.
It is technically possible to attach Quads and 3D Geometries to the HUD. They show up as flat, static <abbr title="Graphical User Interface">GUI</abbr> elements. The size unit for the guiNode is pixels, not world units. If you attach a Geometry that uses a lit Material, you must add a light to the guiNode.
</p>
<p>
<p><div>If you don&#039;t see an attached object in the <acronym title="Graphical User Interface">GUI</acronym>, check it&#039;s position and material (add a light to guiNode). Also verify whether it is not too tiny to be seen. For comparison: A 1 world-unit wide cube is only 1 pixel wide when attached to the guiNode! You may need to scale it bigger.
<p><div>If you don&#039;t see an attached object in the <abbr title="Graphical User Interface">GUI</abbr>, check it&#039;s position and material (add a light to guiNode). Also verify whether it is not too tiny to be seen. For comparison: A 1 world-unit wide cube is only 1 pixel wide when attached to the guiNode! You may need to scale it bigger.
</div></p>
</p>
</div>
<!-- EDIT7 SECTION "Displaying Geometries in the HUD" [4188-4803] -->
<h3><a>Keeping the HUD Up-To-Date</a></h3>
<h3>Keeping the HUD Up-To-Date</h3>
<div>
<p>
Use the update loop to keep the content up-to-date.
</p>
<pre>public void simpleUpdate&#40;float tpf&#41; &#123;
@ -175,25 +168,23 @@ Use the update loop to keep the content up-to-date.
</div>
<!-- EDIT8 SECTION "Keeping the HUD Up-To-Date" [4804-5078] -->
<h2><a>Advanced HUD: Nifty GUI</a></h2>
<h2>Advanced HUD: Nifty GUI</h2>
<div>
<p>
The recommended approach to create HUDs is using <a href="/com/jme3/gde/docs/jme3/advanced/nifty_gui.html">Nifty GUI</a>.
</p>
<ol>
<li><div> Lay out the <acronym title="Graphical User Interface">GUI</acronym> in one or several Nifty <acronym title="Extensible Markup Language">XML</acronym> or Java files. </div>
<li><div> Lay out the <abbr title="Graphical User Interface">GUI</abbr> in one or several Nifty XML or Java files. </div>
</li>
<li><div> Write the controller classes in Java.</div>
</li>
<li><div> Load the <acronym title="Extensible Markup Language">XML</acronym> file with the controller object in your game&#039;s simpleInit() method.</div>
<li><div> Load the XML file with the controller object in your game&#039;s simpleInit() method.</div>
</li>
</ol>
<p>
The advantage of Nifty <acronym title="Graphical User Interface">GUI</acronym> is that it is well integrated into jME and the jMonkeyEngine <acronym title="Software Development Kit">SDK</acronym>, and that it offers all the features that you expect from a professional modern user interface.
The advantage of Nifty <abbr title="Graphical User Interface">GUI</abbr> is that it is well integrated into jME and the jMonkeyEngine SDK, and that it offers all the features that you expect from a professional modern user interface.
</p>
<p>
@ -202,19 +193,17 @@ For HUDs, you basically follow the same instructions as for creating a normal <a
</div>
<!-- EDIT9 SECTION "Advanced HUD: Nifty GUI" [5079-5722] -->
<h2><a>See also</a></h2>
<h2>See also</h2>
<div>
<ul>
<li><div> <a href="/com/jme3/gde/docs/jme3/external/fonts.html">Fonts</a></div>
</li>
</ul>
<div><span>
<a href="/wiki/doku.php/tag:gui?do=showtag&amp;tag=tag%3Agui">gui</a>,
<a href="/wiki/doku.php/tag:display?do=showtag&amp;tag=tag%3Adisplay">display</a>,
<a href="/wiki/doku.php/tag:documentation?do=showtag&amp;tag=tag%3Adocumentation">documentation</a>,
<a href="/wiki/doku.php/tag:hud?do=showtag&amp;tag=tag%3Ahud">hud</a>
</span></div>
<p>
<a href="nbdocs:/com/jme3/gde/docs/jme3:advanced/tag_gui_display_documentation_hud">tag_gui_display_documentation_hud</a>
</p>
</div>
<!-- EDIT10 SECTION "See also" [5723-] -->
<p><em><a href="http://hub.jmonkeyengine.org/wiki/doku.php/jme3:advanced:hud?do=export_xhtmlbody">view online version</a></em></p>
<p><em><a href="http://wiki.jmonkeyengine.org/doku.php/jme3:advanced:hud?do=export_xhtmlbody">view online version</a></em></p>

@ -1,15 +1,13 @@
<h1><a>Input Handling</a></h1>
<h1>Input Handling</h1>
<div>
<p>
Users interact with your jME3 application with different input devices ??? the mouse, the keyboard, or a joystick. To respond to inputs we use the <code>inputManager</code> object in <code>SimpleApplication</code>.
Users interact with your jME3 application with different input devices – the mouse, the keyboard, or a joystick. To respond to inputs we use the <code>inputManager</code> object in <code>SimpleApplication</code>.
</p>
<p>
This is how you add interaction to your game:
</p>
<ol>
<li><div> For each action, choose the trigger(s) (a key or mouse click etc)</div>
@ -26,7 +24,7 @@ This is how you add interaction to your game:
</div>
<!-- EDIT1 SECTION "Input Handling" [1-561] -->
<h2><a>Code Samples</a></h2>
<h2>Code Samples</h2>
<div>
<ul>
<li><div> <object classid="java:org.netbeans.modules.javahelp.BrowserDisplayer"><param name="content" value="http://code.google.com/p/jmonkeyengine/source/browse/trunk/engine/src/test/jme3test/input/TestControls.java"><param name="text" value="<html><u>TestControls.java</u></html>"><param name="textColor" value="blue"></object></div>
@ -37,22 +35,22 @@ This is how you add interaction to your game:
</div>
<!-- EDIT2 SECTION "Code Samples" [562-858] -->
<h2><a>1. Choose Trigger</a></h2>
<h2>1. Choose Trigger</h2>
<div>
<p>
Choose one or several key/mouse events for the interaction. We use <code>KeyTrigger</code>, <code>MouseAxisTrigger</code>, <code>MouseButtonTrigger</code>, <code>JoyAxisTrigger</code> and <code>JoyButtonTrigger</code> constants from the <code>com.jme3.input.controls</code> package.
</p>
<p>
<strong>Note:</strong> The MouseAxis and JoyAxis triggers go along the X axis (right/left) or Y axis (up/down). These Triggers come with extra booleans for the negative half of the axis (left, down). Remember to write code that listens to the negative (true) and positive (false) axis!
</p>
<div><table>
<thead>
<tr>
<th> Trigger </th><th> Code </th>
</tr>
</thead>
<tr>
<td> Mouse button: Left Click </td><td> MouseButtonTrigger(MouseInput.BUTTON_LEFT) </td>
</tr>
@ -81,13 +79,13 @@ Choose one or several key/mouse events for the interaction. We use <code>KeyTrig
<td> Mouse wheel: Down </td><td> MouseAxisTrigger(MouseInput.AXIS_WHEEL,true) </td>
</tr>
<tr>
<td> NumPad: 1, 2, 3, ??? </td><td> KeyTrigger(KeyInput.KEY_NUMPAD1) ??? </td>
<td> NumPad: 1, 2, 3, </td><td> KeyTrigger(KeyInput.KEY_NUMPAD1) </td>
</tr>
<tr>
<td> Keyboard: 1, 2 , 3, ??? </td><td> KeyTrigger(KeyInput.KEY_1) ??? </td>
<td> Keyboard: 1, 2 , 3, </td><td> KeyTrigger(KeyInput.KEY_1) </td>
</tr>
<tr>
<td> Keyboard: A, B, C, ??? </td><td> KeyTrigger(KeyInput.KEY_A) ??? </td>
<td> Keyboard: A, B, C, </td><td> KeyTrigger(KeyInput.KEY_A) </td>
</tr>
<tr>
<td> Keyboard: Spacebar </td><td> KeyTrigger(KeyInput.KEY_SPACE) </td>
@ -97,7 +95,7 @@ Choose one or several key/mouse events for the interaction. We use <code>KeyTrig
KeyTrigger(KeyInput.KEY_LSHIFT) </td>
</tr>
<tr>
<td> Keyboard: F1, F2, ??? </td><td> KeyTrigger(KeyInput.KEY_F1) ??? </td>
<td> Keyboard: F1, F2, </td><td> KeyTrigger(KeyInput.KEY_F1) </td>
</tr>
<tr>
<td> Keyboard: Return, Enter </td><td> KeyTrigger(KeyInput.KEY_RETURN), <br/>
@ -138,19 +136,20 @@ JoyButtonTrigger(0, JoyInput.AXIS_POV_Y) ? </td>
</table></div>
<!-- EDIT4 TABLE [1395-3373] -->
<p>
In your IDE, use code completion to quickly look up Trigger literals. In the jMonkeyEngine <acronym title="Software Development Kit">SDK</acronym> for example, press ctrl-space or ctrl-/ after <code>KeyInput.|</code> to choose from the list of all keys.
In your IDE, use code completion to quickly look up Trigger literals. In the jMonkeyEngine SDK for example, press ctrl-space or ctrl-/ after <code>KeyInput.|</code> to choose from the list of all keys.
</p>
</div>
<!-- EDIT3 SECTION "1. Choose Trigger" [859-3568] -->
<h2><a>2. Remove Default Trigger Mappings</a></h2>
<h2>2. Remove Default Trigger Mappings</h2>
<div>
<pre>inputManager.deleteMapping( SimpleApplication.INPUT_MAPPING_MEMORY );</pre>
<div><table>
<thead>
<tr>
<th>Default Mapping</th><th>Key</th><th>Description</th>
</tr>
</thead>
<tr>
<td>INPUT_MAPPING_HIDE_STATS</td><td>F5</td><td>Hides the statistics in the bottom left.</td>
</tr>
@ -167,11 +166,10 @@ In your IDE, use code completion to quickly look up Trigger literals. In the jMo
<!-- EDIT6 TABLE [3701-4117] -->
</div>
<!-- EDIT5 SECTION "2. Remove Default Trigger Mappings" [3569-4118] -->
<h2><a>3. Add Custom Trigger Mapping</a></h2>
<h2>3. Add Custom Trigger Mapping</h2>
<div>
<p>
When initializing the application, add a Mapping for each Trigger.
</p>
@ -193,11 +191,10 @@ inputManager.addMapping&#40;&quot;Right&quot;, new KeyTrigger&#40;KeyInput.KEY_D
</div>
<!-- EDIT7 SECTION "3. Add Custom Trigger Mapping" [4119-5183] -->
<h2><a>4. Create Listeners</a></h2>
<h2>4. Create Listeners</h2>
<div>
<p>
The jME3 input manager supports two types of event listeners for inputs: AnalogListener and ActionListener. You can use one or both listeners in the same application. Add one or both of the following code snippets to your main SimpleApplication-based class to activate the listeners.
</p>
@ -207,15 +204,14 @@ The jME3 input manager supports two types of event listeners for inputs: AnalogL
</div>
<!-- EDIT8 SECTION "4. Create Listeners" [5184-5657] -->
<h3><a>ActionListener</a></h3>
<h3>ActionListener</h3>
<div>
<p>
<code>com.jme3.input.controls.ActionListener</code>
</p>
<ul>
<li><div> Use for absolute &quot;button pressed or released?&quot;, &quot;on or off?&quot; actions. </div>
<li><div> Use for absolute “button pressed or released?”, “on or off?” actions. </div>
<ul>
<li><div> Examples: Pause/unpause, a rifle or revolver shot, jump, click to select.</div>
</li>
@ -234,7 +230,7 @@ The jME3 input manager supports two types of event listeners for inputs: AnalogL
<li><div> </div>
</li>
</ul>
<pre>private ActionListener actionListener = new ActionListener&#40;&#41; &#123;
<pre>private ActionListener&#40;&#41; &#123;
public void onAction&#40;String name, boolean keyPressed, float tpf&#41; &#123;
/** TODO: test for mapping names and implement actions */
&#125;
@ -242,11 +238,10 @@ The jME3 input manager supports two types of event listeners for inputs: AnalogL
</div>
<!-- EDIT9 SECTION "ActionListener" [5658-6324] -->
<h3><a>AnalogListener</a></h3>
<h3>AnalogListener</h3>
<div>
<p>
<code>com.jme3.input.controls.AnalogListener</code>
</p>
<ul>
@ -275,21 +270,20 @@ The jME3 input manager supports two types of event listeners for inputs: AnalogL
</div>
<!-- EDIT10 SECTION "AnalogListener" [6325-6961] -->
<h2><a>4. Register Mappings to Listeners</a></h2>
<h2>4. Register Mappings to Listeners</h2>
<div>
<p>
To activate the mappings, you must register them to a Listener. Write your registration code after the code block where you have added the mappings to the inputManager.
</p>
<p>
In the following example, you register the &quot;Pause Game&quot; mapping to the <code>actionListener</code> object, because pausing a game is in &quot;either/or&quot; decision.
In the following example, you register the “Pause Game” mapping to the <code>actionListener</code> object, because pausing a game is in “either/or” decision.
</p>
<pre>inputManager.addListener&#40;actionListener, new String&#91;&#93;&#123;&quot;Pause Game&quot;&#125;&#41;;</pre>
<p>
In the following example, you register navigational mappings to the <code>analogListener</code> object, because walking is a continuous action. Players typically keep the key pressed to express continuity, for example when they want to &quot;walk on&quot; or &quot;accelerate&quot;.
In the following example, you register navigational mappings to the <code>analogListener</code> object, because walking is a continuous action. Players typically keep the key pressed to express continuity, for example when they want to “walk on” or “accelerate”.
</p>
<pre>inputManager.addListener&#40;analogListener, new String&#91;&#93;&#123;&quot;Left&quot;, &quot;Right&quot;&#125;&#41;;</pre>
@ -304,11 +298,10 @@ As you see, you can add several listeners in one String array. You can call the
</div>
<!-- EDIT11 SECTION "4. Register Mappings to Listeners" [6962-8210] -->
<h2><a>5. Implement Actions in Listeners</a></h2>
<h2>5. Implement Actions in Listeners</h2>
<div>
<p>
You specify the action to be triggered where it says TODO in the Listener code snippets. Typically, you write a series of if/else conditions, testing for all the mapping names, and then calling the respective action.
</p>
@ -324,14 +317,13 @@ Make use of the distinction between <code>if</code> and <code>else if</code> in
</div>
<!-- EDIT12 SECTION "5. Implement Actions in Listeners" [8211-8946] -->
<h3><a>ActionListener</a></h3>
<h3>ActionListener</h3>
<div>
<p>
In the most common case, you want an action to be triggered once, in the moment when the button or key trigger is released. For example, when the player presses a key to open a door, or clicks to pick up an item. For these cases, use an ActionListener and test for <code>&amp;&amp; !keyPressed</code>, like shown in the following example.
</p>
<pre>private ActionListener actionListener = new ActionListener&#40;&#41; &#123;
<pre>private ActionListener&#40;&#41; &#123;
public void onAction&#40;String name, boolean keyPressed, float tpf&#41; &#123;
&nbsp;
if &#40;name.equals&#40;&quot;Pause Game&quot;&#41; &amp;&amp; !keyPressed&#41; &#123; // test?
@ -345,11 +337,10 @@ In the most common case, you want an action to be triggered once, in the moment
</div>
<!-- EDIT13 SECTION "ActionListener" [8947-9618] -->
<h3><a>AnalogListener</a></h3>
<h3>AnalogListener</h3>
<div>
<p>
The following example shows how you define actions with an AnalogListener. Thiese actions are triggered continuously, as long (intensity <code>value</code>) as the named key or mouse button is down. Use this listeners for semi-automatic weapons and navigational actions.
</p>
<pre>private AnalogListener analogListener = new AnalogListener&#40;&#41; &#123;
@ -366,23 +357,21 @@ The following example shows how you define actions with an AnalogListener. Thies
</div>
<!-- EDIT14 SECTION "AnalogListener" [9619-10199] -->
<h2><a>Let Users Remap Keys</a></h2>
<h2>Let Users Remap Keys</h2>
<div>
<p>
It is likely that your players have different keyboard layouts, are used to &quot;reversed&quot; mouse navigation, or prefer different navigational keys than the ones that you defined. You should create an options screen that lets users customize their mouse/key triggers for your mappings. Replace the trigger literals in the <code>inputManager.addMapping()</code> lines with variables, and load sets of triggers when the game starts.
It is likely that your players have different keyboard layouts, are used to “reversed” mouse navigation, or prefer different navigational keys than the ones that you defined. You should create an options screen that lets users customize their mouse/key triggers for your mappings. Replace the trigger literals in the <code>inputManager.addMapping()</code> lines with variables, and load sets of triggers when the game starts.
</p>
<p>
The abstraction of separating triggers and mappings has the advantage that you can remap triggers easily. Your code only needs to remove and add some trigger mappings. The core of the code (the listeners and actions) remains unchanged.
</p>
<div><span>
<a href="/wiki/doku.php/tag:keyinput?do=showtag&amp;tag=tag%3Akeyinput">keyinput</a>,
<a href="/wiki/doku.php/tag:input?do=showtag&amp;tag=tag%3Ainput">input</a>,
<a href="/wiki/doku.php/tag:documentation?do=showtag&amp;tag=tag%3Adocumentation">documentation</a>
</span></div>
<p>
<a href="nbdocs:/com/jme3/gde/docs/jme3:advanced/tag_keyinput_input_documentation">tag_keyinput_input_documentation</a>
</p>
</div>
<!-- EDIT15 SECTION "Let Users Remap Keys" [10200-] -->
<p><em><a href="http://hub.jmonkeyengine.org/wiki/doku.php/jme3:advanced:input_handling?do=export_xhtmlbody">view online version</a></em></p>
<p><em><a href="http://wiki.jmonkeyengine.org/doku.php/jme3:advanced:input_handling?do=export_xhtmlbody">view online version</a></em></p>

@ -1,9 +1,8 @@
<h1><a>Saving and Loading Materials with .j3m Files</a></h1>
<h1>Saving and Loading Materials with .j3m Files</h1>
<div>
<p>
In the <a href="/com/jme3/gde/docs/jme3/advanced/material_definitions.html">Material Definitions</a> article you learned how to configure <a href="/com/jme3/gde/docs/jme3/advanced/materials_overview.html">Materials</a> programmatically in Java code. If you have certain commonly used Materials that never change, you can clean up the amount of Java code that clutters your init method, by moving material settings into .j3m files. Then later in your code, you only need to call one setter instead of several to apply the material.
</p>
@ -13,7 +12,7 @@ If you want to colorize simple shapes (one texture all around), then .j3m are th
</div>
<!-- EDIT1 SECTION "Saving and Loading Materials with .j3m Files" [1-753] -->
<h2><a>Writing the .j3m File</a></h2>
<h2>Writing the .j3m File</h2>
<div>
<ol>
<li><div> For every Material, create a file and give it a name that describes it: e.g. <code>SimpleBump.j3m</code></div>
@ -35,7 +34,6 @@ If you want to colorize simple shapes (one texture all around), then .j3m are th
</ol>
<p>
How to this file is structured:
</p>
<ol>
@ -60,40 +58,36 @@ How to this file is structured:
</ol>
<p>
<p><div>In the jMonkeyEngine <acronym title="Software Development Kit">SDK</acronym>, use File???New File???Material???Empty Material File to create .j3m files. You can edit .j3m files directly in the <acronym title="Software Development Kit">SDK</acronym>. On the other hand, they are plain text files, so you can also create them in any plain text editor.
<p><div>In the jMonkeyEngine SDK, use File→New File→Material→Empty Material File to create .j3m files. You can edit .j3m files directly in the SDK. On the other hand, they are plain text files, so you can also create them in any plain text editor.
</div></p>
</p>
</div>
<!-- EDIT2 SECTION "Writing the .j3m File" [754-2349] -->
<h2><a>How to Use .j3m Materials</a></h2>
<h2>How to Use .j3m Materials</h2>
<div>
<p>
This is how you use the prepared .j3m Material on a Spatial. Since you have saved the .j3m file to your project&#039;s Assets directory, the .j3m path is relative to <code>MyGame/src/assets/???</code>.
This is how you use the prepared .j3m Material on a Spatial. Since you have saved the .j3m file to your project&#039;s Assets directory, the .j3m path is relative to <code>MyGame/src/assets/…</code>.
</p>
<pre>myGeometry.setMaterial&#40;assetManager.loadMaterial&#40;&quot;Materials/SimpleBump.j3m&quot;&#41;&#41;;</pre>
<p>
<strong>Tip:</strong> In the jMonkeyEngine <acronym title="Software Development Kit">SDK</acronym>, open Windows&gt;Palette and drag the <code>JME Material: Set J3M</code> snippet into your code.
<strong>Tip:</strong> In the jMonkeyEngine SDK, open Windows&gt;Palette and drag the <code>JME Material: Set J3M</code> snippet into your code.
</p>
</div>
<!-- EDIT3 SECTION "How to Use .j3m Materials" [2350-2795] -->
<h2><a>Syntax Reference for .j3m Files</a></h2>
<h2>Syntax Reference for .j3m Files</h2>
<div>
</div>
<!-- EDIT4 SECTION "Syntax Reference for .j3m Files" [2796-2840] -->
<h3><a>Paths</a></h3>
<h3>Paths</h3>
<div>
<p>
Make sure to get the paths to the textures (.png, .jpg) and material definitions (.j3md) right.
</p>
<ul>
<li><div> The paths to the built-in .j3md files are relative to jME3&#039;s Core Data directory. Just copy the path stated in the <a href="/com/jme3/gde/docs/jme3/advanced/materials_overview.html">Material</a> table. <br/>
@ -106,19 +100,19 @@ Make sure to get the paths to the textures (.png, .jpg) and material definitions
</div>
<!-- EDIT5 SECTION "Paths" [2841-3417] -->
<h3><a>Data Types</a></h3>
<h3>Data Types</h3>
<div>
<p>
All data types (except Color) are specified in com.jme3.shader.VarType.
&quot;Color&quot; is specified as Vector4 in J3MLoader.java.
“Color” is specified as Vector4 in J3MLoader.java.
</p>
<div><table>
<thead>
<tr>
<th>Name</th><th>jME Java class</th><th>.j3m file syntax</th>
</tr>
</thead>
<tr>
<td> Float</td><td> (basic Java type) </td><td> a float (e.g. 0.72) , no comma or parentheses </td>
</tr>
@ -183,7 +177,7 @@ All data types (except Color) are specified in com.jme3.shader.VarType.
<!-- EDIT7 TABLE [3565-4979] -->
</div>
<!-- EDIT6 SECTION "Data Types" [3418-4981] -->
<h3><a>Flip and Repeat Syntax</a></h3>
<h3>Flip and Repeat Syntax</h3>
<div>
<ul>
<li><div> A texture can be flipped using the following syntax <code>NormalMap: Flip Textures/bump_rock_normal.png</code></div>
@ -196,26 +190,26 @@ All data types (except Color) are specified in com.jme3.shader.VarType.
</div>
<!-- EDIT8 SECTION "Flip and Repeat Syntax" [4982-5325] -->
<h3><a>Syntax for Additional Render States</a></h3>
<h3>Syntax for Additional Render States</h3>
<div>
<ul>
<li><div> A Boolean can be &quot;On&quot; or &quot;Off&quot;</div>
<li><div> A Boolean can be “On” or “Off”</div>
</li>
<li><div> Float is &quot;123.0&quot; etc</div>
<li><div> Float is “123.0” etc</div>
</li>
<li><div> Enum - values depend on the enum</div>
</li>
</ul>
<p>
See the <object classid="java:org.netbeans.modules.javahelp.BrowserDisplayer"><param name="content" value="http://jmonkeyengine.org/javadoc/com/jme3/material/RenderState.html"><param name="text" value="<html><u>RenderState</u></html>"><param name="textColor" value="blue"></object> javadoc for a detailed explanation of render states.
</p>
<div><table>
<thead>
<tr>
<th>Name</th><th>Type</th><th>Purpose</th>
</tr>
</thead>
<tr>
<td> <object classid="java:org.netbeans.modules.javahelp.BrowserDisplayer"><param name="content" value="http://jmonkeyengine.org/javadoc/com/jme3/material/RenderState.html#setWireframe(boolean)"><param name="text" value="<html><u>Wireframe</u></html>"><param name="textColor" value="blue"></object> </td><td>(Boolean)</td><td> Enable wireframe rendering mode </td>
</tr>
@ -247,12 +241,12 @@ See the <object classid="java:org.netbeans.modules.javahelp.BrowserDisplayer"><p
<!-- EDIT10 TABLE [5617-7185] -->
</div>
<!-- EDIT9 SECTION "Syntax for Additional Render States" [5326-7187] -->
<h2><a>Examples</a></h2>
<h2>Examples</h2>
<div>
</div>
<!-- EDIT11 SECTION "Examples" [7188-7209] -->
<h3><a>Example 1: Shiny</a></h3>
<h3>Example 1: Shiny</h3>
<div>
<pre>Spatial signpost = &#40;Spatial&#41; assetManager.loadAsset&#40;
new OgreMeshKey&#40;&quot;Models/Sign Post/Sign Post.mesh.xml&quot;, null&#41;&#41;;
@ -278,12 +272,12 @@ The file <code>assets/Models/Sign Post/Sign Post.j3m</code> contains:
}</pre>
<p>
The <acronym title="Joint Photographics Experts Group">JPG</acronym> files are in the same directory, <code>assets/Models/Sign Post/???</code>.
The JPG files are in the same directory, <code>assets/Models/Sign Post/</code>.
</p>
</div>
<!-- EDIT12 SECTION "Example 1: Shiny" [7210-8142] -->
<h3><a>Example 2: Repeating Texture</a></h3>
<h3>Example 2: Repeating Texture</h3>
<div>
<pre>Material mat = assetManager.loadMaterial&#40;
&quot;Textures/Terrain/Pond/Pond.j3m&quot;&#41;;
@ -303,16 +297,15 @@ The file <code>assets/Textures/Terrain/Pond/Pond.j3m</code> contains:
}</pre>
<p>
The <acronym title="Portable Network Graphics">PNG</acronym> files are in the same directory, <code>assets/Textures/Terrain/Pond/</code>
The PNG files are in the same directory, <code>assets/Textures/Terrain/Pond/</code>
</p>
</div>
<!-- EDIT13 SECTION "Example 2: Repeating Texture" [8143-8810] -->
<h3><a>Example 3: Transparent</a></h3>
<h3>Example 3: Transparent</h3>
<div>
<p>
The file <code>assets/Models/Tree/Leaves.j3m</code> contains:
</p>
<pre>Material Leaves : Common/MatDefs/Light/Lighting.j3md {
@ -337,26 +330,22 @@ The file <code>assets/Models/Tree/Leaves.j3m</code> contains:
}</pre>
<p>
The <acronym title="Portable Network Graphics">PNG</acronym> file is in the same directory, <code>assets/Models/Tree/???</code>
The PNG file is in the same directory, <code>assets/Models/Tree/</code>
</p>
</div>
<!-- EDIT14 SECTION "Example 3: Transparent" [8811-9444] -->
<h2><a>Related Links</a></h2>
<h2>Related Links</h2>
<div>
<ul>
<li><div> <a href="/com/jme3/gde/docs/jme3/advanced/material_specification.html">Developer specification of the jME3 material system (.j3md,.j3m)</a></div>
</li>
</ul>
<div><span>
<a href="/wiki/doku.php/tag:material?do=showtag&amp;tag=tag%3Amaterial">material</a>,
<a href="/wiki/doku.php/tag:texture?do=showtag&amp;tag=tag%3Atexture">texture</a>,
<a href="/wiki/doku.php/tag:file?do=showtag&amp;tag=tag%3Afile">file</a>,
<a href="/wiki/doku.php/tag:sdk?do=showtag&amp;tag=tag%3Asdk">sdk</a>,
<a href="/wiki/doku.php/tag:wireframe?do=showtag&amp;tag=tag%3Awireframe">wireframe</a>,
<a href="/wiki/doku.php/tag:documentation?do=showtag&amp;tag=tag%3Adocumentation">documentation</a>
</span></div>
<p>
<a href="nbdocs:/com/jme3/gde/docs/jme3:advanced/tag_material_texture_file_sdk_wireframe_documentation">tag_material_texture_file_sdk_wireframe_documentation</a>
</p>
</div>
<!-- EDIT15 SECTION "Related Links" [9445-] -->
<p><em><a href="http://hub.jmonkeyengine.org/wiki/doku.php/jme3:advanced:j3m_material_files?do=export_xhtmlbody">view online version</a></em></p>
<p><em><a href="http://wiki.jmonkeyengine.org/doku.php/jme3:advanced:j3m_material_files?do=export_xhtmlbody">view online version</a></em></p>

@ -1,33 +1,31 @@
<h1><a>JME3 and Shaders</a></h1>
<h1>JME3 and Shaders</h1>
<div>
<p>
<br/>
</p>
</div>
<!-- EDIT1 SECTION "JME3 and Shaders" [1-36] -->
<h1><a>Shaders Basics</a></h1>
<h1>Shaders Basics</h1>
<div>
<p>
Shaders are sets of instructions that are executed on the GPU. They are used to take advantage of hardware acceleration available on the GPU for rendering purposes.<br/>
This paper only covers Vertex and Fragment shaders because they are the only ones supported by JME3 for the moment. But be aware that there are some other types of shaders (geometry, tessellation,???).<br/>
This paper only covers Vertex and Fragment shaders because they are the only ones supported by JME3 for the moment. But be aware that there are some other types of shaders (geometry, tessellation,).<br/>
There are multiple frequently used languages that you may encounter to code shaders but as JME3 is based on OpenGL, shaders in JME use GLSL and any example in this paper will be written in GLSL.<br/>
<br/>
</p>
</div>
<!-- EDIT2 SECTION "Shaders Basics" [37-634] -->
<h3><a>How Does it work?</a></h3>
<h3>How Does it work?</h3>
<div>
<p>
@ -42,12 +40,11 @@ This is a very simplified graphic to describe the call stack: <br/>
The main program sends mesh data to the vertex shader (vertex position in object space, normals, tangents, etc..). The vertex shader computes the screen position of the vertex and sends it to the Fragment shader. The fragment shader computes the color, and the result is displayed on screen or in a texture.
<br/>
</p>
</div>
<!-- EDIT3 SECTION "How Does it work?" [635-1483] -->
<h3><a>Variables scope</a></h3>
<h3>Variables scope</h3>
<div>
<p>
@ -67,12 +64,11 @@ There is a large panel of variable types to be used, for more information about
<br/>
</p>
</div>
<!-- EDIT4 SECTION "Variables scope" [1484-2149] -->
<h3><a>Spaces and Matrices</a></h3>
<h3>Spaces and Matrices</h3>
<div>
<p>
@ -84,12 +80,11 @@ The engine passes the object space coordinates to the vertex shader. We need to
<br/>
</p>
</div>
<!-- EDIT5 SECTION "Spaces and Matrices" [2150-2694] -->
<h3><a>Simple example : rendering a solid color on an object</a></h3>
<h3>Simple example : rendering a solid color on an object</h3>
<div>
<p>
@ -97,7 +92,6 @@ Here is the simplest application to shaders, rendering a solid color.<br/>
Vertex Shader : <br/>
</p>
<pre>//the global uniform World view projection matrix
//(more on global uniforms below)
@ -116,10 +110,8 @@ void main&#40;&#41;&#123;
&#125;</pre>
<p>
Fragment Shader : <br/>
</p>
<pre>void main&#40;&#41;&#123;
//returning the color of the pixel (here solid blue)
@ -129,28 +121,25 @@ Fragment Shader : <br/>
&#125;</pre>
<p>
For example applying this shader to a sphere would render a solid blue sphere on screen.<br/>
<br/>
</p>
</div>
<!-- EDIT6 SECTION "Simple example : rendering a solid color on an object" [2695-3932] -->
<h1><a>How to use shaders in JME3</a></h1>
<h1>How to use shaders in JME3</h1>
<div>
<p>
You probably heard that JME3 is ???shader oriented???, but what does that mean?<br/>
You probably heard that JME3 is “shader oriented”, but what does that mean?<br/>
Usually to use shaders you must create what is called a program. This program specify the vertex shader and the fragment shader to use.<br/>
JME3 encloses this in the material system. Every material in JME3 uses shaders.<br/>
For example let???s have a look at the SolidColor.j3md file : <br/>
For example let’s have a look at the SolidColor.j3md file : <br/>
</p>
<pre>MaterialDef Solid Color &#123;
@ -175,23 +164,21 @@ For example let???s have a look at the SolidColor.j3md file : <br/>
&#125;</pre>
<p>
For more information on JME3 material system, i suggest you read this <object classid="java:org.netbeans.modules.javahelp.BrowserDisplayer"><param name="content" value="http://jmonkeyengine.org/groups/development-discussion-jme3/forum/topic/jmonkeyengine3-material-system-full-explanation"><param name="text" value="<html><u>topic</u></html>"><param name="textColor" value="blue"></object>.<br/>
<br/>
</p>
</div>
<!-- EDIT7 SECTION "How to use shaders in JME3" [3933-5176] -->
<h3><a>JME3 Global uniforms</a></h3>
<h3>JME3 Global uniforms</h3>
<div>
<p>
JME3 can expose pre-computed global uniforms to your shaders. You must specify the one that are required for your shader in the WorldParameters section of the material definition file (.j3md).<br/>
Note that in the shader the uniform names will be prefixed by a ???g_???.<br/>
Note that in the shader the uniform names will be prefixed by a “g_”.<br/>
In the example above, WorldViewProjectionMatrix is declared as uniform mat4 g_WorldViewProjectionMatrix in the shader.<br/>
@ -199,12 +186,11 @@ The complete list of global uniforms that can be used in JME3 can be found <obje
<br/>
</p>
</div>
<!-- EDIT8 SECTION "JME3 Global uniforms" [5177-5798] -->
<h3><a>JME3 Lighting Global uniforms</a></h3>
<h3>JME3 Lighting Global uniforms</h3>
<div>
<p>
@ -225,7 +211,7 @@ JME3 uses some global uniforms for lighting :
</li>
<li><div> use for PointLight : x,y,z contain the world position of the light, the w component contains 1/lightRadius</div>
</li>
<li><div> use for DirectionalLight : strangely enough it&#039;s used for the direction of the light???this might change though. The fourth component contains -1 and it&#039;s used in the lighting shader to know if it&#039;s a directionalLight or not.</div>
<li><div> use for DirectionalLight : strangely enough it&#039;s used for the direction of the lightthis might change though. The fourth component contains -1 and it&#039;s used in the lighting shader to know if it&#039;s a directionalLight or not.</div>
</li>
</ul>
</li>
@ -234,15 +220,14 @@ JME3 uses some global uniforms for lighting :
</ul>
<p>
These uniforms are passed to the shader without having to declare them in the j3md file, but you have to specify in the technique definition &quot; LightMode MultiPass&quot; see lighting.j3md for more information.
These uniforms are passed to the shader without having to declare them in the j3md file, but you have to specify in the technique definition “ LightMode MultiPass” see lighting.j3md for more information.
<br/>
</p>
</div>
<!-- EDIT9 SECTION "JME3 Lighting Global uniforms" [5799-6889] -->
<h3><a>JME3 attributes</a></h3>
<h3>JME3 attributes</h3>
<div>
<p>
@ -250,7 +235,7 @@ Those are different attributes that are always passed to your shader.<br/>
You can find a complete list of those attribute in the Type enum of the VertexBuffer <object classid="java:org.netbeans.modules.javahelp.BrowserDisplayer"><param name="content" value="http://code.google.com/p/jmonkeyengine/source/browse/trunk/engine/src/core/com/jme3/scene/VertexBuffer.java"><param name="text" value="<html><u>here</u></html>"><param name="textColor" value="blue"></object>.<br/>
Note that in the shader the attributes names will be prefixed by an ???in???.<br/>
Note that in the shader the attributes names will be prefixed by an “in”.<br/>
<br/>
@ -259,14 +244,13 @@ When the enumeration lists some usual types for each attribute (for example texC
</div>
<!-- EDIT10 SECTION "JME3 attributes" [6890-7701] -->
<h3><a>User&#039;s uniforms</a></h3>
<h3>User&#039;s uniforms</h3>
<div>
<p>
At some point when making your own shader you&#039;ll need to pass your own uniforms<br/>
Any uniform has to be declared in the material definition file (.j3md) in the &quot;MaterialParameters&quot; section.<br/>
Any uniform has to be declared in the material definition file (.j3md) in the “MaterialParameters” section.<br/>
</p>
<pre> MaterialParameters &#123;
@ -279,7 +263,6 @@ You can also pass some define to your vertex/fragment programs to know if an uni
You simply add it in the Defines section of your Technique in the definition file. <br/>
</p>
<pre> Defines &#123;
COLORMAP : ColorMap
@ -298,7 +281,6 @@ If no value is set for that parameter, the define is not declared in the shader.
Those material parameters will be sent from the engine to the shader as follows,
there are setXXXX methods for any type of uniform you want to pass.<br/>
</p>
<pre> material.setColor&#40;&quot;Color&quot;, new ColorRGBA&#40;1.0f, 0.0f, 0.0f, 1.0f&#41;; // red color
material.setTexture&#40;&quot;ColorMap&quot;, myTexture&#41;; // bind myTexture for that sampler uniform</pre>
@ -306,8 +288,7 @@ there are setXXXX methods for any type of uniform you want to pass.<br/>
<p>
To use this uniform in the shader, you need to declare it in the .frag or .vert files (depending on where you need it).
You can make use of the defines here and later in the code:
<strong>Note that the &quot;m_&quot; prefix specifies that the uniform is a material parameter.</strong><br/>
<strong>Note that the “m_” prefix specifies that the uniform is a material parameter.</strong><br/>
</p>
<pre> uniform vec4 m_Color;
@ -321,7 +302,7 @@ The uniforms will be populated at runtime with the value you sent.
</div>
<!-- EDIT11 SECTION "User's uniforms" [7702-9304] -->
<h3><a>Example: Adding Color Keying to the Lighting.j3md Material Definition</a></h3>
<h3>Example: Adding Color Keying to the Lighting.j3md Material Definition</h3>
<div>
<p>
@ -340,7 +321,6 @@ to blend color on this texture: <object classid="java:org.netbeans.modules.javah
<br/>
We need to pass 2 new parameters to the Lighting.j3md definition, MaterialParameters section :
</p>
<pre>// Keying Map
Texture2D KeyMap
@ -350,13 +330,11 @@ Color KeyColor</pre>
<p>
Below, add a new Define in the main Technique section:
</p>
<pre>KEYMAP : KeyMap</pre>
<p>
In the Lighting.frag file, define the new uniforms:
</p>
<pre>#ifdef KEYMAP
uniform sampler2D m_KeyMap;
@ -366,7 +344,6 @@ In the Lighting.frag file, define the new uniforms:
<p>
Further, when obtaining the diffuseColor from the DiffuseMap texture, check
if we need to blend it:
</p>
<pre> #ifdef KEYMAP
vec4 keyColor = texture2D&#40;m_KeyMap, newTexCoord&#41;;
@ -385,7 +362,7 @@ A result preview can be seen here: <object classid="java:org.netbeans.modules.ja
</div>
<!-- EDIT12 SECTION "Example: Adding Color Keying to the Lighting.j3md Material Definition" [9305-10795] -->
<h3><a>Step by step</a></h3>
<h3>Step by step</h3>
<div>
<ul>
<li><div> Create a vertex shader (.vert) file</div>
@ -396,37 +373,37 @@ A result preview can be seen here: <object classid="java:org.netbeans.modules.ja
</li>
<li><div> In your initSimpleApplication, create a material using this definition, apply it to a geometry</div>
</li>
<li><div> That???s it!!</div>
<li><div> Thats it!!</div>
</li>
</ul>
<pre> // A cube
Box box= new Box&#40;Vector3f.ZERO, 1f,1f,1f&#41;;
Box&#40;Vector3f.ZERO, 1f,1f,1f&#41;;
Geometry cube = new Geometry&#40;&quot;box&quot;, box&#41;;
Material mat = new Material&#40;assetManager,&quot;Path/To/My/materialDef.j3md&quot;&#41;;
cube.setMaterial&#40;mat&#41;;
rootNode.attachChild&#40;cube&#41;;</pre>
<p>
<br/>
</p>
</div>
<!-- EDIT13 SECTION "Step by step" [10796-11415] -->
<h3><a>JME3 and OpenGL 3 &amp; 4 compatibility</a></h3>
<h3>JME3 and OpenGL 3 &amp; 4 compatibility</h3>
<div>
<p>
GLSL 1.0 to 1.2 comes with built in attributes and uniforms (ie, gl_Vertex, gl_ModelViewMatrix, etc???).<br/>
GLSL 1.0 to 1.2 comes with built in attributes and uniforms (ie, gl_Vertex, gl_ModelViewMatrix, etc).<br/>
Those attributes are deprecated since GLSL 1.3 (opengl 3), hence JME3 global uniforms and attributes. Here is a list of deprecated attributes and their equivalent in JME3<br/>
</p>
<div><table>
<thead>
<tr>
<th>GLSL 1.2 attributes</th><th>JME3 equivalent</th>
</tr>
</thead>
<tr>
<td>gl_Vertex </td><td>inPosition</td>
</tr>
@ -455,7 +432,7 @@ Those attributes are deprecated since GLSL 1.3 (opengl 3), hence JME3 global uni
<!-- EDIT15 TABLE [11741-12052] -->
</div>
<!-- EDIT14 SECTION "JME3 and OpenGL 3 & 4 compatibility" [11416-12052] -->
<h3><a>Useful links</a></h3>
<h3>Useful links</h3>
<div>
<p>
@ -464,4 +441,4 @@ Those attributes are deprecated since GLSL 1.3 (opengl 3), hence JME3 global uni
</div>
<!-- EDIT16 SECTION "Useful links" [12053-] -->
<p><em><a href="http://hub.jmonkeyengine.org/wiki/doku.php/jme3:advanced:jme3_shaders?do=export_xhtmlbody">view online version</a></em></p>
<p><em><a href="http://wiki.jmonkeyengine.org/doku.php/jme3:advanced:jme3_shaders?do=export_xhtmlbody">view online version</a></em></p>

Binary file not shown.

Before

Width:  |  Height:  |  Size: 23 KiB

After

Width:  |  Height:  |  Size: 293 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 31 KiB

After

Width:  |  Height:  |  Size: 84 KiB

@ -1,9 +1,8 @@
<h1><a>Light and Shadow</a></h1>
<h1>Light and Shadow</h1>
<div>
<p>
<img src="nbdocs:/com/jme3/gde/docs/jme3/advanced/shading-ani.gif">
</p>
@ -18,18 +17,16 @@ Light and Shadow are two separate things in 3D engines, although we percieve the
</ul>
<p>
<p><div>A light source with a direction or location is required for all Geometries with Lighting.j3md-based Materials. An ambient light is not sufficient. In a scene with no appropriate light sources, Geometries with Lighting.j3md-based Materials do not render. Only Geometries with Unshaded.j3md-based Materials are visible independent of any light sources.
</div></p>
</p>
</div>
<!-- EDIT1 SECTION "Light and Shadow" [1-1017] -->
<h2><a>Light Sources and Colors</a></h2>
<h2>Light Sources and Colors</h2>
<div>
<p>
<img src="nbdocs:/com/jme3/gde/docs/jme3/advanced/light-sources.png">
</p>
@ -38,7 +35,7 @@ You can add several types of light sources to a scene using <code>rootNode.addLi
</p>
<p>
The available light sources in <code>com.???jme3.???light</code> are:
The available light sources in <code>com.jme3.light</code> are:
</p>
<ul>
<li><div> SpotLight </div>
@ -52,7 +49,6 @@ The available light sources in <code>com.???jme3.???light</code> are:
</ul>
<p>
You control the color and intensity of each light source. Typically you set the color to white (<code>new ColorRGBA(1.0f,1.0f,1.0f,1.0f)</code> or <code>ColorRGBA.White</code>), which makes all scene elements appear in their natural color.
</p>
@ -66,11 +62,10 @@ You can get a list of all lights added to a Spatial by calling <code>getWorldLig
</div>
<!-- EDIT2 SECTION "Light Sources and Colors" [1018-2059] -->
<h3><a>PointLight</a></h3>
<h3>PointLight</h3>
<div>
<p>
<img src="nbdocs:/com/jme3/gde/docs/jme3/advanced/elephant-pointlights.png">
</p>
@ -89,16 +84,15 @@ rootNode.addLight&#40;lamp_light&#41;;</pre>
</div>
<!-- EDIT3 SECTION "PointLight" [2060-2750] -->
<h3><a>DirectionalLight</a></h3>
<h3>DirectionalLight</h3>
<div>
<p>
<img src="nbdocs:/com/jme3/gde/docs/jme3/advanced/house-directionallight.png">
</p>
<p>
A DirectionalLight has no position, only a direction. It sends out parallel beams of light and is considered &quot;infinitely&quot; far away. You typically have one directional light per scene. A DirectionalLight can be used together with shadows.
A DirectionalLight has no position, only a direction. It sends out parallel beams of light and is considered “infinitely” far away. You typically have one directional light per scene. A DirectionalLight can be used together with shadows.
</p>
<p>
@ -111,11 +105,10 @@ rootNode.addLight&#40;sun&#41;;</pre>
</div>
<!-- EDIT4 SECTION "DirectionalLight" [2751-3355] -->
<h3><a>SpotLight</a></h3>
<h3>SpotLight</h3>
<div>
<p>
<img src="nbdocs:/com/jme3/gde/docs/jme3/advanced/spotlight.png">
</p>
@ -136,16 +129,15 @@ spot.setDirection&#40;cam.getDirection&#40;&#41;&#41;; // shine forw
rootNode.addLight&#40;spot&#41;;</pre>
<p>
If you want the spotlight to follow the flycam, repeat the setDirection(???) and setPosition(???) calls in the update loop, and kee syncing them with the camera position and direction.
If you want the spotlight to follow the flycam, repeat the setDirection(…) and setPosition(…) calls in the update loop, and kee syncing them with the camera position and direction.
</p>
</div>
<!-- EDIT5 SECTION "SpotLight" [3356-4490] -->
<h3><a>AmbientLight</a></h3>
<h3>AmbientLight</h3>
<div>
<p>
An AmbientLight simply influences the brightness and color of the scene globally. It has no direction and no location and shines equally everywhere. An AmbientLight does not cast any shadows, and it lights all sides of Geometries evenly, which makes 3D objects look unnaturally flat; this is why you typically do not use an AmbientLight alone without one of the other lights.
</p>
@ -164,11 +156,10 @@ Example: <code>mylight.setColor(ColorRGBA.White.mult(1.3f));</code>
</div>
<!-- EDIT6 SECTION "AmbientLight" [4491-5313] -->
<h2><a>Light Follows Spatial</a></h2>
<h2>Light Follows Spatial</h2>
<div>
<p>
You can use a <code>com.jme3.scene.control.LightControl</code> to make a SpotLight or PointLight follow a Spatial. This can be used for a flashlight being carried by a character, or for car headlights, or an aircraft&#039;s spotlight, etc.
</p>
<pre>PointLight myLight = new PointLight&#40;&#41;;
@ -182,11 +173,10 @@ Obviously, this does not apply to AmbientLights, which have no position.
</div>
<!-- EDIT7 SECTION "Light Follows Spatial" [5314-5880] -->
<h2><a>BasicShadowRenderer (deprecated)</a></h2>
<h2>BasicShadowRenderer (deprecated)</h2>
<div>
<p>
Full code sample
</p>
<ul>
@ -196,11 +186,10 @@ Full code sample
</div>
<!-- EDIT8 SECTION "BasicShadowRenderer (deprecated)" [5881-6073] -->
<h2><a>Casting Shadows</a></h2>
<h2>Casting Shadows</h2>
<div>
<p>
For each type of non-ambient light source, JME3 implements two ways to simulate geometries casting shadows on other geometries:
</p>
<ul>
@ -210,9 +199,11 @@ For each type of non-ambient light source, JME3 implements two ways to simulate
</li>
</ul>
<div><table>
<thead>
<tr>
<th> light source class </th><th> shadow renderer class </th><th> shadow filter class </th>
</tr>
</thead>
<tr>
<td> DirectionalLight </td><td> DirectionalLightShadowRenderer </td><td> DirectionalLightShadowFilter </td>
</tr>
@ -228,7 +219,6 @@ For each type of non-ambient light source, JME3 implements two ways to simulate
</table></div>
<!-- EDIT10 TABLE [6369-6708] -->
<p>
You only need one shadow simulation per light source: if you use shadow rendering, you won&#039;t need a shadow filter and vice versa. Which way is more efficient depends partly on the complexity of your scene. All six shadow simulation classes have similar interfaces, so once you know how to use one, you can easily figure out the rest.
</p>
@ -255,9 +245,7 @@ Here&#039;s a sample application which demonstrates both DirectionalLightShadowR
</ul>
<p>
Here is the key code fragment:
</p>
<pre> DirectionalLight sun = new DirectionalLight&#40;&#41;;
sun.setColor&#40;ColorRGBA.White&#41;;
@ -280,26 +268,24 @@ Here is the key code fragment:
<p>
Constructor arguments:
* your AssetManager object
* size of the rendered shadow maps, in pixels per side (512, 1024, 2048, etc???)
* size of the rendered shadow maps, in pixels per side (512, 1024, 2048, etc)
* the number of shadow maps rendered (more shadow maps = better quality, but slower)
</p>
<p>
Properties you can set:
* setDirection(Vector3f) ??? the direction of the light
* setLambda(0.65f) ??? to reduce the split size
* setShadowIntensity(0.7f) ??? shadow darkness (1=black, 0=invisible)
* setShadowZextend(float) ??? distance from camera to which shadows will be computed
* setDirection(Vector3f) – the direction of the light
* setLambda(0.65f) – to reduce the split size
* setShadowIntensity(0.7f) – shadow darkness (1=black, 0=invisible)
* setShadowZextend(float) – distance from camera to which shadows will be computed
</p>
</div>
<!-- EDIT9 SECTION "Casting Shadows" [6074-9825] -->
<h2><a>Parallel-Split Shadow Map (deprecated)</a></h2>
<h2>Parallel-Split Shadow Map (deprecated)</h2>
<div>
<p>
Full sample code
</p>
<ul>
@ -308,7 +294,6 @@ Full sample code
</ul>
<p>
<img src="nbdocs:/com/jme3/gde/docs/jme3/advanced/shadow.png">
</p>
<pre>private PssmShadowRenderer pssmRenderer;
@ -321,24 +306,22 @@ public void simpleInitApp&#40;&#41; &#123;
</div>
<!-- EDIT11 SECTION "Parallel-Split Shadow Map (deprecated)" [9826-10415] -->
<h2><a>Screen Space Ambient Occlusion</a></h2>
<h2>Screen Space Ambient Occlusion</h2>
<div>
<p>
Full sample code
</p>
<ul>
<li><div> <object classid="java:org.netbeans.modules.javahelp.BrowserDisplayer"><param name="content" value="http://code.google.com/p/jmonkeyengine/source/browse/trunk/engine/src/test/jme3test/post/TestSSAO.java"><param name="text" value="<html><u>jme3/src/test/jme3test/post/TestSSAO.java</u></html>"><param name="textColor" value="blue"></object> ??? Screen-Space Ambient Occlusion shadows</div>
<li><div> <object classid="java:org.netbeans.modules.javahelp.BrowserDisplayer"><param name="content" value="http://code.google.com/p/jmonkeyengine/source/browse/trunk/engine/src/test/jme3test/post/TestSSAO.java"><param name="text" value="<html><u>jme3/src/test/jme3test/post/TestSSAO.java</u></html>"><param name="textColor" value="blue"></object> Screen-Space Ambient Occlusion shadows</div>
</li>
<li><div> <object classid="java:org.netbeans.modules.javahelp.BrowserDisplayer"><param name="content" value="http://code.google.com/p/jmonkeyengine/source/browse/trunk/engine/src/test/jme3test/post/TestTransparentSSAO.java"><param name="text" value="<html><u>jme3/src/test/jme3test/post/TestTransparentSSAO.java</u></html>"><param name="textColor" value="blue"></object> ??? Screen-Space Ambient Occlusion shadows plus transparancy</div>
<li><div> <object classid="java:org.netbeans.modules.javahelp.BrowserDisplayer"><param name="content" value="http://code.google.com/p/jmonkeyengine/source/browse/trunk/engine/src/test/jme3test/post/TestTransparentSSAO.java"><param name="text" value="<html><u>jme3/src/test/jme3test/post/TestTransparentSSAO.java</u></html>"><param name="textColor" value="blue"></object> Screen-Space Ambient Occlusion shadows plus transparancy</div>
</li>
<li><div> <object classid="java:org.netbeans.modules.javahelp.BrowserDisplayer"><param name="content" value="http://hub.jmonkeyengine.org/2010/08/screen-space-ambient-occlusion-for-jmonkeyengine-3-0/"><param name="text" value="<html><u>Screen Space Ambient Occlusion for jMonkeyEngine (article)</u></html>"><param name="textColor" value="blue"></object></div>
</li>
</ul>
<p>
Ambient Occlusion refers to the shadows which nearby objects cast on each other under an ambient lighting. Screen Space Ambient Occlusion (SSAO) approximates how light radiates in real life.
</p>
@ -352,9 +335,8 @@ viewPort.addProcessor&#40;fpp&#41;;</pre>
<p>
<img src="nbdocs:/com/jme3/gde/docs/jme3/advanced/shading-textured-ani.gif">
</p>
</div>
<!-- EDIT12 SECTION "Screen Space Ambient Occlusion" [10416-] -->
<p><em><a href="http://hub.jmonkeyengine.org/wiki/doku.php/jme3:advanced:light_and_shadow?do=export_xhtmlbody">view online version</a></em></p>
<p><em><a href="http://wiki.jmonkeyengine.org/doku.php/jme3:advanced:light_and_shadow?do=export_xhtmlbody">view online version</a></em></p>

@ -1,9 +1,8 @@
<h3><a>Nifty Loading Screen (Progress Bar)</a></h3>
<h3>Nifty Loading Screen (Progress Bar)</h3>
<div>
<p>
There is a good tutorial about creating a nifty progress bar here:
<object classid="java:org.netbeans.modules.javahelp.BrowserDisplayer"><param name="content" value="http://sourceforge.net/apps/mediawiki/nifty-gui/index.php?title=Create_your_own_Control_%28A_Nifty_Progressbar%29"><param name="text" value="<html><u>http://sourceforge.net/apps/mediawiki/nifty-gui/index.php?title=Create_your_own_Control_%28A_Nifty_Progressbar%29</u></html>"><param name="textColor" value="blue"></object>
</p>
@ -28,7 +27,6 @@ This is the progress bar at 90%:
<p>
nifty_loading.xml
</p>
<pre><span>&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;</span>
<span><span>&lt;nifty&gt;</span></span>
@ -71,14 +69,12 @@ nifty_loading.xml
</div>
<h4><a>Understanding Nifty XML</a></h4>
<h4>Understanding Nifty XML</h4>
<div>
<p>
The progress bar and text is done statically using nifty <acronym title="Extensible Markup Language">XML</acronym>.
The progress bar and text is done statically using nifty XML.
A custom control is created, which represents the progress bar.
</p>
<pre> <span>&lt;controlDefinition name = &quot;loadingbar&quot; controller = &quot;jme3test.TestLoadingScreen&quot;&gt;</span>
<span>&lt;image filename=&quot;Interface/border.png&quot; childLayout=&quot;absolute&quot; </span>
@ -90,7 +86,6 @@ A custom control is created, which represents the progress bar.
<p>
This screen simply displays a button in the middle of the screen, which could be seen as a simple main menu UI.
</p>
<pre> <span>&lt;screen id=&quot;start&quot; controller = &quot;jme3test.TestLoadingScreen&quot;&gt;</span>
<span>&lt;layer id=&quot;layer&quot; childLayout=&quot;center&quot;&gt;</span>
@ -105,7 +100,6 @@ This screen simply displays a button in the middle of the screen, which could be
<p>
This screen displays our custom progress bar control with a text control
</p>
<pre> <span>&lt;screen id=&quot;loadlevel&quot; controller = &quot;jme3test.TestLoadingScreen&quot;&gt;</span>
<span>&lt;layer id=&quot;loadinglayer&quot; childLayout=&quot;center&quot; backgroundColor=&quot;#000000&quot;&gt;</span>
@ -119,7 +113,7 @@ This screen displays our custom progress bar control with a text control
</div>
<!-- EDIT1 SECTION "Nifty Loading Screen (Progress Bar)" [1-4344] -->
<h3><a>Creating the bindings to use the Nifty XML</a></h3>
<h3>Creating the bindings to use the Nifty XML</h3>
<div>
<p>
@ -128,7 +122,6 @@ There are 3 main ways to update a progress bar. To understand why these methods
<p>
Something like this in a single thread will not work:
</p>
<pre>load_scene&#40;&#41;;
update_bar&#40;30%&#41;;
@ -138,8 +131,7 @@ load_sounds&#40;&#41;;
update_bar&#40;100%&#41;;</pre>
<p>
If you do all of this in a single frame, then it is sent to the graphics card only after the whole code block has executed. By this time the bar has reached 100% and the game has already begun ??? for the user, the progressbar on the screen would not have visibly changed.
If you do all of this in a single frame, then it is sent to the graphics card only after the whole code block has executed. By this time the bar has reached 100% and the game has already begun – for the user, the progressbar on the screen would not have visibly changed.
</p>
<p>
@ -154,13 +146,11 @@ The 2 main good solutions are:
</div>
<h4><a>Updating progress bar over a number of frames</a></h4>
<h4>Updating progress bar over a number of frames</h4>
<div>
<p>
The idea is to break down the loading of the game into discrete parts
</p>
<pre>package jme3test;
&nbsp;
@ -324,12 +314,12 @@ public class TestLoadingScreen extends SimpleApplication implements ScreenContro
&#125;
&nbsp;
@Override
public void bind&#40;Nifty nifty, Screen screen, Element elmnt, Properties prprts, Attributes atrbts&#41; &#123;
public void bind&#40;Nifty nifty, Screen screen, Attributes atrbts&#41; &#123;
progressBarElement = elmnt.findElementByName&#40;&quot;progressbar&quot;&#41;;
&#125;
&nbsp;
@Override
public void init&#40;Properties prprts, Attributes atrbts&#41; &#123;
public void init&#40;Attributes atrbts&#41; &#123;
&#125;
&nbsp;
public void onFocus&#40;boolean getFocus&#41; &#123;
@ -346,7 +336,7 @@ Note:
</div>
<h4><a>Using multithreading</a></h4>
<h4>Using multithreading</h4>
<div>
<p>
@ -354,8 +344,7 @@ For more info on multithreading: <object classid="java:org.netbeans.modules.java
</p>
<p>
Make sure to change the <acronym title="Extensible Markup Language">XML</acronym> file to point the controller to TestLoadingScreen<strong>1</strong>
Make sure to change the XML file to point the controller to TestLoadingScreen<strong>1</strong>
</p>
<pre>package jme3test;
&nbsp;
@ -504,7 +493,7 @@ public class TestLoadingScreen1 extends SimpleApplication implements ScreenContr
//since this method is called from another thread, we enqueue the changes to the progressbar to the update loop thread
enqueue&#40;new Callable&#40;&#41; &#123;
&nbsp;
public Object call&#40;&#41; throws Exception &#123;
public Exception &#123;
final int MIN_WIDTH = 32;
int pixelWidth = &#40;int&#41; &#40;MIN_WIDTH + &#40;progressBarElement.getParent&#40;&#41;.getWidth&#40;&#41; - MIN_WIDTH&#41; * progress&#41;;
progressBarElement.setConstraintWidth&#40;new SizeValue&#40;pixelWidth + &quot;px&quot;&#41;&#41;;
@ -542,12 +531,12 @@ public class TestLoadingScreen1 extends SimpleApplication implements ScreenContr
&#125;
&nbsp;
@Override
public void bind&#40;Nifty nifty, Screen screen, Element elmnt, Properties prprts, Attributes atrbts&#41; &#123;
public void bind&#40;Nifty nifty, Screen screen, Attributes atrbts&#41; &#123;
progressBarElement = elmnt.findElementByName&#40;&quot;progressbar&quot;&#41;;
&#125;
&nbsp;
@Override
public void init&#40;Properties prprts, Attributes atrbts&#41; &#123;
public void init&#40;Attributes atrbts&#41; &#123;
&#125;
&nbsp;
public void onFocus&#40;boolean getFocus&#41; &#123;
@ -564,4 +553,4 @@ public class TestLoadingScreen1 extends SimpleApplication implements ScreenContr
</div>
<!-- EDIT2 SECTION "Creating the bindings to use the Nifty XML" [4345-] -->
<p><em><a href="http://hub.jmonkeyengine.org/wiki/doku.php/jme3:advanced:loading_screen?do=export_xhtmlbody">view online version</a></em></p>
<p><em><a href="http://wiki.jmonkeyengine.org/doku.php/jme3:advanced:loading_screen?do=export_xhtmlbody">view online version</a></em></p>

@ -1,47 +1,42 @@
<h1><a>Localizing jME 3 Games</a></h1>
<h1>Localizing jME 3 Games</h1>
<div>
</div>
<!-- EDIT1 SECTION "Localizing jME 3 Games" [1-38] -->
<h2><a>Scope</a></h2>
<h2>Scope</h2>
<div>
<p>
Localizing an application can mean several things:
</p>
<ul>
<li><div> At minimum you translate all messages and dialogs in the user interface to your target languages.</div>
</li>
<li><div> You should also translate the &quot;read me&quot;, help, and other documentation.</div>
<li><div> You should also translate the “read me”, help, and other documentation.</div>
</li>
<li><div> Also translating web content related to the application makes sure international users find out about your localized game.</div>
</li>
<li><div> If you go the whole way of internationalization, you also &quot;translate&quot; metaphors in icons or symbols used. <br/>
<li><div> If you go the whole way of internationalization, you also “translate” metaphors in icons or symbols used. <br/>
E.g. For localizations to right-to-left languages, you must also adjust the whole flow of the UI (order of menus and buttons).</div>
</li>
</ul>
<p>
There are tools that assist you with localizing Java Swing GUIs. jME3 applications do not typically have a Swing <acronym title="Graphical User Interface">GUI</acronym>, so those tools are not of much help. Just stick to the normal Java rules about using Bundle Properties:
There are tools that assist you with localizing Java Swing GUIs. jME3 applications do not typically have a Swing <abbr title="Graphical User Interface">GUI</abbr>, so those tools are not of much help. Just stick to the normal Java rules about using Bundle Properties:
</p>
</div>
<!-- EDIT2 SECTION "Scope" [39-879] -->
<h2><a>Preparing the Localization</a></h2>
<h2>Preparing the Localization</h2>
<div>
<p>
<strong>Tip:</strong> The jMonkeyEngine <acronym title="Software Development Kit">SDK</acronym> supports opening and editing Bundle.properties files. Also note the Tools &gt; Localization menu.
<strong>Tip:</strong> The jMonkeyEngine SDK supports opening and editing Bundle.properties files. Also note the Tools &gt; Localization menu.
</p>
<p>
To prepare the application for localization, you have to first identify all hard-coded messages.
</p>
<ol>
<li><div> Find every line in your jME3 game where you hard-coded message strings, e.g. <br/>
@ -56,31 +51,27 @@ UiText.setText&#40;&quot;Score: &quot;+score&#41;;</pre>
score.display=Score: </pre>
</div>
</li>
<li><div> In the source code, replace every occurence of a hard-coded message with the appropriate Resource Bundle call to its unique key: <pre>System.out.print&#40;ResourceBundle.getBundle&#40;&quot;Bundle&quot;&#41;.getString&#40;&quot;greeting&quot;&#41;&#41;;
<li><div> In the source code, replace every occurence of a hard-coded message with the appropriate Resource Bundle call to its unique key: <pre>ResourceBundle.getBundle&#40;&quot;Bundle&quot;&#41;.getString&#40;&quot;greeting&quot;&#41;&#41;;
UiText.setText&#40;ResourceBundle.getBundle&#40;&quot;Bundle&quot;&#41;.getString&#40;&quot;score.display&quot;&#41;+score&#41;;</pre>
</div>
</li>
</ol>
<p>
The language used in the Bundle.properties files will be the default language for your game.
</p>
</div>
<!-- EDIT3 SECTION "Preparing the Localization" [880-2088] -->
<h2><a>Translating the Messages</a></h2>
<h2>Translating the Messages</h2>
<div>
<p>
Each additional language comes in a set of files that is marked with a (usually) two-letter suffix. Common locales are de for German, en for English, fr for French, ja for Japanese, pt for Portuguese, etc.
</p>
<p>
To translate the messages to another language, for example, German:
</p>
<ol>
<li><div> Make a copy of the <code>Bundle.properties</code> files.</div>
@ -100,23 +91,20 @@ score.display=Spielstand: </pre>
</ol>
<p>
<strong>Tip:</strong> In the jMonkeyEngine <acronym title="Software Development Kit">SDK</acronym>, you set this VM Option in the Project properties under Run. Here you can also save individual run configuraions for each language you want to test.
<strong>Tip:</strong> In the jMonkeyEngine SDK, you set this VM Option in the Project properties under Run. Here you can also save individual run configuraions for each language you want to test.
</p>
<p>
To get the full list of language suffixes use
</p>
<pre>System.out.println&#40;Arrays.toString&#40;Locale.getISOLanguages&#40;&#41;&#41;&#41;;</pre>
<pre>Locale.getISOLanguages&#40;&#41;&#41;&#41;;</pre>
</div>
<!-- EDIT4 SECTION "Translating the Messages" [2089-3243] -->
<h2><a>Which Strings Not to Translate</a></h2>
<h2>Which Strings Not to Translate</h2>
<div>
<p>
<strong>Important:</strong> In the Bundle.properties file, do not include any strings that are asset paths, node or geometry names, input mappings, or material layers.
</p>
<ul>
@ -137,47 +125,43 @@ inputManager.addListener&#40;actionListener, &quot;Shoot&quot;&#41;;</pre>
</ul>
<p>
Only localize messages and UI text!
</p>
</div>
<!-- EDIT5 SECTION "Which Strings Not to Translate" [3244-3918] -->
<h2><a>Common Localization Problems</a></h2>
<h2>Common Localization Problems</h2>
<div>
<p>
Typical problems include:
</p>
<ul>
<li><div> Localized strings will be of vastly different lengths and will totally break your UI layout. ??? Test every localization.</div>
<li><div> Localized strings will be of vastly different lengths and will totally break your UI layout. Test every localization.</div>
</li>
<li><div> Strings with variable text or numbers don&#039;t work the same in different languages. ??? Either work in grammatical cases/numbers/gender for each language, or use <object classid="java:org.netbeans.modules.javahelp.BrowserDisplayer"><param name="content" value="http://www.gnu.org/software/gettext/manual/gettext.html#Plural-forms"><param name="text" value="<html><u>gettext</u></html>"><param name="textColor" value="blue"></object> or <object classid="java:org.netbeans.modules.javahelp.BrowserDisplayer"><param name="content" value="http://userguide.icu-project.org/formatparse/messages"><param name="text" value="<html><u>ICU4J</u></html>"><param name="textColor" value="blue"></object>.</div>
<li><div> Strings with variable text or numbers don&#039;t work the same in different languages. Either work in grammatical cases/numbers/gender for each language, or use <object classid="java:org.netbeans.modules.javahelp.BrowserDisplayer"><param name="content" value="http://www.gnu.org/software/gettext/manual/gettext.html#Plural-forms"><param name="text" value="<html><u>gettext</u></html>"><param name="textColor" value="blue"></object> or <object classid="java:org.netbeans.modules.javahelp.BrowserDisplayer"><param name="content" value="http://userguide.icu-project.org/formatparse/messages"><param name="text" value="<html><u>ICU4J</u></html>"><param name="textColor" value="blue"></object>.</div>
</li>
<li><div> The localizer only sees the strings, without any context. E.g. does &quot;Search History&quot; mean &quot;display the history of searches&quot;, or &quot;search through the history&quot;? ??? Use clear key labels. Work closely with the localizers if they require extra info, and add that info as comments to the translation file.</div>
<li><div> The localizer only sees the strings, without any context. E.g. does “Search History” mean “display the history of searches”, or “search through the history”? ⇒ Use clear key labels. Work closely with the localizers if they require extra info, and add that info as comments to the translation file.</div>
</li>
<li><div> Broken international characters ??? Make sure the files are saved with the same character encoding as the font file(s) you&#039;re using. Nowadays, that usually means UTF-8 since font files tend to come for Unicode.</div>
<li><div> Broken international characters Make sure the files are saved with the same character encoding as the font file(s) you&#039;re using. Nowadays, that usually means UTF-8 since font files tend to come for Unicode.</div>
</li>
<li><div> Missing international characters ??? Make sure that there&#039;s a glyph for every needed character in your font, either by using more complete font files or by having the translation changed.</div>
<li><div> Missing international characters Make sure that there&#039;s a glyph for every needed character in your font, either by using more complete font files or by having the translation changed.</div>
</li>
</ul>
</div>
<!-- EDIT6 SECTION "Common Localization Problems" [3919-5131] -->
<h2><a>More Documentation</a></h2>
<h2>More Documentation</h2>
<div>
<p>
<object classid="java:org.netbeans.modules.javahelp.BrowserDisplayer"><param name="content" value="http://java.sun.com/developer/technicalArticles/Intl/ResourceBundles/"><param name="text" value="<html><u>http://java.sun.com/developer/technicalArticles/Intl/ResourceBundles/</u></html>"><param name="textColor" value="blue"></object>
</p>
<p>
<object classid="java:org.netbeans.modules.javahelp.BrowserDisplayer"><param name="content" value="http://sourceforge.net/apps/mediawiki/nifty-gui/index.php?title=Localisation"><param name="text" value="<html><u>http://sourceforge.net/apps/mediawiki/nifty-gui/index.php?title=Localisation</u></html>"><param name="textColor" value="blue"></object>
</p>
</div>
<!-- EDIT7 SECTION "More Documentation" [5132-] -->
<p><em><a href="http://hub.jmonkeyengine.org/wiki/doku.php/jme3:advanced:localization?do=export_xhtmlbody">view online version</a></em></p>
<p><em><a href="http://wiki.jmonkeyengine.org/doku.php/jme3:advanced:localization?do=export_xhtmlbody">view online version</a></em></p>

@ -1,24 +1,22 @@
<h1><a>Logging and Monitoring</a></h1>
<h1>Logging and Monitoring</h1>
<div>
</div>
<!-- EDIT1 SECTION "Logging and Monitoring" [1-38] -->
<h2><a>Logging Like a Newbie</a></h2>
<h2>Logging Like a Newbie</h2>
<div>
<p>
Many developers just use <code>System.out.println()</code> to print diagnostic strings to the terminal. The problem with that is that before the release, you have to go through all your code and make certain you removed all these <code>println()</code> calls. You do not want your customers to see them, and needlessly worry about ominous outdated debugging diagnostics.
</p>
</div>
<!-- EDIT2 SECTION "Logging Like a Newbie" [39-428] -->
<h2><a>Logging Like a Pro</a></h2>
<h2>Logging Like a Pro</h2>
<div>
<p>
Instead of <code>println()</code>, use the standard Java logger from <code>java.util.logging</code>. It has many advantages for professional game development:
</p>
<ul>
@ -37,7 +35,6 @@ Instead of <code>println()</code>, use the standard Java logger from <code>java.
</ul>
<p>
To print comments like a pro, you use the following logger syntax.
</p>
<ol>
@ -64,8 +61,7 @@ Example: <code>Vector3f a = cam.getLocation();</code> </div>
</ol>
<p>
<p><div>As you see in the examples, you should phrase potentially &quot;customer facing&quot; errors in a neutral way and offer <em>a reason and a solution</em> for the error (if you don&#039;t, it has no value to your customer). If your deveopment team uses WARNINGs as replacement for casual printlns, make sure you deactivate them for the release.
<p><div>As you see in the examples, you should phrase potentially “customer facing” errors in a neutral way and offer <em>a reason and a solution</em> for the error (if you don&#039;t, it has no value to your customer). If your deveopment team uses WARNINGs as replacement for casual printlns, make sure you deactivate them for the release.
</div></p>
</p>
@ -75,39 +71,34 @@ More details about <object classid="java:org.netbeans.modules.javahelp.BrowserDi
</div>
<!-- EDIT3 SECTION "Logging Like a Pro" [429-2826] -->
<h2><a>Switching the Logger on and off</a></h2>
<h2>Switching the Logger on and off</h2>
<div>
<p>
In the release version you will deactivate the logging output to the terminal.
</p>
<p>
To deactivate the default logger for a release, you set the log level to only report <code>severe</code> messages:
</p>
<pre>Logger.getLogger&#40;??????&#41;.setLevel&#40;Level.SEVERE&#41;;</pre>
<pre>Logger.getLogger&#40;””&#41;.setLevel&#40;Level.SEVERE&#41;;</pre>
<p>
During development or a beta test, you can tune down the default logger, and set the log level to only report <code>warning</code>s:
</p>
<pre>Logger.getLogger&#40;??????&#41;.setLevel&#40;Level.WARNING&#41;;</pre>
<pre>Logger.getLogger&#40;””&#41;.setLevel&#40;Level.WARNING&#41;;</pre>
<p>
To activate full logging, e.g. for debugging and testing, use the <code>fine</code> level:
</p>
<pre>Logger.getLogger&#40;??????&#41;.setLevel&#40;Level.FINE&#41;;</pre>
<pre>Logger.getLogger&#40;””&#41;.setLevel&#40;Level.FINE&#41;;</pre>
</div>
<!-- EDIT4 SECTION "Switching the Logger on and off" [2827-3468] -->
<h2><a>Advanced Error Handling</a></h2>
<h2>Advanced Error Handling</h2>
<div>
<p>
When an uncaught exception reaches certain parts of the jME3 system then the default response is to log the error and then exit the application. This is because an error happening every frame will rapidly fill logs with repeated failings and potentially mask or over-write the original cause of the problem or even the application may continue for a while and then suffer other errors caused by the first and make the root cause hard to determine.
</p>
@ -117,4 +108,4 @@ This behaviour can be partially modified by overriding the method handleError in
</div>
<!-- EDIT5 SECTION "Advanced Error Handling" [3469-] -->
<p><em><a href="http://hub.jmonkeyengine.org/wiki/doku.php/jme3:advanced:logging?do=export_xhtmlbody">view online version</a></em></p>
<p><em><a href="http://wiki.jmonkeyengine.org/doku.php/jme3:advanced:logging?do=export_xhtmlbody">view online version</a></em></p>

@ -1,9 +1,8 @@
<h1><a>Making the Camera Follow a 3rd-Person Character</a></h1>
<h1>Making the Camera Follow a 3rd-Person Character</h1>
<div>
<p>
When players steer a game character with 1st-person view, they directly steer the camera (<code>flyCam.setEnabled(true);</code>), and they never see the walking character itself. In a game with 3rd-person view, however, the players see the character walk, and you (the game developer) want to make the camera follow the character around when it walks.
</p>
@ -18,13 +17,12 @@ There are two ways how the camera can do that:
</ul>
<p>
<strong>Important:</strong> Using third-person view requires you to deactivate the default flyCam (first-person view). This means that you have to configure your own navigation (<a href="/com/jme3/gde/docs/jme3/advanced/input_handling.html">key inputs and analogListener</a>) that make your player character walk. For moving a physical player character, use <code>player.setWalkDirection()</code>, for a non-physical character you can use <code>player.move()</code>.
</p>
</div>
<!-- EDIT1 SECTION "Making the Camera Follow a 3rd-Person Character" [1-990] -->
<h2><a>Code Samples</a></h2>
<h2>Code Samples</h2>
<div>
<p>
@ -39,7 +37,7 @@ Press the WASD or arrow keys to move. Drag with the left mouse button to rotate.
</div>
<!-- EDIT2 SECTION "Code Samples" [991-1372] -->
<h2><a>Camera Node</a></h2>
<h2>Camera Node</h2>
<div>
<p>
@ -60,12 +58,13 @@ camNode.lookAt&#40;target.getLocalTranslation&#40;&#41;, Vector3f.UNIT_Y&#41;;</
<p>
<strong>Important:</strong> Where the example says <code>camNode.setLocalTranslation(new Vector3f(0, 5, -5));</code>, you have to supply your own start position for the camera. This depends on the size of your target (the player character) and its position in your particular scene. Optimally, you set this to a spot a bit behind and above the target.
</p>
<div><table>
<thead>
<tr>
<th>Methods</th><th>Description</th>
</tr>
</thead>
<tr>
<td>setControlDir(ControlDirection.SpatialToCamera)</td><td>User input steers the target spatial, and the camera follows the spatial.<br/>
The spatial&#039;s transformation is copied over the camera&#039;s transformation. <br/>
@ -78,21 +77,19 @@ The camera&#039;s transformation is copied over the spatial&#039;s transformatio
</table></div>
<!-- EDIT4 TABLE [2446-2957] -->
<p>
<strong>Code sample:</strong>
</p>
<ul>
<li><div> <object classid="java:org.netbeans.modules.javahelp.BrowserDisplayer"><param name="content" value="http://code.google.com/p/jmonkeyengine/source/browse/trunk/engine/src/test/jme3test/input/TestCameraNode.java"><param name="text" value="<html><u>TestCameraNode.java</u></html>"><param name="textColor" value="blue"></object> ??? Press the WASD or arrow keys to move. Drag with the left mouse button to rotate.</div>
<li><div> <object classid="java:org.netbeans.modules.javahelp.BrowserDisplayer"><param name="content" value="http://code.google.com/p/jmonkeyengine/source/browse/trunk/engine/src/test/jme3test/input/TestCameraNode.java"><param name="text" value="<html><u>TestCameraNode.java</u></html>"><param name="textColor" value="blue"></object> Press the WASD or arrow keys to move. Drag with the left mouse button to rotate.</div>
</li>
</ul>
</div>
<!-- EDIT3 SECTION "Camera Node" [1373-3198] -->
<h2><a>Chase Camera</a></h2>
<h2>Chase Camera</h2>
<div>
<p>
To activate the chase camera, add the following code to your init method (e.g. <code>simpleInitApp()</code>). The <code>target</code> spatial is typically the player node. You will be able to rotate the target by dragging (keeping the left mouse button pressed and moving the mouse).
</p>
<pre>// Disable the default flyby cam
@ -101,9 +98,11 @@ flyCam.setEnabled&#40;false&#41;;
ChaseCamera chaseCam = new ChaseCamera&#40;cam, target, inputManager&#41;;
chaseCam.setSmoothMotion&#40;true&#41;;</pre>
<div><table>
<thead>
<tr>
<th>Method</th><th>Description</th>
</tr>
</thead>
<tr>
<td>setInvertVerticalAxis(true)</td><td>Invert the camera&#039;s vertical rotation Axis </td>
</tr>
@ -139,28 +138,27 @@ new KeyTrigger(KeyInput.KEY_SPACE))</td><td>Activate mutiple triggers for the ro
</table></div>
<!-- EDIT6 TABLE [3733-5145] -->
<p>
<strong>Code sample:</strong>
</p>
<ul>
<li><div> <object classid="java:org.netbeans.modules.javahelp.BrowserDisplayer"><param name="content" value="http://code.google.com/p/jmonkeyengine/source/browse/trunk/engine/src/test/jme3test/input/TestChaseCamera.java"><param name="text" value="<html><u>TestChaseCamera.java</u></html>"><param name="textColor" value="blue"></object> ??? Press the WASD or arrow keys to move. Drag with the left mouse button to rotate.</div>
<li><div> <object classid="java:org.netbeans.modules.javahelp.BrowserDisplayer"><param name="content" value="http://code.google.com/p/jmonkeyengine/source/browse/trunk/engine/src/test/jme3test/input/TestChaseCamera.java"><param name="text" value="<html><u>TestChaseCamera.java</u></html>"><param name="textColor" value="blue"></object> Press the WASD or arrow keys to move. Drag with the left mouse button to rotate.</div>
</li>
</ul>
</div>
<!-- EDIT5 SECTION "Chase Camera" [3199-5388] -->
<h2><a>Which to Choose?</a></h2>
<h2>Which to Choose?</h2>
<div>
<p>
What is the difference of the two code samples above?
</p>
<div><table>
<thead>
<tr>
<th>CameraNode</th><th>ChaseCam</th>
</tr>
</thead>
<tr>
<td>Camera follows immediately, flies at same speed as target.</td><td>Camera moves smoothly and accelerates and decelerates, flies more slowly than the target and catches up.</td>
</tr>
@ -174,4 +172,4 @@ What is the difference of the two code samples above?
<!-- EDIT8 TABLE [5474-5945] -->
</div>
<!-- EDIT7 SECTION "Which to Choose?" [5389-] -->
<p><em><a href="http://hub.jmonkeyengine.org/wiki/doku.php/jme3:advanced:making_the_camera_follow_a_character?do=export_xhtmlbody">view online version</a></em></p>
<p><em><a href="http://wiki.jmonkeyengine.org/doku.php/jme3:advanced:making_the_camera_follow_a_character?do=export_xhtmlbody">view online version</a></em></p>

@ -1,10 +1,9 @@
<h1><a>How to Use Material Definitions (.j3md)</a></h1>
<h1>How to Use Material Definitions (.j3md)</h1>
<div>
<p>
All Geometries need a Material to be visible. Every Material is based on a Material Definition. Material definitions provide the &quot;logic&quot; for the material, and a shader draws the material according to the parameters specified in the definition. The J3MD file abstracts the shader and its configuration away from the user, allowing a simple interface where the user can simply set a few parameters on the material to change its appearance and the way its handled by the shaders.
All Geometries need a Material to be visible. Every Material is based on a Material Definition. Material definitions provide the “logic” for the material, and a shader draws the material according to the parameters specified in the definition. The J3MD file abstracts the shader and its configuration away from the user, allowing a simple interface where the user can simply set a few parameters on the material to change its appearance and the way its handled by the shaders.
</p>
<p>
@ -13,7 +12,6 @@ The most common Material Definitions are included in the engine, advanced users
<p>
<strong>Example:</strong>
</p>
<pre>Spatial myGeometry = assetManager.loadModel&#40;&quot;Models/Teapot/Teapot.j3o&quot;&#41;;
Material mat = new Material&#40;assetManager, // Create new material and...
@ -28,11 +26,10 @@ myGeometry.setMaterial&#40;mat&#41;; // Use material on this Geome
</div>
<!-- EDIT1 SECTION "How to Use Material Definitions (.j3md)" [1-1585] -->
<h2><a>Preparing a Material</a></h2>
<h2>Preparing a Material</h2>
<div>
<p>
In the <a href="/com/jme3/gde/docs/jme3/advanced/materials_overview.html">Materials Overview</a> list:
</p>
<ol>
@ -42,17 +39,17 @@ In the <a href="/com/jme3/gde/docs/jme3/advanced/materials_overview.html">Materi
</li>
</ul>
</li>
<li><div> Look at the applicable parameters of the Material Definition and determine which parameters you need to achieve the desired effect (e.g. &quot;glow&quot; or &quot;color&quot;). Most parameters are optional! </div>
<li><div> Look at the applicable parameters of the Material Definition and determine which parameters you need to achieve the desired effect (e.g. “glow” or “color”). Most parameters are optional! </div>
</li>
<li><div> Create and save the necessary Texture files to your <code>assets/Textures</code> directory.</div>
<ul>
<li><div> E.g. mytex_diffuse.png as ColorMap / DiffuseMap, mytex_normal.png as NormalMap, mytex_alpha.png as AlphaMap, etc???</div>
<li><div> E.g. mytex_diffuse.png as ColorMap / DiffuseMap, mytex_normal.png as NormalMap, mytex_alpha.png as AlphaMap, etc</div>
</li>
</ul>
</li>
<li><div> Determine the required values to achieve the effect that you want.</div>
<ul>
<li><div> E.g. set colors, floats, booleans, etc??? </div>
<li><div> E.g. set colors, floats, booleans, etc </div>
</li>
</ul>
</li>
@ -60,11 +57,10 @@ In the <a href="/com/jme3/gde/docs/jme3/advanced/materials_overview.html">Materi
</div>
<!-- EDIT2 SECTION "Preparing a Material" [1586-2329] -->
<h2><a>Using a Material</a></h2>
<h2>Using a Material</h2>
<div>
<p>
In your Java code,
</p>
<ol>
@ -83,36 +79,32 @@ In your Java code,
</ol>
<p>
For details see also: <a href="/com/jme3/gde/docs/jme3/intermediate/how_to_use_materials.html">How to Use Materials</a>
</p>
</div>
<!-- EDIT3 SECTION "Using a Material" [2330-3036] -->
<h3><a>Examples</a></h3>
<h3>Examples</h3>
<div>
<p>
Here are examples of the methods that set the different data types:
</p>
<ul>
<li><div> <code>mat.setColor( &quot;Color&quot;, ColorRGBA.White );</code> </div>
<li><div> <code>mat.setColor( “Color”, ColorRGBA.White );</code> </div>
</li>
<li><div> <code>mat.setTexture( &quot;ColorMap&quot;, assetManager.loadTexture(&quot;Interface/Logo/Monkey.png&quot; ));</code></div>
<li><div> <code>mat.setTexture( “ColorMap”, assetManager.loadTexture(“Interface/Logo/Monkey.png” ));</code></div>
</li>
<li><div> <code>mat.setFloat( &quot;Shininess&quot;, 5f);</code></div>
<li><div> <code>mat.setFloat( “Shininess”, 5f);</code></div>
</li>
<li><div> <code>mat.setBoolean( &quot;SphereMap&quot;, true);</code></div>
<li><div> <code>mat.setBoolean( “SphereMap”, true);</code></div>
</li>
<li><div> <code>mat.setVector3( &quot;NormalScale&quot;, new Vector3f(1f,1f,1f));</code></div>
<li><div> <code>mat.setVector3( “NormalScale”, new Vector3f(1f,1f,1f));</code></div>
</li>
</ul>
<p>
A simpled textured material.
</p>
<pre>Material mat = new Material&#40;assetManager,
&quot;Common/MatDefs/Misc/Unshaded.j3md&quot;&#41;;
@ -121,7 +113,6 @@ mat.setTexture&#40;&quot;ColorMap&quot;, assetManager.loadTexture&#40;
<p>
A textured material with a color bleeding through transparent areas.
</p>
<pre>Material mat = new Material&#40;assetManager,
&quot;Common/MatDefs/Misc/Unshaded.j3md&quot;&#41;;
@ -132,30 +123,28 @@ mat.setColor&#40;&quot;Color&quot;, ColorRGBA.Blue&#41;;</pre>
<p>
You can test these examples within the following code snippet. It creates a box and applies the material:
</p>
<pre> Box b = new Box&#40;Vector3f.ZERO, 1, 1, 1&#41;;
<pre> Box&#40;Vector3f.ZERO, 1, 1, 1&#41;;
Geometry geom = new Geometry&#40;&quot;Box&quot;, b&#41;;
// ... insert Material definition...
geom.setMaterial&#40;mat&#41;;
rootNode.attachChild&#40;geom&#41;;</pre>
<p>
<p><div>You can find these and other common code snippets in the jMonkeyEngine <acronym title="Software Development Kit">SDK</acronym> Code Palette. Drag and drop them into your source code.
<p><div>You can find these and other common code snippets in the jMonkeyEngine SDK Code Palette. Drag and drop them into your source code.
</div></p>
</p>
</div>
<!-- EDIT4 SECTION "Examples" [3037-4410] -->
<h2><a>Creating a Custom Material Definition</a></h2>
<h2>Creating a Custom Material Definition</h2>
<div>
<p>
First read the <a href="/com/jme3/gde/docs/jme3/advanced/material_specification.html">developer specification of the jME3 material system (.j3md,.j3m)</a>. Also check out the <a href="/com/jme3/gde/docs/jme3/build_from_sources.html">engine source code</a> and have a look at how some Material Definitions are implemented.
</p>
<p>
You can create your own Material Definitions and place them in your project&#039;s <code>assets/MatDefs</code> directory.
</p>
<ol>
<li><div> Find the existing MatDefs in <code>engine/src/core-data/Common/MatDefs/</code>. </div>
@ -174,20 +163,17 @@ You can create your own Material Definitions and place them in your project&#039
</div>
<!-- EDIT5 SECTION "Creating a Custom Material Definition" [4411-5384] -->
<h2><a>Related Links</a></h2>
<h2>Related Links</h2>
<div>
<ul>
<li><div> <a href="/com/jme3/gde/docs/jme3/advanced/material_specification.html">Developer specification of the jME3 material system (.j3md,.j3m)</a></div>
</li>
</ul>
<div><span>
<a href="/wiki/doku.php/tag:material?do=showtag&amp;tag=tag%3Amaterial">Material</a>,
<a href="/wiki/doku.php/tag:sdk?do=showtag&amp;tag=tag%3Asdk">SDK</a>,
<a href="/wiki/doku.php/tag:matdef?do=showtag&amp;tag=tag%3Amatdef">MatDef</a>,
<a href="/wiki/doku.php/tag:file?do=showtag&amp;tag=tag%3Afile">file</a>,
<a href="/wiki/doku.php/tag:documentation?do=showtag&amp;tag=tag%3Adocumentation">documentation</a>
</span></div>
<p>
<a href="nbdocs:/com/jme3/gde/docs/jme3:advanced/tag_material_sdk_matdef_file_documentation">tag_material_sdk_matdef_file_documentation</a>
</p>
</div>
<!-- EDIT6 SECTION "Related Links" [5385-] -->
<p><em><a href="http://hub.jmonkeyengine.org/wiki/doku.php/jme3:advanced:material_definitions?do=export_xhtmlbody">view online version</a></em></p>
<p><em><a href="http://wiki.jmonkeyengine.org/doku.php/jme3:advanced:material_definitions?do=export_xhtmlbody">view online version</a></em></p>

@ -1,11 +1,9 @@
<h1><a>Material Definition Properties</a></h1>
<h1>Material Definition Properties</h1>
<div>
<p>
In jMonkeyEngine 3, colors and textures are represented as Material objects.
</p>
<ul>
<li><div> All Geometries must have Materials. To improve performance, reuse Materials for similar models, don&#039;t create a new Material object for every Geometry. (E.g. use one bark Material for several tree models.) </div>
@ -15,7 +13,6 @@ In jMonkeyEngine 3, colors and textures are represented as Material objects.
</ul>
<p>
<p><div>Find out quickly <a href="/com/jme3/gde/docs/jme3/intermediate/how_to_use_materials.html">How to Use Materials</a>, including the most commonly used code samples and RenderStates. <br/>
Or find more background info on <a href="/com/jme3/gde/docs/jme3/advanced/material_definitions.html">How to use Material Definitions</a>.
</div></p>
@ -23,11 +20,10 @@ Or find more background info on <a href="/com/jme3/gde/docs/jme3/advanced/materi
</div>
<!-- EDIT1 SECTION "Material Definition Properties" [1-841] -->
<h2><a>All Materials Definition Properties</a></h2>
<h2>All Materials Definition Properties</h2>
<div>
<p>
The following Materials table shows you the Material Definitions that jMonkeyEngine 3 supports.
</p>
@ -45,11 +41,10 @@ Most Material parameters are optional. For example, it is okay to specify solely
</div>
<!-- EDIT2 SECTION "All Materials Definition Properties" [842-1717] -->
<h3><a>Unshaded Coloring and Textures</a></h3>
<h3>Unshaded Coloring and Textures</h3>
<div>
<p>
jMonkeyEngine supports illuminated and unshaded Material Definitions.
</p>
<ul>
@ -60,54 +55,54 @@ jMonkeyEngine supports illuminated and unshaded Material Definitions.
</ul>
<p>
&quot;Unshaded&quot; materials look somewhat abstract because they ignore lighting and shading. Unshaded Materials work even if the scene does not include a light source. These Materials can be single-colored or textured. For example, they are used for cards and tiles, for the sky, billboards and UI elements, for toon-style games, or for testing.
“Unshaded” materials look somewhat abstract because they ignore lighting and shading. Unshaded Materials work even if the scene does not include a light source. These Materials can be single-colored or textured. For example, they are used for cards and tiles, for the sky, billboards and UI elements, for toon-style games, or for testing.
</p>
<div><table>
<thead>
<tr>
<th> Standard Unshaded Material Definition </th><th> Usage </th><th> Material Parameters </th>
</tr>
</thead>
<tr>
<td> Common/MatDefs/Misc/Unshaded.j3md </td><td> Standard, non-illuminated Materials. <br/>
Use this for simple coloring and texturing, glow, and transparency. <br/>
See also: <a href="/com/jme3/gde/docs/jme3/beginner/hello_material.html">Hello Material</a> </td><td> <strong>Texture Maps</strong> <br/>
setTexture(&quot;ColorMap&quot;, assetManager.loadTexture(&quot;&quot;)); <br/>
setBoolean(&quot;SeparateTexCoord&quot;,true); <br/>
setTexture(&quot;LightMap&quot;, assetManager.loadTexture(&quot;&quot;)); <br/>
setTexture(“ColorMap”, assetManager.loadTexture(“”)); <br/>
setBoolean(“SeparateTexCoord”,true); <br/>
setTexture(“LightMap”, assetManager.loadTexture(“”)); <br/>
<strong>Colors</strong> <br/>
setColor(&quot;Color&quot;, ColorRGBA.White); <br/>
setBoolean(&quot;VertexColor&quot;,true); <br/>
setColor(“Color”, ColorRGBA.White); <br/>
setBoolean(“VertexColor”,true); <br/>
<strong>Glow</strong> <br/>
setTexture(&quot;GlowMap&quot;, assetManager.loadTexture(&quot;&quot;)); <br/>
setColor(&quot;GlowColor&quot;, ColorRGBA.White); </td>
setTexture(“GlowMap”, assetManager.loadTexture(“”)); <br/>
setColor(“GlowColor”, ColorRGBA.White); </td>
</tr>
</table></div>
<!-- EDIT4 TABLE [2273-2913] -->
<p>
Other useful, but less commonly used material definitions:
</p>
<div><table>
<thead>
<tr>
<th> Special Unshaded Material Definitions </th><th> Usage </th><th> Material Parameters </th>
</tr>
</thead>
<tr>
<td> Common/MatDefs/Misc/Sky.j3md </td><td> A solid skyblue, or use with a custom SkyDome texture. <br/>
See also: <a href="/com/jme3/gde/docs/jme3/advanced/sky.html">Sky</a> </td><td> setTexture(&quot;TextureCubeMap&quot;, assetManager.loadTexture(&quot;&quot;)); <br/>
setBoolean(&quot;SphereMap&quot;,true); <br/>
setVector3(&quot;NormalScale&quot;, new Vector3f(0,0,0)); </td>
See also: <a href="/com/jme3/gde/docs/jme3/advanced/sky.html">Sky</a> </td><td> setTexture(“TextureCubeMap”, assetManager.loadTexture(“”)); <br/>
setBoolean(“SphereMap”,true); <br/>
setVector3(“NormalScale”, new Vector3f(0,0,0)); </td>
</tr>
<tr>
<td> Common/MatDefs/Terrain/Terrain.j3md </td><td> Splat textures for e.g. terrains. <br/>
See also: <a href="/com/jme3/gde/docs/jme3/beginner/hello_terrain.html">Hello Terrain</a> </td><td> setTexture(&quot;Tex1&quot;, assetManager.loadTexture(&quot;&quot;)); (red) <br/>
setFloat(&quot;Tex1Scale&quot;,1f); <br/>
setTexture(&quot;Tex2&quot;, assetManager.loadTexture(&quot;&quot;)); (green) <br/>
setFloat(&quot;Tex2Scale&quot;,1f); <br/>
setTexture(&quot;Tex3&quot;, assetManager.loadTexture(&quot;&quot;)); (blue) <br/>
setFloat(&quot;Tex3Scale&quot;,1f); <br/>
setTexture(&quot;Alpha&quot;, assetManager.loadTexture(&quot;&quot;)); </td>
See also: <a href="/com/jme3/gde/docs/jme3/beginner/hello_terrain.html">Hello Terrain</a> </td><td> setTexture(“Tex1”, assetManager.loadTexture(“”)); (red) <br/>
setFloat(“Tex1Scale”,1f); <br/>
setTexture(“Tex2”, assetManager.loadTexture(“”)); (green) <br/>
setFloat(“Tex2Scale”,1f); <br/>
setTexture(“Tex3”, assetManager.loadTexture(“”)); (blue) <br/>
setFloat(“Tex3Scale”,1f); <br/>
setTexture(“Alpha”, assetManager.loadTexture(“”)); </td>
</tr>
<tr>
<td>Common/MatDefs/Terrain/HeightBasedTerrain.j3md</td><td>A multi-layered texture for terrains. <br/>
@ -119,38 +114,37 @@ Texture regions can overlap. <br/>
For example: Specify a seafloor texture for the lowest areas, <br/>
a sandy texture for the beaches, <br/>
a grassy texure for inland areas, <br/>
and a rocky texture for mountain tops.</td><td> setFloat(&quot;terrainSize&quot;,512f); <br/>
setTexture(&quot;region1ColorMap&quot;, assetManager.loadTexture(&quot;&quot;)); <br/>
setTexture(&quot;region2ColorMap&quot;, assetManager.loadTexture(&quot;&quot;)); <br/>
setTexture(&quot;region3ColorMap&quot;, assetManager.loadTexture(&quot;&quot;)); <br/>
setTexture(&quot;region4ColorMap&quot;, assetManager.loadTexture(&quot;&quot;)); <br/>
setVector3(&quot;region1&quot;, new Vector3f(0,0,0)); <br/>
setVector3(&quot;region2&quot;, new Vector3f(0,0,0)); <br/>
setVector3(&quot;region3&quot;, new Vector3f(0,0,0)); <br/>
setVector3(&quot;region4&quot;, new Vector3f(0,0,0)); <br/>
and a rocky texture for mountain tops.</td><td> setFloat(“terrainSize”,512f); <br/>
setTexture(“region1ColorMap”, assetManager.loadTexture(“”)); <br/>
setTexture(“region2ColorMap”, assetManager.loadTexture(“”)); <br/>
setTexture(“region3ColorMap”, assetManager.loadTexture(“”)); <br/>
setTexture(“region4ColorMap”, assetManager.loadTexture(“”)); <br/>
setVector3(“region1”, new Vector3f(0,0,0)); <br/>
setVector3(“region2”, new Vector3f(0,0,0)); <br/>
setVector3(“region3”, new Vector3f(0,0,0)); <br/>
setVector3(“region4”, new Vector3f(0,0,0)); <br/>
<strong>Settings for steep areas:</strong> <br/>
setTexture(&quot;slopeColorMap&quot;, assetManager.loadTexture(&quot;&quot;)); <br/>
setFloat(&quot;slopeTileFactor&quot;,1f);</td>
setTexture(“slopeColorMap”, assetManager.loadTexture(“”)); <br/>
setFloat(“slopeTileFactor”,1f);</td>
</tr>
<tr>
<td> Common/MatDefs/Misc/Particle.j3md </td><td> Used with texture masks for particle effects, or for point sprites. <br/>
The Quadratic value scales the particle for perspective view (<object classid="java:org.netbeans.modules.javahelp.BrowserDisplayer"><param name="content" value="http://code.google.com/p/jmonkeyengine/source/browse/trunk/engine/src/core/com/jme3/effect/ParticleEmitter.java"><param name="text" value="<html><u>formula</u></html>"><param name="textColor" value="blue"></object>). <br/>
Does support an optional colored glow effect. <br/>
See also: <a href="/com/jme3/gde/docs/jme3/beginner/hello_effects.html">Hello Effects</a> </td><td> setTexture(&quot;Texture&quot;, assetManager.loadTexture(&quot;&quot;)); <br/>
setTexture(&quot;GlowMap&quot;, assetManager.loadTexture(&quot;&quot;)); <br/>
setColor(&quot;GlowColor&quot;, ColorRGBA.White); <br/>
setFloat(&quot;Quadratic&quot;,1f); <br/>
setBoolean(&quot;PointSprite&quot;,true); </td>
See also: <a href="/com/jme3/gde/docs/jme3/beginner/hello_effects.html">Hello Effects</a> </td><td> setTexture(“Texture”, assetManager.loadTexture(“”)); <br/>
setTexture(“GlowMap”, assetManager.loadTexture(“”)); <br/>
setColor(“GlowColor”, ColorRGBA.White); <br/>
setFloat(“Quadratic”,1f); <br/>
setBoolean(“PointSprite”,true); </td>
</tr>
</table></div>
<!-- EDIT5 TABLE [2975-5467] -->
</div>
<!-- EDIT3 SECTION "Unshaded Coloring and Textures" [1718-5468] -->
<h3><a>Phong Illuminated</a></h3>
<h3>Phong Illuminated</h3>
<div>
<p>
jMonkeyEngine supports illuminated and unshaded Material Definitions.
</p>
<ul>
@ -161,52 +155,54 @@ jMonkeyEngine supports illuminated and unshaded Material Definitions.
</ul>
<p>
Illuminated materials require a <a href="/com/jme3/gde/docs/jme3/advanced/light_and_shadow.html">light source</a> added to at least one of their parent nodes! (e.g. rootNode.) Illuminated materials are darker on the sides facing away from light sources. They use Phong illumination model (default), or the Ward isotropic gaussian specular shader (WardIso) which looks more like plastic. They do not cast <a href="/com/jme3/gde/docs/jme3/advanced/light_and_shadow.html">drop shadows</a> unless you use a FilterPostProcessor.
</p>
<div><table>
<thead>
<tr>
<th>Standard Illuminated Material Definition </th><th> Usage </th><th> Material Parameters </th>
</tr>
</thead>
<tr>
<td> Common/MatDefs/Light/Lighting.j3md </td><td> Commonly used Material with Phong illumination. <br/>
Use this material together with DiffuseMap, SpecularMap, BumpMap (NormalMaps, ParalaxMap) textures. <br/>
Supports shininess, transparency, and plain material colors (Diffuse, Ambient, Specular colors). <br/>
See also: <a href="/com/jme3/gde/docs/jme3/beginner/hello_material.html">Hello Material</a> </td><td> <strong>Texture Maps</strong> <br/>
setTexture(&quot;DiffuseMap&quot;, assetManager.loadTexture(&quot;&quot;)); <br/>
setBoolean(&quot;UseAlpha&quot;,true);<sup><a href="#fn__1">1)</a></sup> <br/>
setTexture(&quot;NormalMap&quot;, assetManager.loadTexture(&quot;&quot;)); <br/>
setBoolean(&quot;LATC&quot;,true); <sup><a href="#fn__2">2)</a></sup> <br/>
setTexture(&quot;SpecularMap&quot;, assetManager.loadTexture(&quot;&quot;)); <br/>
setFloat(&quot;Shininess&quot;,64f); <br/>
setTexture(&quot;ParallaxMap&quot;, assetManager.loadTexture(&quot;&quot;)); <br/>
setTexture(&quot;AlphaMap&quot;, assetManager.loadTexture(&quot;&quot;)); <br/>
setFloat(&quot;AlphaDiscardThreshold&quot;,1f); <br/>
setTexture(&quot;ColorRamp&quot;, assetManager.loadTexture(&quot;&quot;)); <br/>
setTexture(“DiffuseMap”, assetManager.loadTexture(“”)); <br/>
setBoolean(“UseAlpha”,true);<sup><a href="#fn__1">1)</a></sup> <br/>
setTexture(“NormalMap”, assetManager.loadTexture(“”)); <br/>
setBoolean(“LATC”,true); <sup><a href="#fn__2">2)</a></sup> <br/>
setTexture(“SpecularMap”, assetManager.loadTexture(“”)); <br/>
setFloat(“Shininess”,64f); <br/>
setTexture(“ParallaxMap”, assetManager.loadTexture(“”)); <br/>
setTexture(“AlphaMap”, assetManager.loadTexture(“”)); <br/>
setFloat(“AlphaDiscardThreshold”,1f); <br/>
setTexture(“ColorRamp”, assetManager.loadTexture(“”)); <br/>
<strong>Glow</strong> <br/>
setTexture(&quot;GlowMap&quot;, assetManager.loadTexture(&quot;&quot;)); <br/>
setColor(&quot;GlowColor&quot;, ColorRGBA.White); <br/>
setTexture(“GlowMap”, assetManager.loadTexture(“”)); <br/>
setColor(“GlowColor”, ColorRGBA.White); <br/>
<strong>Performance and quality</strong> <br/>
setBoolean(&quot;VertexLighting&quot;,true); <br/>
setBoolean(&quot;UseVertexColor&quot;,true); <br/>
setBoolean(&quot;LowQuality&quot;,true); <br/>
setBoolean(&quot;HighQuality&quot;,true); <br/>
setBoolean(“VertexLighting”,true); <br/>
setBoolean(“UseVertexColor”,true); <br/>
setBoolean(“LowQuality”,true); <br/>
setBoolean(“HighQuality”,true); <br/>
<strong>Material Colors</strong> <br/>
setBoolean(&quot;UseMaterialColors&quot;,true); <br/>
setColor(&quot;Diffuse&quot;, ColorRGBA.White); <br/>
setColor(&quot;Ambient&quot;, ColorRGBA.White); <br/>
setColor(&quot;Specular&quot;, ColorRGBA.White); <br/>
setBoolean(“UseMaterialColors”,true); <br/>
setColor(“Diffuse”, ColorRGBA.White); <br/>
setColor(“Ambient”, ColorRGBA.White); <br/>
setColor(“Specular”, ColorRGBA.White); <br/>
<strong>Tangent shading:</strong> <br/>
setBoolean(&quot;VTangent&quot;,true); <br/>
setBoolean(&quot;Minnaert&quot;,true);<sup><a href="#fn__3">3)</a></sup> <br/>
setBoolean(&quot;WardIso&quot;,true);<sup><a href="#fn__4">4)</a></sup> </td>
setBoolean(“VTangent”,true); <br/>
setBoolean(“Minnaert”,true);<sup><a href="#fn__3">3)</a></sup> <br/>
setBoolean(“WardIso”,true);<sup><a href="#fn__4">4)</a></sup> </td>
</tr>
</table></div>
<!-- EDIT7 TABLE [6128-7846] --><div><table>
<thead>
<tr>
<th>Special Illuminated Material Definitions </th><th> Usage </th><th> Material Parameters </th>
</tr>
</thead>
<tr>
<td>Common/MatDefs/Terrain/TerrainLighting.j3md</td><td>Same kind of multi-layered splat texture as Terrain.j3md, but with illumination and shading. <br/>
Typically used for terrains, but works on any mesh. <br/>
@ -215,50 +211,52 @@ You can use a total of 11 texture maps in the terrain&#039;s splat texture: <br/
Note that diffuse and normal maps all count against that. <br/>
For example, you can use a maximum of 9 diffuse textures, two of which can have normal maps; <br/>
or, five textures with both diffuse and normal maps.</td><td><strong>Texture Splat Maps</strong> <br/>
setTexture(&quot;DiffuseMap&quot;, assetManager.loadTexture(&quot;&quot;)); <br/>
setFloat(&quot;DiffuseMap_0_scale&quot;,1f); <br/>
setTexture(&quot;NormalMap&quot;, assetManager.loadTexture(&quot;&quot;)); <br/>
setTexture(&quot;DiffuseMap_1&quot;, assetManager.loadTexture(&quot;&quot;)); <br/>
setFloat(&quot;DiffuseMap_1_scale&quot;,1f); <br/>
setTexture(&quot;NormalMap_1&quot;, assetManager.loadTexture(&quot;&quot;)); <br/>
setTexture(&quot;DiffuseMap_2&quot;, assetManager.loadTexture(&quot;&quot;)); <br/>
setFloat(&quot;DiffuseMap_2_scale&quot;,1f); <br/>
setTexture(&quot;NormalMap_2&quot;, assetManager.loadTexture(&quot;&quot;)); <br/>
setTexture(&quot;DiffuseMap_3&quot;, assetManager.loadTexture(&quot;&quot;)); <br/>
setFloat(&quot;DiffuseMap_3_scale&quot;,1f); <br/>
setTexture(&quot;NormalMap_3&quot;, assetManager.loadTexture(&quot;&quot;)); <br/>
setTexture(“DiffuseMap”, assetManager.loadTexture(“”)); <br/>
setFloat(“DiffuseMap_0_scale”,1f); <br/>
setTexture(“NormalMap”, assetManager.loadTexture(“”)); <br/>
setTexture(“DiffuseMap_1”, assetManager.loadTexture(“”)); <br/>
setFloat(“DiffuseMap_1_scale”,1f); <br/>
setTexture(“NormalMap_1”, assetManager.loadTexture(“”)); <br/>
setTexture(“DiffuseMap_2”, assetManager.loadTexture(“”)); <br/>
setFloat(“DiffuseMap_2_scale”,1f); <br/>
setTexture(“NormalMap_2”, assetManager.loadTexture(“”)); <br/>
setTexture(“DiffuseMap_3”, assetManager.loadTexture(“”)); <br/>
setFloat(“DiffuseMap_3_scale”,1f); <br/>
setTexture(“NormalMap_3”, assetManager.loadTexture(“”)); <br/>
etc, up to 11. <br/>
<strong>Alpha Maps</strong> <br/>
setTexture(&quot;AlphaMap&quot;, assetManager.loadTexture(&quot;&quot;)); <br/>
setTexture(&quot;AlphaMap_1&quot;, assetManager.loadTexture(&quot;&quot;)); <br/>
setTexture(&quot;AlphaMap_2&quot;, assetManager.loadTexture(&quot;&quot;)); <br/>
setTexture(“AlphaMap”, assetManager.loadTexture(“”)); <br/>
setTexture(“AlphaMap_1”, assetManager.loadTexture(“”)); <br/>
setTexture(“AlphaMap_2”, assetManager.loadTexture(“”)); <br/>
<strong>Glowing</strong> <br/>
setTexture(&quot;GlowMap&quot;, assetManager.loadTexture(&quot;&quot;)); <br/>
setColor(&quot;GlowColor&quot;, ColorRGBA.White); <br/>
setTexture(“GlowMap”, assetManager.loadTexture(“”)); <br/>
setColor(“GlowColor”, ColorRGBA.White); <br/>
<strong>Miscellaneous</strong> <br/>
setColor(&quot;Diffuse&quot;, ColorRGBA.White); <br/>
setColor(&quot;Ambient&quot;, ColorRGBA.White); <br/>
setFloat(&quot;Shininess&quot;,64f); <br/>
setColor(&quot;Specular&quot;, ColorRGBA.White); <br/>
setTexture(&quot;SpecularMap&quot;, assetManager.loadTexture(&quot;&quot;)); <br/>
setBoolean(&quot;WardIso&quot;,true); <br/>
setBoolean(&quot;useTriPlanarMapping&quot;,true); <br/>
setBoolean(&quot;isTerrainGrid&quot;,true); </td>
setColor(“Diffuse”, ColorRGBA.White); <br/>
setColor(“Ambient”, ColorRGBA.White); <br/>
setFloat(“Shininess”,64f); <br/>
setColor(“Specular”, ColorRGBA.White); <br/>
setTexture(“SpecularMap”, assetManager.loadTexture(“”)); <br/>
setBoolean(“WardIso”,true); <br/>
setBoolean(“useTriPlanarMapping”,true); <br/>
setBoolean(“isTerrainGrid”,true); </td>
</tr>
<tr>
<td> Common/MatDefs/Light/Reflection.j3md </td><td> Reflective glass material with environment map (CubeMap/SphereMap). See also: <object classid="java:org.netbeans.modules.javahelp.BrowserDisplayer"><param name="content" value="http://code.google.com/p/jmonkeyengine/source/browse/trunk/engine/src/test/jme3test/texture/TestCubeMap.java"><param name="text" value="<html><u>TestCubeMap.java</u></html>"><param name="textColor" value="blue"></object> </td><td> setTexture(&quot;Texture&quot;, assetManager.loadTexture(&quot;&quot;)); <br/>
setBoolean(&quot;SphereMap&quot;,true); </td>
<td> Common/MatDefs/Light/Reflection.j3md </td><td> Reflective glass material with environment map (CubeMap/SphereMap). See also: <object classid="java:org.netbeans.modules.javahelp.BrowserDisplayer"><param name="content" value="http://code.google.com/p/jmonkeyengine/source/browse/trunk/engine/src/test/jme3test/texture/TestCubeMap.java"><param name="text" value="<html><u>TestCubeMap.java</u></html>"><param name="textColor" value="blue"></object> </td><td> setTexture(“Texture”, assetManager.loadTexture(“”)); <br/>
setBoolean(“SphereMap”,true); </td>
</tr>
</table></div>
<!-- EDIT8 TABLE [7848-10134] -->
</div>
<!-- EDIT6 SECTION "Phong Illuminated" [5469-10135] -->
<h3><a>Other: Test and Debug</a></h3>
<h3>Other: Test and Debug</h3>
<div>
<div><table>
<thead>
<tr>
<th> Material Definition </th><th> Usage </th>
</tr>
</thead>
<tr>
<td> Common/MatDefs/Misc/ShowNormals.j3md </td><td> A color gradient calculated from the model&#039;s surface normals. You can use this built-in material to debug the generation of normals in meshes, to preview models that have no material and no lights, or as fall-back default material. This built-in material has no parameters. </td>
</tr>
@ -266,29 +264,31 @@ setBoolean(&quot;WardIso&quot;,true); <br/>
<!-- EDIT10 TABLE [10169-10540] -->
</div>
<!-- EDIT9 SECTION "Other: Test and Debug" [10136-10541] -->
<h2><a>RenderStates</a></h2>
<h2>RenderStates</h2>
<div>
</div>
<!-- EDIT11 SECTION "RenderStates" [10542-10567] -->
<h3><a>Transparency</a></h3>
<h3>Transparency</h3>
<div>
<div><table>
<thead>
<tr>
<th>Material Option</th><th>Description</th><th>Example</th>
</tr>
</thead>
<tr>
<td>getAdditionalRenderState().setBlendMode(BlendMode.Off);</td><td>This is the default, no transparency.</td><td>Use for all opaque objects like walls, floors, people???</td>
<td>getAdditionalRenderState().setBlendMode(BlendMode.Off);</td><td>This is the default, no transparency.</td><td>Use for all opaque objects like walls, floors, people</td>
</tr>
<tr>
<td>getAdditionalRenderState().setBlendMode(BlendMode.Alpha);</td><td>Interpolates the background pixel with the current pixel by using the current pixel&#039;s alpha.</td><td>Use this for normal every-day translucency: Frosted window panes, ice, glass, alpha-blended vegetation textures??? </td>
<td>getAdditionalRenderState().setBlendMode(BlendMode.Alpha);</td><td>Interpolates the background pixel with the current pixel by using the current pixel&#039;s alpha.</td><td>Use this for normal every-day translucency: Frosted window panes, ice, glass, alpha-blended vegetation textures </td>
</tr>
<tr>
<td>getAdditionalRenderState().setDepthWrite(false);</td><td>Disables writing of the pixel&#039;s depth value to the depth buffer.</td><td>Use this on Materials if you have several transparent/translucent objects obscuring one another, but you want to see through both.</td>
</tr>
<tr>
<td>getAdditionalRenderState().setAlphaFallOff(0.5f); <br/>
getAdditionalRenderState().setAlphaTest(true)</td><td>Enables Alpha Testing with a &quot;AlphaDiscardThreshold&quot; in the AlphaMap.</td><td>Activate Alpha Testing for (partially) <strong>transparent</strong> objects such as foliage, hair, etc. <br/>
getAdditionalRenderState().setAlphaTest(true)</td><td>Enables Alpha Testing with a “AlphaDiscardThreshold” in the AlphaMap.</td><td>Activate Alpha Testing for (partially) <strong>transparent</strong> objects such as foliage, hair, etc. <br/>
Deactivate Alpha Testing for gradually <strong>translucent</strong> objects, such as colored glass, smoked glass, ghosts.</td>
</tr>
<tr>
@ -296,7 +296,7 @@ Deactivate Alpha Testing for gradually <strong>translucent</strong> objects, suc
<strong>Note:</strong> Viewed in front of a white background, Additive textures become fully transparent! </td><td> This is the default for Particle.j3md-based textures that have a black color background. </td>
</tr>
<tr>
<td>getAdditionalRenderState().setBlendMode(BlendMode.AlphaAdditive);</td><td>Same as &quot;Additive&quot;, except first it multiplies the current pixel color by the pixel alpha.</td><td>This can be used for particle effects that have alpha as background. </td>
<td>getAdditionalRenderState().setBlendMode(BlendMode.AlphaAdditive);</td><td>Same as “Additive”, except first it multiplies the current pixel color by the pixel alpha.</td><td>This can be used for particle effects that have alpha as background. </td>
</tr>
<tr>
<td>getAdditionalRenderState().setBlendMode(BlendMode.Color);</td><td>Blends by color.</td><td>Generally useless.</td>
@ -305,17 +305,15 @@ Deactivate Alpha Testing for gradually <strong>translucent</strong> objects, suc
<td>getAdditionalRenderState().setBlendMode(BlendMode.Modulate);</td><td>Multiplies the background pixel by the current pixel.</td><td>?</td>
</tr>
<tr>
<td>getAdditionalRenderState().setBlendMode(BlendMode.ModulateX2);</td><td>Same as &quot;Modulate&quot;, except the result is doubled.</td><td>?</td>
<td>getAdditionalRenderState().setBlendMode(BlendMode.ModulateX2);</td><td>Same as “Modulate”, except the result is doubled.</td><td>?</td>
</tr>
<tr>
<td>getAdditionalRenderState().setBlendMode(BlendMode.PremultAlpha);</td><td>Pre-multiplied alpha blending. E.g. if the color of the object has already been multiplied by its alpha, this is used instead of &quot;Alpha&quot; blend mode.</td><td>For use with Premult Alpha textures.</td>
<td>getAdditionalRenderState().setBlendMode(BlendMode.PremultAlpha);</td><td>Pre-multiplied alpha blending. E.g. if the color of the object has already been multiplied by its alpha, this is used instead of “Alpha” blend mode.</td><td>For use with Premult Alpha textures.</td>
</tr>
</table></div>
<!-- EDIT13 TABLE [10592-13042] -->
<p>
If the DiffuseMap has an alpha channel, use:
</p>
<pre>mat.setBoolean&#40;&quot;UseAlpha&quot;,true&#41;;</pre>
@ -333,12 +331,14 @@ Later, put the Geometry (not the Material!) in the appropriate render queue
</div>
<!-- EDIT12 SECTION "Transparency" [10568-13341] -->
<h3><a>Culling</a></h3>
<h3>Culling</h3>
<div>
<div><table>
<thead>
<tr>
<th>Material Option</th><th>Usage</th><th>Example</th>
</tr>
</thead>
<tr>
<td>getAdditionalRenderState().setFaceCullMode(FaceCullMode.Back); </td><td>Activates back-face culling. Mesh faces that are facing away from the camera are not rendered, which saves time. *Backface culling is activated by default as a major optimization.* </td><td>The invisible backsides and insides of models are not calculated. </td>
</tr>
@ -346,7 +346,7 @@ Later, put the Geometry (not the Material!) in the appropriate render queue
<td>getAdditionalRenderState().setFaceCullMode(FaceCullMode.Off); </td><td>No meshes are culled. Both mesh faces are rendered, even if they face away from the camera. Slow.</td><td>Sometimes used to debug custom meshes if you messed up some of the polygon sides, or for special shadow effects.</td>
</tr>
<tr>
<td>getAdditionalRenderState().setFaceCullMode(FaceCullMode.Front); </td><td>Activates front-face culling. Mesh faces facing the camera are not rendered.</td><td>No example ??? Typically not used because you wouldn&#039;t see anything meaningful.</td>
<td>getAdditionalRenderState().setFaceCullMode(FaceCullMode.Front); </td><td>Activates front-face culling. Mesh faces facing the camera are not rendered.</td><td>No example Typically not used because you wouldn&#039;t see anything meaningful.</td>
</tr>
<tr>
<td>getAdditionalRenderState().setFaceCullMode(FaceCullMode.FrontAndBack)</td><td>Culls both backfaces and frontfaces.</td><td>Use this as an efficient way to make an object temporarily invisible, while keeping all its other in-game properties (such as node attachment, collision shapes, interactions, etc) active.</td>
@ -355,14 +355,14 @@ Later, put the Geometry (not the Material!) in the appropriate render queue
<!-- EDIT15 TABLE [13361-14503] -->
</div>
<!-- EDIT14 SECTION "Culling" [13342-14504] -->
<h3><a>Miscellaneous</a></h3>
<h3>Miscellaneous</h3>
<div>
<div><table>
<tr>
<td>getAdditionalRenderState().setColorWrite(false);</td><td>Disable writing the color of pixels.</td><td>Use this together with setDepthWrite(true) to write pixels only to the depth buffer, for example. </td>
</tr>
<tr>
<td>getAdditionalRenderState().setPointSprite(true);</td><td>Enables point-sprite mode, e.g. meshes with &quot;Mode.Points&quot; will be rendered as textured sprites. Note that gl_PointCoord must be set in the shader.</td><td>Point sprites are used internally for hardware accelerated particle effects.</td>
<td>getAdditionalRenderState().setPointSprite(true);</td><td>Enables point-sprite mode, e.g. meshes with “Mode.Points” will be rendered as textured sprites. Note that gl_PointCoord must be set in the shader.</td><td>Point sprites are used internally for hardware accelerated particle effects.</td>
</tr>
<tr>
<td>getAdditionalRenderState().setPolyOffset();</td><td>Enable polygon offset.</td><td>Use this when you have meshes that have triangles really close to each over (e.g. <object classid="java:org.netbeans.modules.javahelp.BrowserDisplayer"><param name="content" value="http://en.wikipedia.org/wiki/Coplanarity"><param name="text" value="<html><u>Coplanar</u></html>"><param name="textColor" value="blue"></object>), it will shift the depth values to prevent <object classid="java:org.netbeans.modules.javahelp.BrowserDisplayer"><param name="content" value="http://en.wikipedia.org/wiki/Z-fighting"><param name="text" value="<html><u>Z-fighting</u></html>"><param name="textColor" value="blue"></object>.</td>
@ -370,23 +370,16 @@ Later, put the Geometry (not the Material!) in the appropriate render queue
</table></div>
<!-- EDIT17 TABLE [14530-15296] -->
<p>
<strong>Related Links</strong>
</p>
<ul>
<li><div> <a href="/com/jme3/gde/docs/jme3/advanced/material_specification.html">Developer specification of the jME3 material system (.j3md,.j3m)</a></div>
</li>
</ul>
<div><span>
<a href="/wiki/doku.php/tag:material?do=showtag&amp;tag=tag%3Amaterial">material</a>,
<a href="/wiki/doku.php/tag:texture?do=showtag&amp;tag=tag%3Atexture">texture</a>,
<a href="/wiki/doku.php/tag:matdefs?do=showtag&amp;tag=tag%3Amatdefs">MatDefs</a>,
<a href="/wiki/doku.php/tag:light?do=showtag&amp;tag=tag%3Alight">light</a>,
<a href="/wiki/doku.php/tag:culling?do=showtag&amp;tag=tag%3Aculling">culling</a>,
<a href="/wiki/doku.php/tag:renderstates?do=showtag&amp;tag=tag%3Arenderstates">RenderStates</a>,
<a href="/wiki/doku.php/tag:documentation?do=showtag&amp;tag=tag%3Adocumentation">documentation</a>
</span></div>
<p>
<a href="nbdocs:/com/jme3/gde/docs/jme3:advanced/tag_material_texture_matdefs_light_culling_renderstates_documentation">tag_material_texture_matdefs_light_culling_renderstates_documentation</a>
</p>
</div>
<!-- EDIT16 SECTION "Miscellaneous" [14505-] --><div>
@ -399,4 +392,4 @@ Minnaert is a shader type.</div>
<div><sup><a href="#fnt__4">4)</a></sup>
WardIso is a shader type.</div>
</div>
<p><em><a href="http://hub.jmonkeyengine.org/wiki/doku.php/jme3:advanced:materials_overview?do=export_xhtmlbody">view online version</a></em></p>
<p><em><a href="http://wiki.jmonkeyengine.org/doku.php/jme3:advanced:materials_overview?do=export_xhtmlbody">view online version</a></em></p>

@ -1,18 +1,16 @@
<h1><a>Polygon Meshes</a></h1>
<h1>Polygon Meshes</h1>
<div>
<p>
<img src="nbdocs:/com/jme3/gde/docs/jme3/dolphin-mesh.png">
</p>
<p>
All visible game elements in a scene, whether it is a Model or a Shape, are made up of polygon meshes. JME3 has a com.jme3.scene.Mesh class that represents all meshes.
</p>
<ul>
<li><div> Meshes are made up of triangles: <code>getTriangleCount(???)</code> and <code>getTriangle(???)</code></div>
<li><div> Meshes are made up of triangles: <code>getTriangleCount()</code> and <code>getTriangle()</code></div>
</li>
<li><div> Each mesh has a unique ID: <code>getId()</code></div>
</li>
@ -31,7 +29,6 @@ All visible game elements in a scene, whether it is a Model or a Shape, are made
</ul>
<p>
You have several options when <a href="/com/jme3/gde/docs/jme3/advanced/spatial.html">creating Geometries from meshes</a>:
</p>
<ul>
@ -45,22 +42,23 @@ You have several options when <a href="/com/jme3/gde/docs/jme3/advanced/spatial.
</div>
<!-- EDIT1 SECTION "Polygon Meshes" [1-1154] -->
<h2><a>Vertex Buffer</a></h2>
<h2>Vertex Buffer</h2>
<div>
<p>
The VertexBuffer contains a particular type of geometry data used by Meshes. Every VertexBuffer set on a Mesh is sent as an attribute to the vertex shader to be processed.
</p>
</div>
<!-- EDIT2 SECTION "Vertex Buffer" [1155-1354] -->
<h3><a>Mesh Vertex Buffers</a></h3>
<h3>Mesh Vertex Buffers</h3>
<div>
<div><table>
<thead>
<tr>
<th>Vertex Buffer Type</th><th>Description</th>
</tr>
</thead>
<tr>
<td>Type.Position </td><td>Position of the vertex (3 floats)</td>
</tr>
@ -107,12 +105,14 @@ The VertexBuffer contains a particular type of geometry data used by Meshes. Eve
<!-- EDIT4 TABLE [1386-2205] -->
</div>
<!-- EDIT3 SECTION "Mesh Vertex Buffers" [1355-2206] -->
<h3><a>Mesh Properties</a></h3>
<h3>Mesh Properties</h3>
<div>
<div><table>
<thead>
<tr>
<th>Mesh method</th><th>Description</th>
</tr>
</thead>
<tr>
<td>setLineWidth(1)</td><td>the thickness of the line if using Mode.Lines</td>
</tr>
@ -144,12 +144,14 @@ The VertexBuffer contains a particular type of geometry data used by Meshes. Eve
<!-- EDIT6 TABLE [2234-2957] -->
</div>
<!-- EDIT5 SECTION "Mesh Properties" [2207-2958] -->
<h3><a>Mesh Rendering Modes</a></h3>
<h3>Mesh Rendering Modes</h3>
<div>
<div><table>
<thead>
<tr>
<th>Mesh Mode</th><th>Description</th>
</tr>
</thead>
<tr>
<td>Mesh.Mode.Points</td><td>Show only corner points (vertices) of mesh</td>
</tr>
@ -178,21 +180,17 @@ The VertexBuffer contains a particular type of geometry data used by Meshes. Eve
<!-- EDIT8 TABLE [2991-3267] -->
</div>
<!-- EDIT7 SECTION "Mesh Rendering Modes" [2959-3268] -->
<h3><a>Level of Detail</a></h3>
<h3>Level of Detail</h3>
<div>
<p>
Optionally, custom meshes can have a LOD (level of detail optimization) that renders more or less detail, depending on the distance of the mesh from the camera. You have to specify several vertex buffers, one for each level of detail you want (very far away with few details, close up with all details, and something in the middle). Use <code>setLodLevels(VertexBuffer[] lodLevels)</code>.
</p>
<div><span>
<a href="/wiki/doku.php/tag:spatial?do=showtag&amp;tag=tag%3Aspatial">spatial</a>,
<a href="/wiki/doku.php/tag:node?do=showtag&amp;tag=tag%3Anode">node</a>,
<a href="/wiki/doku.php/tag:mesh?do=showtag&amp;tag=tag%3Amesh">mesh</a>,
<a href="/wiki/doku.php/tag:geometry?do=showtag&amp;tag=tag%3Ageometry">geometry</a>,
<a href="/wiki/doku.php/tag:scenegraph?do=showtag&amp;tag=tag%3Ascenegraph">scenegraph</a>
</span></div>
<p>
<a href="nbdocs:/com/jme3/gde/docs/jme3:advanced/tag_spatial_node_mesh_geometry_scenegraph">tag_spatial_node_mesh_geometry_scenegraph</a>
</p>
</div>
<!-- EDIT9 SECTION "Level of Detail" [3269-] -->
<p><em><a href="http://hub.jmonkeyengine.org/wiki/doku.php/jme3:advanced:mesh?do=export_xhtmlbody">view online version</a></em></p>
<p><em><a href="http://wiki.jmonkeyengine.org/doku.php/jme3:advanced:mesh?do=export_xhtmlbody">view online version</a></em></p>

@ -1,5 +1,5 @@
<h1><a>Monkey Zone: Multi-player Sample Project</a></h1>
<h1>Monkey Zone: Multi-player Sample Project</h1>
<div>
<p>
@ -10,7 +10,7 @@ MonkeyZone is an multi-player demo game provided by the jME core developer team.
</li>
<li><div> <object classid="java:org.netbeans.modules.javahelp.BrowserDisplayer"><param name="content" value="http://www.youtube.com/watch?v=98yITEoJvqE"><param name="text" value="<html><u>Watch pre-alpha video footage</u></html>"><param name="textColor" value="blue"></object> (YouTube Video)</div>
</li>
<li><div> <object classid="java:org.netbeans.modules.javahelp.BrowserDisplayer"><param name="content" value="http://jmonkeyengine.org/2011/02/13/monkeyzone-a-jme3-game-from-the-core/"><param name="text" value="<html><u>Read &quot;MonkeyZone ??? a jME3 game from the core&quot;</u></html>"><param name="textColor" value="blue"></object> (news article)</div>
<li><div> <object classid="java:org.netbeans.modules.javahelp.BrowserDisplayer"><param name="content" value="http://jmonkeyengine.org/2011/02/13/monkeyzone-a-jme3-game-from-the-core/"><param name="text" value="<html><u>Read &quot;MonkeyZone a jME3 game from the core&quot;</u></html>"><param name="textColor" value="blue"></object> (news article)</div>
</li>
<li><div> <object classid="java:org.netbeans.modules.javahelp.BrowserDisplayer"><param name="content" value="http://jmonkeyengine.org/groups/user-code-projects/forum/topic/open-game-finder/"><param name="text" value="<html><u>Related forum thread: Open Game Finder</u></html>"><param name="textColor" value="blue"></object></div>
</li>
@ -22,20 +22,19 @@ This open-source demo:
<ol>
<li><div> showcases one possible way to implement a game with jME3, and</div>
</li>
<li><div> helps the jME team verify the jME3 <acronym title="Application Programming Interface">API</acronym> in terms of usability.</div>
<li><div> helps the jME team verify the jME3 <abbr title="Application Programming Interface">API</abbr> in terms of usability.</div>
</li>
</ol>
<p>
The game idea is based on ???BattleZone??? arcade game from the 1980s, a first-person shooter the with real-time strategy elements.
The game was written using the jMonkeyEngine <acronym title="Software Development Kit">SDK</acronym>, and it&#039;s based off the BasicGame project template. It took us one week to create a playable pre-alpha, including networking.
The project design follows best practices that make it possible to edit maps, vehicles, etc, in jMonkeyEngine <acronym title="Software Development Kit">SDK</acronym> without having to change the code ??? This allows 3D graphic designers to contribute models more easily. (If you feel like contributing assets or working on parts of the game code, drop us a note!)
The game idea is based on “BattleZone” arcade game from the 1980s, a first-person shooter the with real-time strategy elements.
The game was written using the jMonkeyEngine SDK, and it&#039;s based off the BasicGame project template. It took us one week to create a playable pre-alpha, including networking.
The project design follows best practices that make it possible to edit maps, vehicles, etc, in jMonkeyEngine SDK without having to change the code – This allows 3D graphic designers to contribute models more easily. (If you feel like contributing assets or working on parts of the game code, drop us a note!)
</p>
</div>
<!-- EDIT1 SECTION "Monkey Zone: Multi-player Sample Project" [1-1376] -->
<h2><a>Implementation</a></h2>
<h2>Implementation</h2>
<div>
<p>
@ -44,96 +43,89 @@ When a human user or an AI performs an action (presses a button), the actual log
<br/>
<br/>
<em>The way MonkeyZone is implemented is just one of the many possible ways to do a game like this in jME. Some things might be done more efficiently, some might be done in another way completely. MonkeyZone tries to do things the way that are most appropriate to implement the game at hand and it shows nicely how jME3 and the standard Java <acronym title="Application Programming Interface">API</acronym> can make game development easier and faster. Also note that the way MonkeyZone is designed is not scalable to a MMO style game, it will only work in a FPS style environment where the whole game world can be loaded at once.</em>
<em>The way MonkeyZone is implemented is just one of the many possible ways to do a game like this in jME. Some things might be done more efficiently, some might be done in another way completely. MonkeyZone tries to do things the way that are most appropriate to implement the game at hand and it shows nicely how jME3 and the standard Java <abbr title="Application Programming Interface">API</abbr> can make game development easier and faster. Also note that the way MonkeyZone is designed is not scalable to a MMO style game, it will only work in a FPS style environment where the whole game world can be loaded at once.</em>
</p>
</div>
<!-- EDIT2 SECTION "Implementation" [1377-2671] -->
<h3><a>Terminology</a></h3>
<h3>Terminology</h3>
<div>
<p>
The game uses certain terms that might be familiar to you but maybe used in another way, so heres a quick rundown on the terms being used.
</p>
<ul>
<li><div> Player ??? Logical human or AI player that can enter entities and generally act, only exists as PlayerData ???database??? with an id.</div>
<li><div> Player – Logical human or AI player that can enter entities and generally act, only exists as PlayerData “database” with an id.</div>
</li>
<li><div> Entity ??? Spatial with UserData, a world object like character, vehicle, box or factory. The base form is defined only by a String pointing to the j3o which already has all userdata like hitpoints, speed etc.</div>
<li><div> Entity Spatial with UserData, a world object like character, vehicle, box or factory. The base form is defined only by a String pointing to the j3o which already has all userdata like hitpoints, speed etc.</div>
</li>
<li><div> User ??? Human player using a client</div>
<li><div> User Human player using a client</div>
</li>
<li><div> Player Group ??? Group of players that play together (e.g. one human player and one AI companion per client). For now that&#039;s the same as client_id of human player for all AIControl???ed players originating from that client.</div>
<li><div> Player Group Group of players that play together (e.g. one human player and one AI companion per client). For now that&#039;s the same as client_id of human player for all AIControled players originating from that client.</div>
</li>
<li><div> Client ??? Computer connected to server</div>
<li><div> Client Computer connected to server</div>
</li>
</ul>
</div>
<!-- EDIT3 SECTION "Terminology" [2672-3492] -->
<h3><a>Manager Classes</a></h3>
<h3>Manager Classes</h3>
<div>
<p>
The WorldManager does the main work of organizing players, entities and the world and synchronizing them between the server and client. Both client and server use this class. Some other managers like ClientEffectsManager only exist on the client or server and manage e.g. effects display.
The gameplay is largely controlled by the ServerGameManager which does gameplay logic on the server, combined with the actions issued by the AI and user on the client (see below) it implements the gameplay. It extensively uses the functions exposed by the WorldManager to perform actions and gather data. This is also the class where the actions of the players are actually executed on the server to determine the outcome (ray testing for shooting etc.).
</p>
</div>
<!-- EDIT4 SECTION "Manager Classes" [3493-4262] -->
<h3><a>Use of Controls</a></h3>
<h3>Use of Controls</h3>
<div>
<p>
<a href="/com/jme3/gde/docs/jme3/advanced/custom_controls.html">Controls</a> are used extensively in MonkeyZone for many aspects of the game. When a player enters an entity, the Spatials Controls are configured based on the player that enters. For example when the human user enters an entity, Controls that update the user interface (DefaultHUDControl) or user input (UserInputControl) are added to the current entity Spatial.
</p>
</div>
<h4><a>...As entity capabilities</a></h4>
<h4>...As entity capabilities</h4>
<div>
<p>
Controls attached to Spatials are generally used like an ???array of capabilities??? that the entity posesses. So when an entity has a VehicleControl its expected to be a vehicle, when its got a CharacterControl its expected to be a character.
Controls attached to Spatials are generally used like an “array of capabilities” that the entity posesses. So when an entity has a VehicleControl its expected to be a vehicle, when its got a CharacterControl its expected to be a character.
Other Controls work completely on their own, like CharacterAnimControl which just uses the CharacterControl of the entity to check if the character is running, jumping etc. and then animates the entity if it has an AnimControl.
</p>
</div>
<h4><a>... to abstract</a></h4>
<h4>... to abstract</h4>
<div>
<p>
Furthermore theres special interfaces for Controls that allow abstraction of different Controls into one base interface. For example ManualControl and AutonomousControl are interfaces for controls that manage the movement of a spatial in a generalized way. This way AI code and e.g. the UserInputControl only have to check for a valid AutonomousControl or ManualControl on the spatial to control and move it. The details of the movement are handled by classes like ManualVehicleControl and AutonomousCharacterControl.
</p>
</div>
<h4><a>... for AI functions</a></h4>
<h4>... for AI functions</h4>
<div>
<p>
A special Control called CommandControl handles the Commands that can be executed by user controlled players, see below.
</p>
</div>
<!-- EDIT5 SECTION "Use of Controls" [4263-5866] -->
<h3><a>Artificial Intelligence</a></h3>
<h3>Artificial Intelligence</h3>
<div>
<p>
MonkeyZone includes simple AI functions based on a command queue.
</p>
</div>
<h4><a>Commands</a></h4>
<h4>Commands</h4>
<div>
<p>
@ -164,73 +156,67 @@ To implement autonomous AI players MonkeyZone uses a system of Commands that are
</div>
<h4><a>Triggers</a></h4>
<h4>Triggers</h4>
<div>
<p>
The SphereTrigger is a TriggerControl that is also attached to each AI players current entity. It consists of a GhostControl that checks the overlapping entities around the entity its attached to. It can be assigned a command that is checked with every entity entering the SphereTrigger and executed if applicable (e.g. normal ???attack enemy??? mode).
The SphereTrigger is a TriggerControl that is also attached to each AI players current entity. It consists of a GhostControl that checks the overlapping entities around the entity its attached to. It can be assigned a command that is checked with every entity entering the SphereTrigger and executed if applicable (e.g. normal “attack enemy” mode).
</p>
</div>
<h4><a>NavMesh</a></h4>
<h4>NavMesh</h4>
<div>
<p>
For each map a navigation mesh is generated that allows the entities to navigate the terrain. Autonomous entities automatically get a NavigationControl based on the current map. The AutonomousControl implementations automatically recognize the NavigationControl attached to the Spatial and use it for navigation. The NavMeshNavigationControl implementation contains a reference to the levels NavMesh and implements a navigation algorithm similar to the A* algorithm.
</p>
</div>
<!-- EDIT6 SECTION "Artificial Intelligence" [5867-7721] -->
<h3><a>Networking</a></h3>
<h3>Networking</h3>
<div>
<p>
Networking is realized in the PhysicsSyncManager which we hope to extend to a state where it can serve as a general sync system for physics based network games.
The sync manager basically puts a timestamp on every message sent from the server and then buffers all arriving messages on the client within a certain time window. This allows to compensate for messages arriving too soon or too late within the constraints of the buffer, a future version might step the clients physics space different to compensate for network delays without ???snapping???.
The sync manager basically puts a timestamp on every message sent from the server and then buffers all arriving messages on the client within a certain time window. This allows to compensate for messages arriving too soon or too late within the constraints of the buffer, a future version might step the clients physics space different to compensate for network delays without “snapping”.
</p>
</div>
<!-- EDIT7 SECTION "Networking" [7722-8296] -->
<h2><a>Use of jMonkeyEngine SDK tools</a></h2>
<h2>Use of jMonkeyEngine SDK tools</h2>
<div>
<p>
All assets used in the game, like entity models and loaded maps can be preconfigured and edited using the jMonkeyEngine <acronym title="Software Development Kit">SDK</acronym>. For example, to add a new vehicle type, a vehicle is created in the jMonkeyEngine <acronym title="Software Development Kit">SDK</acronym> vehicle editor and UserData like Speed, HitPoints etc. is applied directly in the editor. When the model is loaded in the game it is automatically configured based on these settings, the same accounts for maps that are loaded, special Nodes that mark e.g. player start locations are recognized automatically etc.
All assets used in the game, like entity models and loaded maps can be preconfigured and edited using the jMonkeyEngine SDK. For example, to add a new vehicle type, a vehicle is created in the jMonkeyEngine SDK vehicle editor and UserData like Speed, HitPoints etc. is applied directly in the editor. When the model is loaded in the game it is automatically configured based on these settings, the same accounts for maps that are loaded, special Nodes that mark e.g. player start locations are recognized automatically etc.
</p>
</div>
<!-- EDIT8 SECTION "Use of jMonkeyEngine SDK tools" [8297-8863] -->
<h3><a>UserData</a></h3>
<h3>UserData</h3>
<div>
<p>
Entities (Nodes and Geometries) that are loaded from disk have certain UserData like HitPoints, Speed etc. that is used to configure the entity at runtime. The jMonkeyEngine <acronym title="Software Development Kit">SDK</acronym> allows adding and editing this UserData, so entity properties are editable visually.
Entities (Nodes and Geometries) that are loaded from disk have certain UserData like HitPoints, Speed etc. that is used to configure the entity at runtime. The jMonkeyEngine SDK allows adding and editing this UserData, so entity properties are editable visually.
</p>
</div>
<!-- EDIT9 SECTION "UserData" [8864-9145] -->
<h3><a>Physics</a></h3>
<h3>Physics</h3>
<div>
<p>
VehicleControls, CharacterControls and RigidBodyControls with mesh collision shape for terrain and objects are generated in the jMonkeyEngine <acronym title="Software Development Kit">SDK</acronym> and saved in the entity j3o file. When an entity is loaded, the type of entity is identified based on the available controls and UserData and it is configured accordingly.
VehicleControls, CharacterControls and RigidBodyControls with mesh collision shape for terrain and objects are generated in the jMonkeyEngine SDK and saved in the entity j3o file. When an entity is loaded, the type of entity is identified based on the available controls and UserData and it is configured accordingly.
</p>
</div>
<!-- EDIT10 SECTION "Physics" [9146-9480] -->
<h2><a>API Info</a></h2>
<h2>API Info</h2>
<div>
</div>
<!-- EDIT11 SECTION "API Info" [9481-9501] -->
<h3><a>Designer Infos</a></h3>
<h3>Designer Infos</h3>
<div>
<p>
@ -271,7 +257,7 @@ Level Spatial marking Node names:
</div>
<h4><a>Developer Infos</a></h4>
<h4>Developer Infos</h4>
<div>
<p>
@ -302,17 +288,17 @@ Programmatic PlayerData:
</div>
<!-- EDIT12 SECTION "Designer Infos" [9502-10027] -->
<h2><a>The Future</a></h2>
<h2>The Future</h2>
<div>
<p>
Have a look at the code and feel free to ask about it, if you want any new features, you are free to implement them. ;)
MonkeyZone is hosted at GoogleCode, where you can check out the jMonkeyEngine <acronym title="Software Development Kit">SDK</acronym>-ready project via svn:
MonkeyZone is hosted at GoogleCode, where you can check out the jMonkeyEngine SDK-ready project via svn:
</p>
<ol>
<li><div> jMonkeyEngine <acronym title="Software Development Kit">SDK</acronym>???Team???Subversion???Checkout,</div>
<li><div> jMonkeyEngine SDK→Team→Subversion→Checkout,</div>
</li>
<li><div> Enter the SVN <acronym title="Uniform Resource Locator">URL</acronym> <code><object classid="java:org.netbeans.modules.javahelp.BrowserDisplayer"><param name="content" value="http://monkeyzone.googlecode.com/svn/trunk/"><param name="text" value="<html><u>http://monkeyzone.googlecode.com/svn/trunk/</u></html>"><param name="textColor" value="blue"></object></code></div>
<li><div> Enter the SVN <abbr title="Uniform Resource Locator">URL</abbr> <code><object classid="java:org.netbeans.modules.javahelp.BrowserDisplayer"><param name="content" value="http://monkeyzone.googlecode.com/svn/trunk/"><param name="text" value="<html><u>http://monkeyzone.googlecode.com/svn/trunk/</u></html>"><param name="textColor" value="blue"></object></code></div>
</li>
<li><div> Download, open, and build the project</div>
</li>
@ -322,20 +308,17 @@ MonkeyZone is hosted at GoogleCode, where you can check out the jMonkeyEngine <a
</div>
<!-- EDIT13 SECTION "The Future" [10028-10550] -->
<h2><a>Troubleshooting</a></h2>
<h2>Troubleshooting</h2>
<div>
<ol>
<li><div> After download, errors could appear because jme3tools.navmesh.util\NavMeshGenerator.java import com.jme3.terrain.Terrain is not known, you should correct this by setting Project Properties &gt; Libraries &gt; Add Library &gt; jme3-libraries-terrain </div>
</li>
</ol>
<div><span>
<a href="/wiki/doku.php/tag:network?do=showtag&amp;tag=tag%3Anetwork">network</a>,
<a href="/wiki/doku.php/tag:basegame?do=showtag&amp;tag=tag%3Abasegame">basegame</a>,
<a href="/wiki/doku.php/tag:physics?do=showtag&amp;tag=tag%3Aphysics">physics</a>,
<a href="/wiki/doku.php/tag:inputs?do=showtag&amp;tag=tag%3Ainputs">inputs</a>,
<a href="/wiki/doku.php/tag:spidermonkey?do=showtag&amp;tag=tag%3Aspidermonkey">spidermonkey</a>
</span></div>
<p>
<a href="nbdocs:/com/jme3/gde/docs/jme3:advanced/tag_network_basegame_physics_inputs_spidermonkey">tag_network_basegame_physics_inputs_spidermonkey</a>
</p>
</div>
<!-- EDIT14 SECTION "Troubleshooting" [10551-] -->
<p><em><a href="http://hub.jmonkeyengine.org/wiki/doku.php/jme3:advanced:monkey_zone?do=export_xhtmlbody">view online version</a></em></p>
<p><em><a href="http://wiki.jmonkeyengine.org/doku.php/jme3:advanced:monkey_zone?do=export_xhtmlbody">view online version</a></em></p>

@ -1,9 +1,8 @@
<h1><a>MotionPath</a></h1>
<h1>MotionPath</h1>
<div>
<p>
A MotionPath describes the motion of a spatial between waypoints. The path can be linear or rounded. You use MotionPaths to remote-control a spatial, or the camera.
</p>
@ -13,7 +12,7 @@ A MotionPath describes the motion of a spatial between waypoints. The path can b
</div>
<!-- EDIT1 SECTION "MotionPath" [1-365] -->
<h2><a>Sample Code</a></h2>
<h2>Sample Code</h2>
<div>
<ul>
<li><div> <object classid="java:org.netbeans.modules.javahelp.BrowserDisplayer"><param name="content" value="http://code.google.com/p/jmonkeyengine/source/browse/trunk/engine/src/test/jme3test/animation/TestMotionPath.java"><param name="text" value="<html><u>TestMotionPath.java</u></html>"><param name="textColor" value="blue"></object></div>
@ -24,11 +23,10 @@ A MotionPath describes the motion of a spatial between waypoints. The path can b
</div>
<!-- EDIT2 SECTION "Sample Code" [366-689] -->
<h2><a>What Are Way Points?</a></h2>
<h2>What Are Way Points?</h2>
<div>
<p>
When shooting a movie scene, the director tells actors where to walk, for example, by drawing a series of small crosses on the floor. Cameramen often mount the camera on rails (so called dolly track) so they can follow along complex scenes more easily.
</p>
@ -48,13 +46,11 @@ The final shape of the path is computed using a linear interpolation or a <objec
</div>
<!-- EDIT3 SECTION "What Are Way Points?" [690-1498] -->
<h2><a>Create a MotionPath</a></h2>
<h2>Create a MotionPath</h2>
<div>
<p>
Create a Motionpath object and add way points to it.
</p>
<pre>MotionPath path = new MotionPath&#40;&#41;;
path.addWayPoint&#40;new Vector3f&#40;10, 3, 0&#41;&#41;;
@ -63,12 +59,13 @@ path.addWayPoint&#40;new Vector3f&#40;8, -2, 1&#41;&#41;;
<p>
You can configure the path as follows.
</p>
<div><table>
<thead>
<tr>
<th> MotionPath Method </th><th> Usage </th>
</tr>
</thead>
<tr>
<td>path.setCycle(true)</td><td>Sets whether the motion along this path should be closed (true) or open-ended (false). </td>
</tr>
@ -95,11 +92,10 @@ removeWayPoint(index)</td><td>Removes a way point from this path. You can specif
<!-- EDIT5 TABLE [1769-2660] -->
</div>
<!-- EDIT4 SECTION "Create a MotionPath" [1499-2661] -->
<h2><a>MotionPathListener</a></h2>
<h2>MotionPathListener</h2>
<div>
<p>
You can hook interactions into a playing MotionPath. Register a MotionPathListener to the MotionPath to track whether way points have been reached, and then trigger a custom action. The onWayPointReach() method of the interface gives you access to the MotionTrack object <code>control</code>, and an integer value representing the current wayPointIndex.
</p>
@ -118,4 +114,4 @@ In this example, you just print the status at every way point. In a game you cou
</div>
<!-- EDIT6 SECTION "MotionPathListener" [2662-] -->
<p><em><a href="http://hub.jmonkeyengine.org/wiki/doku.php/jme3:advanced:motionpath?do=export_xhtmlbody">view online version</a></em></p>
<p><em><a href="http://wiki.jmonkeyengine.org/doku.php/jme3:advanced:motionpath?do=export_xhtmlbody">view online version</a></em></p>

@ -1,9 +1,8 @@
<h1><a>Mouse Picking</a></h1>
<h1>Mouse Picking</h1>
<div>
<p>
Mouse picking means that the user clicks an object in the scene to select it, or to interact with it otherwise. Games use picking to implement aiming and shooting, casting spells, picking up objects, selecting targets, dragging and moving objects, etc. Mouse picking can be done using fixed crosshairs, or using the mouse pointer.
</p>
@ -17,13 +16,11 @@ See <a href="/com/jme3/gde/docs/jme3/advanced/input_handling.html">Input Handlin
</div>
<!-- EDIT1 SECTION "Mouse Picking" [1-533] -->
<h2><a>Pick a Target Using Fixed Crosshairs</a></h2>
<h2>Pick a Target Using Fixed Crosshairs</h2>
<div>
<p>
The following <code>pick target</code> input mapping implements an action that determines what a user clicked. It assumes that the mouse pointer is invisible and there are crosshairs painted in the center of the screen. It assumes that the user aims the crosshairs at an object in the scene and clicks. You use Ray Casting to identify the geometry that was picked by the user. Use this method together with a first-person flyCam.
</p>
<ol>
<li><div> Activate the first-person camera: <code>flyCam.setEnabled(true);</code></div>
@ -37,7 +34,7 @@ The following <code>pick target</code> input mapping implements an action that d
</ol>
<p>
The following example rotates Spatials named &quot;Red Box&quot; or &quot;Blue Box&quot; when they are clicked. Modify this code to do whatever your game needs to do with the identified target (shoot it, take it, move it, etc).
The following example rotates Spatials named “Red Box” or “Blue Box” when they are clicked. Modify this code to do whatever your game needs to do with the identified target (shoot it, take it, move it, etc).
</p>
<pre> private AnalogListener analogListener = new AnalogListener&#40;&#41; &#123;
public void onAnalog&#40;String name, float intensity, float tpf&#41; &#123;
@ -51,7 +48,7 @@ The following example rotates Spatials named &quot;Red Box&quot; or &quot;Blue B
rootNode.collideWith&#40;ray, results&#41;;
// Print the results so we see what is going on
for &#40;int i = 0; i &lt; results.size&#40;&#41;; i++&#41; &#123;
// For each ???hit???, we know distance, impact point, geometry.
// For each “hit”, we know distance, impact point, geometry.
float dist = results.getCollision&#40;i&#41;.getDistance&#40;&#41;;
Vector3f pt = results.getCollision&#40;i&#41;.getContactPoint&#40;&#41;;
String target = results.getCollision&#40;i&#41;.getGeometry&#40;&#41;.getName&#40;&#41;;
@ -73,17 +70,15 @@ The following example rotates Spatials named &quot;Red Box&quot; or &quot;Blue B
</div>
<!-- EDIT2 SECTION "Pick a Target Using Fixed Crosshairs" [534-3105] -->
<h2><a>Pick a Target Using the Mouse Pointer</a></h2>
<h2>Pick a Target Using the Mouse Pointer</h2>
<div>
<p>
The following <code>pick target</code> input mapping implements an action that determines what a user clicked. It assumes that the mouse pointer is visible, and the user aims the cursor at an object in the scene. You use ray casting to determine the geometry that was picked by the user.
</p>
<p>
<strong>Note:</strong> Picking with a visible mouse pointer implies that your application can no longer use the default flyCam where the MouseAxisTrigger rotates the camera. You have to deactivate the flyCam mappings and provide custom mappings. Either different inputs rotate the camera, or the camera is fixed.
</p>
<ol>
<li><div> Map the <code>pick target</code> action to a MouseButtonTrigger. </div>
@ -97,8 +92,7 @@ The following <code>pick target</code> input mapping implements an action that d
</ol>
<p>
The following example rotates Spatials named &quot;Red Box&quot; or &quot;Blue Box&quot; when they are clicked. Modify this code to do whatever your game needs to do with the identified target (shoot it, take it, move it, etc).
The following example rotates Spatials named “Red Box” or “Blue Box” when they are clicked. Modify this code to do whatever your game needs to do with the identified target (shoot it, take it, move it, etc).
</p>
<pre>private AnalogListener analogListener = new AnalogListener&#40;&#41; &#123;
public void onAnalog&#40;String name, float intensity, float tpf&#41; &#123;
@ -115,7 +109,7 @@ The following example rotates Spatials named &quot;Red Box&quot; or &quot;Blue B
rootNode.collideWith&#40;ray, results&#41;;
// (Print the results so we see what is going on:)
for &#40;int i = 0; i &lt; results.size&#40;&#41;; i++&#41; &#123;
// (For each ???hit???, we know distance, impact point, geometry.)
// (For each “hit”, we know distance, impact point, geometry.)
float dist = results.getCollision&#40;i&#41;.getDistance&#40;&#41;;
Vector3f pt = results.getCollision&#40;i&#41;.getContactPoint&#40;&#41;;
String target = results.getCollision&#40;i&#41;.getGeometry&#40;&#41;.getName&#40;&#41;;
@ -135,16 +129,11 @@ The following example rotates Spatials named &quot;Red Box&quot; or &quot;Blue B
&#125; // else if ...
&#125;
&#125;;</pre>
<div><span>
<a href="/wiki/doku.php/tag:documentation?do=showtag&amp;tag=tag%3Adocumentation">documentation</a>,
<a href="/wiki/doku.php/tag:node?do=showtag&amp;tag=tag%3Anode">node</a>,
<a href="/wiki/doku.php/tag:ray?do=showtag&amp;tag=tag%3Aray">ray</a>,
<a href="/wiki/doku.php/tag:click?do=showtag&amp;tag=tag%3Aclick">click</a>,
<a href="/wiki/doku.php/tag:collision?do=showtag&amp;tag=tag%3Acollision">collision</a>,
<a href="/wiki/doku.php/tag:keyinput?do=showtag&amp;tag=tag%3Akeyinput">keyinput</a>,
<a href="/wiki/doku.php/tag:input?do=showtag&amp;tag=tag%3Ainput">input</a>
</span></div>
<p>
<a href="nbdocs:/com/jme3/gde/docs/jme3:advanced/tag_documentation_node_ray_click_collision_keyinput_input">tag_documentation_node_ray_click_collision_keyinput_input</a>
</p>
</div>
<!-- EDIT3 SECTION "Pick a Target Using the Mouse Pointer" [3106-] -->
<p><em><a href="http://hub.jmonkeyengine.org/wiki/doku.php/jme3:advanced:mouse_picking?do=export_xhtmlbody">view online version</a></em></p>
<p><em><a href="http://wiki.jmonkeyengine.org/doku.php/jme3:advanced:mouse_picking?do=export_xhtmlbody">view online version</a></em></p>

@ -1,9 +1,8 @@
<h1><a>Multiple Camera Views</a></h1>
<h1>Multiple Camera Views</h1>
<div>
<p>
You can split the screen and look into the 3D scene from different camera angles at the same time. E.g. you can have two rootnodes with different scene graphs, and two viewPorts, each of which can only see its own subset of the scene with its own subset of port-processing filters, so you get two very different views of the scene.
</p>
@ -13,22 +12,19 @@ The packages used in this example are <code>com.jme3.renderer.Camera</code> and
</div>
<!-- EDIT1 SECTION "Multiple Camera Views" [1-650] -->
<h2><a>How to resize and Position ViewPorts</a></h2>
<h2>How to resize and Position ViewPorts</h2>
<div>
<p>
The default viewPort is as big as the window. If you have several, they must be of different sizes, either overlapping or adjacent to one another. How do you tell jME which of the ViewPorts should appear where on the screen, and how big they should be?
</p>
<p>
Imagine the window as a 1.0f x 1.0f rectangle. The default cam&#039;s viewPort is set to
</p>
<pre>cam.setViewPort&#40;0f, 1f, 0f, 1f&#41;;</pre>
<p>
This setting makes the ViewPort take up the whole rectangle.
</p>
@ -44,9 +40,7 @@ The four values are read in the following order:
</ul>
<p>
Here are a few examples:
</p>
<pre>cam1.setViewPort&#40; 0.0f , 1.0f , 0.0f , 1.0f &#41;;
cam2.setViewPort&#40; 0.5f , 1.0f , 0.0f , 0.5f &#41;;</pre>
@ -65,7 +59,7 @@ These viewport parameters are, (in this order) the left-right extend, and the bo
0.0 , 0.0 1.0 , 0.0</pre>
<p>
Example: Cam2&#039;s rectangle is int he bottom right: It extends from mid (x1=0.5f) bottom (y1=0.0f), to right (x2=1.0f) mid (y2=0.5f)
Example: Cam2&#039;s rectangle is in the bottom right: It extends from mid (x1=0.5f) bottom (y1=0.0f), to right (x2=1.0f) mid (y2=0.5f)
</p>
<p>
@ -75,43 +69,36 @@ Example: Cam2&#039;s rectangle is int he bottom right: It extends from mid (x1=0
</div>
<!-- EDIT2 SECTION "How to resize and Position ViewPorts" [651-2294] -->
<h2><a>Four-Time Split Screen</a></h2>
<h2>Four-Time Split Screen</h2>
<div>
<p>
In this example, you create four views (2x2) with the same aspect ratio as the window, but each is only half the width and height.
In this example, you create four views (2&times;2) with the same aspect ratio as the window, but each is only half the width and height.
</p>
</div>
<!-- EDIT3 SECTION "Four-Time Split Screen" [2295-2463] -->
<h3><a>Set up the First View</a></h3>
<h3>Set up the First View</h3>
<div>
<p>
You use the preconfigured Camera <code>cam</code> and <code>viewPort</code> from <code>SimpleApplication</code> for the first view. It&#039;s in the bottom right.
</p>
<pre>cam.setViewPort&#40;.5f, 1f, 0f, 0.5f&#41;; // Resize the viewPort to half its size, bottom right.</pre>
<p>
Optionally, place the main camera in the scene and rotate it in its start position.
</p>
<pre>cam.setLocation&#40;new Vector3f&#40;3.32f, 4.48f, 4.28f&#41;&#41;;
cam.setRotation&#40;new Quaternion &#40;-0.07f, 0.92f, -0.25f, -0.27f&#41;&#41;;</pre>
</div>
<!-- EDIT4 SECTION "Set up the First View" [2464-2960] -->
<h3><a>Set Up Three More Views</a></h3>
<h3>Set Up Three More Views</h3>
<div>
<p>
Here is the outline for how you create the three other cams and viewPorts (<object classid="java:org.netbeans.modules.javahelp.BrowserDisplayer"><param name="content" value="http://code.google.com/p/jmonkeyengine/source/browse/trunk/engine/src/test/jme3test/renderer/TestMultiViews.java"><param name="text" value="<html><u>Full code sample is here</u></html>"><param name="textColor" value="blue"></object>.) In the code snippet, <code>cam_n</code> stand for <code>cam_2</code> - <code>cam_4</code>, respectively, same for <code>view_n</code>.
</p>
<ol>
<li><div> Clone the first cam to reuse its settings</div>
@ -130,9 +117,7 @@ The camera doesn&#039;t have to look at the rootNode, but that is the most commo
</ol>
<p>
Here is the abstract code sample for camera <code>n</code>:
</p>
<pre>Camera cam_n = cam.clone&#40;&#41;;
cam_n.setViewPort&#40;...&#41;; // resize the viewPort
@ -170,11 +155,10 @@ cam4.setViewPort&#40; 0.5f , 1.0f , 0.5f , 1.0f&#41;;</pre>
</div>
<!-- EDIT5 SECTION "Set Up Three More Views" [2961-4771] -->
<h2><a>Picture in Picture</a></h2>
<h2>Picture in Picture</h2>
<div>
<p>
The following code snippet sets up two views, one covers the whole screen, and the second is a small view in the top center.
</p>
<pre> +-----+-----+
@ -200,34 +184,28 @@ viewPort2.attachScene&#40;rootNode&#41;;</pre>
</div>
<!-- EDIT6 SECTION "Picture in Picture" [4772-5652] -->
<h2><a>ViewPort Settings</a></h2>
<h2>ViewPort Settings</h2>
<div>
<p>
You can customize the camera and the viewPort of each view individually. For example, each view can have a different background color:
</p>
<pre>viewPort.setBackgroundColor&#40;ColorRGBA.Blue&#41;;</pre>
<p>
You have full control to determine which Nodes the camera can see! It can see the full rootNode???
You have full control to determine which Nodes the camera can see! It can see the full rootNode…
</p>
<pre>viewPort1.attachScene&#40;rootNode&#41;;</pre>
<p>
??? or you can give each camera a special node whose content it can see:
… or you can give each camera a special node whose content it can see:
</p>
<pre>viewPort2.attachScene&#40;spookyGhostDetectorNode&#41;;</pre>
<div><span>
<a href="/wiki/doku.php/tag:camera?do=showtag&amp;tag=tag%3Acamera">camera</a>,
<a href="/wiki/doku.php/tag:documentation?do=showtag&amp;tag=tag%3Adocumentation">documentation</a>
</span></div>
<p>
<a href="nbdocs:/com/jme3/gde/docs/jme3:advanced/tag_camera_documentation">tag_camera_documentation</a>
</p>
</div>
<!-- EDIT7 SECTION "ViewPort Settings" [5653-] -->
<p><em><a href="http://hub.jmonkeyengine.org/wiki/doku.php/jme3:advanced:multiple_camera_views?do=export_xhtmlbody">view online version</a></em></p>
<p><em><a href="http://wiki.jmonkeyengine.org/doku.php/jme3:advanced:multiple_camera_views?do=export_xhtmlbody">view online version</a></em></p>

@ -1,9 +1,8 @@
<h3><a>The jME3 Threading Model</a></h3>
<h3>The jME3 Threading Model</h3>
<div>
<p>
jME3 is similar to Swing in that, for speed and efficiency, all changes to the scene graph must be made in a single update thread. If you make changes only in Control.update(), AppState.update(), or SimpleApplication.simpleUpdate(), this will happen automatically. However, if you pass work to another thread, you may need to pass results back to the main jME3 thread so that scene graph changes can take place there.
</p>
<pre>public void rotateGeometry&#40;final Geometry geo, final Quaternion rot&#41; &#123;
@ -20,16 +19,14 @@ Note that this example does not fetch the returned value by calling <code>get()<
<p>
If the processing thread needs to wait or needs the return value then <code>get()</code> or the other methods in the returned Future object such as <code>isDone()</code> can be used.
</p>
</div>
<!-- EDIT1 SECTION "The jME3 Threading Model" [1-1143] -->
<h1><a>Multithreading Optimization</a></h1>
<h1>Multithreading Optimization</h1>
<div>
<p>
First, make sure you know what <a href="/com/jme3/gde/docs/jme3/advanced/application_states.html">Application States</a> and <a href="/com/jme3/gde/docs/jme3/advanced/custom_controls.html">Custom Controls</a> are.
</p>
@ -47,13 +44,11 @@ Effectively, each for-loop in the main update loop might be a chance for multith
</div>
<!-- EDIT2 SECTION "Multithreading Optimization" [1144-2274] -->
<h2><a>Java Multithreading</a></h2>
<h2>Java Multithreading</h2>
<div>
<p>
The java.util.concurrent package provides a good foundation for multithreading and dividing work into tasks that can be executed concurrently (hence the name). The three basic components are the Executor (supervises threads), Callable Objects (the tasks), and Future Objects (the result). You can <object classid="java:org.netbeans.modules.javahelp.BrowserDisplayer"><param name="content" value="http://download.oracle.com/javase/tutorial/essential/concurrency/"><param name="text" value="<html><u>read about the concurrent package more here</u></html>"><param name="textColor" value="blue"></object>, I will give just a short introduction.
</p>
<ul>
<li><div> A Callable is one of the classes that gets executed on a thread in the Executor. The object represents one of several concurrent tasks (e.g, one NPC&#039;s path finding task). Each Callable is started from the updateloop by calling a method named <code>call()</code>.</div>
@ -66,11 +61,10 @@ The java.util.concurrent package provides a good foundation for multithreading a
</div>
<!-- EDIT3 SECTION "Java Multithreading" [2275-3347] -->
<h2><a>Multithreading in jME3</a></h2>
<h2>Multithreading in jME3</h2>
<div>
<p>
So how do we implement multithreading in jME3?
</p>
@ -84,11 +78,10 @@ To avoid slowdown, we decide to keep the pathfinding operations in the NPC Contr
</div>
<!-- EDIT4 SECTION "Multithreading in jME3" [3348-4020] -->
<h3><a>Executor</a></h3>
<h3>Executor</h3>
<div>
<p>
You create the executor object in a global AppState (or the initSimpleApp() method), in any case in a high-level place where multiple controls can access it.
</p>
<pre>/* This constructor creates a new executor with a core pool size of 4. */
@ -101,7 +94,6 @@ Pool size means the executor will keep four threads alive at any time. Having mo
<p>
!!! Executor needs to be shut down when the application ends, in order to make the process die properly
In your simple application you can override the destroy method and shutdown the executor:
</p>
<pre> @Override
public void destroy&#40;&#41; &#123;
@ -111,11 +103,10 @@ In your simple application you can override the destroy method and shutdown the
</div>
<!-- EDIT5 SECTION "Executor" [4021-5096] -->
<h3><a>Control Class Fields</a></h3>
<h3>Control Class Fields</h3>
<div>
<p>
In the NPC Control, we create the individual objects that the thread manipulates. In our example case (the pathfinding control), the task is about locations and path arrays, so we need the following variables:
</p>
<pre>//The vector to store the desired location in:
@ -131,11 +122,10 @@ Here we also created the Future variable to track the state of this task.
</div>
<!-- EDIT6 SECTION "Control Class Fields" [5097-5687] -->
<h3><a>Control Update() Method</a></h3>
<h3>Control Update() Method</h3>
<div>
<p>
Next let&#039;s look at the update() call of the Control where the time-intensive task starts. In our example, the task is the <code>findWay</code> Callable (which contains the pathfinding process). So instead of spelling out the pathfinding process in the Control&#039;s update() loop, we start the process via <code>future = executor.submit(findWay);</code>.
</p>
<pre>public void update&#40;float tpf&#41; &#123;
@ -174,16 +164,15 @@ Note how this logic makes its decision based on the Future object.
</p>
<p>
Remember not to mess with the class fields after starting the thread, because they are being accessed and modified on the new thread. In more obvious terms: You cannot change the &quot;desired location&quot; of the NPC while the path finder is calculating a different path. You have to cancel the current Future first.
Remember not to mess with the class fields after starting the thread, because they are being accessed and modified on the new thread. In more obvious terms: You cannot change the “desired location” of the NPC while the path finder is calculating a different path. You have to cancel the current Future first.
</p>
</div>
<!-- EDIT7 SECTION "Control Update() Method" [5688-7559] -->
<h3><a>The Callable</a></h3>
<h3>The Callable</h3>
<div>
<p>
The next code sample shows the Callable that is dedicated to performing the long-running task (here, wayfinding). This is the task that used to block the rest of the application, and is now executed on a thread of its own. You implement the task in the Callable always in an inner method named <code>call()</code>.
</p>
@ -193,7 +182,6 @@ The task code in the Callable should be self-contained! It should not write or r
<p>
In reality, you might need access to the game state. If you must read or write a current state from the scene graph, you must have a clone of the data in your thread. There are only two ways:
</p>
<ul>
<li><div> Use the execution queue <code>application.enqueue()</code> to create a sub-thread that clones the info. Only disadvantage is, it may be slower. <br/>
@ -205,7 +193,6 @@ The following example gets the object <code>Data data = myWorld.getData();</code
</ul>
<p>
These two ways are thread-safe, they don&#039;t mess up the game logic, and keep the Callable code readable.
</p>
<pre>// A self-contained time-intensive task:
@ -214,10 +201,10 @@ private Callable&lt;MyWayList&gt; findWay = new Callable&lt;MyWayList&gt;&#40;&#
&nbsp;
//Read or write data from the scene graph -- via the execution queue:
Vector3f location = application.enqueue&#40;new Callable&lt;Vector3f&gt;&#40;&#41; &#123;
????????public Vector3f call&#40;&#41; throws Exception &#123;
????????????????//we clone the location so we can use the variable safely on our thread
????????????????return mySpatial.getLocalTranslation&#40;&#41;.clone&#40;&#41;;
????????&#125;
    public Vector3f call&#40;&#41; throws Exception &#123;
        //we clone the location so we can use the variable safely on our thread
        return mySpatial.getLocalTranslation&#40;&#41;.clone&#40;&#41;;
    &#125;
&#125;&#41;.get&#40;&#41;;
&nbsp;
// This world class allows safe access via synchronized methods
@ -231,33 +218,23 @@ private Callable&lt;MyWayList&gt; findWay = new Callable&lt;MyWayList&gt;&#40;&#
</div>
<!-- EDIT8 SECTION "The Callable" [7560-9926] -->
<h2><a>Useful Links</a></h2>
<h2>Useful Links</h2>
<div>
<p>
High level description which describes how to manage the game state and the rendering in different threads - <object classid="java:org.netbeans.modules.javahelp.BrowserDisplayer"><param name="content" value="http://www.altdevblogaday.com/2011/07/03/threading-and-your-game-loop/"><param name="text" value="<html><u>link</u></html>"><param name="textColor" value="blue"></object>
High level description which describes how to manage the game state and the rendering in different threads - <del><object classid="java:org.netbeans.modules.javahelp.BrowserDisplayer"><param name="content" value="http://www.altdevblogaday.com/2011/07/03/threading-and-your-game-loop/"><param name="text" value="<html><u>link</u></html>"><param name="textColor" value="blue"></object></del> Outdated link. A C++ example can be found at <object classid="java:org.netbeans.modules.javahelp.BrowserDisplayer"><param name="content" value="http://gamasutra.com/blogs/AndreaMagnorsky/20130527/193087/Multithreading_rendering_in_a_game_engine_with_CDouble_buffer_implementation.php"><param name="text" value="<html><u>link</u></html>"><param name="textColor" value="blue"></object>
</p>
</div>
<!-- EDIT9 SECTION "Useful Links" [9927-10143] -->
<h2><a>Conclusion</a></h2>
<!-- EDIT9 SECTION "Useful Links" [9927-10347] -->
<h2>Conclusion</h2>
<div>
<p>
The cool thing about this approach is that every entity creates one self-contained Callable for the Executor, and they are all executed in parallel. In theory, you can have one thread per entity without changing anything else but the settings of the executor.
<a href="nbdocs:/com/jme3/gde/docs/jme3:advanced/tag_loop_game_performance_state_states_documentation">tag_loop_game_performance_state_states_documentation</a>
</p>
<div><span>
<a href="/wiki/doku.php/tag:loop?do=showtag&amp;tag=tag%3Aloop">loop</a>,
<a href="/wiki/doku.php/tag:game?do=showtag&amp;tag=tag%3Agame">game</a>,
<a href="/wiki/doku.php/tag:performance?do=showtag&amp;tag=tag%3Aperformance">performance</a>,
<a href="/wiki/doku.php/tag:state?do=showtag&amp;tag=tag%3Astate">state</a>,
<a href="/wiki/doku.php/tag:states?do=showtag&amp;tag=tag%3Astates">states</a>,
<a href="/wiki/doku.php/tag:documentation?do=showtag&amp;tag=tag%3Adocumentation">documentation</a>
</span></div>
</div>
<!-- EDIT10 SECTION "Conclusion" [10144-] -->
<p><em><a href="http://hub.jmonkeyengine.org/wiki/doku.php/jme3:advanced:multithreading?do=export_xhtmlbody">view online version</a></em></p>
<!-- EDIT10 SECTION "Conclusion" [10348-] -->
<p><em><a href="http://wiki.jmonkeyengine.org/doku.php/jme3:advanced:multithreading?do=export_xhtmlbody">view online version</a></em></p>

@ -1,11 +1,9 @@
<h1><a>SpiderMonkey: Multi-Player Networking</a></h1>
<h1>SpiderMonkey: Multi-Player Networking</h1>
<div>
<p>
This document introduces you to the SpiderMonkey networking <acronym title="Application Programming Interface">API</acronym>. You use this <acronym title="Application Programming Interface">API</acronym> when you develop games where several players compete with one another in real time. A multi-player game is made up of several clients connecting to a server:
This document introduces you to the SpiderMonkey networking <abbr title="Application Programming Interface">API</abbr>. You use this <abbr title="Application Programming Interface">API</abbr> when you develop games where several players compete with one another in real time. A multi-player game is made up of several clients connecting to a server:
</p>
<ul>
<li><div> The central server (one headless SimpleApplication) coordinates the game in the background.</div>
@ -15,35 +13,33 @@ This document introduces you to the SpiderMonkey networking <acronym title="Appl
</ul>
<p>
Each Client keeps the Server informed about its player&#039;s moves and actions. The Server centrally maintains the game state and broadcasts the state info back to all connected clients. This network synchronization allows all clients to share the same game world. Each client then displays the game state to one player from this player&#039;s perspective.
</p>
</div>
<!-- EDIT1 SECTION "SpiderMonkey: Multi-Player Networking" [1-841] -->
<h2><a>SpiderMonkey API Overview</a></h2>
<h2>SpiderMonkey API Overview</h2>
<div>
<p>
The SpiderMonkey <acronym title="Application Programming Interface">API</acronym> is a set of interfaces and helper classes in the &#039;com.jme3.network&#039; package. For most users, this package and the &#039;message&#039; package is all they need to worry about. (The &#039;base&#039; and &#039;kernel&#039; packages only come into play when implementing custom network transports or alternate client/server protocols, which is now possible).
The SpiderMonkey <abbr title="Application Programming Interface">API</abbr> is a set of interfaces and helper classes in the &#039;com.jme3.network&#039; package. For most users, this package and the &#039;message&#039; package is all they need to worry about. (The &#039;base&#039; and &#039;kernel&#039; packages only come into play when implementing custom network transports or alternate client/server protocols, which is now possible).
</p>
<p>
The SpiderMonkey <acronym title="Application Programming Interface">API</acronym> assists you in creating a Server, Clients, and Messages. Once a Server instance is created and started, the Server accepts remote connections from Clients, and you can send and receive Messages. Client objects represent the client-side of the client-server connection. Within the Server, these Client objects are referred to as HostedConnections. HostedConnections can hold application-defined client-specific session attributes that the server-side listeners and services can use to track player information, etc.
The SpiderMonkey <abbr title="Application Programming Interface">API</abbr> assists you in creating a Server, Clients, and Messages. Once a Server instance is created and started, the Server accepts remote connections from Clients, and you can send and receive Messages. Client objects represent the client-side of the client-server connection. Within the Server, these Client objects are referred to as HostedConnections. HostedConnections can hold application-defined client-specific session attributes that the server-side listeners and services can use to track player information, etc.
</p>
<div><table>
<thead>
<tr>
<th> Seen from the Client </th><th> </th><th> Seen from the Server </th>
</tr>
</thead>
<tr>
<td> com.jme3.network.Client </td><td> == </td><td> com.jme3.network.HostedConnection </td>
</tr>
</table></div>
<!-- EDIT3 TABLE [1767-1885] -->
<p>
You can register several types of listeners to be notified of changes.
</p>
<ul>
@ -59,17 +55,16 @@ You can register several types of listeners to be notified of changes.
</div>
<!-- EDIT2 SECTION "SpiderMonkey API Overview" [842-2609] -->
<h2><a>Client and Server</a></h2>
<h2>Client and Server</h2>
<div>
</div>
<!-- EDIT4 SECTION "Client and Server" [2610-2640] -->
<h3><a>Creating a Server</a></h3>
<h3>Creating a Server</h3>
<div>
<p>
The game server is a &quot;headless&quot; com.jme3.app.SimpleApplication:
The game server is a “headless” com.jme3.app.SimpleApplication:
</p>
<pre>public class ServerMain extends SimpleApplication &#123;
public static void main&#40;String&#91;&#93; args&#41; &#123;
@ -99,11 +94,10 @@ When you run this app on a host, the server is ready to accept clients. Let&#039
</div>
<!-- EDIT5 SECTION "Creating a Server" [2641-3591] -->
<h3><a>Creating a Client</a></h3>
<h3>Creating a Client</h3>
<div>
<p>
A game client is a standard com.jme3.app.SimpleApplication.
</p>
<pre>public class ClientMain extends SimpleApplication &#123;
@ -119,7 +113,6 @@ A game client is a standard com.jme3.app.SimpleApplication.
</p>
<p>
Create a com.jme3.network.Client in the <code>simpleInitApp()</code> method and specify the servers IP address, and the same communication port as for the server, here 6143.
</p>
<pre>public void simpleInitApp&#40;&#41; &#123;
@ -129,7 +122,7 @@ Create a com.jme3.network.Client in the <code>simpleInitApp()</code> method and
...</pre>
<p>
The server address can be in the format &quot;localhost&quot; or &quot;127.0.0.1&quot; (for local testing), or an IP address of a remote host in the format ???123.456.78.9???. In this example, we assume the server is running on the localhost.
The server address can be in the format “localhost” or “127.0.0.1” (for local testing), or an IP address of a remote host in the format “123.456.78.9”. In this example, we assume the server is running on the localhost.
</p>
<p>
@ -138,18 +131,18 @@ When you run this client, it connects to the server.
</div>
<!-- EDIT6 SECTION "Creating a Client" [3592-4757] -->
<h3><a>Getting Info About a Client</a></h3>
<h3>Getting Info About a Client</h3>
<div>
<p>
The server refers to a connected client as com.jme3.network.HostedConnection objects. The server can get info about clients as follows:
</p>
<div><table>
<thead>
<tr>
<th>Accessor</th><th>Purpose</th>
</tr>
</thead>
<tr>
<td>myServer.getConnections()</td><td>Server gets a collection of all connected HostedConnection objects (all connected clients).</td>
</tr>
@ -162,34 +155,33 @@ The server refers to a connected client as com.jme3.network.HostedConnection obj
</table></div>
<!-- EDIT8 TABLE [4934-5313] -->
<p>
Your game can define its own game data based on whatever criteria you want, typically these include player ID and state. If the server needs to look up player/client-specific information, you can store this information directly on the HostedConnection object. The following examples read and write a custom Java object <code>MyState</code> in the HostedConnection object <code>conn</code>:
</p>
<div><table>
<thead>
<tr>
<th>Accessor</th><th>Purpose</th>
</tr>
</thead>
<tr>
<td> conn.setAttribute(&quot;MyState&quot;, new MyState()); </td><td> Server can change an attribute of the HostedConnection. </td>
<td> conn.setAttribute(“MyState”, new MyState()); </td><td> Server can change an attribute of the HostedConnection. </td>
</tr>
<tr>
<td> MyState state = conn.getAttribute(&quot;MyState&quot;)</td><td> Server can read an attribute of the HostedConnection. </td>
<td> MyState state = conn.getAttribute(“MyState”)</td><td> Server can read an attribute of the HostedConnection. </td>
</tr>
</table></div>
<!-- EDIT9 TABLE [5688-5917] -->
</div>
<!-- EDIT7 SECTION "Getting Info About a Client" [4758-5918] -->
<h2><a>Messaging</a></h2>
<h2>Messaging</h2>
<div>
</div>
<!-- EDIT10 SECTION "Messaging" [5919-5941] -->
<h3><a>Creating Message Types</a></h3>
<h3>Creating Message Types</h3>
<div>
<p>
Each message represents data that you want to transmit between client and server. Common message examples include transformation updates or game actions. For each message type, create a message class that extends com.jme3.network.AbstractMessage. Use the @Serializable annotation from com.jme3.network.serializing.Serializable and create an empty default constructor. Custom constructors, fields, and methods are up to you and depend on the message data that you want to transmit.
</p>
<pre>@Serializable
@ -206,23 +198,20 @@ You must register each message type to the com.jme3.network.serializing.Serializ
</div>
<!-- EDIT11 SECTION "Creating Message Types" [5942-6894] -->
<h3><a>Responding to Messages</a></h3>
<h3>Responding to Messages</h3>
<div>
<p>
After a Message was received, a Listener responds to it. The listener can access fields of the message, and send messages back, start new threads, etc. There are two listeners, one on the server, one on the client. For each message type, you implement the responses in either Listeners??? <code>messageReceived()</code> method.
After a Message was received, a Listener responds to it. The listener can access fields of the message, and send messages back, start new threads, etc. There are two listeners, one on the server, one on the client. For each message type, you implement the responses in either Listeners’ <code>messageReceived()</code> method.
</p>
</div>
<h4><a>ClientListener.java</a></h4>
<h4>ClientListener.java</h4>
<div>
<p>
Create one ClientListener.java and make it extend <code>com.jme3.network.MessageListener</code>.
</p>
<pre>public class ClientListener implements MessageListener&lt;Client&gt; &#123;
public void messageReceived&#40;Client source, Message message&#41; &#123;
@ -240,11 +229,10 @@ For each message type, register a client listener to the client.
</div>
<h4><a>ServerListener.java</a></h4>
<h4>ServerListener.java</h4>
<div>
<p>
Create one ServerListener.java and make it extend <code>com.jme3.network.MessageListener</code>.
</p>
<pre>public class ServerListener implements MessageListener&lt;HostedConnection&gt; &#123;
@ -263,11 +251,10 @@ For each message type, register a server listener to the server:
</div>
<!-- EDIT12 SECTION "Responding to Messages" [6895-8639] -->
<h3><a>Creating and Sending Messages</a></h3>
<h3>Creating and Sending Messages</h3>
<div>
<p>
Let&#039;s create a new message of type HelloMessage:
</p>
<pre>Message message = new HelloMessage&#40;&quot;Hello World!&quot;&#41;;</pre>
@ -290,7 +277,6 @@ Or the server can send the message to a specific subset of clients (e.g. to Host
<p>
Or the server can send the message to all but a few selected clients (e.g. to all HostedConnections but conn4):
</p>
<pre>myServer.broadcast&#40; Filters.notEqualTo&#40; conn4 &#41;, message &#41;;</pre>
@ -300,11 +286,10 @@ The last two broadcasting methods use com.jme3.network.Filters to select a subse
</div>
<!-- EDIT13 SECTION "Creating and Sending Messages" [8640-9729] -->
<h2><a>Identification and Rejection</a></h2>
<h2>Identification and Rejection</h2>
<div>
<p>
The ID of the Client and HostedConnection are the same at both ends of a connection. The ID is given out authoritatively by the Server.
</p>
<pre>... myClient.getId&#40;&#41; ...</pre>
@ -316,21 +301,19 @@ A server has a game version and game name property. Each client expects to commu
<p>
<p><div>Typically, your networked game defines its own attributes (such as player ID) based on whatever criteria you want. If you want to look up player/client-specific information beyond the game version, you can set this information directly on the Client/HostedConnection object (see Getting Info About a Client).
</div></p>
</p>
</div>
<!-- EDIT14 SECTION "Identification and Rejection" [9730-10680] -->
<h2><a>Closing Clients and Server Cleanly</a></h2>
<h2>Closing Clients and Server Cleanly</h2>
<div>
</div>
<!-- EDIT15 SECTION "Closing Clients and Server Cleanly" [10681-10727] -->
<h3><a>Closing a Client</a></h3>
<h3>Closing a Client</h3>
<div>
<p>
You must override the client&#039;s destroy() method to close the connection cleanly when the player quits the client:
</p>
<pre> @Override
@ -342,11 +325,10 @@ You must override the client&#039;s destroy() method to close the connection cle
</div>
<!-- EDIT16 SECTION "Closing a Client" [10728-11003] -->
<h3><a>Closing a Server</a></h3>
<h3>Closing a Server</h3>
<div>
<p>
You must override the server&#039;s destroy() method to close the connection when the server quits:
</p>
<pre> @Override
@ -358,44 +340,42 @@ You must override the server&#039;s destroy() method to close the connection whe
</div>
<!-- EDIT17 SECTION "Closing a Server" [11004-11260] -->
<h3><a>Kicking a Client</a></h3>
<h3>Kicking a Client</h3>
<div>
<p>
The server can kick a HostedConnection to make it disconnect. You should provide a String with further info (an explanation to the user what happened, e.g. &quot;Shutting down for maintenance&quot;) for the server to send along. This info message can be used (displayed to the user) by a ClientStateListener. (See below)
The server can kick a HostedConnection to make it disconnect. You should provide a String with further info (an explanation to the user what happened, e.g. “Shutting down for maintenance”) for the server to send along. This info message can be used (displayed to the user) by a ClientStateListener. (See below)
</p>
<pre>conn.close&#40;&quot;We kick cheaters.&quot;&#41;;</pre>
</div>
<!-- EDIT18 SECTION "Kicking a Client" [11261-11651] -->
<h2><a>Listening to Connection Notification</a></h2>
<h2>Listening to Connection Notification</h2>
<div>
<p>
The server and clients are notified about connection changes.
</p>
</div>
<!-- EDIT19 SECTION "Listening to Connection Notification" [11652-11763] -->
<h3><a>ClientStateListener</a></h3>
<h3>ClientStateListener</h3>
<div>
<p>
The com.jme3.network.ClientStateListener notifies the Client when the Client has fully connected to the server (including any internal handshaking), and when the Client is kicked (disconnected) from the server.
</p>
<p>
<p><div>The ClientStateListener when it receives a network exception applies the default close action. This just stops the client and you&#039;ll have to build around it so your application knows what to do. If you need more control when a network exception happens and the client closes, you may want to investigate in a ErrorListener.
</div></p>
</p>
<div><table>
<thead>
<tr>
<th> ClientStateListener interface method </th><th> Purpose </th>
</tr>
</thead>
<tr>
<td> public void clientConnected(Client c){} </td><td> Implement here what happens as soon as this client has fully connected to the server. </td>
</tr>
@ -405,25 +385,24 @@ The com.jme3.network.ClientStateListener notifies the Client when the Client has
</table></div>
<!-- EDIT21 TABLE [12348-12717] -->
<p>
First implement the ClientStateListener interface in the Client class. Then register it to myClient in MyGameClient&#039;s simpleInitApp() method:
</p>
<pre>myClient.addClientStateListener&#40;this&#41;;</pre>
</div>
<!-- EDIT20 SECTION "ClientStateListener" [11764-12918] -->
<h3><a>ConnectionListener</a></h3>
<h3>ConnectionListener</h3>
<div>
<p>
The com.jme3.network.ConnectionListener notifies the Server whenever new HostedConnections (clients) come and go. The listener notifies the server after the Client connection is fully established (including any internal handshaking).
</p>
<div><table>
<thead>
<tr>
<th> ConnectionListener interface method </th><th> Purpose </th>
</tr>
</thead>
<tr>
<td> public void connectionAdded(Server s, HostedConnection c){} </td><td> Implemenent here what happens after a new HostedConnection has joined the Server. </td>
</tr>
@ -433,19 +412,16 @@ The com.jme3.network.ConnectionListener notifies the Server whenever new HostedC
</table></div>
<!-- EDIT23 TABLE [13184-13582] -->
<p>
First implement the ConnectionListener interface in the Server class. Then register it to myServer in MyGameServer&#039;s simpleInitApp() method.
</p>
<pre>myServer.addConnectionListener&#40;this&#41;;</pre>
</div>
<!-- EDIT22 SECTION "ConnectionListener" [12919-13782] -->
<h3><a>ErrorListener</a></h3>
<h3>ErrorListener</h3>
<div>
<p>
The com.jme3.network.ErrorListener is a listener for when network exception happens. This listener is built so that you can override the default actions when a network exception happens.
</p>
@ -453,19 +429,19 @@ The com.jme3.network.ErrorListener is a listener for when network exception happ
<p><div>If you intend on using the default network mechanics, <strong>don&#039;t</strong> use this!
If you do override this, make sure you add a mechanic that can close the client otherwise your client will get stuck open and cause errors.
</div></p>
</p>
<div><table>
<thead>
<tr>
<th> ErrorListener interface method </th><th> Purpose </th>
</tr>
</thead>
<tr>
<td> public void handleError(Client c, Throwable t){} </td><td> Implemenent here what happens after a exception affects the network . </td>
</tr>
</table></div>
<!-- EDIT25 TABLE [14233-14402] -->
<p>
<p><div>This interface was built for the client and server, but the code has never been put on the server to handle this listener.
</div></p>
</p>
@ -484,22 +460,20 @@ In the class that implements the ErrorListener, a method would of been added cal
<p>
Replace <strong>exception</strong> part in the <strong>if</strong> statement for the type of exception that you would like it to handle.
</p>
</div>
<!-- EDIT24 SECTION "ErrorListener" [13783-15194] -->
<h2><a>UDP versus TCP</a></h2>
<h2>UDP versus TCP</h2>
<div>
<p>
SpiderMonkey supports both UDP (unreliable, fast) and TCP (reliable, slow) transport of messages.
</p>
<pre>message1.setReliable&#40;true&#41;; // TCP
message2.setReliable&#40;false&#41;; // UDP</pre>
<ul>
<li><div> Choose reliable and slow transport for messages, if you want to make certain the message is delivered (resent) when lost, and if the order of a series of messages is relevant. E.g. game actions such as &quot;1. wield weapon, 2. attack, 3. dodge&quot;.</div>
<li><div> Choose reliable and slow transport for messages, if you want to make certain the message is delivered (resent) when lost, and if the order of a series of messages is relevant. E.g. game actions such as “1. wield weapon, 2. attack, 3. dodge”.</div>
</li>
<li><div> Choose unreliable and fast transport for messages if the next message makes any previously delayed or lost message obsolete and synchronizes the state again. E.g. a series of new locations while walking.</div>
</li>
@ -507,11 +481,10 @@ message2.setReliable&#40;false&#41;; // UDP</pre>
</div>
<!-- EDIT26 SECTION "UDP versus TCP" [15195-15865] -->
<h2><a>Important: Use Multi-Threading</a></h2>
<h2>Important: Use Multi-Threading</h2>
<div>
<p>
<p><div><strong>You cannot modify the scenegraph directly from the network thread.</strong> A common example for such a modification is when you synchronize the player&#039;s position in the scene. You have to use Java Multithreading.
</div></p>
</p>
@ -531,19 +504,17 @@ For general advice, see the articles <object classid="java:org.netbeans.modules.
</div>
<!-- EDIT27 SECTION "Important: Use Multi-Threading" [15866-17012] -->
<h2><a>Troubleshooting</a></h2>
<h2>Troubleshooting</h2>
<div>
<p>
If you have set up a server in your home network, and the game clients cannot reach the server from the outside, it&#039;s time to learn about <object classid="java:org.netbeans.modules.javahelp.BrowserDisplayer"><param name="content" value="http://portforward.com/"><param name="text" value="<html><u>port forwarding</u></html>"><param name="textColor" value="blue"></object>.
</p>
<div><span>
<a href="/wiki/doku.php/tag:documentation?do=showtag&amp;tag=tag%3Adocumentation">documentation</a>,
<a href="/wiki/doku.php/tag:network?do=showtag&amp;tag=tag%3Anetwork">network</a>,
<a href="/wiki/doku.php/tag:spidermonkey?do=showtag&amp;tag=tag%3Aspidermonkey">spidermonkey</a>
</span></div>
<p>
<a href="nbdocs:/com/jme3/gde/docs/jme3:advanced/tag_documentation_network_spidermonkey">tag_documentation_network_spidermonkey</a>
</p>
</div>
<!-- EDIT28 SECTION "Troubleshooting" [17013-] -->
<p><em><a href="http://hub.jmonkeyengine.org/wiki/doku.php/jme3:advanced:networking?do=export_xhtmlbody">view online version</a></em></p>
<p><em><a href="http://wiki.jmonkeyengine.org/doku.php/jme3:advanced:networking?do=export_xhtmlbody">view online version</a></em></p>

Binary file not shown.

Before

Width:  |  Height:  |  Size: 73 KiB

After

Width:  |  Height:  |  Size: 1003 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 61 KiB

After

Width:  |  Height:  |  Size: 668 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 51 KiB

After

Width:  |  Height:  |  Size: 214 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 29 KiB

After

Width:  |  Height:  |  Size: 40 KiB

@ -1,5 +1,5 @@
<h1><a>Creating JME3 User Interfaces with Nifty GUI</a></h1>
<h1>Creating JME3 User Interfaces with Nifty GUI</h1>
<div>
<p>
@ -7,12 +7,11 @@
</p>
<p>
You may want your players to press a button to save a game, you want a scrolling text field for highscores, a text label to display the score, drop-downs to select keymap preferences, or checkboxes to specify multi-media options. Usually you solve these tasks by using Swing controls. Although it is possible to embed a <a href="/com/jme3/gde/docs/jme3/advanced/swing_canvas.html">jME3 canvas</a> in a Swing <acronym title="Graphical User Interface">GUI</acronym>, a 3D game typically runs full-screen, or in a window of its own.
You may want your players to press a button to save a game, you want a scrolling text field for highscores, a text label to display the score, drop-downs to select keymap preferences, or checkboxes to specify multi-media options. Usually you solve these tasks by using Swing controls. Although it is possible to embed a <a href="/com/jme3/gde/docs/jme3/advanced/swing_canvas.html">jME3 canvas</a> in a Swing <abbr title="Graphical User Interface">GUI</abbr>, a 3D game typically runs full-screen, or in a window of its own.
</p>
<p>
This document introduces you to <object classid="java:org.netbeans.modules.javahelp.BrowserDisplayer"><param name="content" value="http://nifty-gui.lessvoid.com/"><param name="text" value="<html><u>Nifty GUI</u></html>"><param name="textColor" value="blue"></object>, a Java library for building interactive graphical user interfaces (GUIs) for games or similar applications. Nifty <acronym title="Graphical User Interface">GUI</acronym> (the <code>de.lessvoid.nifty</code> package) is well integrated with jME3 through the <code>com.jme3.niftygui</code> package. You define the base <acronym title="Graphical User Interface">GUI</acronym> layout in <acronym title="Extensible Markup Language">XML</acronym>, and control it dynamically from your Java code. The necessary JAR libraries are included in your jME3 download, you do not need to install anything extra. (Just make sure they are on the classpath.)
This document introduces you to <object classid="java:org.netbeans.modules.javahelp.BrowserDisplayer"><param name="content" value="http://nifty-gui.lessvoid.com/"><param name="text" value="<html><u>Nifty GUI</u></html>"><param name="textColor" value="blue"></object>, a Java library for building interactive graphical user interfaces (GUIs) for games or similar applications. Nifty <abbr title="Graphical User Interface">GUI</abbr> (the <code>de.lessvoid.nifty</code> package) is well integrated with jME3 through the <code>com.jme3.niftygui</code> package. You define the base <abbr title="Graphical User Interface">GUI</abbr> layout in XML, and control it dynamically from your Java code. The necessary JAR libraries are included in your jME3 download, you do not need to install anything extra. (Just make sure they are on the classpath.)
</p>
<ul>
<li><div> <object classid="java:org.netbeans.modules.javahelp.BrowserDisplayer"><param name="content" value="http://vimeo.com/25637085"><param name="text" value="<html><u>Video demo of Nifty GUI 1.3</u></html>"><param name="textColor" value="blue"></object> </div>
@ -21,12 +20,11 @@ This document introduces you to <object classid="java:org.netbeans.modules.javah
</div>
<!-- EDIT1 SECTION "Creating JME3 User Interfaces with Nifty GUI" [1-1159] -->
<h2><a>Tutorial Overview</a></h2>
<h2>Tutorial Overview</h2>
<div>
<p>
Learn to add a Nifty <acronym title="Graphical User Interface">GUI</acronym> to your jME3 game by going through this multi-part tutorial:
Learn to add a Nifty <abbr title="Graphical User Interface">GUI</abbr> to your jME3 game by going through this multi-part tutorial:
</p>
<ol>
<li><div> <span><a href="/com/jme3/gde/docs/jme3/advanced/nifty_gui.html">Understand the Nifty GUI Concepts</a></span> described on this page.</div>
@ -35,15 +33,15 @@ Learn to add a Nifty <acronym title="Graphical User Interface">GUI</acronym> to
</li>
<li><div> Lay out your graphical user interface:</div>
<ul>
<li><div> <a href="/com/jme3/gde/docs/jme3/advanced/nifty_gui_xml_layout.html">Lay out the GUI in XML</a> ??? or ???</div>
<li><div> <a href="/com/jme3/gde/docs/jme3/advanced/nifty_gui_xml_layout.html">Lay out the GUI in XML</a> – or –</div>
</li>
<li><div> <a href="/com/jme3/gde/docs/jme3/advanced/nifty_gui_java_layout.html">Lay out the GUI in Java</a></div>
</li>
</ul>
</li>
<li><div> Integrate the <acronym title="Graphical User Interface">GUI</acronym> into the game:</div>
<li><div> Integrate the <abbr title="Graphical User Interface">GUI</abbr> into the game:</div>
<ul>
<li><div> <a href="/com/jme3/gde/docs/jme3/advanced/nifty_gui_overlay.html">Overlay the User Interface Over the Screen</a> ??? or ???</div>
<li><div> <a href="/com/jme3/gde/docs/jme3/advanced/nifty_gui_overlay.html">Overlay the User Interface Over the Screen</a> – or –</div>
</li>
<li><div> <a href="/com/jme3/gde/docs/jme3/advanced/nifty_gui_projection.html">Project the User Interface Onto a Texture</a></div>
</li>
@ -55,20 +53,18 @@ Learn to add a Nifty <acronym title="Graphical User Interface">GUI</acronym> to
</div>
<!-- EDIT2 SECTION "Tutorial Overview" [1160-1952] -->
<h2><a>Must Know: Nifty GUI Concepts</a></h2>
<h2>Must Know: Nifty GUI Concepts</h2>
<div>
<p>
<img src="nbdocs:/com/jme3/gde/docs/jme3/advanced/nifty-screen-layer-panel.png">
</p>
<p>
Nifty GUIs are made up of the following <strong>elements</strong>:
</p>
<ul>
<li><div> A Nifty <acronym title="Graphical User Interface">GUI</acronym> contains one or more <strong>screens</strong>.</div>
<li><div> A Nifty <abbr title="Graphical User Interface">GUI</abbr> contains one or more <strong>screens</strong>.</div>
<ul>
<li><div> Only one screen is visible at a time.</div>
</li>
@ -100,7 +96,7 @@ Nifty GUIs are made up of the following <strong>elements</strong>:
</div>
<!-- EDIT3 SECTION "Must Know: Nifty GUI Concepts" [1953-2830] -->
<h2><a>Resources</a></h2>
<h2>Resources</h2>
<div>
<ul>
<li><div> <a href="/com/jme3/gde/docs/jme3/advanced/nifty_gui_best_practices.html">Browse this short list of Best Practices before you start</a></div>
@ -109,10 +105,10 @@ Nifty GUIs are made up of the following <strong>elements</strong>:
</div>
<!-- EDIT4 SECTION "Resources" [2831-2960] -->
<h3><a>JME-Nifty Sample Code</a></h3>
<h3>JME-Nifty Sample Code</h3>
<div>
<ul>
<li><div> <acronym title="Extensible Markup Language">XML</acronym> examples</div>
<li><div> XML examples</div>
<ul>
<li><div> <object classid="java:org.netbeans.modules.javahelp.BrowserDisplayer"><param name="content" value="http://code.google.com/p/jmonkeyengine/source/browse/trunk/engine/test-data/Interface/Nifty/HelloJme.xml"><param name="text" value="<html><u>HelloJme.xml</u></html>"><param name="textColor" value="blue"></object></div>
</li>
@ -126,7 +122,7 @@ Nifty GUIs are made up of the following <strong>elements</strong>:
</li>
</ul>
</li>
<li><div> jME3-ready version of the Nifty <acronym title="Graphical User Interface">GUI</acronym> 1.3 demo (sample code, Java)</div>
<li><div> jME3-ready version of the Nifty <abbr title="Graphical User Interface">GUI</abbr> 1.3 demo (sample code, Java)</div>
<ul>
<li><div> <object classid="java:org.netbeans.modules.javahelp.BrowserDisplayer"><param name="content" value="http://files.seapegasus.org/NiftyGuiDemo.zip"><param name="text" value="<html><u>NiftyGuiDemo.zip</u></html>"><param name="textColor" value="blue"></object></div>
</li>
@ -138,11 +134,10 @@ Nifty GUIs are made up of the following <strong>elements</strong>:
</div>
<!-- EDIT5 SECTION "JME-Nifty Sample Code" [2961-3740] -->
<h3><a>External Documentation</a></h3>
<h3>External Documentation</h3>
<div>
<p>
Learn more from the NiftyGUI page:
</p>
<ul>
@ -164,12 +159,11 @@ Learn more from the NiftyGUI page:
</div>
<!-- EDIT6 SECTION "External Documentation" [3741-4677] -->
<h2><a>Next Steps</a></h2>
<h2>Next Steps</h2>
<div>
<p>
Now that you understand the concepts and know where to find more information, learn how to lay out a simple graphical user interface. Typically, you start doing this in <acronym title="Extensible Markup Language">XML</acronym>.
Now that you understand the concepts and know where to find more information, learn how to lay out a simple graphical user interface. Typically, you start doing this in XML.
</p>
<ul>
<li><div> <a href="/com/jme3/gde/docs/jme3/advanced/nifty_gui_xml_layout.html">Lay out the GUI in XML</a> (recommended)</div>
@ -182,22 +176,19 @@ Now that you understand the concepts and know where to find more information, le
</div>
<!-- EDIT7 SECTION "Next Steps" [4678-5117] -->
<h2><a>Nifty Logging (Nifty 1.3.1)</a></h2>
<h2>Nifty Logging (Nifty 1.3.1)</h2>
<div>
<p>
If you want to disable the nifty log lines, add this code after you created nifty:
</p>
<pre>Logger.getLogger(&quot;de.lessvoid.nifty&quot;).setLevel(Level.SEVERE);
Logger.getLogger(&quot;NiftyInputEventHandlingLog&quot;).setLevel(Level.SEVERE); </pre>
<div><span>
<a href="/wiki/doku.php/tag:gui?do=showtag&amp;tag=tag%3Agui">gui</a>,
<a href="/wiki/doku.php/tag:documentation?do=showtag&amp;tag=tag%3Adocumentation">documentation</a>,
<a href="/wiki/doku.php/tag:nifty?do=showtag&amp;tag=tag%3Anifty">nifty</a>,
<a href="/wiki/doku.php/tag:hud?do=showtag&amp;tag=tag%3Ahud">hud</a>
</span></div>
<p>
<a href="nbdocs:/com/jme3/gde/docs/jme3:advanced/tag_gui_documentation_nifty_hud">tag_gui_documentation_nifty_hud</a>
</p>
</div>
<!-- EDIT8 SECTION "Nifty Logging (Nifty 1.3.1)" [5118-] -->
<p><em><a href="http://hub.jmonkeyengine.org/wiki/doku.php/jme3:advanced:nifty_gui?do=export_xhtmlbody">view online version</a></em></p>
<p><em><a href="http://wiki.jmonkeyengine.org/doku.php/jme3:advanced:nifty_gui?do=export_xhtmlbody">view online version</a></em></p>

@ -1,5 +1,5 @@
<h1><a>Interacting with the GUI from Java</a></h1>
<h1>Interacting with the GUI from Java</h1>
<div>
<ol>
<li><div> <a href="/com/jme3/gde/docs/jme3/advanced/nifty_gui.html">Nifty GUI Concepts</a></div>
@ -10,32 +10,60 @@
</li>
<li><div> <a href="/com/jme3/gde/docs/jme3/advanced/nifty_gui_overlay.html">Nifty GUI Overlay</a> or <a href="/com/jme3/gde/docs/jme3/advanced/nifty_gui_projection.html">Nifty GUI Projection</a></div>
</li>
<li><div> <strong>Nifty <acronym title="Graphical User Interface">GUI</acronym> Java Interaction</strong></div>
<li><div> <strong>Nifty <abbr title="Graphical User Interface">GUI</abbr> Java Interaction</strong></div>
</li>
</ol>
<p>
In the previous parts of the tutorial, you created a two-screen user interface. But it is still static, and when you click the buttons, nothing happens yet. The purpose of the <acronym title="Graphical User Interface">GUI</acronym> is to communicate with your Java classes: Your game needs to know what the users clicked, which settings they chose, which values they entered into a field, etc. Similarly, the user needs to know what the currently game state is (score, health, etc).
In the previous parts of the tutorial, you created a two-screen user interface. But it is still static, and when you click the buttons, nothing happens yet. The purpose of the <abbr title="Graphical User Interface">GUI</abbr> is to communicate with your Java classes: Your game needs to know what the users clicked, which settings they chose, which values they entered into a field, etc. Similarly, the user needs to know what the currently game state is (score, health, etc).
</p>
</div>
<!-- EDIT1 SECTION "Interacting with the GUI from Java" [1-791] -->
<h2><a>Connect GUI to Java Controller</a></h2>
<h2>Connect GUI to Java Controller</h2>
<div>
<p>
To let a Nifty screen communicate with the Java application, you register a <code>ScreenController</code> to every NiftyGUI screen. You create a ScreenController by creating a Java class that implements the <code>de.lessvoid.nifty.screen.ScreenController</code> interface and its abstract methods.
</p>
<p>
Create an AppState <strong>MyStartScreen</strong>.java file in your package. ( Rightclick on your package → New → Other… → JME3 Classes → New AppState)
</p>
<p>
<strong>Pro Tip:</strong> Since you are writing a jME3 application, you can additionally make the ScreenController class extend the <a href="/com/jme3/gde/docs/jme3/advanced/application_states.html">AbstractAppState</a> class! This gives the ScreenController access to the application object and to the update loop!
</p>
<pre>package tutorial;
<p>
Now add <strong>implements ScreenController</strong> to <em>public class MyStartScreen extends AbstractAppState{</em> and add <strong>import de.lessvoid.nifty.screen.ScreenController;</strong>
</p>
<p>
Continue with adding:
</p>
<pre>import de.lessvoid.nifty.screen.Screen;
&nbsp;
...
&nbsp;
public void bind&#40;Nifty nifty, Screen screen&#41; &#123;
throw new UnsupportedOperationException&#40;&quot;Not supported yet.&quot;&#41;;
&#125;
&nbsp;
public void onStartScreen&#40;&#41; &#123;
throw new UnsupportedOperationException&#40;&quot;Not supported yet.&quot;&#41;;
&#125;
&nbsp;
public void onEndScreen&#40;&#41; &#123;
throw new UnsupportedOperationException&#40;&quot;Not supported yet.&quot;&#41;;
&#125;</pre>
<pre><span>/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/</span>
package mygame;
&nbsp;
import com.jme3.app.Application;
import com.jme3.app.SimpleApplication;
import com.jme3.app.state.AbstractAppState;
import com.jme3.app.state.AppStateManager;
import de.lessvoid.nifty.Nifty;
@ -44,47 +72,44 @@ import de.lessvoid.nifty.screen.ScreenController;
&nbsp;
public class MyStartScreen extends AbstractAppState implements ScreenController &#123;
&nbsp;
private Nifty nifty;
private Screen screen;
private SimpleApplication app;
@Override
public void initialize&#40;AppStateManager stateManager, Application app&#41; &#123;
super.initialize&#40;stateManager, app&#41;;
//TODO: initialize your AppState, e.g. attach spatials to rootNode
//this is called on the OpenGL thread after the AppState has been attached
&#125;
&nbsp;
/** custom methods */
@Override
public void update&#40;float tpf&#41; &#123;
//TODO: implement behavior during runtime
&#125;
&nbsp;
public MyStartScreen&#40;String data&#41; &#123;
/** Your custom constructor, can accept arguments */
&#125;
@Override
public void cleanup&#40;&#41; &#123;
super.cleanup&#40;&#41;;
//TODO: clean up what you initialized in the initialize method,
//e.g. remove all spatials from rootNode
//this is called on the OpenGL thread after the AppState has been detached
&#125;
&nbsp;
/** Nifty GUI ScreenControl methods */
public void bind&#40;Nifty nifty, Screen screen&#41; &#123;
throw new UnsupportedOperationException&#40;&quot;Not supported yet.&quot;&#41;;
&#125;
&nbsp;
public void bind&#40;Nifty nifty, Screen screen&#41; &#123;
this.nifty = nifty;
this.screen = screen;
&#125;
&nbsp;
public void onStartScreen&#40;&#41; &#123; &#125;
&nbsp;
public void onEndScreen&#40;&#41; &#123; &#125;
&nbsp;
/** jME3 AppState methods */
&nbsp;
@Override
public void initialize&#40;AppStateManager stateManager, Application app&#41; &#123;
super.initialize&#40;stateManager, app&#41;;
this.app=&#40;SimpleApplication&#41;app;
&#125;
&nbsp;
@Override
public void update&#40;float tpf&#41; &#123;
/** jME update loop! */
&#125;
public void onStartScreen&#40;&#41; &#123;
throw new UnsupportedOperationException&#40;&quot;Not supported yet.&quot;&#41;;
&#125;
&nbsp;
public void onEndScreen&#40;&#41; &#123;
throw new UnsupportedOperationException&#40;&quot;Not supported yet.&quot;&#41;;
&#125;
&#125;</pre>
<p>
The name and package of your custom ScreenController class (here <code>tutorial.MyStartScreen</code>) goes into the controller parameter of the respective <acronym title="Extensible Markup Language">XML</acronym> screen it belongs to. For example:
The name and package of your custom ScreenController class (here <code>mygame.MyStartScreen</code>) goes into the controller parameter of the respective XML screen it belongs to. For example:
</p>
<pre><span><span>&lt;nifty&gt;</span></span>
<span>&lt;screen id=&quot;start&quot; controller=&quot;tutorial.MyStartScreen&quot;&gt;</span>
<span>&lt;screen id=&quot;start&quot; controller=&quot;mygame.MyStartScreen&quot;&gt;</span>
&lt;!-- layer and panel code ... --&gt;
<span><span>&lt;/screen&gt;</span></span>
<span><span>&lt;/nifty&gt;</span></span></pre>
@ -93,61 +118,57 @@ The name and package of your custom ScreenController class (here <code>tutorial.
Or the same in a Java syntax, respectively:
</p>
<pre> nifty.addScreen&#40;&quot;start&quot;, new ScreenBuilder&#40;&quot;start&quot;&#41; &#123;&#123;
controller&#40;new tutorial.MyStartScreen&#40;&#41;&#41;&#125;&#125;&#41;;</pre>
controller&#40;new mygame.MyStartScreen&#40;&#41;&#41;&#125;&#125;&#41;;</pre>
<p>
Now the Java class <code>MyStartScreen</code> and this <acronym title="Graphical User Interface">GUI</acronym> screen (<code>start</code>) are connected. For this example you can also connect the <code>hud</code> screen to MyStartScreen.
Now the Java class <code>MyStartScreen</code> and this <abbr title="Graphical User Interface">GUI</abbr> screen (<code>start</code>) are connected. For this example you can also connect the <code>hud</code> screen to MyStartScreen.
</p>
</div>
<!-- EDIT2 SECTION "Connect GUI to Java Controller" [792-3175] -->
<h2><a>Make GUI and Java Interact</a></h2>
<!-- EDIT2 SECTION "Connect GUI to Java Controller" [792-4282] -->
<h2>Make GUI and Java Interact</h2>
<div>
<p>
In most cases, you will want to pass game data in and out of the ScreenController. Note that you can pass any custom arguments from your Java class into your ScreenController constructor (<code>public MyStartScreen(GameData data) {}</code>).
</p>
<p>
Use any combination of the three following approaches to make Java classes interact with the <acronym title="Graphical User Interface">GUI</acronym>.
Use any combination of the three following approaches to make Java classes interact with the <abbr title="Graphical User Interface">GUI</abbr>.
</p>
</div>
<!-- EDIT3 SECTION "Make GUI and Java Interact" [3176-3548] -->
<h3><a>GUI Calls a Void Java Method</a></h3>
<!-- EDIT3 SECTION "Make GUI and Java Interact" [4283-4655] -->
<h3>GUI Calls a Void Java Method</h3>
<div>
<p>
This is how you respond to an <acronym title="Graphical User Interface">GUI</acronym> interaction such as clicks in <acronym title="Extensible Markup Language">XML</acronym> GUIs:
This is how you respond to an <abbr title="Graphical User Interface">GUI</abbr> interaction such as clicks in XML GUIs:
</p>
<ol>
<li><div> Add <code>visibleToMouse=&quot;true&quot;</code> to the parent element!</div>
<li><div> Add <code>visibleToMouse=“true”</code> to the parent element!</div>
</li>
<li><div> Embed the <code>&lt;interact /&gt;</code> element into the parent element. </div>
</li>
<li><div> Specify the Java methods that you want to call when the users performs certain actions, such as clicking. <br/>
Example: <code>&lt;interact onClick=&quot;startGame(hud)&quot; /&gt;</code></div>
Example: <code>&lt;interact onClick=“startGame(hud)” /&gt;</code></div>
</li>
</ol>
<p>
Or this is how you respond to an <acronym title="Graphical User Interface">GUI</acronym> interaction such as clicks in Java GUIs:
Or this is how you respond to an <abbr title="Graphical User Interface">GUI</abbr> interaction such as clicks in Java GUIs:
</p>
<ol>
<li><div> Add <code>visibleToMouse(true);</code> to the parent element!</div>
</li>
<li><div> Embed one of the <code>interact???()</code> elements into the parent element</div>
<li><div> Embed one of the <code>interact()</code> elements into the parent element</div>
</li>
<li><div> Specify the Java method that you want to call after the interaction. <br/>
Example: <code>interactOnClick(&quot;startGame(hud)&quot;);</code></div>
Example: <code>interactOnClick(“startGame(hud)”);</code></div>
</li>
</ol>
<p>
In the following example, we call the <code>startGame()</code> method when the player clicks the Start button, and <code>quitGame()</code> when the player clicks the Quit button.
</p>
<pre> <span>&lt;panel id=&quot;panel_bottom_left&quot; height=&quot;50%&quot; width=&quot;50%&quot; valign=&quot;center&quot; childLayout=&quot;center&quot;&gt;</span>
@ -206,7 +227,7 @@ Back in the MyStartScreen class, you specify what the <code>startGame()</code> a
&#125;</pre>
<p>
The startGame() example simply switches the <acronym title="Graphical User Interface">GUI</acronym> to the <code>hud</code> screen when the user clicks Start. Of course, in a real game, you would perform more steps here: Load the game level, switch to in-game input and navigation handling, set a custom <code>running</code> boolean to true, attach custom in-game AppStates ??? and lots more.
The startGame() example simply switches the <abbr title="Graphical User Interface">GUI</abbr> to the <code>hud</code> screen when the user clicks Start. Of course, in a real game, you would perform more steps here: Load the game level, switch to in-game input and navigation handling, set a custom <code>running</code> boolean to true, attach custom in-game AppStates and lots more.
</p>
<p>
@ -214,13 +235,12 @@ The quitGame() example shows that you have access to the application <code>app</
</p>
</div>
<!-- EDIT4 SECTION "GUI Calls a Void Java Method" [3549-6725] -->
<h3><a>GUI Gets Return Value from Java Method</a></h3>
<!-- EDIT4 SECTION "GUI Calls a Void Java Method" [4656-7832] -->
<h3>GUI Gets Return Value from Java Method</h3>
<div>
<p>
When the Nifty <acronym title="Graphical User Interface">GUI</acronym> is initialized, you can get data from Java. In this example, the Java class <code>getPlayerName()</code> in <code>MyStartScreen</code> defines the Text that is displayed in the textfield before the words <code>&#039;s Cool Game</code>.
When the Nifty <abbr title="Graphical User Interface">GUI</abbr> is initialized, you can get data from Java. In this example, the Java class <code>getPlayerName()</code> in <code>MyStartScreen</code> defines the Text that is displayed in the textfield before the words <code>&#039;s Cool Game</code>.
</p>
<p>
@ -249,17 +269,16 @@ Or the same in a Java syntax, respectively:
&#125;&#125;&#41;;</pre>
<p>
You can use this for Strings and numeric values (e.g. when you read settings from a file, you display the results in the <acronym title="Graphical User Interface">GUI</acronym>) and also for methods with side effects.
You can use this for Strings and numeric values (e.g. when you read settings from a file, you display the results in the <abbr title="Graphical User Interface">GUI</abbr>) and also for methods with side effects.
</p>
</div>
<!-- EDIT5 SECTION "GUI Gets Return Value from Java Method" [6726-7913] -->
<h3><a>Java Modifies Nifty Elements and Events</a></h3>
<!-- EDIT5 SECTION "GUI Gets Return Value from Java Method" [7833-9020] -->
<h3>Java Modifies Nifty Elements and Events</h3>
<div>
<p>
You can also alter the appearance and functions of your nifty elements from Java. Make certain that the element that you want to alter has its <code>id=&quot;name&quot;</code> attribute set, so you can identy and address it.
You can also alter the appearance and functions of your nifty elements from Java. Make certain that the element that you want to alter has its <code>id=“name”</code> attribute set, so you can identy and address it.
</p>
<p>
@ -273,7 +292,7 @@ Element niftyElement = nifty.getCurrentScreen&#40;&#41;.findElementByName&#40;&q
niftyElement.getRenderer&#40;ImageRenderer.class&#41;.setImage&#40;img&#41;;</pre>
<p>
The same is valid for other elements, for example a text label &quot;score&quot;:
The same is valid for other elements, for example a text label “score”:
</p>
<pre>// find old text
Element niftyElement = nifty.getCurrentScreen&#40;&#41;.findElementByName&#40;&quot;score&quot;&#41;;
@ -288,18 +307,16 @@ niftyElement.getElementInteraction&#40;&#41;.getPrimary&#40;&#41;.setOnMouseOver
<p>
For this to work, there already needs to be a (possibly inactive) <code>&lt;interact /&gt;</code> tag inside your xml element:
</p>
<pre><span>&lt;interact onClick=&quot;doNothing()&quot;/&gt;</span></pre>
</div>
<!-- EDIT6 SECTION "Java Modifies Nifty Elements and Events" [7914-9330] -->
<h2><a>Next Steps</a></h2>
<!-- EDIT6 SECTION "Java Modifies Nifty Elements and Events" [9021-10437] -->
<h2>Next Steps</h2>
<div>
<p>
You&#039;re done with the basic Nifty <acronym title="Graphical User Interface">GUI</acronym> for jME3 tutorial. You can proceed to advanced topics and learn how add controls and effects:
You&#039;re done with the basic Nifty <abbr title="Graphical User Interface">GUI</abbr> for jME3 tutorial. You can proceed to advanced topics and learn how add controls and effects:
</p>
<ul>
<li><div> <a href="/com/jme3/gde/docs/jme3/advanced/nifty_gui_scenarios.html"> Nifty GUI Scenarios</a></div>
@ -307,15 +324,11 @@ You&#039;re done with the basic Nifty <acronym title="Graphical User Interface">
<li><div> <object classid="java:org.netbeans.modules.javahelp.BrowserDisplayer"><param name="content" value="http://sourceforge.net/projects/nifty-gui/files/nifty-gui/nifty-gui-the-manual-v1.0.pdf/download"><param name="text" value="<html><u>Nifty GUI - the Manual</u></html>"><param name="textColor" value="blue"></object></div>
</li>
</ul>
<div><span>
<a href="/wiki/doku.php/tag:gui?do=showtag&amp;tag=tag%3Agui">gui</a>,
<a href="/wiki/doku.php/tag:documentation?do=showtag&amp;tag=tag%3Adocumentation">documentation</a>,
<a href="/wiki/doku.php/tag:input?do=showtag&amp;tag=tag%3Ainput">input</a>,
<a href="/wiki/doku.php/tag:control?do=showtag&amp;tag=tag%3Acontrol">control</a>,
<a href="/wiki/doku.php/tag:hud?do=showtag&amp;tag=tag%3Ahud">hud</a>,
<a href="/wiki/doku.php/tag:nifty?do=showtag&amp;tag=tag%3Anifty">nifty</a>
</span></div>
<p>
<a href="nbdocs:/com/jme3/gde/docs/jme3:advanced/tag_gui_documentation_input_control_hud_nifty">tag_gui_documentation_input_control_hud_nifty</a>
</p>
</div>
<!-- EDIT7 SECTION "Next Steps" [9331-] -->
<p><em><a href="http://hub.jmonkeyengine.org/wiki/doku.php/jme3:advanced:nifty_gui_java_interaction?do=export_xhtmlbody">view online version</a></em></p>
<!-- EDIT7 SECTION "Next Steps" [10438-] -->
<p><em><a href="http://wiki.jmonkeyengine.org/doku.php/jme3:advanced:nifty_gui_java_interaction?do=export_xhtmlbody">view online version</a></em></p>

@ -1,12 +1,12 @@
<h1><a>Laying Out the GUI in Java</a></h1>
<h1>Laying Out the GUI in Java</h1>
<div>
<ol>
<li><div> <a href="/com/jme3/gde/docs/jme3/advanced/nifty_gui.html">Nifty GUI Concepts</a></div>
</li>
<li><div> <a href="/com/jme3/gde/docs/jme3/advanced/nifty_gui_best_practices.html">Nifty GUI Best Practices</a></div>
</li>
<li><div> <a href="/com/jme3/gde/docs/jme3/advanced/nifty_gui_xml_layout.html">Nifty GUI XML Layout</a> or <strong>Nifty <acronym title="Graphical User Interface">GUI</acronym> Java Layout</strong></div>
<li><div> <a href="/com/jme3/gde/docs/jme3/advanced/nifty_gui_xml_layout.html">Nifty GUI XML Layout</a> or <strong>Nifty <abbr title="Graphical User Interface">GUI</abbr> Java Layout</strong></div>
</li>
<li><div> <a href="/com/jme3/gde/docs/jme3/advanced/nifty_gui_overlay.html">Nifty GUI Overlay</a> or <a href="/com/jme3/gde/docs/jme3/advanced/nifty_gui_projection.html">Nifty GUI Projection</a></div>
</li>
@ -15,17 +15,15 @@
</ol>
<p>
<strong>Work in progress</strong> You can &quot;draw&quot; the <acronym title="Graphical User Interface">GUI</acronym> to the screen by writing Java code ??? alternatively to using <acronym title="Extensible Markup Language">XML</acronym>. Typically you lay out the static base <acronym title="Graphical User Interface">GUI</acronym> in <acronym title="Extensible Markup Language">XML</acronym>, and use Java commands if you need to change the <acronym title="Graphical User Interface">GUI</acronym> dynamically at runtime. In theory, you can also lay out the whole <acronym title="Graphical User Interface">GUI</acronym> in Java (but we don&#039;t cover that here).
<strong>Work in progress</strong> You can “draw” the <abbr title="Graphical User Interface">GUI</abbr> to the screen by writing Java code – alternatively to using XML. Typically you lay out the static base <abbr title="Graphical User Interface">GUI</abbr> in XML, and use Java commands if you need to change the <abbr title="Graphical User Interface">GUI</abbr> dynamically at runtime. In theory, you can also lay out the whole <abbr title="Graphical User Interface">GUI</abbr> in Java (but we don&#039;t cover that here).
</p>
</div>
<!-- EDIT1 SECTION "Laying Out the GUI in Java" [1-690] -->
<h2><a>Sample Code</a></h2>
<h2>Sample Code</h2>
<div>
<p>
Sample project
</p>
<ul>
@ -35,15 +33,15 @@ Sample project
<li><div> <strong>Download demo project:</strong> <object classid="java:org.netbeans.modules.javahelp.BrowserDisplayer"><param name="content" value="http://files.seapegasus.org/NiftyGuiDemo.zip"><param name="text" value="<html><u>http://files.seapegasus.org/NiftyGuiDemo.zip</u></html>"><param name="textColor" value="blue"></object> (jme3-ready) <br/>
The full demo ZIP is based on <code>de.lessvoid.nifty.examples.controls.ControlsDemo.java</code>.</div>
<ol>
<li><div> The demo is a SimpleApplication-based game (use e.g. the BasicGame template in the jMonkeyEngine <acronym title="Software Development Kit">SDK</acronym>).</div>
<li><div> The demo is a SimpleApplication-based game (use e.g. the BasicGame template in the jMonkeyEngine SDK).</div>
</li>
<li><div> Copy images and sound files into your project&#039;s <code>assets/Interface/</code> directory. (In this example, I copied them from <code>nifty-default-controls-examples/trunk/src/main/resources/</code> to <code>assets/Interface/</code>).</div>
</li>
<li><div> Make sure to use paths relative to your project&#039;s <code>assets/</code> directory.</div>
<ul>
<li><div> E.g. for .fnt/.png/.jpg files use <code>filename(&quot;Interface/yang.png&quot;);</code> ( not <code>filename(&quot;yang.png&quot;);</code>).</div>
<li><div> E.g. for .fnt/.png/.jpg files use <code>filename(“Interface/yang.png”);</code> ( not <code>filename(“yang.png”);</code>).</div>
</li>
<li><div> E.g. for .wav/.ogg files use <code>filename(&quot;Interface/sounds/gong.wav&quot;);</code> (not <code>filename(&quot;sounds/gong.wav&quot;);</code>).</div>
<li><div> E.g. for .wav/.ogg files use <code>filename(“Interface/sounds/gong.wav”);</code> (not <code>filename(“sounds/gong.wav”);</code>).</div>
</li>
</ul>
</li>
@ -52,8 +50,7 @@ The full demo ZIP is based on <code>de.lessvoid.nifty.examples.controls.Controls
</ul>
<p>
Just so you get a quick picture what Nifty <acronym title="Graphical User Interface">GUI</acronym>&#039;s Java Syntax looks like, here is the most basic example. It creates a screen with a layer and a panel that contains a button.
Just so you get a quick picture what Nifty <abbr title="Graphical User Interface">GUI</abbr>&#039;s Java Syntax looks like, here is the most basic example. It creates a screen with a layer and a panel that contains a button.
</p>
<pre>package mygame;
&nbsp;
@ -122,16 +119,15 @@ public class Main extends SimpleApplication &#123;
</div>
<!-- EDIT2 SECTION "Sample Code" [691-3958] -->
<h2><a>Implement Your GUI Layout</a></h2>
<h2>Implement Your GUI Layout</h2>
<div>
<p>
<img src="nbdocs:/com/jme3/gde/docs/jme3/advanced/gui-layout-draft.png">
</p>
<p>
In this tutorial, you recreate the same screen as in the Nifty <acronym title="Graphical User Interface">GUI</acronym> <acronym title="Extensible Markup Language">XML</acronym> example.
In this tutorial, you recreate the same screen as in the Nifty <abbr title="Graphical User Interface">GUI</abbr> XML example.
</p>
<p>
@ -140,11 +136,10 @@ Create an Screen.Java file in the <code>assets/Interfaces/</code> directory of y
</div>
<!-- EDIT3 SECTION "Implement Your GUI Layout" [3959-4495] -->
<h3><a>Make Screens</a></h3>
<h3>Make Screens</h3>
<div>
<p>
The following minimal Java file contains a start screen and a HUD screen. (Neither has been defined yet.)
</p>
<pre>nifty.addScreen&#40;&quot;start&quot;, new ScreenBuilder&#40;&quot;start&quot;&#41;&#123;&#123;
@ -158,16 +153,15 @@ nifty.addScreen&#40;&quot;hud&quot;, new ScreenBuilder&#40;&quot;hud&quot;&#41;&
&#125;&#125;.build&#40;nifty&#41;&#41;;</pre>
<p>
Every Nifty <acronym title="Graphical User Interface">GUI</acronym> must have a start screen. The others (in this example, the HUD screen) are optional.
Every Nifty <abbr title="Graphical User Interface">GUI</abbr> must have a start screen. The others (in this example, the HUD screen) are optional.
</p>
</div>
<!-- EDIT4 SECTION "Make Screens" [4496-5030] -->
<h3><a>Make Layers</a></h3>
<h3>Make Layers</h3>
<div>
<p>
The following Java code shows how we add layers to the start screen and HUD screen:
</p>
<pre>nifty.addScreen&#40;&quot;start&quot;, new ScreenBuilder&#40;&quot;start&quot;&#41;&#123;&#123;
@ -206,11 +200,10 @@ In a layer, you can now add panels and arrange them. Panels are containers that
</div>
<!-- EDIT5 SECTION "Make Layers" [5031-5968] -->
<h3><a>Make Panels</a></h3>
<h3>Make Panels</h3>
<div>
<p>
A panel is the inner-most container (that will contain the actual content: text, images, or controls). You place panels inside layers. The following panels go into in the <code>start</code> screen:
</p>
<pre> nifty.addScreen&#40;&quot;start&quot;, new ScreenBuilder&#40;&quot;start&quot;&#41; &#123;&#123;
@ -326,7 +319,7 @@ The following panels go into in the <code>hud</code> screen:
&#125;&#125;.build&#40;nifty&#41;&#41;;</pre>
<p>
Try the sample. Remember to activate a screen using <code>nifty.gotoScreen(&quot;start&quot;);</code> or <code>hud</code> respectively.
Try the sample. Remember to activate a screen using <code>nifty.gotoScreen(“start”);</code> or <code>hud</code> respectively.
The result should look as follows:
</p>
@ -336,23 +329,20 @@ The result should look as follows:
</div>
<!-- EDIT6 SECTION "Make Panels" [5969-9926] -->
<h2><a>Adding Content to Panels</a></h2>
<h2>Adding Content to Panels</h2>
<div>
<p>
See also <object classid="java:org.netbeans.modules.javahelp.BrowserDisplayer"><param name="content" value="http://sourceforge.net/apps/mediawiki/nifty-gui/index.php?title=Layout_Introduction"><param name="text" value="<html><u>Layout Introduction</u></html>"><param name="textColor" value="blue"></object> on the Nifty <acronym title="Graphical User Interface">GUI</acronym> site.
See also <object classid="java:org.netbeans.modules.javahelp.BrowserDisplayer"><param name="content" value="http://sourceforge.net/apps/mediawiki/nifty-gui/index.php?title=Layout_Introduction"><param name="text" value="<html><u>Layout Introduction</u></html>"><param name="textColor" value="blue"></object> on the Nifty <abbr title="Graphical User Interface">GUI</abbr> site.
</p>
</div>
<!-- EDIT7 SECTION "Adding Content to Panels" [9927-10105] -->
<h3><a>Add Images</a></h3>
<h3>Add Images</h3>
<div>
<p>
The start-background.png image is a fullscreen background picture. In the <code>start</code> screen, add the following image element:
</p>
<pre> nifty.addScreen&#40;&quot;start&quot;, new ScreenBuilder&#40;&quot;start&quot;&#41; &#123;&#123;
controller&#40;new DefaultScreenController&#40;&#41;&#41;;
@ -369,7 +359,6 @@ The start-background.png image is a fullscreen background picture. In the <code>
<p>
The hud-frame.png image is a transparent frame that we use as HUD decoration. In the <code>hud</code> screen, add the following image element:
</p>
<pre> nifty.addScreen&#40;&quot;hud&quot;, new ScreenBuilder&#40;&quot;hud&quot;&#41; &#123;&#123;
controller&#40;new DefaultScreenController&#40;&#41;&#41;;
@ -388,7 +377,6 @@ The hud-frame.png image is a transparent frame that we use as HUD decoration. In
<p>
The face1.png image is an image that you want to use as a status icon.
In the <code>hud</code> screen&#039;s <code>foreground</code> layer, add the following image element:
</p>
<pre> panel&#40;new PanelBuilder&#40;&quot;panel_top_right2&quot;&#41; &#123;&#123;
childLayoutCenter&#40;&#41;;
@ -408,19 +396,16 @@ In the <code>hud</code> screen&#039;s <code>foreground</code> layer, add the fol
&#125;&#125;&#41;;</pre>
<p>
This image is scaled to use 50% of the height and 30% of the width of its container.
</p>
</div>
<!-- EDIT8 SECTION "Add Images" [10106-12093] -->
<h3><a>Add Static Text</a></h3>
<h3>Add Static Text</h3>
<div>
<p>
The game title is a typical example of static text. In the <code>start</code> screen, add the following text element:
</p>
<pre> // panel added
panel&#40;new PanelBuilder&#40;&quot;panel_top&quot;&#41; &#123;&#123;
@ -441,7 +426,7 @@ The game title is a typical example of static text. In the <code>start</code> sc
&#125;&#125;&#41;;</pre>
<p>
For longer pieces of static text, such as an introduction, you can use wrap=&quot;true&quot;. Add the following text element to the <code>Start screen</code>:
For longer pieces of static text, such as an introduction, you can use wrap=“true”. Add the following text element to the <code>Start screen</code>:
</p>
<pre> panel&#40;new PanelBuilder&#40;&quot;panel_mid&quot;&#41; &#123;&#123;
childLayoutCenter&#40;&#41;;
@ -462,16 +447,15 @@ For longer pieces of static text, such as an introduction, you can use wrap=&quo
&#125;&#125;&#41;;</pre>
<p>
The font used is jME3&#039;s default font &quot;Interface/Fonts/Default.fnt&quot; which is included in the jMonkeyEngine.JAR. You can add your own fonts to your own <code>assets/Interface</code> directory.
The font used is jME3&#039;s default font “Interface/Fonts/Default.fnt” which is included in the jMonkeyEngine.JAR. You can add your own fonts to your own <code>assets/Interface</code> directory.
</p>
</div>
<!-- EDIT9 SECTION "Add Static Text" [12094-13843] -->
<h3><a>Add Controls</a></h3>
<h3>Add Controls</h3>
<div>
<p>
Before you can use any control, you must load a Control Definition first. Add the following two lines <em>before</em> your screen definitions:
</p>
<pre> nifty.loadStyleFile&#40;&quot;nifty-default-styles.xml&quot;&#41;;
@ -479,11 +463,10 @@ Before you can use any control, you must load a Control Definition first. Add th
</div>
<h4><a>Label Control</a></h4>
<h4>Label Control</h4>
<div>
<p>
Use label controls for text that you want to edit dynamically from Java. One example for this is the score display.
In the <code>hud</code> screen&#039;s <code>foreground</code> layer, add the following text element:
</p>
@ -506,12 +489,11 @@ Note that the width and height do not scale the bitmap font, but make indirectly
</div>
<h4><a>Button Control</a></h4>
<h4>Button Control</h4>
<div>
<p>
Our <acronym title="Graphical User Interface">GUI</acronym> plan asks for two buttons on the start screen. You add the Start and Quit buttons to the bottom panel of the <code>start</code> screen using the <code>&lt;control&gt;</code> element:
Our <abbr title="Graphical User Interface">GUI</abbr> plan asks for two buttons on the start screen. You add the Start and Quit buttons to the bottom panel of the <code>start</code> screen using the <code>&lt;control&gt;</code> element:
</p>
<pre> panel&#40;new PanelBuilder&#40;&quot;panel_bottom_left&quot;&#41; &#123;&#123;
childLayoutCenter&#40;&#41;;
@ -548,27 +530,25 @@ Our <acronym title="Graphical User Interface">GUI</acronym> plan asks for two bu
&#125;&#125;&#41;;</pre>
<p>
Note that these controls don&#039;t do anything yet ??? we&#039;ll get to that soon.
Note that these controls don&#039;t do anything yet we&#039;ll get to that soon.
</p>
</div>
<h4><a>Other Controls</a></h4>
<h4>Other Controls</h4>
<div>
<p>
Nifty additionally offers many customizable controls such as check boxes, text fields, menus, chats, tabs, ??? See also <object classid="java:org.netbeans.modules.javahelp.BrowserDisplayer"><param name="content" value="http://sourceforge.net/apps/mediawiki/nifty-gui/index.php?title=Elements"><param name="text" value="<html><u>Elements</u></html>"><param name="textColor" value="blue"></object> on the Nifty <acronym title="Graphical User Interface">GUI</acronym> site.
Nifty additionally offers many customizable controls such as check boxes, text fields, menus, chats, tabs, … See also <object classid="java:org.netbeans.modules.javahelp.BrowserDisplayer"><param name="content" value="http://sourceforge.net/apps/mediawiki/nifty-gui/index.php?title=Elements"><param name="text" value="<html><u>Elements</u></html>"><param name="textColor" value="blue"></object> on the Nifty <abbr title="Graphical User Interface">GUI</abbr> site.
</p>
</div>
<!-- EDIT10 SECTION "Add Controls" [13844-16777] -->
<h2><a>Intermediate Result</a></h2>
<h2>Intermediate Result</h2>
<div>
<p>
When you preview this code in the jMonkeyEngine <acronym title="Software Development Kit">SDK</acronym>, our tutorial demo should looks as follows: A start screen with two buttons, and a game screen with a simple HUD frame and a blue cube (which stands for any jME3 game content).
When you preview this code in the jMonkeyEngine SDK, our tutorial demo should looks as follows: A start screen with two buttons, and a game screen with a simple HUD frame and a blue cube (which stands for any jME3 game content).
</p>
<p>
@ -581,25 +561,26 @@ When you preview this code in the jMonkeyEngine <acronym title="Software Develop
</div>
<!-- EDIT11 SECTION "Intermediate Result" [16778-17190] -->
<h2><a>Nifty Java Settings</a></h2>
<h2>Nifty Java Settings</h2>
<div>
<p>
Before initializing the nifty screens, you set up properties and register media.
</p>
<div><table>
<thead>
<tr>
<th> Nifty Method </th><th> Description </th>
</tr>
</thead>
<tr>
<td> registerSound(&quot;mysound&quot;, &quot;Interface/abc.wav&quot;); </td><td> </td>
<td> registerSound(“mysound”, “Interface/abc.wav”); </td><td> </td>
</tr>
<tr>
<td> registerMusic(&quot;mymusic&quot;, &quot;Interface/xyz.ogg&quot;); </td><td> </td>
<td> registerMusic(“mymusic”, “Interface/xyz.ogg”); </td><td> </td>
</tr>
<tr>
<td> registerMouseCursor(&quot;mypointer&quot;, &quot;Interface/abc.png&quot;, 5, 4); </td><td> </td>
<td> registerMouseCursor(“mypointer”, “Interface/abc.png”, 5, 4); </td><td> </td>
</tr>
<tr>
<td> registerEffect(?); </td><td> ? </td>
@ -610,19 +591,17 @@ Before initializing the nifty screens, you set up properties and register media.
</table></div>
<!-- EDIT13 TABLE [17305-17628] -->
<p>
Example:
</p>
<pre>nifty.registerMouseCursor&#40;&quot;hand&quot;, &quot;Interface/mouse-cursor-hand.png&quot;, 5, 4&#41;;</pre>
</div>
<!-- EDIT12 SECTION "Nifty Java Settings" [17191-17733] -->
<h2><a>Next Steps</a></h2>
<h2>Next Steps</h2>
<div>
<p>
Integrate the <acronym title="Graphical User Interface">GUI</acronym> into the game. Typically, you will overlay the <acronym title="Graphical User Interface">GUI</acronym>.
Integrate the <abbr title="Graphical User Interface">GUI</abbr> into the game. Typically, you will overlay the <abbr title="Graphical User Interface">GUI</abbr>.
</p>
<ul>
<li><div> <a href="/com/jme3/gde/docs/jme3/advanced/nifty_gui_overlay.html">Nifty GUI Overlay</a> (recommended)</div>
@ -630,13 +609,11 @@ Integrate the <acronym title="Graphical User Interface">GUI</acronym> into the g
<li><div> <a href="/com/jme3/gde/docs/jme3/advanced/nifty_gui_projection.html">Nifty GUI Projection</a> (optional)</div>
</li>
</ul>
<div><span>
<a href="/wiki/doku.php/tag:gui?do=showtag&amp;tag=tag%3Agui">gui</a>,
<a href="/wiki/doku.php/tag:documentation?do=showtag&amp;tag=tag%3Adocumentation">documentation</a>,
<a href="/wiki/doku.php/tag:nifty?do=showtag&amp;tag=tag%3Anifty">nifty</a>,
<a href="/wiki/doku.php/tag:hud?do=showtag&amp;tag=tag%3Ahud">hud</a>
</span></div>
<p>
<a href="nbdocs:/com/jme3/gde/docs/jme3:advanced/tag_gui_documentation_nifty_hud">tag_gui_documentation_nifty_hud</a>
</p>
</div>
<!-- EDIT14 SECTION "Next Steps" [17734-] -->
<p><em><a href="http://hub.jmonkeyengine.org/wiki/doku.php/jme3:advanced:nifty_gui_java_layout?do=export_xhtmlbody">view online version</a></em></p>
<p><em><a href="http://wiki.jmonkeyengine.org/doku.php/jme3:advanced:nifty_gui_java_layout?do=export_xhtmlbody">view online version</a></em></p>

@ -1,5 +1,5 @@
<h1><a>Integrating Nifty GUI: Overlay</a></h1>
<h1>Integrating Nifty GUI: Overlay</h1>
<div>
<ol>
<li><div> <a href="/com/jme3/gde/docs/jme3/advanced/nifty_gui.html">Nifty GUI Concepts</a></div>
@ -8,29 +8,28 @@
</li>
<li><div> <a href="/com/jme3/gde/docs/jme3/advanced/nifty_gui_xml_layout.html">Nifty GUI XML Layout</a> or <a href="/com/jme3/gde/docs/jme3/advanced/nifty_gui_java_layout.html">Nifty GUI Java Layout</a></div>
</li>
<li><div> <strong>Nifty <acronym title="Graphical User Interface">GUI</acronym> Overlay</strong> or <a href="/com/jme3/gde/docs/jme3/advanced/nifty_gui_projection.html">Nifty GUI Projection</a></div>
<li><div> <strong>Nifty <abbr title="Graphical User Interface">GUI</abbr> Overlay</strong> or <a href="/com/jme3/gde/docs/jme3/advanced/nifty_gui_projection.html">Nifty GUI Projection</a></div>
</li>
<li><div> <a href="/com/jme3/gde/docs/jme3/advanced/nifty_gui_java_interaction.html">Interact with the GUI from Java</a></div>
</li>
</ol>
<p>
<img src="nbdocs:/com/jme3/gde/docs/jme3/advanced/nifty-gui-example.png">
</p>
<p>
Typically, you define a key (for example escape) that switches the <acronym title="Graphical User Interface">GUI</acronym> on and off. The <acronym title="Graphical User Interface">GUI</acronym> can be a StartScreen, OptionsScreen, CharacterCreationScreen, etc. While the <acronym title="Graphical User Interface">GUI</acronym> is up, you pause the running game, and then overlay the <acronym title="Graphical User Interface">GUI</acronym>. You also must switch to a different set of user inputs while the game is paused, so the player can use the mouse pointer and keyboard to interact with the <acronym title="Graphical User Interface">GUI</acronym>.
Typically, you define a key (for example escape) that switches the <abbr title="Graphical User Interface">GUI</abbr> on and off. The <abbr title="Graphical User Interface">GUI</abbr> can be a StartScreen, OptionsScreen, CharacterCreationScreen, etc. While the <abbr title="Graphical User Interface">GUI</abbr> is up, you pause the running game, and then overlay the <abbr title="Graphical User Interface">GUI</abbr>. You also must switch to a different set of user inputs while the game is paused, so the player can use the mouse pointer and keyboard to interact with the <abbr title="Graphical User Interface">GUI</abbr>.
</p>
<p>
You can also <a href="/com/jme3/gde/docs/jme3/advanced/nifty_gui_projection.html">project</a> the <acronym title="Graphical User Interface">GUI</acronym> as a texture onto a mesh texture (but then you cannot click to select).
You can also <a href="/com/jme3/gde/docs/jme3/advanced/nifty_gui_projection.html">project</a> the <abbr title="Graphical User Interface">GUI</abbr> as a texture onto a mesh texture (but then you cannot click to select).
On this page, we look at the overlay variant, which is more commonly used in games.
</p>
</div>
<!-- EDIT1 SECTION "Integrating Nifty GUI: Overlay" [1-1043] -->
<h2><a>Sample Code</a></h2>
<h2>Sample Code</h2>
<div>
<ul>
<li><div> <object classid="java:org.netbeans.modules.javahelp.BrowserDisplayer"><param name="content" value="http://code.google.com/p/jmonkeyengine/source/browse/trunk/engine/src/test/jme3test/niftygui/TestNiftyGui.java"><param name="text" value="<html><u>TestNiftyGui.java</u></html>"><param name="textColor" value="blue"></object></div>
@ -39,12 +38,11 @@ On this page, we look at the overlay variant, which is more commonly used in gam
</div>
<!-- EDIT2 SECTION "Sample Code" [1044-1206] -->
<h2><a>Overlaying the User Interface Over the Screen</a></h2>
<h2>Overlaying the User Interface Over the Screen</h2>
<div>
<p>
This code shows you how to overlay anything on the screen with the <acronym title="Graphical User Interface">GUI</acronym>. This is the most common usecase.
This code shows you how to overlay anything on the screen with the <abbr title="Graphical User Interface">GUI</abbr>. This is the most common usecase.
</p>
<pre>NiftyJmeDisplay niftyDisplay = new NiftyJmeDisplay&#40;
assetManager, inputManager, audioRenderer, guiViewPort&#41;;
@ -59,34 +57,37 @@ guiViewPort.addProcessor&#40;niftyDisplay&#41;;
flyCam.setDragToRotate&#40;true&#41;;</pre>
<p>
Currently you do not have a ScreenController ??? we will create one in the next exercise. As soon as you have a screen controller, you will use the commented variant of the <acronym title="Extensible Markup Language">XML</acronym> loading method:
Currently you do not have a ScreenController we will create one in the next exercise. As soon as you have a screen controller, you will use the commented variant of the XML loading method:
</p>
<pre>nifty.fromXml&#40;&quot;Interface/helloworld.xml&quot;, &quot;start&quot;, new MySettingsScreen&#40;&#41;&#41;;</pre>
<p>
The <code>MySettingsScreen</code> class is a custom de.lessvoid.nifty.screen.ScreenController in which you will implement your <acronym title="Graphical User Interface">GUI</acronym> behaviour.
The <code>MySettingsScreen</code> class is a custom de.lessvoid.nifty.screen.ScreenController in which you will implement your <abbr title="Graphical User Interface">GUI</abbr> behaviour.
</p>
<p>
If you have many screens or you want to keep them organized in separate files there is a method available that will just load an additional XML file. The content of the files are
simply added to whatever XML data has been loaded before.
</p>
<pre>nifty.addXml&#40;&quot;Interface/mysecondscreen.xml&quot;&#41;;</pre>
</div>
<!-- EDIT3 SECTION "Overlaying the User Interface Over the Screen" [1207-2372] -->
<h2><a>Next Steps</a></h2>
<!-- EDIT3 SECTION "Overlaying the User Interface Over the Screen" [1207-2675] -->
<h2>Next Steps</h2>
<div>
<p>
Now that you have layed out and integrated the <acronym title="Graphical User Interface">GUI</acronym> in your app, you want to respond to user input and display the current game. Time to create a ScreenController!
Now that you have layed out and integrated the <abbr title="Graphical User Interface">GUI</abbr> in your app, you want to respond to user input and display the current game. Time to create a ScreenController!
</p>
<ul>
<li><div> <a href="/com/jme3/gde/docs/jme3/advanced/nifty_gui_java_interaction.html">Interact with the GUI from Java</a></div>
</li>
</ul>
<div><span>
<a href="/wiki/doku.php/tag:gui?do=showtag&amp;tag=tag%3Agui">gui</a>,
<a href="/wiki/doku.php/tag:documentation?do=showtag&amp;tag=tag%3Adocumentation">documentation</a>,
<a href="/wiki/doku.php/tag:nifty?do=showtag&amp;tag=tag%3Anifty">nifty</a>,
<a href="/wiki/doku.php/tag:hud?do=showtag&amp;tag=tag%3Ahud">hud</a>
</span></div>
<p>
<a href="nbdocs:/com/jme3/gde/docs/jme3:advanced/tag_gui_documentation_nifty_hud">tag_gui_documentation_nifty_hud</a>
</p>
</div>
<!-- EDIT4 SECTION "Next Steps" [2373-] -->
<p><em><a href="http://hub.jmonkeyengine.org/wiki/doku.php/jme3:advanced:nifty_gui_overlay?do=export_xhtmlbody">view online version</a></em></p>
<!-- EDIT4 SECTION "Next Steps" [2676-] -->
<p><em><a href="http://wiki.jmonkeyengine.org/doku.php/jme3:advanced:nifty_gui_overlay?do=export_xhtmlbody">view online version</a></em></p>

@ -1,10 +1,9 @@
<h1><a>Nifty GUI: Create a PopUp Menu</a></h1>
<h1>Nifty GUI: Create a PopUp Menu</h1>
<div>
<p>
Even though you create and populate the popup menu in Java, you still need a &quot;placeholder&quot; in your <acronym title="Extensible Markup Language">XML</acronym> file.
Even though you create and populate the popup menu in Java, you still need a “placeholder” in your XML file.
The popup element needs to be placed <em>outside</em> of any screen!
</p>
<pre><span>&lt;useControls filename=&quot;nifty-default-controls.xml&quot;/&gt;</span>
@ -31,14 +30,13 @@ A brief explanation of some the attributes above:
</ul>
<p>
The Java code within your defined ScreenController implementation:
</p>
<pre>private Element popup;
...
public void createMyPopupMenu&#40;&#41;&#123;
popup = nifty.createPopup&#40;&quot;niftyPopupMenu&quot;&#41;;
Menu myMenu = popup.findNiftyControl&#40;&quot;#menu&quot;, Menu.class&#41;;
Menu.class&#41;;
myMenu.setWidth&#40;new SizeValue&#40;&quot;100px&quot;&#41;&#41;; // must be set
myMenu.addMenuItem&#40;&quot;Click me!&quot;, &quot;menuItemIcon.png&quot;,
new menuItem&#40;&quot;menuItemid&quot;, &quot;blah blah&quot;&#41;&#41;; // menuItem is a custom class
@ -60,7 +58,7 @@ public void showMenu&#40;&#41; &#123; // the method to trigger the menu
private class menuItem &#123;
public String id;
public String name;
public menuItem&#40;String id, String name&#41;&#123;
public menuItem&#40;String name&#41;&#123;
this.id= id;
this.name = name;
&#125;
@ -75,7 +73,6 @@ private class menuItem &#123;
</ul>
<p>
To handle menu item events (i.e. calling a method when you click on a menu item), you register (subscribe) a EventTopicSubscriber&lt;MenuItemActivatedEvent&gt; class implementation to a nifty screen and element.
</p>
<pre> private class MenuItemActivatedEventSubscriber
@ -91,4 +88,4 @@ To handle menu item events (i.e. calling a method when you click on a menu item)
&#125;;</pre>
</div>
<p><em><a href="http://hub.jmonkeyengine.org/wiki/doku.php/jme3:advanced:nifty_gui_popup_menu?do=export_xhtmlbody">view online version</a></em></p>
<p><em><a href="http://wiki.jmonkeyengine.org/doku.php/jme3:advanced:nifty_gui_popup_menu?do=export_xhtmlbody">view online version</a></em></p>

@ -1,5 +1,5 @@
<h1><a>Integrating Nifty GUI: Projection</a></h1>
<h1>Integrating Nifty GUI: Projection</h1>
<div>
<ol>
<li><div> <a href="/com/jme3/gde/docs/jme3/advanced/nifty_gui.html">Nifty GUI Concepts</a></div>
@ -8,32 +8,31 @@
</li>
<li><div> <a href="/com/jme3/gde/docs/jme3/advanced/nifty_gui_xml_layout.html">Nifty GUI XML Layout</a> or <a href="/com/jme3/gde/docs/jme3/advanced/nifty_gui_java_layout.html">Nifty GUI Java Layout</a></div>
</li>
<li><div> <a href="/com/jme3/gde/docs/jme3/advanced/nifty_gui_overlay.html">Nifty GUI Overlay</a> or <strong>Nifty <acronym title="Graphical User Interface">GUI</acronym> Projection</strong></div>
<li><div> <a href="/com/jme3/gde/docs/jme3/advanced/nifty_gui_overlay.html">Nifty GUI Overlay</a> or <strong>Nifty <abbr title="Graphical User Interface">GUI</abbr> Projection</strong></div>
</li>
<li><div> <a href="/com/jme3/gde/docs/jme3/advanced/nifty_gui_java_interaction.html">Interact with the GUI from Java</a></div>
</li>
</ol>
<p>
<img src="nbdocs:/com/jme3/gde/docs/jme3/advanced/nifty-gui.png">
</p>
<p>
Typically you define a key (for example escape) to switch the <acronym title="Graphical User Interface">GUI</acronym> on and off. Then you <a href="/com/jme3/gde/docs/jme3/advanced/nifty_gui_overlay.html">overlay</a> the running game with the <acronym title="Graphical User Interface">GUI</acronym> (you will most likely pause the game then).
Typically you define a key (for example escape) to switch the <abbr title="Graphical User Interface">GUI</abbr> on and off. Then you <a href="/com/jme3/gde/docs/jme3/advanced/nifty_gui_overlay.html">overlay</a> the running game with the <abbr title="Graphical User Interface">GUI</abbr> (you will most likely pause the game then).
</p>
<p>
Alternatively, you can also project the <acronym title="Graphical User Interface">GUI</acronym> as a texture onto a mesh textures inside the game. Allthough this looks cool and &quot;immersive&quot;, this approach is rarely used since it is difficult to record clicks this way. You can only interact with this projected <acronym title="Graphical User Interface">GUI</acronym> by keyboard, or programmatically. You can select input fields using the arrow keys, and trigger actions using the return key.
Alternatively, you can also project the <abbr title="Graphical User Interface">GUI</abbr> as a texture onto a mesh textures inside the game. Allthough this looks cool and “immersive”, this approach is rarely used since it is difficult to record clicks this way. You can only interact with this projected <abbr title="Graphical User Interface">GUI</abbr> by keyboard, or programmatically. You can select input fields using the arrow keys, and trigger actions using the return key.
</p>
<p>
This <acronym title="Graphical User Interface">GUI</acronym> projection variant is less commonly used than the <acronym title="Graphical User Interface">GUI</acronym> overlay variant. Usecases for <acronym title="Graphical User Interface">GUI</acronym> projection are, for example, a player avatar using an in-game computer screen.
This <abbr title="Graphical User Interface">GUI</abbr> projection variant is less commonly used than the <abbr title="Graphical User Interface">GUI</abbr> overlay variant. Usecases for <abbr title="Graphical User Interface">GUI</abbr> projection are, for example, a player avatar using an in-game computer screen.
</p>
</div>
<!-- EDIT1 SECTION "Integrating Nifty GUI: Projection" [1-1192] -->
<h2><a>Sample Code</a></h2>
<h2>Sample Code</h2>
<div>
<ul>
<li><div> <object classid="java:org.netbeans.modules.javahelp.BrowserDisplayer"><param name="content" value="http://code.google.com/p/jmonkeyengine/source/browse/trunk/engine/src/test/jme3test/niftygui/TestNiftyToMesh.java"><param name="text" value="<html><u>TestNiftyToMesh.java</u></html>"><param name="textColor" value="blue"></object></div>
@ -42,12 +41,11 @@ This <acronym title="Graphical User Interface">GUI</acronym> projection variant
</div>
<!-- EDIT2 SECTION "Sample Code" [1193-1360] -->
<h2><a>Projecting the User Interface Onto a Texture</a></h2>
<h2>Projecting the User Interface Onto a Texture</h2>
<div>
<p>
You can project the Nifty <acronym title="Graphical User Interface">GUI</acronym> onto a texture, load the texture into a material, and assign it to a Geometry (Quads or Boxes are best).
You can project the Nifty <abbr title="Graphical User Interface">GUI</abbr> onto a texture, load the texture into a material, and assign it to a Geometry (Quads or Boxes are best).
</p>
<pre>/** Create a special viewport for the Nifty GUI */
ViewPort niftyView = renderManager.createPreView&#40;&quot;NiftyView&quot;, new Camera&#40;1024, 768&#41;&#41;;
@ -70,7 +68,7 @@ niftyView.setClearEnabled&#40;true&#41;;
niftyView.setOutputFrameBuffer&#40;fb&#41;;
&nbsp;
/** This is the 3D cube we project the GUI on */
Box b = new Box&#40;Vector3f.ZERO, 1, 1, 1&#41;;
Box&#40;Vector3f.ZERO, 1, 1, 1&#41;;
Geometry geom = new Geometry&#40;&quot;Box&quot;, b&#41;;
Material mat = new Material&#40;assetManager, &quot;Common/MatDefs/Misc/Unshaded.j3md&quot;&#41;;
mat.setTexture&#40;&quot;m_ColorMap&quot;, niftytex&#41;; /** Here comes the texture! */
@ -78,34 +76,30 @@ geom.setMaterial&#40;mat&#41;;
rootNode.attachChild&#40;geom&#41;;</pre>
<p>
The MySettingsScreen class is a custom de.lessvoid.nifty.screen.ScreenController in which you implement your <acronym title="Graphical User Interface">GUI</acronym> behaviour. The variable <code>data</code> contains an object that you use to exchange state info with the game. See <a href="/com/jme3/gde/docs/jme3/advanced/nifty_gui_java_interaction.html">Nifty GUI Java Interaction</a> for details on how to create this class.
The MySettingsScreen class is a custom de.lessvoid.nifty.screen.ScreenController in which you implement your <abbr title="Graphical User Interface">GUI</abbr> behaviour. The variable <code>data</code> contains an object that you use to exchange state info with the game. See <a href="/com/jme3/gde/docs/jme3/advanced/nifty_gui_java_interaction.html">Nifty GUI Java Interaction</a> for details on how to create this class.
</p>
<p>
Run the code sample. You select buttons on this <acronym title="Graphical User Interface">GUI</acronym> with the arrow keys and then press return. Note that clicking on the texture will not work!
Run the code sample. You select buttons on this <abbr title="Graphical User Interface">GUI</abbr> with the arrow keys and then press return. Note that clicking on the texture will not work!
</p>
</div>
<!-- EDIT3 SECTION "Projecting the User Interface Onto a Texture" [1361-3239] -->
<h2><a>Next Steps</a></h2>
<h2>Next Steps</h2>
<div>
<p>
Now that you have layed out and integrated the <acronym title="Graphical User Interface">GUI</acronym> in your app, you want to respond to user input and display the current game.
Now that you have layed out and integrated the <abbr title="Graphical User Interface">GUI</abbr> in your app, you want to respond to user input and display the current game.
</p>
<ul>
<li><div> <a href="/com/jme3/gde/docs/jme3/advanced/nifty_gui_java_interaction.html">Interact with the GUI from Java</a></div>
</li>
</ul>
<div><span>
<a href="/wiki/doku.php/tag:gui?do=showtag&amp;tag=tag%3Agui">gui</a>,
<a href="/wiki/doku.php/tag:documentation?do=showtag&amp;tag=tag%3Adocumentation">documentation</a>,
<a href="/wiki/doku.php/tag:nifty?do=showtag&amp;tag=tag%3Anifty">nifty</a>,
<a href="/wiki/doku.php/tag:hud?do=showtag&amp;tag=tag%3Ahud">hud</a>,
<a href="/wiki/doku.php/tag:texture?do=showtag&amp;tag=tag%3Atexture">texture</a>
</span></div>
<p>
<a href="nbdocs:/com/jme3/gde/docs/jme3:advanced/tag_gui_documentation_nifty_hud_texture">tag_gui_documentation_nifty_hud_texture</a>
</p>
</div>
<!-- EDIT4 SECTION "Next Steps" [3240-] -->
<p><em><a href="http://hub.jmonkeyengine.org/wiki/doku.php/jme3:advanced:nifty_gui_projection?do=export_xhtmlbody">view online version</a></em></p>
<p><em><a href="http://wiki.jmonkeyengine.org/doku.php/jme3:advanced:nifty_gui_projection?do=export_xhtmlbody">view online version</a></em></p>

@ -1,23 +1,21 @@
<h1><a>Nifty GUI 1.3 - Usecase Scenarios</a></h1>
<h1>Nifty GUI 1.3 - Usecase Scenarios</h1>
<div>
<p>
This document contains typical NiftyGUI usecase scenarios, such as adding effects, game states, and creating typical game screens.
</p>
<p>
Requirements: These tips assume that you have read and understood the <a href="/com/jme3/gde/docs/jme3/advanced/nifty_gui.html">Creating JME3 User Interfaces with Nifty GUI</a> tutorial, and have already laid out a basic <acronym title="Graphical User Interface">GUI</acronym> that interacts with your JME3 application. Here you learn how you integrate the <acronym title="Graphical User Interface">GUI</acronym> better, and add effects and advanced controls.
Requirements: These tips assume that you have read and understood the <a href="/com/jme3/gde/docs/jme3/advanced/nifty_gui.html">Creating JME3 User Interfaces with Nifty GUI</a> tutorial, and have already laid out a basic <abbr title="Graphical User Interface">GUI</abbr> that interacts with your JME3 application. Here you learn how you integrate the <abbr title="Graphical User Interface">GUI</abbr> better, and add effects and advanced controls.
</p>
</div>
<!-- EDIT1 SECTION "Nifty GUI 1.3 - Usecase Scenarios" [1-506] -->
<h2><a>Switch Game States</a></h2>
<h2>Switch Game States</h2>
<div>
<p>
In a JME game, you typically have three game states:
</p>
<ol>
@ -30,7 +28,6 @@ In a JME game, you typically have three game states:
</ol>
<p>
(Aside: Additionally, the Stopped state often contains a LoadScreen, LogonScreen, OptionsScreen, CharacterCreationScreen, HighScoreScreen, CreditsScreen, etc. Some games let you access the OptionsScreen in the Paused state as well. The Running state can also contain an InventoryScreen, ItemShopScreen, StatsScreen, SkillScreen, etc.)
</p>
@ -42,22 +39,20 @@ In JME, game states are implemented as custom <a href="/com/jme3/gde/docs/jme3/a
</li>
<li><div> Paused: PausedScreen AppState + GuiInputs AppState</div>
</li>
<li><div> Running: HudScreen AppState + InGameInputs AppState + BulletAppState (jme physics), ???</div>
<li><div> Running: HudScreen AppState + InGameInputs AppState + BulletAppState (jme physics), </div>
</li>
</ol>
<p>
When the player switches between game states, you detach one set of AppStates, and attach another. For example, when the player pauses the running game, you use a boolean switch to pause the game loop and deactivate the game inputs (shooting, navigation). The screen is overlayed with a PausedScreen, which contains a visible mouse pointer and a Continue button. When the player clicks Continue, the mouse pointer is deactivated, the in-game input and navigational mappings are activated, and the game loop continues.
</p>
</div>
<!-- EDIT2 SECTION "Switch Game States" [507-2043] -->
<h2><a>Get Access to Application and Update Loop</a></h2>
<h2>Get Access to Application and Update Loop</h2>
<div>
<p>
Since you are writing a jME3 application, you can additionally make any ScreenController class extend the <a href="/com/jme3/gde/docs/jme3/advanced/application_states.html">AbstractAppState</a> class.
This gives the ScreenController access to the application object and to the update loop!
</p>
@ -81,6 +76,11 @@ public StartScreenState&#40;SimpleApplication app&#41;&#123;
@Override
public void initialize&#40;AppStateManager stateManager, Application app&#41; &#123;
super.initialize&#40;stateManager, app&#41;;
&nbsp;
rootNode.attachChild&#40;localRootNode&#41;;
guiNode.attachChild&#40;localGuiNode&#41;;
viewPort.setBackgroundColor&#40;backgroundColor&#41;;
&nbsp;
/** init the screen */
&#125;
&nbsp;
@ -90,22 +90,16 @@ public StartScreenState&#40;SimpleApplication app&#41;&#123;
&#125;
&nbsp;
@Override
public void stateAttached&#40;AppStateManager stateManager&#41; &#123;
rootNode.attachChild&#40;localRootNode&#41;;
guiNode.attachChild&#40;localGuiNode&#41;;
viewPort.setBackgroundColor&#40;backgroundColor&#41;;
&#125;
&nbsp;
@Override
public void stateDetached&#40;AppStateManager stateManager&#41; &#123;
public void cleanup&#40;&#41; &#123;
rootNode.detachChild&#40;localRootNode&#41;;
guiNode.detachChild&#40;localGuiNode&#41;;
&nbsp;
super.cleanup&#40;&#41;;
&#125;
&nbsp;
&#125;</pre>
<p>
<p><div>It is not sufficient to just inherit from AbstractAppState. You need to instantiate your controller class, register it with app&#039;s stateManager and then pass it to nifty. See code sample below.
</div></p>
</p>
@ -119,13 +113,15 @@ public StartScreenState&#40;SimpleApplication app&#41;&#123;
&#125;</pre>
</div>
<!-- EDIT3 SECTION "Get Access to Application and Update Loop" [2044-4243] -->
<h2><a>Know Your Variables</a></h2>
<!-- EDIT3 SECTION "Get Access to Application and Update Loop" [2044-4170] -->
<h2>Know Your Variables</h2>
<div>
<div><table>
<thead>
<tr>
<th>Variable</th><th>Description</th>
</tr>
</thead>
<tr>
<td>${CALL.myMethod()} </td><td> Calls a method in the current ScreenController and gets the method&#039;s return String. The method can also be void and have a side effect, e.g. play a sound etc.</td>
</tr>
@ -133,25 +129,23 @@ public StartScreenState&#40;SimpleApplication app&#41;&#123;
<td>${ENV.HOME}</td><td> Returns the path to user&#039;s home directory.</td>
</tr>
<tr>
<td>${ENV.key} </td><td> Looks up <code>key</code> in the environment variables. Use it like Java&#039;s System.getEnv(&quot;key&quot;).</td>
<td>${ENV.key} </td><td> Looks up <code>key</code> in the environment variables. Use it like Java&#039;s System.getEnv(“key”).</td>
</tr>
<tr>
<td>${PROP.key}</td><td> looks up <code>key</code> in the Nifty properties. Use Nifty.setGlobalproperties(properties) and Nifty.getGlobalproperties(&quot;key&quot;). Or SystemGetProperties(key);</td>
<td>${PROP.key}</td><td> looks up <code>key</code> in the Nifty properties. Use Nifty.setGlobalproperties(properties) and Nifty.getGlobalproperties(“key”). Or SystemGetProperties(key);</td>
</tr>
</table></div>
<!-- EDIT5 TABLE [4276-4807] -->
<!-- EDIT5 TABLE [4203-4734] -->
<p>
See also: <object classid="java:org.netbeans.modules.javahelp.BrowserDisplayer"><param name="content" value="http://sourceforge.net/apps/mediawiki/nifty-gui/index.php?title=MarkUp"><param name="text" value="<html><u>http://sourceforge.net/apps/mediawiki/nifty-gui/index.php?title=MarkUp</u></html>"><param name="textColor" value="blue"></object>
</p>
</div>
<!-- EDIT4 SECTION "Know Your Variables" [4244-4890] -->
<h2><a>Use ScreenControllers for Mutally Exclusive Functionality</a></h2>
<!-- EDIT4 SECTION "Know Your Variables" [4171-4817] -->
<h2>Use ScreenControllers for Mutally Exclusive Functionality</h2>
<div>
<p>
Technically you are free to create one ScreenController class for each screen, or reuse the same ScreenController for all or some of them. In the end it may be best to create individual ScreenControllers for functionality that is mutually exclusive.
</p>
@ -166,32 +160,29 @@ For example, create a <code>MyHudScreen.java</code> for the <code>hud</code> scr
</ul>
</div>
<!-- EDIT6 SECTION "Use ScreenControllers for Mutally Exclusive Functionality" [4891-6273] -->
<h2><a>Create a &quot;Loading...&quot; Screen</a></h2>
<!-- EDIT6 SECTION "Use ScreenControllers for Mutally Exclusive Functionality" [4818-6200] -->
<h2>Create a &quot;Loading...&quot; Screen</h2>
<div>
<p>
Get the full <a href="/com/jme3/gde/docs/jme3/advanced/loading_screen.html">Loading Screen</a> tutorial here.
</p>
</div>
<!-- EDIT7 SECTION "Create a Loading... Screen" [6274-6378] -->
<h2><a>Create a Popup Menu</a></h2>
<!-- EDIT7 SECTION "Create a Loading... Screen" [6201-6305] -->
<h2>Create a Popup Menu</h2>
<div>
<p>
Get the full <a href="/com/jme3/gde/docs/jme3/advanced/nifty_gui_popup_menu.html">Nifty GUI PopUp Menu</a> tutorial here.
</p>
</div>
<!-- EDIT8 SECTION "Create a Popup Menu" [6379-6481] -->
<h2><a>Add Visual Effects</a></h2>
<!-- EDIT8 SECTION "Create a Popup Menu" [6306-6408] -->
<h2>Add Visual Effects</h2>
<div>
<p>
You can register effects to screen elements.
</p>
<ul>
@ -202,7 +193,6 @@ You can register effects to screen elements.
</ul>
<p>
Here is an example that moves a panel when the startScreen opens. You place an &lt; effect &gt; tag inside the element that you want to be affected.
</p>
<pre><span>&lt;panel height=&quot;25%&quot; width=&quot;35%&quot; ...&gt;</span>
@ -220,12 +210,11 @@ Learn more from the NiftyGUI page:
</ul>
</div>
<!-- EDIT9 SECTION "Add Visual Effects" [6482-7194] -->
<h2><a>Add Sound Effects</a></h2>
<!-- EDIT9 SECTION "Add Visual Effects" [6409-7121] -->
<h2>Add Sound Effects</h2>
<div>
<p>
Playing sounds using Nifty is also possible with a <code>playSound</code> effect as trigger. Remember to first register the sound that you want to play:
</p>
<pre><span>&lt;registerSound id=&quot;myclick&quot; filename=&quot;Interface/sounds/ButtonClick.ogg&quot; /&gt;</span>
@ -237,44 +226,38 @@ Playing sounds using Nifty is also possible with a <code>playSound</code> effect
<span><span>&lt;/label&gt;</span></span></pre>
</div>
<!-- EDIT10 SECTION "Add Sound Effects" [7195-7557] -->
<h2><a>Pass ClickLoc From Nifty to Java</a></h2>
<!-- EDIT10 SECTION "Add Sound Effects" [7122-7484] -->
<h2>Pass ClickLoc From Nifty to Java</h2>
<div>
<p>
After a mouse click, you may want to record the 2D clickLoc and send this info to your Java application. Typical ScreenController methods however only have a String argument. You&#039;d have to convert the String to ints.
</p>
<p>
To pass the clickLoc as two ints, you can use the special <code>(int x, int y)</code> syntax in the ScreenController:
</p>
<pre> public void clicked&#40;int x, int y&#41; &#123;
// here you can use the x and y of the clickLoc
&#125;</pre>
<p>
In the Nifty <acronym title="Graphical User Interface">GUI</acronym> screen code (e.g. <acronym title="Extensible Markup Language">XML</acronym> file) you must call the <code>(int x, int y)</code> method <em>without</em> any parameters!
In the Nifty <abbr title="Graphical User Interface">GUI</abbr> screen code (e.g. XML file) you must call the <code>(int x, int y)</code> method <em>without</em> any parameters!
</p>
<pre><span>&lt;interact onClick=&quot;clicked()&quot;/&gt;</span> </pre>
<p>
You can name the method (here <code>clicked</code>) what ever you like, as long as you keep the argument syntax.
</p>
</div>
<!-- EDIT11 SECTION "Pass ClickLoc From Nifty to Java" [7558-8319] -->
<h2><a>Load Several XML Files</a></h2>
<!-- EDIT11 SECTION "Pass ClickLoc From Nifty to Java" [7485-8246] -->
<h2>Load Several XML Files</h2>
<div>
<p>
The basic Nifty <acronym title="Graphical User Interface">GUI</acronym> example showed how to use the <code>nifty.fromXML()</code> method to load one <acronym title="Extensible Markup Language">XML</acronym> file containing all Nifty <acronym title="Graphical User Interface">GUI</acronym> screens.
The following code sample shows how you can load several <acronym title="Extensible Markup Language">XML</acronym> files into one nifty object. Loading several files with <code>nifty.addXml()</code> allows you to split up each screen into one <acronym title="Extensible Markup Language">XML</acronym> file, instead of all into one hard-to-read <acronym title="Extensible Markup Language">XML</acronym> file.
The basic Nifty <abbr title="Graphical User Interface">GUI</abbr> example showed how to use the <code>nifty.fromXML()</code> method to load one XML file containing all Nifty <abbr title="Graphical User Interface">GUI</abbr> screens.
The following code sample shows how you can load several XML files into one nifty object. Loading several files with <code>nifty.addXml()</code> allows you to split up each screen into one XML file, instead of all into one hard-to-read XML file.
</p>
<pre>NiftyJmeDisplay niftyDisplay = new NiftyJmeDisplay&#40;assetManager, inputManager, audioRenderer, viewPort&#41;;
Nifty nifty = niftyDisplay.getNifty&#40;&#41;;
@ -288,17 +271,16 @@ stateManager.attach&#40;optionsControl&#41;;
guiViewPort.addProcessor&#40;niftyDisplay&#41;;</pre>
</div>
<!-- EDIT12 SECTION "Load Several XML Files" [8320-9368] -->
<h2><a>Register additional explicit screen controllers</a></h2>
<!-- EDIT12 SECTION "Load Several XML Files" [8247-9295] -->
<h2>Register additional explicit screen controllers</h2>
<div>
<p>
In addition to the <code>nifty.addXml()</code> methods to attach many nifty <acronym title="Extensible Markup Language">XML</acronym> files, there exists a <code>nifty.registerScreenController()</code> method to explicitly attach more screen controllers.
In addition to the <code>nifty.addXml()</code> methods to attach many nifty XML files, there exists a <code>nifty.registerScreenController()</code> method to explicitly attach more screen controllers.
</p>
<p>
The following code sample shows how you can explicitly attach several screen controllers before adding the <acronym title="Extensible Markup Language">XML</acronym> file to nifty, which would otherwise cause nifty to implicitly instantiate the screen controller class.
The following code sample shows how you can explicitly attach several screen controllers before adding the XML file to nifty, which would otherwise cause nifty to implicitly instantiate the screen controller class.
</p>
<pre>NiftyJmeDisplay niftyDisplay = new NiftyJmeDisplay&#40;assetManager, inputManager, audioRenderer, viewPort&#41;;
Nifty nifty = niftyDisplay.getNifty&#40;&#41;;
@ -307,13 +289,12 @@ nifty.registerScreenController&#40;new OptionsScreenController&#40;randomConstru
nifty.addXml&#40;&quot;Interface/Screens/OptionsScreen.xml&quot;&#41;;</pre>
</div>
<!-- EDIT13 SECTION "Register additional explicit screen controllers" [9369-10137] -->
<h2><a>Design Your Own Styles</a></h2>
<!-- EDIT13 SECTION "Register additional explicit screen controllers" [9296-10064] -->
<h2>Design Your Own Styles</h2>
<div>
<p>
By default, your Nifty <acronym title="Extensible Markup Language">XML</acronym> screens use the built.in styles:
By default, your Nifty XML screens use the built.in styles:
</p>
<pre> <span>&lt;useStyles filename=&quot;nifty-default-styles.xml&quot; /&gt;</span> </pre>
@ -334,8 +315,7 @@ Inside myCustomStyles.xml you define styles like this:
<span><span>&lt;/nifty-styles&gt;</span></span></pre>
<p>
Learn more about how to create styles by looking at the <object classid="java:org.netbeans.modules.javahelp.BrowserDisplayer"><param name="content" value="http://sourceforge.net/apps/mediawiki/nifty-gui/index.php?title=Build_from_Source"><param name="text" value="<html><u>Nifty GUI source code</u></html>"><param name="textColor" value="blue"></object> for ???nifty-style-black???. Copy it as a template and change it to create your own style.
Learn more about how to create styles by looking at the <object classid="java:org.netbeans.modules.javahelp.BrowserDisplayer"><param name="content" value="http://sourceforge.net/apps/mediawiki/nifty-gui/index.php?title=Build_from_Source"><param name="text" value="<html><u>Nifty GUI source code</u></html>"><param name="textColor" value="blue"></object> for “nifty-style-black”. Copy it as a template and change it to create your own style.
</p>
<hr />
@ -346,18 +326,11 @@ Learn more from the NiftyGUI page:
<li><div> <object classid="java:org.netbeans.modules.javahelp.BrowserDisplayer"><param name="content" value="http://sourceforge.net/apps/mediawiki/nifty-gui/index.php?title=Effects"><param name="text" value="<html><u>http://sourceforge.net/apps/mediawiki/nifty-gui/index.php?title=Effects</u></html>"><param name="textColor" value="blue"></object></div>
</li>
</ul>
<div><span>
<a href="/wiki/doku.php/tag:gui?do=showtag&amp;tag=tag%3Agui">gui</a>,
<a href="/wiki/doku.php/tag:documentation?do=showtag&amp;tag=tag%3Adocumentation">documentation</a>,
<a href="/wiki/doku.php/tag:nifty?do=showtag&amp;tag=tag%3Anifty">nifty</a>,
<a href="/wiki/doku.php/tag:hud?do=showtag&amp;tag=tag%3Ahud">hud</a>,
<a href="/wiki/doku.php/tag:click?do=showtag&amp;tag=tag%3Aclick">click</a>,
<a href="/wiki/doku.php/tag:state?do=showtag&amp;tag=tag%3Astate">state</a>,
<a href="/wiki/doku.php/tag:states?do=showtag&amp;tag=tag%3Astates">states</a>,
<a href="/wiki/doku.php/tag:sound?do=showtag&amp;tag=tag%3Asound">sound</a>,
<a href="/wiki/doku.php/tag:effect?do=showtag&amp;tag=tag%3Aeffect">effect</a>
</span></div>
<p>
<a href="nbdocs:/com/jme3/gde/docs/jme3:advanced/tag_gui_documentation_nifty_hud_click_state_states_sound_effect">tag_gui_documentation_nifty_hud_click_state_states_sound_effect</a>
</p>
</div>
<!-- EDIT14 SECTION "Design Your Own Styles" [10138-] -->
<p><em><a href="http://hub.jmonkeyengine.org/wiki/doku.php/jme3:advanced:nifty_gui_scenarios?do=export_xhtmlbody">view online version</a></em></p>
<!-- EDIT14 SECTION "Design Your Own Styles" [10065-] -->
<p><em><a href="http://wiki.jmonkeyengine.org/doku.php/jme3:advanced:nifty_gui_scenarios?do=export_xhtmlbody">view online version</a></em></p>

@ -1,12 +1,12 @@
<h1><a>Laying out the GUI in XML</a></h1>
<h1>Laying out the GUI in XML</h1>
<div>
<ol>
<li><div> <a href="/com/jme3/gde/docs/jme3/advanced/nifty_gui.html">Nifty GUI Concepts</a></div>
</li>
<li><div> <a href="/com/jme3/gde/docs/jme3/advanced/nifty_gui_best_practices.html">Nifty GUI Best Practices</a></div>
</li>
<li><div> <strong>Nifty <acronym title="Graphical User Interface">GUI</acronym> <acronym title="Extensible Markup Language">XML</acronym> Layout</strong> or <a href="/com/jme3/gde/docs/jme3/advanced/nifty_gui_java_layout.html">Nifty GUI Java Layout</a></div>
<li><div> <strong>Nifty <abbr title="Graphical User Interface">GUI</abbr> XML Layout</strong> or <a href="/com/jme3/gde/docs/jme3/advanced/nifty_gui_java_layout.html">Nifty GUI Java Layout</a></div>
</li>
<li><div> <a href="/com/jme3/gde/docs/jme3/advanced/nifty_gui_overlay.html">Nifty GUI Overlay</a> or <a href="/com/jme3/gde/docs/jme3/advanced/nifty_gui_projection.html">Nifty GUI Projection</a></div>
</li>
@ -15,22 +15,20 @@
</ol>
<p>
You can &quot;draw&quot; the <acronym title="Graphical User Interface">GUI</acronym> to the screen by writing <acronym title="Extensible Markup Language">XML</acronym> code (alternatively you can also use Java).
You can “draw” the <abbr title="Graphical User Interface">GUI</abbr> to the screen by writing XML code (alternatively you can also use Java).
</p>
</div>
<!-- EDIT1 SECTION "Laying out the GUI in XML" [1-478] -->
<h2><a>Plan Your GUI Layout</a></h2>
<h2>Plan Your GUI Layout</h2>
<div>
<p>
<img src="nbdocs:/com/jme3/gde/docs/jme3/advanced/gui-layout-draft.png">
</p>
<p>
In this tutorial, you want to create two game screens: An out-of-game StartScreen that the players see before the game starts; and an in-game <object classid="java:org.netbeans.modules.javahelp.BrowserDisplayer"><param name="content" value="http://en.wikipedia.org/wiki/HUD_%28video_gaming%29"><param name="text" value="<html><u>HUD</u></html>"><param name="textColor" value="blue"></object> that displays info during the game. Before writing code, you plan the <acronym title="Graphical User Interface">GUI</acronym> layout, either on paper or in a graphic application.
In this tutorial, you want to create two game screens: An out-of-game StartScreen that the players see before the game starts; and an in-game <object classid="java:org.netbeans.modules.javahelp.BrowserDisplayer"><param name="content" value="http://en.wikipedia.org/wiki/HUD_%28video_gaming%29"><param name="text" value="<html><u>HUD</u></html>"><param name="textColor" value="blue"></object> that displays info during the game. Before writing code, you plan the <abbr title="Graphical User Interface">GUI</abbr> layout, either on paper or in a graphic application.
</p>
<p>
@ -58,7 +56,6 @@ The StartScreen contains:
</ul>
<p>
The HUD contains:
</p>
<ul>
@ -76,31 +73,32 @@ The HUD contains:
</div>
<!-- EDIT2 SECTION "Plan Your GUI Layout" [479-1663] -->
<h2><a>Implement Your GUI Layout</a></h2>
<h2>Implement Your GUI Layout</h2>
<div>
<p>
<img src="nbdocs:/com/jme3/gde/docs/jme3/advanced/nifty-screen-layer-panel.png">
</p>
<p>
Create an empty screen.xml file in the <code>assets/Interfaces/</code> directory of your project. One <acronym title="Extensible Markup Language">XML</acronym> file can contain several, or even all screens. As a reminder: Nifty displays one screen at a time; a screen contains several layers on top of one another; each layer contains panels that are embedded into another; the panels contain the actual content (text, images, or controls).
Create an empty <strong>screen</strong>.xml file in the <code>assets/Interface/</code> directory of your project. ( Rightclick on Interface → New → Other… → <abbr title="Graphical User Interface">GUI</abbr> → Empty NiftyGui file)
Afterwards create the directory <code>assets/Interface/Fonts</code> and add a new font e.g. Arial. ( <strong>Rightclick on Interface → New → Other… →</strong> Other → Folder and <abbr title="Graphical User Interface">GUI</abbr> → Font)
</p>
<p>
One XML file can contain several, or even all screens. As a reminder: Nifty displays one screen at a time; a screen contains several layers on top of one another; each layer contains panels that are embedded into another; the panels contain the actual content (text, images, or controls).
</p>
</div>
<!-- EDIT3 SECTION "Implement Your GUI Layout" [1664-2139] -->
<h3><a>Make Screens</a></h3>
<!-- EDIT3 SECTION "Implement Your GUI Layout" [1664-2394] -->
<h3>Make Screens</h3>
<div>
<p>
The following minimal <acronym title="Extensible Markup Language">XML</acronym> file contains a start screen and a HUD screen. (Neither has been defined yet.)
The following minimal XML file contains a start screen and a HUD screen. (Neither has been defined yet.)
</p>
<pre><span>&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;</span>
<span>&lt;nifty xmlns=&quot;http://nifty-gui.sourceforge.net/nifty-1.3.xsd&quot;</span>
<span> xmlns:xsi=&quot;http://www.w3.org/2001/XMLSchema-instance&quot;</span>
<span> xsi:schemaLocation=&quot;http://nifty-gui.sourceforge.net/nifty-1.3.xsd&quot;&gt;</span>
<span>&lt;nifty xmlns=&quot;http://nifty-gui.sourceforge.net/nifty-1.3.xsd&quot; xmlns:xsi=&quot;http://www.w3.org/2001/XMLSchema-instance&quot; xsi:schemaLocation=&quot;http://nifty-gui.sourceforge.net/nifty-1.3.xsd http://nifty-gui.sourceforge.net/nifty-1.3.xsd&quot;&gt;</span>
<span>&lt;screen id=&quot;start&quot;&gt;</span>
&lt;!-- ... --&gt;
<span><span>&lt;/screen&gt;</span></span>
@ -110,21 +108,21 @@ The following minimal <acronym title="Extensible Markup Language">XML</acronym>
<span><span>&lt;/nifty&gt;</span></span></pre>
<p>
Every Nifty <acronym title="Graphical User Interface">GUI</acronym> must have a start screen. The others (in this example, the HUD screen) are optional.
Every Nifty <abbr title="Graphical User Interface">GUI</abbr> must have a start screen. The others (in this example, the HUD screen) are optional.
</p>
<p>
<strong>Note:</strong> In the following examples, the <acronym title="Extensible Markup Language">XML</acronym> schema header is abbreviated to just <code>&lt;nifty&gt;</code>.
<strong>Note:</strong> In the following examples, the XML schema header is abbreviated to just <code>&lt;nifty&gt;</code>.
</p>
</div>
<!-- EDIT4 SECTION "Make Screens" [2140-2825] -->
<h3><a>Make Layers</a></h3>
<!-- EDIT4 SECTION "Make Screens" [2395-3123] -->
<h3>Make Layers</h3>
<div>
<p>
The following minimal <acronym title="Extensible Markup Language">XML</acronym> file shows how we added layers to the start screen and HUD screen:
The following minimal XML file shows how we added layers to the start screen and HUD screen.
Delete all from the file and add following code:
</p>
<pre><span><span>&lt;nifty&gt;</span></span>
<span>&lt;screen id=&quot;start&quot;&gt;</span>
@ -150,12 +148,11 @@ In a layer, you can now add panels and arrange them. Panels are containers that
</p>
</div>
<!-- EDIT5 SECTION "Make Layers" [2826-3599] -->
<h3><a>Make Panels</a></h3>
<!-- EDIT5 SECTION "Make Layers" [3124-3946] -->
<h3>Make Panels</h3>
<div>
<p>
A panel is the inner-most container (that will contain the actual content: text, images, or controls). You place panels inside layers. The following panels go into in the <code>start</code> screen&#039;s <code>foreground</code> layer:
</p>
<pre> <span>&lt;panel id=&quot;panel_top&quot; height=&quot;25%&quot; width=&quot;75%&quot; align=&quot;center&quot; childLayout=&quot;center&quot;</span>
@ -203,76 +200,67 @@ The result should look as follows:
</p>
</div>
<!-- EDIT6 SECTION "Make Panels" [3600-5482] -->
<h2><a>Adding Content to Panels</a></h2>
<!-- EDIT6 SECTION "Make Panels" [3947-5829] -->
<h2>Adding Content to Panels</h2>
<div>
<p>
See also <object classid="java:org.netbeans.modules.javahelp.BrowserDisplayer"><param name="content" value="http://sourceforge.net/apps/mediawiki/nifty-gui/index.php?title=Layout_Introduction"><param name="text" value="<html><u>Layout Introduction</u></html>"><param name="textColor" value="blue"></object> on the Nifty <acronym title="Graphical User Interface">GUI</acronym> site.
See also <object classid="java:org.netbeans.modules.javahelp.BrowserDisplayer"><param name="content" value="http://sourceforge.net/apps/mediawiki/nifty-gui/index.php?title=Layout_Introduction"><param name="text" value="<html><u>Layout Introduction</u></html>"><param name="textColor" value="blue"></object> on the Nifty <abbr title="Graphical User Interface">GUI</abbr> site.
</p>
</div>
<!-- EDIT7 SECTION "Adding Content to Panels" [5483-5661] -->
<h3><a>Add Images</a></h3>
<!-- EDIT7 SECTION "Adding Content to Panels" [5830-6008] -->
<h3>Add Images</h3>
<div>
<p>
The start-background.png image is a fullscreen background picture. In the <code>start</code> screen, add the following image element:
The <object classid="java:org.netbeans.modules.javahelp.BrowserDisplayer"><param name="content" value="http://hub.jmonkeyengine.org/wikinbdocs:/com/jme3/gde/docs/jme3:advanced:start-background.png"><param name="text" value="<html><u>start-background.png</u></html>"><param name="textColor" value="blue"></object> image is a fullscreen background picture. Add it to <code>Interface</code>. In the <code>start</code> screen, add the following image element:
</p>
<pre> <span>&lt;layer id=&quot;background&quot; childLayout=&quot;center&quot;&gt;</span>
<span>&lt;image filename=&quot;Interface/tutorial/step2/start-background.png&quot;&gt;<span>&lt;/image&gt;</span></span>
<span>&lt;image filename=&quot;Interface/start-background.png&quot;&gt;<span>&lt;/image&gt;</span></span>
<span><span>&lt;/layer&gt;</span></span></pre>
<p>
The hud-frame.png image is a transparent frame that we use as HUD decoration. In the <code>hud</code> screen, add the following image element:
The <object classid="java:org.netbeans.modules.javahelp.BrowserDisplayer"><param name="content" value="http://hub.jmonkeyengine.org/wikinbdocs:/com/jme3/gde/docs/jme3:advanced:hud-frame.png"><param name="text" value="<html><u>hud-frame.png</u></html>"><param name="textColor" value="blue"></object> image is a transparent frame that we use as HUD decoration. Add it to <code>Interface</code>. In the <code>hud</code> screen, add the following image element:
</p>
<pre> <span>&lt;layer id=&quot;background&quot; childLayout=&quot;center&quot;&gt;</span>
<span>&lt;image filename=&quot;Interface/tutorial/step2/hud-frame.png&quot;&gt;<span>&lt;/image&gt;</span></span>
<span>&lt;image filename=&quot;Interface/hud-frame.png&quot;&gt;<span>&lt;/image&gt;</span></span>
<span><span>&lt;/layer&gt;</span></span></pre>
<p>
In order to make the hud-frame.png independent of the screen resolution you are using, you could use the <code>imageMode</code> attribute on the image element <object classid="java:org.netbeans.modules.javahelp.BrowserDisplayer"><param name="content" value="http://sourceforge.net/apps/mediawiki/nifty-gui/index.php?title=Resizable_Images_(ImageMode%3Dresize)_explained"><param name="text" value="<html><u> Resizable Images (ImageMode=resize) explained</u></html>"><param name="textColor" value="blue"></object>
</p>
<pre> <span>&lt;layer id=&quot;background&quot; childLayout=&quot;center&quot;&gt;</span>
<span>&lt;image filename=&quot;Interface/tutorial/step2/hud-frame.png&quot; imageMode=&quot;resize:40,490,110,170,40,560,40,270,40,560,40,40&quot; width=&quot;100%&quot; height=&quot;100%&quot;/&gt;</span>
<span>&lt;image filename=&quot;Interface/hud-frame.png&quot; imageMode=&quot;resize:40,490,110,170,40,560,40,270,40,560,40,40&quot; width=&quot;100%&quot; height=&quot;100%&quot;/&gt;</span>
<span><span>&lt;/layer&gt;</span></span></pre>
<p>
The face1.png image is an image that you want to use as a status icon.
The <object classid="java:org.netbeans.modules.javahelp.BrowserDisplayer"><param name="content" value="http://hub.jmonkeyengine.org/wikinbdocs:/com/jme3/gde/docs/jme3:advanced:face1.png"><param name="text" value="<html><u>face1.png</u></html>"><param name="textColor" value="blue"></object> image is an image that you want to use as a status icon. Add it to <code>Interface</code>.
In the <code>hud</code> screen&#039;s <code>foreground</code> layer, add the following image element:
</p>
<pre> <span>&lt;panel id=&quot;panel_bottom_left&quot; height=&quot;75%&quot; width=&quot;20%&quot; valign=&quot;center&quot; childLayout=&quot;center&quot;&gt;</span>
<span>&lt;image filename=&quot;Interface/tutorial/step2/face1.png&quot; </span>
<span> valign=&quot;center&quot; align=&quot;center&quot; height=&quot;50%&quot; width=&quot;30%&quot; &gt;</span>
<span><span>&lt;/image&gt;</span></span>
<pre> <span>&lt;panel id=&quot;panel_top_right2&quot; width=&quot;100%&quot; height=&quot;15%&quot; childLayout=&quot;center&quot;&gt;</span>
<span>&lt;image filename=&quot;Interface/face1.png&quot; valign=&quot;center&quot; align=&quot;center&quot; height=&quot;50%&quot; width=&quot;30%&quot; &gt;</span>
<span><span>&lt;/image&gt;</span></span>
<span><span>&lt;/panel&gt;</span></span></pre>
<p>
This image is scaled to use 50% of the height and 30% of the width of its container.
</p>
</div>
<!-- EDIT8 SECTION "Add Images" [5662-7348] -->
<h3><a>Add Static Text</a></h3>
<!-- EDIT8 SECTION "Add Images" [6009-7930] -->
<h3>Add Static Text</h3>
<div>
<p>
The game title is a typical example of static text. In the <code>start</code> screen, add the following text element:
</p>
<pre> <span>&lt;panel id=&quot;panel_top&quot; height=&quot;25%&quot; width=&quot;75%&quot; align=&quot;center&quot; childLayout=&quot;center&quot;&gt;</span>
<span>&lt;text text=&quot;My Cool Game&quot; font=&quot;Interface/Fonts/Default.fnt&quot; width=&quot;100%&quot; height=&quot;100%&quot; /&gt;</span>
<span><span>&lt;/panel&gt;</span></span></pre>
<p>
For longer pieces of static text, such as an introduction, you can use wrap=&quot;true&quot;. Add the following text element to the <code>Start screen</code>:
For longer pieces of static text, such as an introduction, you can use wrap=“true”. Add the following text element to the <code>Start screen</code>:
</p>
<pre> <span>&lt;panel id=&quot;panel_mid&quot; height=&quot;50%&quot; width=&quot;75%&quot; align=&quot;center&quot; childLayout=&quot;center&quot;&gt;</span>
<span>&lt;text text=&quot;Here goes some text describing the game and the rules and stuff. Incidentally,
@ -281,16 +269,16 @@ For longer pieces of static text, such as an introduction, you can use wrap=&quo
<span><span>&lt;/panel&gt;</span></span></pre>
<p>
The font used is jME3&#039;s default font &quot;Interface/Fonts/Default.fnt&quot; which is included in the jMonkeyEngine.JAR. You can add your own fonts to your own <code>assets/Interface</code> directory.
The font used is jME3&#039;s default font “Interface/Fonts/Default.fnt” which is included in the jMonkeyEngine.JAR. You can add your own fonts to your own <code>assets/Interface/Fonts</code> directory.
Adjust the path to your font-name.
</p>
</div>
<!-- EDIT9 SECTION "Add Static Text" [7349-8429] -->
<h3><a>Add Controls</a></h3>
<!-- EDIT9 SECTION "Add Static Text" [7931-9052] -->
<h3>Add Controls</h3>
<div>
<p>
Before you can use any control, you must load a Control Definition first. Add the following two lines <em>before</em> your screen definitions:
</p>
<pre> <span>&lt;useStyles filename=&quot;nifty-default-styles.xml&quot; /&gt;</span>
@ -302,11 +290,10 @@ Note that the useStyles tag must be the first child of the nifty tag, otherwise
</div>
<h4><a>Label Control</a></h4>
<h4>Label Control</h4>
<div>
<p>
Use label controls for text that you want to edit dynamically from Java. One example for this is the score display.
In the <code>hud</code> screen&#039;s <code>foreground</code> layer, add the following text element:
</p>
@ -320,12 +307,11 @@ Note that the width and height do not scale the bitmap font, but indirectly make
</div>
<h4><a>Button Control</a></h4>
<h4>Button Control</h4>
<div>
<p>
Our <acronym title="Graphical User Interface">GUI</acronym> plan asks for two buttons on the start screen. You add the Start and Quit buttons to the bottom panel of the <code>start</code> screen using the <code>&lt;control&gt;</code> element:
Our <abbr title="Graphical User Interface">GUI</abbr> plan asks for two buttons on the start screen. You add the Start and Quit buttons to the bottom panel of the <code>start</code> screen using the <code>&lt;control&gt;</code> element:
</p>
<pre> <span>&lt;panel id=&quot;panel_bottom_left&quot; height=&quot;50%&quot; width=&quot;50%&quot; valign=&quot;center&quot; childLayout=&quot;center&quot;&gt;</span>
<span>&lt;control name=&quot;button&quot; label=&quot;Start&quot; id=&quot;StartButton&quot; align=&quot;center&quot; valign=&quot;center&quot;&gt;</span>
@ -337,27 +323,76 @@ Our <acronym title="Graphical User Interface">GUI</acronym> plan asks for two bu
<span><span>&lt;/panel&gt;</span></span></pre>
<p>
Note that these controls don&#039;t do anything yet ??? we&#039;ll get to that soon.
Note that these controls don&#039;t do anything yet – we&#039;ll get to that soon.
</p>
<p>
Now remove all <strong>backgroundColor=““</strong> tags from your code. They were only needed to show the layout.
</p>
<p>
Your screen.xml should look like this:
</p>
<pre><span>&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;</span>
<span>&lt;nifty xmlns=&quot;http://nifty-gui.sourceforge.net/nifty-1.3.xsd&quot; xmlns:xsi=&quot;http://www.w3.org/2001/XMLSchema-instance&quot; xsi:schemaLocation=&quot;http://nifty-gui.sourceforge.net/nifty-1.3.xsd http://nifty-gui.sourceforge.net/nifty-1.3.xsd&quot;&gt;</span>
<span>&lt;useStyles filename=&quot;nifty-default-styles.xml&quot; /&gt;</span>
<span>&lt;useControls filename=&quot;nifty-default-controls.xml&quot; /&gt;</span>
<span>&lt;screen id=&quot;start&quot;&gt;</span>
<span>&lt;layer id=&quot;background&quot; childLayout=&quot;center&quot;&gt;</span>
<span>&lt;image filename=&quot;Interface/start-background.png&quot;&gt;<span>&lt;/image&gt;</span></span>
<span><span>&lt;/layer&gt;</span></span>
<span>&lt;layer id=&quot;foreground&quot; childLayout=&quot;vertical&quot;&gt;</span>
<span>&lt;panel id=&quot;panel_top&quot; height=&quot;25%&quot; width=&quot;75%&quot; align=&quot;center&quot; childLayout=&quot;center&quot;&gt;</span>
<span>&lt;text text=&quot;My Cool Game&quot; font=&quot;Interface/Fonts/Default.fnt&quot; width=&quot;100%&quot; height=&quot;100%&quot; /&gt;</span>
<span><span>&lt;/panel&gt;</span></span>
<span>&lt;panel id=&quot;panel_mid&quot; height=&quot;50%&quot; width=&quot;75%&quot; align=&quot;center&quot; childLayout=&quot;center&quot;&gt;</span>
<span>&lt;text text=&quot;Here goes some text describing the game and the rules and stuff. Incidentally, the text is quite long and needs to wrap at the end of lines. ...&quot; font=&quot;Interface/Fonts/Default.fnt&quot; width=&quot;100%&quot; height=&quot;100%&quot; wrap=&quot;true&quot; /&gt;</span>
<span><span>&lt;/panel&gt;</span></span>
<span>&lt;panel id=&quot;panel_bottom&quot; height=&quot;25%&quot; width=&quot;75%&quot; align=&quot;center&quot; childLayout=&quot;horizontal&quot; &gt;</span>
<span>&lt;panel id=&quot;panel_bottom_left&quot; height=&quot;50%&quot; width=&quot;50%&quot; valign=&quot;center&quot; childLayout=&quot;center&quot;&gt;</span>
<span>&lt;control name=&quot;button&quot; label=&quot;Start&quot; id=&quot;StartButton&quot; align=&quot;center&quot; valign=&quot;center&quot;&gt;<span>&lt;/control&gt;</span></span>
<span><span>&lt;/panel&gt;</span></span>
<span>&lt;panel id=&quot;panel_bottom_right&quot; height=&quot;50%&quot; width=&quot;50%&quot; valign=&quot;center&quot; childLayout=&quot;center&quot;&gt;</span>
<span>&lt;control name=&quot;button&quot; label=&quot;Quit&quot; id=&quot;QuitButton&quot; align=&quot;center&quot; valign=&quot;center&quot;&gt;<span>&lt;/control&gt;</span></span>
<span><span>&lt;/panel&gt;</span></span>
<span><span>&lt;/panel&gt;</span></span>
<span><span>&lt;/layer&gt;</span></span>
<span><span>&lt;/screen&gt;</span></span>
<span>&lt;screen id=&quot;hud&quot;&gt;</span>
<span>&lt;layer id=&quot;background&quot; childLayout=&quot;center&quot;&gt;</span>
<span>&lt;image filename=&quot;Interface/hud-frame.png&quot;&gt;<span>&lt;/image&gt;</span></span>
<span><span>&lt;/layer&gt;</span></span>
<span>&lt;layer id=&quot;foreground&quot; childLayout=&quot;horizontal&quot;&gt;</span>
<span>&lt;panel id=&quot;panel_left&quot; width=&quot;80%&quot; height=&quot;100%&quot; childLayout=&quot;vertical&quot; &gt;<span>&lt;/panel&gt;</span></span>
<span>&lt;panel id=&quot;panel_right&quot; width=&quot;20%&quot; height=&quot;100%&quot; childLayout=&quot;vertical&quot;&gt;</span>
<span>&lt;panel id=&quot;panel_top_right1&quot; width=&quot;100%&quot; height=&quot;15%&quot; childLayout=&quot;center&quot;&gt;</span>
<span>&lt;control name=&quot;label&quot; color=&quot;#000&quot; text=&quot;123&quot; width=&quot;100%&quot; height=&quot;100%&quot; /&gt;</span>
<span><span>&lt;/panel&gt;</span></span>
<span>&lt;panel id=&quot;panel_top_right2&quot; width=&quot;100%&quot; height=&quot;15%&quot; childLayout=&quot;center&quot;&gt;</span>
<span>&lt;image filename=&quot;Interface/face1.png&quot; valign=&quot;center&quot; align=&quot;center&quot; height=&quot;50%&quot; width=&quot;30%&quot; &gt;<span>&lt;/image&gt;</span></span>
<span><span>&lt;/panel&gt;</span></span>
<span>&lt;panel id=&quot;panel_bot_right&quot; width=&quot;100%&quot; height=&quot;70%&quot; valign=&quot;center&quot; &gt;<span>&lt;/panel&gt;</span></span>
<span><span>&lt;/panel&gt;</span></span>
<span><span>&lt;/layer&gt;</span></span>
<span><span>&lt;/screen&gt;</span></span>
<span><span>&lt;/nifty&gt;</span></span></pre>
</div>
<h4><a>Other Controls</a></h4>
<h4>Other Controls</h4>
<div>
<p>
Nifty additionally offers many customizable controls such as check boxes, text fields, menus, chats, tabs, ??? See also <object classid="java:org.netbeans.modules.javahelp.BrowserDisplayer"><param name="content" value="http://sourceforge.net/apps/mediawiki/nifty-gui/index.php?title=Elements"><param name="text" value="<html><u>Elements</u></html>"><param name="textColor" value="blue"></object> on the Nifty <acronym title="Graphical User Interface">GUI</acronym> site.
Nifty additionally offers many customizable controls such as check boxes, text fields, menus, chats, tabs, … See also <object classid="java:org.netbeans.modules.javahelp.BrowserDisplayer"><param name="content" value="http://sourceforge.net/apps/mediawiki/nifty-gui/index.php?title=Elements"><param name="text" value="<html><u>Elements</u></html>"><param name="textColor" value="blue"></object> on the Nifty <abbr title="Graphical User Interface">GUI</abbr> site.
</p>
</div>
<!-- EDIT10 SECTION "Add Controls" [8430-10517] -->
<h2><a>Intermediate Result</a></h2>
<!-- EDIT10 SECTION "Add Controls" [9053-13918] -->
<h2>Intermediate Result</h2>
<div>
<p>
When you preview this code in the jMonkeyEngine <acronym title="Software Development Kit">SDK</acronym>, our tutorial demo should looks as follows: A start screen with two buttons, and a game screen with a simple HUD frame and a blue cube (which stands for any jME3 game content).
When you preview this code in the jMonkeyEngine SDK, our tutorial demo should looks as follows: A start screen with two buttons, and a game screen with a simple HUD frame and a blue cube (which stands for any jME3 game content).
</p>
<p>
@ -369,13 +404,12 @@ Compare this result with the layout draft above.
</p>
</div>
<!-- EDIT11 SECTION "Intermediate Result" [10518-10878] -->
<h2><a>Next Steps</a></h2>
<!-- EDIT11 SECTION "Intermediate Result" [13919-14279] -->
<h2>Next Steps</h2>
<div>
<p>
Integrate the <acronym title="Graphical User Interface">GUI</acronym> into the game. Typically, you will overlay the <acronym title="Graphical User Interface">GUI</acronym>.
Integrate the <abbr title="Graphical User Interface">GUI</abbr> into the game. Typically, you will overlay the <abbr title="Graphical User Interface">GUI</abbr>.
</p>
<ul>
<li><div> <a href="/com/jme3/gde/docs/jme3/advanced/nifty_gui_overlay.html">Nifty GUI Overlay</a> (recommended)</div>
@ -383,13 +417,11 @@ Integrate the <acronym title="Graphical User Interface">GUI</acronym> into the g
<li><div> <a href="/com/jme3/gde/docs/jme3/advanced/nifty_gui_projection.html">Nifty GUI Projection</a> (optional)</div>
</li>
</ul>
<div><span>
<a href="/wiki/doku.php/tag:gui?do=showtag&amp;tag=tag%3Agui">gui</a>,
<a href="/wiki/doku.php/tag:documentation?do=showtag&amp;tag=tag%3Adocumentation">documentation</a>,
<a href="/wiki/doku.php/tag:nifty?do=showtag&amp;tag=tag%3Anifty">nifty</a>,
<a href="/wiki/doku.php/tag:hud?do=showtag&amp;tag=tag%3Ahud">hud</a>
</span></div>
<p>
<a href="nbdocs:/com/jme3/gde/docs/jme3:advanced/tag_gui_documentation_nifty_hud">tag_gui_documentation_nifty_hud</a>
</p>
</div>
<!-- EDIT12 SECTION "Next Steps" [10879-] -->
<p><em><a href="http://hub.jmonkeyengine.org/wiki/doku.php/jme3:advanced:nifty_gui_xml_layout?do=export_xhtmlbody">view online version</a></em></p>
<!-- EDIT12 SECTION "Next Steps" [14280-] -->
<p><em><a href="http://wiki.jmonkeyengine.org/doku.php/jme3:advanced:nifty_gui_xml_layout?do=export_xhtmlbody">view online version</a></em></p>

Binary file not shown.

Before

Width:  |  Height:  |  Size: 8.6 KiB

After

Width:  |  Height:  |  Size: 38 KiB

@ -1,15 +1,16 @@
<h1><a>Working Blender and OgreXML Versions</a></h1>
<h1>Working Blender and OgreXML Versions</h1>
<div>
<p>
Here you can find working combinations of Blender and the OgreXML exporter, with any tips or bugs associated with each.
</p>
<div><table>
<thead>
<tr>
<th> Blender Version </th><th> OgreXML Exporter Version </th><th> Notes </th>
</tr>
</thead>
<tr>
<td> 2.6.3 </td><td> <object classid="java:org.netbeans.modules.javahelp.BrowserDisplayer"><param name="content" value="http://code.google.com/p/blender2ogre/downloads/list"><param name="text" value="<html><u>0.5.8</u></html>"><param name="textColor" value="blue"></object> </td><td> Root bone, no transforms on object, no envelopes </td>
</tr>
@ -26,11 +27,10 @@ Here you can find working combinations of Blender and the OgreXML exporter, with
<!-- EDIT2 TABLE [173-518] -->
</div>
<!-- EDIT1 SECTION "Working Blender and OgreXML Versions" [1-519] -->
<h1><a>Tips</a></h1>
<h1>Tips</h1>
<div>
<p>
Tips for exporting animations through OgreXML correctly:
</p>
<ul>
@ -47,7 +47,6 @@ Tips for exporting animations through OgreXML correctly:
</ul>
<p>
Test Character - <object classid="java:org.netbeans.modules.javahelp.BrowserDisplayer"><param name="content" value="http://dl.dropbox.com/u/26887202/123/jme_blender/characterOgre26.zip"><param name="text" value="<html><u>http://dl.dropbox.com/u/26887202/123/jme_blender/characterOgre26.zip</u></html>"><param name="textColor" value="blue"></object>
</p>
@ -58,11 +57,10 @@ Test Character - <object classid="java:org.netbeans.modules.javahelp.BrowserDisp
</div>
<!-- EDIT3 SECTION "Tips" [520-996] -->
<h1><a>Troubleshooting</a></h1>
<h1>Troubleshooting</h1>
<div>
<p>
<strong>Q:</strong> <em>My animation is stretched.</em>
</p>
@ -72,4 +70,4 @@ Test Character - <object classid="java:org.netbeans.modules.javahelp.BrowserDisp
</div>
<!-- EDIT4 SECTION "Troubleshooting" [997-] -->
<p><em><a href="http://hub.jmonkeyengine.org/wiki/doku.php/jme3:advanced:ogrecompatibility?do=export_xhtmlbody">view online version</a></em></p>
<p><em><a href="http://wiki.jmonkeyengine.org/doku.php/jme3:advanced:ogrecompatibility?do=export_xhtmlbody">view online version</a></em></p>

@ -1,5 +1,5 @@
<h1><a>Open Game Finder</a></h1>
<h1>Open Game Finder</h1>
<div>
<p>
@ -13,13 +13,12 @@ The Open Game Finder (OGF) by Mark Schrijver can be plugged into any Java game.
</ul>
<p>
Both on the client and the server side of OGF is written purely in Java. OGF has a pluggable architecture and comes with a full set of plugins to get the job done. You can add your own plugins, or replace existing plugins to make them more in line with your game. OGF uses NiftyGUI as the main <acronym title="Graphical User Interface">GUI</acronym> plugin.
Both on the client and the server side of OGF is written purely in Java. OGF has a pluggable architecture and comes with a full set of plugins to get the job done. You can add your own plugins, or replace existing plugins to make them more in line with your game. OGF uses NiftyGUI as the main <abbr title="Graphical User Interface">GUI</abbr> plugin.
</p>
</div>
<!-- EDIT1 SECTION "Open Game Finder" [1-629] -->
<h2><a>Installation</a></h2>
<h2>Installation</h2>
<div>
<ol>
<li><div> Go to <object classid="java:org.netbeans.modules.javahelp.BrowserDisplayer"><param name="content" value="http://code.google.com/p/open-game-finder/downloads/list"><param name="text" value="<html><u>http://code.google.com/p/open-game-finder/downloads/list</u></html>"><param name="textColor" value="blue"></object></div>
@ -32,23 +31,23 @@ Both on the client and the server side of OGF is written purely in Java. OGF has
</div>
<!-- EDIT2 SECTION "Installation" [630-849] -->
<h2><a>Setting up the Database</a></h2>
<h2>Setting up the Database</h2>
<div>
<p>
The OGF server uses an embedded Apache Derby database. You have to install the database, this means creating the data files and adding the tables. You can do this straight from the command line by running a script file.
</p>
<ul>
<li><div> On Windows, use installServer.bat to create a new database from scratch. On Mac <acronym title="Operating System">OS</acronym> or Linux, run <code>java -jar lib/Server-0.1.jar install</code> in the Terminal.</div>
<li><div> On Windows, use installServer.bat to create a new database from scratch. On Mac <abbr title="Operating System">OS</abbr> or Linux, run <code>java -jar lib/Server-0.1.jar install</code> in the Terminal.</div>
</li>
<li><div> On Windows, use updateServer.bat to update the difference between the current state of the database and the way it should be. On Mac <acronym title="Operating System">OS</acronym> and Linux, run <code>java -jar lib/Server-0.1.jar update</code> in the Terminal. <br/>
<li><div> On Windows, use updateServer.bat to update the difference between the current state of the database and the way it should be. On Mac <abbr title="Operating System">OS</abbr> and Linux, run <code>java -jar lib/Server-0.1.jar update</code> in the Terminal. <br/>
<strong>This new feature is currently untested.</strong></div>
</li>
</ul>
</div>
<!-- EDIT3 SECTION "Setting up the Database" [850-1523] -->
<h2><a>Running the server</a></h2>
<h2>Running the server</h2>
<div>
<p>
@ -65,12 +64,11 @@ Change into the OGF-Server directory and run the server:
The server is now running and ready to accept connections. <br/>
<strong>Note:</strong> In the alpha release, the server runs on localhost. In the final release, you will be able to configure the host!
</p>
</div>
<!-- EDIT4 SECTION "Running the server" [1524-1913] -->
<h2><a>Running the client</a></h2>
<h2>Running the client</h2>
<div>
<ol>
<li><div> Change into the OGF-Client directory and run the client:</div>
@ -89,12 +87,11 @@ The server is now running and ready to accept connections. <br/>
A client is now running, connects to the server, and displays a registration/login window.
<img src="nbdocs:/com/jme3/gde/docs/jme3/advanced/open-game-finder-1.png">
<strong>Note:</strong> You can run several clients on localhost for testing.
</p>
</div>
<!-- EDIT5 SECTION "Running the client" [1914-2406] -->
<h3><a>Client: 1. Registration</a></h3>
<h3>Client: 1. Registration</h3>
<div>
<p>
@ -114,12 +111,11 @@ On the main screen of the client:
<p>
The client registers the account and opens the chat window directly.
</p>
</div>
<!-- EDIT6 SECTION "Client: 1. Registration" [2407-2760] -->
<h3><a>Client: 2. Login</a></h3>
<h3>Client: 2. Login</h3>
<div>
<p>
@ -135,22 +131,20 @@ On the main screen of the client:
<p>
The client logs you in and opens the chat window.
</p>
</div>
<!-- EDIT7 SECTION "Client: 2. Login" [2761-3033] -->
<h3><a>Client: 3. Chat</a></h3>
<h3>Client: 3. Chat</h3>
<div>
<p>
The chat window shows a list of all users logged in to the server. Logged-in users can send public messages, and can receive public messages from others.
</p>
</div>
<!-- EDIT8 SECTION "Client: 3. Chat" [3034-3213] -->
<h2><a>Connecting to a Game</a></h2>
<h2>Connecting to a Game</h2>
<div>
<p>
@ -172,12 +166,11 @@ In a JME3 Application&#039;s init method:
<p>
After this, continue writing your JME3 init method.
</p>
</div>
<!-- EDIT9 SECTION "Connecting to a Game" [3214-3904] -->
<h2><a>Configuration</a></h2>
<h2>Configuration</h2>
<div>
<ul>
<li><div> Q: How can I offer more avatars to choose from? <br/>
@ -187,10 +180,11 @@ A: Save the image files in the path <code>jMonkeyProjects/OGF-Client-1.0-bin/OGF
A: TBD</div>
</li>
</ul>
<div><span>
<a href="/wiki/doku.php/tag:network?do=showtag&amp;tag=tag%3Anetwork">network</a>
</span></div>
<p>
<a href="nbdocs:/com/jme3/gde/docs/jme3:advanced/tag_network">tag_network</a>
</p>
</div>
<!-- EDIT10 SECTION "Configuration" [3905-] -->
<p><em><a href="http://hub.jmonkeyengine.org/wiki/doku.php/jme3:advanced:open_game_finder?do=export_xhtmlbody">view online version</a></em></p>
<p><em><a href="http://wiki.jmonkeyengine.org/doku.php/jme3:advanced:open_game_finder?do=export_xhtmlbody">view online version</a></em></p>

Binary file not shown.

Before

Width:  |  Height:  |  Size: 196 KiB

After

Width:  |  Height:  |  Size: 370 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 196 KiB

After

Width:  |  Height:  |  Size: 375 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 14 KiB

After

Width:  |  Height:  |  Size: 35 KiB

@ -1,9 +1,8 @@
<h1><a>Particle Emmitter Settings</a></h1>
<h1>Particle Emmitter Settings</h1>
<div>
<p>
You cannot create a 3D model for delicate things like fire, smoke, or explosions. Particle Emitters are quite an efficient solution to create these kinds of effects: The emitter renders a series of flat orthogonal images and manipulates them in a way that creates the illusion of a anything from a delicate smoke cloud to individual flames, etc.
Creating an effect involves some trial and error to get the settings <em>just right</em>, and it&#039;s worth exploring the expressiveness of the options described below.
</p>
@ -19,11 +18,11 @@ Creating an effect involves some trial and error to get the settings <em>just ri
</div>
<!-- EDIT1 SECTION "Particle Emmitter Settings" [1-844] -->
<h2><a>Create an Emitter</a></h2>
<h2>Create an Emitter</h2>
<div>
<ol>
<li><div> Create one emitter for each effect: <pre>ParticleEmitter explosion = new ParticleEmitter&#40;
&quot;My explosion effect&quot;, ParticleMesh.Type.Triangle, 30&#41;;</pre>
&quot;My explosion effect&quot;, Type.Triangle, 30&#41;;</pre>
</div>
</li>
<li><div> Attach the emitter to the rootNode and position it in the scene: <pre>rootNode.attachChild&#40;explosion&#41;;
@ -42,24 +41,26 @@ explosion.setLocalTranslation&#40;bomb.getLocalTranslation&#40;&#41;&#41;;</pre>
Choose one of the following mesh shapes
</p>
<ul>
<li><div> ParticleMesh.Type.Triangle</div>
<li><div> Type.Triangle</div>
</li>
<li><div> ParticleMesh.Type.Point</div>
<li><div> Type.Point</div>
</li>
</ul>
</div>
<!-- EDIT2 SECTION "Create an Emitter" [845-1473] -->
<h2><a>Configure Parameters</a></h2>
<!-- EDIT2 SECTION "Create an Emitter" [845-1434] -->
<h2>Configure Parameters</h2>
<div>
<p>
Not all of these parameters are required for all kinds of effects. If you don&#039;t specify one of them, a default value will be used.
</p>
<div><table>
<thead>
<tr>
<th> Parameter </th><th> Method </th><th> Default </th><th> Description </th>
</tr>
</thead>
<tr>
<td> number </td><td> <code>setNumParticles()</code> </td><td> </td><td> The maximum number of particles visible at the same time. Specified by user in constructor. </td>
</tr>
@ -82,8 +83,8 @@ Set both to different colors for a gradient effect (e.g. fire). </td>
</tr>
<tr>
<td> fanning out </td><td> <code>getParticleInfluencer(). setVelocityVariation(variation)</code> </td><td> 0.2f </td><td> How much the direction (<code>setInitialVelocity()</code>) can vary among particles. Use a value between 1 and 0 to create a directed swarm-like cloud of particles. <br/>
1 = Maximum variation, particles emit in random 360?? directions (e.g. explosion, butterflies). <br/>
0.5f = particles are emitted within 180?? of the initial direction. <br/>
1 = Maximum variation, particles emit in random 360° directions (e.g. explosion, butterflies). <br/>
0.5f = particles are emitted within 180° of the initial direction. <br/>
0 = No variation, particles fly in a straight line in direction of start velocity (e.g. lasergun blasts). </td>
</tr>
<tr>
@ -115,23 +116,22 @@ false = Particles fly straight like you drew them in the sprite texture (e.g. in
<td> start area </td><td><code>setShape(new EmitterSphereShape( Vector3f.ZERO, 2f));</code></td><td>EmitterPointShape()</td><td>By default, particles are emitted from the emitters location (a point). You can increase the emitter shape to occupy a sphere, so that the start point of new particles can be anywhere inside the sphere, which makes the effect a bit more irregular.</td>
</tr>
</table></div>
<!-- EDIT4 TABLE [1638-5412] -->
<!-- EDIT4 TABLE [1599-5373] -->
<p>
Build up you effect by specifying one parameter after the other. If you change several parameters at the same time, it&#039;s difficult to tell which of the values caused which outcome.
</p>
</div>
<!-- EDIT3 SECTION "Configure Parameters" [1474-5594] -->
<h2><a>Create an Effect Material</a></h2>
<!-- EDIT3 SECTION "Configure Parameters" [1435-5555] -->
<h2>Create an Effect Material</h2>
<div>
<p>
<img src="/wiki/lib/exe/fetch.php">
<img src="/lib/exe/fetch.php">
</p>
<p>
Use the common Particle.j3md Material Definition and a texture to specify the shape of the particles. The shape is defined by the texture you provide and can be anything ??? debris, flames, smoke, mosquitoes, leaves, butterflies??? be creative.
Use the common Particle.j3md Material Definition and a texture to specify the shape of the particles. The shape is defined by the texture you provide and can be anything – debris, flames, smoke, mosquitoes, leaves, butterflies… be creative.
</p>
<pre> Material flash_mat = new Material&#40;
assetManager, &quot;Common/MatDefs/Misc/Particle.j3md&quot;&#41;;
@ -143,7 +143,7 @@ Use the common Particle.j3md Material Definition and a texture to specify the sh
flash.setSelectRandomImage&#40;true&#41;;</pre>
<p>
The effect texture can be one image, or contain a sprite animation ??? a series of slightly different pictures in equally spaced rows and columns. If you choose the sprite animation:
The effect texture can be one image, or contain a sprite animation a series of slightly different pictures in equally spaced rows and columns. If you choose the sprite animation:
</p>
<ul>
<li><div> Specify the number of rows and columns using setImagesX(2) and setImagesY().</div>
@ -153,13 +153,12 @@ The effect texture can be one image, or contain a sprite animation ??? a series
</ul>
<p>
<strong>Examples:</strong> Have a look at the following default textures and you will see how you can create your own sprite textures after the same fashion.
</p>
</div>
<!-- EDIT5 SECTION "Create an Effect Material" [5595-6915] -->
<h3><a>Default Particle Textures</a></h3>
<!-- EDIT5 SECTION "Create an Effect Material" [5556-6876] -->
<h3>Default Particle Textures</h3>
<div>
<p>
@ -167,45 +166,46 @@ The Material is used together with grayscale texture: The black parts will be tr
The following effect textures are available by default from <code>test-data.jar</code>. You can also load your own textures from your assets directory.
</p>
<div><table>
<thead>
<tr>
<th> Texture Path </th><th> Dimension </th><th> Preview </th>
</tr>
</thead>
<tr>
<td> Effects/Explosion/Debris.png </td><td> 3*3 </td><td> <img src="/wiki/lib/exe/fetch.php"> </td>
<td> Effects/Explosion/Debris.png </td><td> 3*3 </td><td> <img src="/lib/exe/fetch.php"> </td>
</tr>
<tr>
<td> Effects/Explosion/flame.png </td><td> 2*2 </td><td> <img src="/wiki/lib/exe/fetch.php"> </td>
<td> Effects/Explosion/flame.png </td><td> 2*2 </td><td> <img src="/lib/exe/fetch.php"> </td>
</tr>
<tr>
<td> Effects/Explosion/flash.png </td><td> 2*2 </td><td> <img src="/wiki/lib/exe/fetch.php"> </td>
<td> Effects/Explosion/flash.png </td><td> 2*2 </td><td> <img src="/lib/exe/fetch.php"> </td>
</tr>
<tr>
<td> Effects/Explosion/roundspark.png </td><td> 1*1 </td><td> <img src="/wiki/lib/exe/fetch.php"> </td>
<td> Effects/Explosion/roundspark.png </td><td> 1*1 </td><td> <img src="/lib/exe/fetch.php"> </td>
</tr>
<tr>
<td> Effects/Explosion/shockwave.png </td><td> 1*1 </td><td> <img src="/wiki/lib/exe/fetch.php"> </td>
<td> Effects/Explosion/shockwave.png </td><td> 1*1 </td><td> <img src="/lib/exe/fetch.php"> </td>
</tr>
<tr>
<td> Effects/Explosion/smoketrail.png </td><td> 1*3 </td><td> <img src="/wiki/lib/exe/fetch.php"> </td>
<td> Effects/Explosion/smoketrail.png </td><td> 1*3 </td><td> <img src="/lib/exe/fetch.php"> </td>
</tr>
<tr>
<td> Effects/Explosion/spark.png </td><td> 1*1 </td><td> <img src="/wiki/lib/exe/fetch.php"> </td>
<td> Effects/Explosion/spark.png </td><td> 1*1 </td><td> <img src="/lib/exe/fetch.php"> </td>
</tr>
<tr>
<td> Effects/Smoke/Smoke.png </td><td> 1*15 </td><td> <img src="/wiki/lib/exe/fetch.php"> </td>
<td> Effects/Smoke/Smoke.png </td><td> 1*15 </td><td> <img src="/lib/exe/fetch.php"> </td>
</tr>
</table></div>
<!-- EDIT7 TABLE [7231-8476] -->
<!-- EDIT7 TABLE [7192-8437] -->
<p>
<strong>Tip:</strong> Use the <code>setStartColor()</code>/<code>setEndColor()</code> settings described above to colorize the white and gray parts of textures.
</p>
</div>
<!-- EDIT6 SECTION "Default Particle Textures" [6916-8608] -->
<h2><a>Usage Example</a></h2>
<!-- EDIT6 SECTION "Default Particle Textures" [6877-8569] -->
<h2>Usage Example</h2>
<div>
<pre> ParticleEmitter fire = new ParticleEmitter&#40;&quot;Emitter&quot;, ParticleMesh.Type.Triangle, 30&#41;;
<pre> ParticleEmitter fire = new ParticleEmitter&#40;&quot;Emitter&quot;, Type.Triangle, 30&#41;;
Material mat_red = new Material&#40;assetManager, &quot;Common/MatDefs/Misc/Particle.j3md&quot;&#41;;
mat_red.setTexture&#40;&quot;Texture&quot;, assetManager.loadTexture&#40;&quot;Effects/Explosion/flame.png&quot;&#41;&#41;;
fire.setMaterial&#40;mat_red&#41;;
@ -222,20 +222,18 @@ The following effect textures are available by default from <code>test-data.jar<
rootNode.attachChild&#40;fire&#41;;</pre>
<p>
Browse the full source code of all <object classid="java:org.netbeans.modules.javahelp.BrowserDisplayer"><param name="content" value="http://code.google.com/p/jmonkeyengine/source/browse/#svn%2Ftrunk%2Fengine%2Fsrc%2Ftest%2Fjme3test%2Feffect"><param name="text" value="<html><u>effect examples</u></html>"><param name="textColor" value="blue"></object> here.
</p>
<hr />
<p>
See also: <a href="/com/jme3/gde/docs/jme3/advanced/effects_overview.html">Effects Overview</a>
</p>
<div><span>
<a href="/wiki/doku.php/tag:documentation?do=showtag&amp;tag=tag%3Adocumentation">documentation</a>,
<a href="/wiki/doku.php/tag:effect?do=showtag&amp;tag=tag%3Aeffect">effect</a>
</span></div>
<p>
<a href="nbdocs:/com/jme3/gde/docs/jme3:advanced/tag_documentation_effect">tag_documentation_effect</a>
</p>
</div>
<!-- EDIT8 SECTION "Usage Example" [8609-] -->
<p><em><a href="http://hub.jmonkeyengine.org/wiki/doku.php/jme3:advanced:particle_emitters?do=export_xhtmlbody">view online version</a></em></p>
<!-- EDIT8 SECTION "Usage Example" [8570-] -->
<p><em><a href="http://wiki.jmonkeyengine.org/doku.php/jme3:advanced:particle_emitters?do=export_xhtmlbody">view online version</a></em></p>

@ -1,9 +1,8 @@
<h1><a>Physics: Gravity, Collisions, Forces</a></h1>
<h1>Physics: Gravity, Collisions, Forces</h1>
<div>
<p>
A physics simulation is used in games and applications where objects are exposed to physical forces: Think of games like pool billiard and car racing simulators. Massive objects are pulled by gravity, forces cause objects to gain momentum, friction slows them down, solid objects collide and bounce off one another, etc. Action and Adventure games also make use of physics to implement solid obstacles, falling, and jumping.
</p>
@ -17,11 +16,11 @@ If you are looking for info on how to respond to physics events such as collisio
</div>
<!-- EDIT1 SECTION "Physics: Gravity, Collisions, Forces" [1-867] -->
<h2><a>Technical Overview</a></h2>
<h2>Technical Overview</h2>
<div>
<p>
jME3 has a complete, slightly adapted but fully wrapped Bullet <acronym title="Application Programming Interface">API</acronym> that uses normal jME math objects (Vector3f, Quaternion etc) as input/output data. All normal bullet objects like RigidBodies, Constraints (called &quot;Joints&quot; in jME3) and the various collision shapes are available, all mesh formats can be converted from jME to bullet.
jME3 has a complete, slightly adapted but fully wrapped Bullet <abbr title="Application Programming Interface">API</abbr> that uses normal jME math objects (Vector3f, Quaternion etc) as input/output data. All normal bullet objects like RigidBodies, Constraints (called “Joints” in jME3) and the various collision shapes are available, all mesh formats can be converted from jME to bullet.
</p>
<p>
@ -29,7 +28,7 @@ The PhysicsSpace object is the central object in bullet and all objects have to
</p>
<p>
The base bullet objects are also available as simple to use controls that can be attached to spatials to directly control these by physics forces and influences. The RigidBodyControl for example includes a simple constructor that automatically creates a hull collision shape or a mesh collision shape based on the given input mass and the mesh of the spatial it is attached to. This makes enabling physics on a Geometry as simple as &quot;spatial.addControl(new RigidBodyControl(1));&quot;
The base bullet objects are also available as simple to use controls that can be attached to spatials to directly control these by physics forces and influences. The RigidBodyControl for example includes a simple constructor that automatically creates a hull collision shape or a mesh collision shape based on the given input mass and the mesh of the spatial it is attached to. This makes enabling physics on a Geometry as simple as “spatial.addControl(new RigidBodyControl(1));”
</p>
<p>
@ -75,7 +74,6 @@ Due to some differences in how bullet and jME handle the scene and other objects
</ul>
<p>
When you use this physics simulation, values correspond to the following units:
</p>
<ul>
@ -88,7 +86,6 @@ When you use this physics simulation, values correspond to the following units:
</ul>
<p>
Bullet physics runs internally at 60fps by default. This rate is not dependent on the actual framerate and it does not lock the framerate at 60fps. Instead, when the actual fps is higher than the physics framerate the system will display interpolated positions for the physics objects. When the framerate is lower than the physics framerate, the physics space will be stepped multiple times per frame to make up for the missing calculations.
</p>
@ -108,11 +105,10 @@ Internally, the updating and syncing of the actual physics objects in the Bullet
</div>
<!-- EDIT2 SECTION "Technical Overview" [868-5940] -->
<h2><a>Sample Code</a></h2>
<h2>Sample Code</h2>
<div>
<p>
Full code samples are here:
</p>
<ul>
@ -128,11 +124,10 @@ Full code samples are here:
</div>
<!-- EDIT3 SECTION "Sample Code" [5941-6540] -->
<h2><a>Physics Application</a></h2>
<h2>Physics Application</h2>
<div>
<p>
A short overview of how to write a jME application with Physics capabilities:
</p>
@ -153,7 +148,6 @@ Do the following once per application to gain access to the <code>physicsSpace</
</ol>
<p>
<p><div>In your application, you can always access the <code>BulletAppState</code> via the ApplicationStateManager:
</p>
<pre>BulletAppState bas = app.getStateManager&#40;&#41;.getState&#40;BulletAppState.class&#41;;</pre>
@ -182,28 +176,27 @@ For each Spatial that you want to be physical:
</ol>
<p>
Let&#039;s look at the details:
</p>
</div>
<!-- EDIT4 SECTION "Physics Application" [6541-7742] -->
<h2><a>Create a CollisionShape</a></h2>
<h2>Create a CollisionShape</h2>
<div>
<p>
A CollisionShape is a simplified shape for which physics are easier to calculate than for the true shape of the model. This simplication approach speeds up the simulation greatly.
</p>
<p>
Before you can create a Physics Control, you must create a CollisionShape from the <code>com.jme3.bullet.collision.shapes</code> package. (Read the tip under &quot;PhysicsControls Code Samples&quot; how to use default CollisionShapes for Boxes and Spheres.)
Before you can create a Physics Control, you must create a CollisionShape from the <code>com.jme3.bullet.collision.shapes</code> package. (Read the tip under “PhysicsControls Code Samples” how to use default CollisionShapes for Boxes and Spheres.)
</p>
<div><table>
<thead>
<tr>
<th> Non-Mesh CollisionShape </th><th> Usage </th><th> Examples </th>
</tr>
</thead>
<tr>
<td> BoxCollisionShape() </td><td> Box-shaped behaviour, does not roll. </td><td> Oblong or cubic objects like bricks, crates, furniture. </td>
</tr>
@ -229,14 +222,14 @@ Disc-shaped objects like wheels, plates. </td>
</table></div>
<!-- EDIT6 TABLE [8201-9598] -->
<p>
All non-mesh CollisionShapes can be used for dynamic, kinematic, as well as static Spatials. (Code samples see below)
</p>
<div><table>
<thead>
<tr>
<th> Mesh CollisionShapes </th><th> Usage </th><th> Examples </th>
</tr>
</thead>
<tr>
<td> MeshCollisionShape </td><td> A mesh-accurate shape for static or kinematic Spatials. Can have complex shapes with openings and appendages. <br/>
<strong>Limitations:</strong> Collisions between two mesh-accurate shapes cannot be detected, only non-mesh shapes can collide with this shape. This Shape does not work with dynamic Spatials. </td><td> A whole static game level model. </td>
@ -256,13 +249,14 @@ All non-mesh CollisionShapes can be used for dynamic, kinematic, as well as stat
</table></div>
<!-- EDIT7 TABLE [9719-11236] -->
<p>
On a CollisionShape, you can apply a few properties
</p>
<div><table>
<thead>
<tr>
<th> CollisionShape Method </th><th> Property </th><th> Examples </th>
</tr>
</thead>
<tr>
<td> setScale(new Vector3f(2f,2f,2f)) </td><td> You can change the scale of collisionshapes (whether it be, Simple or Mesh). You cannot change the scale of a CompoundCollisionShape however. A sphere collision shape, will change its radius based on the X component of the vector passed in. You must scale a collision shape before attaching it to the physicsSpace, or you must readd it to the physicsSpace each time the scale changes. </td><td> Scale a player in the Y axis by 2: <br/>
<code>new Vector3f(1f,2f,1f)</code></td>
@ -270,7 +264,6 @@ On a CollisionShape, you can apply a few properties
</table></div>
<!-- EDIT8 TABLE [11290-11827] -->
<p>
The mesh-accurate shapes can use a CollisionShapeFactory as constructor (code samples see below).
</p>
@ -286,7 +279,7 @@ The mesh-accurate shapes can use a CollisionShapeFactory as constructor (code sa
</div>
<!-- EDIT5 SECTION "Create a CollisionShape" [7743-12497] -->
<h3><a>CollisionShape Code Samples</a></h3>
<h3>CollisionShape Code Samples</h3>
<div>
<ul>
<li><div> One way of using a constructor and a Geometry&#039;s mesh for static Spatials:<pre>MeshCollisionShape level_shape =
@ -317,54 +310,54 @@ The mesh-accurate shapes can use a CollisionShapeFactory as constructor (code sa
</div>
<!-- EDIT9 SECTION "CollisionShape Code Samples" [12498-13624] -->
<h2><a>Create PhysicsControl</a></h2>
<h2>Create PhysicsControl</h2>
<div>
<p>
BulletPhysics are available in jME3 through PhysicsControls classes from the com.jme3.bullet.control package. jME3&#039;s PhysicsControl classes directly extend BulletPhysics objects and are the recommended way to use physics in a jME3 application. PhysicsControls are flexible and can be added to any Spatial to make it act according to physical properties.
</p>
<div><table>
<thead>
<tr>
<th>Standard PhysicsControls</th><th> Usage</th><th> Examples </th>
</tr>
</thead>
<tr>
<td>RigidBodyControl</td><td>The most commonly used PhysicsControl. You can use it for dynamic objects (solid objects that freely affected by collisions, forces, or gravity), for static objects (solid but not affected by any forces), or kinematic objects (remote-controlled solid objects). </td><td>Impacting projectiles, moving obstacles like crates, rolling and bouncing balls, elevators, flying aircaft or space ships. <br/>
Solid immobile floors, walls, static obstacles.</td>
</tr>
<tr>
<td>GhostControl</td><td>Use for collision and intersection detection between physical objects. A GhostControl itself is <em>non-solid</em> and invisible. GhostControl moves with the Spatial it is attached to. Use GhostControls to <a href="/com/jme3/gde/docs/jme3/advanced/physics_listeners.html">implement custom game interactions</a> by adding it to a visible Geometry. </td><td>A monster&#039;s &quot;aggro radius&quot;, CharacterControl collisions, motion detectors, photo-electric alarm sensors, poisonous or radioactive perimeters, life-draining ghosts, etc. </td>
<td>GhostControl</td><td>Use for collision and intersection detection between physical objects. A GhostControl itself is <em>non-solid</em> and invisible. GhostControl moves with the Spatial it is attached to. Use GhostControls to <a href="/com/jme3/gde/docs/jme3/advanced/physics_listeners.html">implement custom game interactions</a> by adding it to a visible Geometry. </td><td>A monster&#039;s “aggro radius”, CharacterControl collisions, motion detectors, photo-electric alarm sensors, poisonous or radioactive perimeters, life-draining ghosts, etc. </td>
</tr>
</table></div>
<!-- EDIT11 TABLE [14016-14995] --><div><table>
<thead>
<tr>
<th>Special PhysicsControls</th><th> Usage</th><th> Examples </th>
</tr>
</thead>
<tr>
<td>VehicleControl <br/>
PhysicsVehicleWheel</td><td> Special Control used for <a href="/com/jme3/gde/docs/jme3/advanced/vehicles.html">&quot;terrestrial&quot; vehicles with suspension and wheels</a>. </td><td>Cars, tanks, hover crafts, ships, motorcycles???</td>
PhysicsVehicleWheel</td><td> Special Control used for <a href="/com/jme3/gde/docs/jme3/advanced/vehicles.html">&quot;terrestrial&quot; vehicles with suspension and wheels</a>. </td><td>Cars, tanks, hover crafts, ships, motorcycles</td>
</tr>
<tr>
<td>CharacterControl</td><td>Special Control used for <a href="/com/jme3/gde/docs/jme3/advanced/walking_character.html">Walking Character</a>s.</td><td>Upright walking persons, animals, robots??? </td>
<td>CharacterControl</td><td>Special Control used for <a href="/com/jme3/gde/docs/jme3/advanced/walking_character.html">Walking Character</a>s.</td><td>Upright walking persons, animals, robots </td>
</tr>
<tr>
<td>RagDollControl</td><td>Special Control used for <a href="/com/jme3/gde/docs/jme3/advanced/ragdoll.html">collapsing, flailing, or falling characters</a> </td><td>Falling persons, animals, robots, &quot;Rag dolls&quot;</td>
<td>RagDollControl</td><td>Special Control used for <a href="/com/jme3/gde/docs/jme3/advanced/ragdoll.html">collapsing, flailing, or falling characters</a> </td><td>Falling persons, animals, robots, “Rag dolls”</td>
</tr>
</table></div>
<!-- EDIT12 TABLE [14997-15509] -->
<p>
Click the links for details on the special PhysicsControls. This article is about RigidBodyControl.
</p>
</div>
<!-- EDIT10 SECTION "Create PhysicsControl" [13625-15611] -->
<h3><a>Physics Control Code Samples</a></h3>
<h3>Physics Control Code Samples</h3>
<div>
<p>
The most commonly used physics control is RigidBodyControl. The RigidBodyControl constructor takes up to two parameters: a collision shape and a mass (a float in kilograms). The mass parameter also determines whether the object is dynamic (movable) or static (fixed). For a static object such as a floor or wall, specify zero mass.
</p>
<pre>RigidBodyControl myThing_phys =
@ -380,14 +373,12 @@ The most commonly used physics control is RigidBodyControl. The RigidBodyContro
<p>
The following creates a box Geometry with the correct default BoxCollisionShape:
</p>
<pre>Box b = new Box&#40;1,1,1&#41;;
<pre>Box&#40;1,1,1&#41;;
Geometry box_geo = new Geometry&#40;&quot;Box&quot;, b&#41;;
box_geo.addControl&#40;new RigidBodyControl&#40; 1.0f &#41;&#41;; // explicit non-zero mass, implicit BoxCollisionShape</pre>
<p>
The following creates a MeshCollisionShape for a whole loaded (static) scene:
</p>
<pre>...
gameLevel.addControl&#40;new RigidBodyControl&#40;0.0f&#41;&#41;; // explicit zero mass, implicit MeshCollisionShape</pre>
@ -395,16 +386,14 @@ gameLevel.addControl&#40;new RigidBodyControl&#40;0.0f&#41;&#41;; // explicit ze
<p>
<p><div>Spheres and Boxes automatically fall back on the correct default CollisionShape if you do not specify a CollisionShape in the RigidBodyControl constructor. Complex static objects can fall back on MeshCollisionShapes, unless it is a Node, in which case it will become a CompoundCollisionShape containing a MeshCollisionShape
</div></p>
</p>
</div>
<!-- EDIT13 SECTION "Physics Control Code Samples" [15612-17129] -->
<h2><a>Add PhysicsControl to Spatial</a></h2>
<h2>Add PhysicsControl to Spatial</h2>
<div>
<p>
For each physical Spatial in the scene:
</p>
<ol>
@ -417,13 +406,11 @@ For each physical Spatial in the scene:
</div>
<!-- EDIT14 SECTION "Add PhysicsControl to Spatial" [17130-17377] -->
<h2><a>Add PhysicsControl to PhysicsSpace</a></h2>
<h2>Add PhysicsControl to PhysicsSpace</h2>
<div>
<p>
The PhysicsSpace is an object in BulletAppState that is like a rootNode for Physics Controls.
</p>
<ul>
<li><div> Just like you add the Geometry to the rootNode, you add its PhysicsControl to the PhysicsSpace. <pre>bulletAppState.getPhysicsSpace&#40;&#41;.add&#40;myThing_phys&#41;;
@ -437,14 +424,13 @@ myThing_geo.removeFromParent&#40;&#41;;</pre>
</ul>
<p>
<p><div>You can either add the <em>PhysicsControl</em> to the PhysicsSpace, or add the PhysicsControl to the Geometry and then add the <em>Geometry</em> to the PhysicsSpace. jME3 understands both and the outcome is the same.
</div></p>
</p>
</div>
<!-- EDIT15 SECTION "Add PhysicsControl to PhysicsSpace" [17378-18193] -->
<h2><a>Changing the Scale of a PhysicsControl</a></h2>
<h2>Changing the Scale of a PhysicsControl</h2>
<div>
<p>
@ -478,28 +464,27 @@ bulletAppState.getPhysicsSpace&#40;&#41;.add&#40;geom&#41;;</pre>
With the corresponding output below:
<object classid="java:org.netbeans.modules.javahelp.BrowserDisplayer"><param name="content" value="http://i.imgur.com/fAXlF.png"><param name="text" value="<html><u>External Link</u></html>"><param name="textColor" value="blue"></object>
<object classid="java:org.netbeans.modules.javahelp.BrowserDisplayer"><param name="content" value="http://i.imgur.com/Josua.png"><param name="text" value="<html><u>External Link</u></html>"><param name="textColor" value="blue"></object>
</p>
</div>
<!-- EDIT16 SECTION "Changing the Scale of a PhysicsControl" [18194-19944] -->
<h3><a>PhysicsSpace Code Samples</a></h3>
<h3>PhysicsSpace Code Samples</h3>
<div>
<p>
The PhysicsSpace also manages global physics settings. Typically, you can leave the defaults, and you don&#039;t need to change the following settings, but it&#039;s good to know what they are for:
</p>
<div><table>
<thead>
<tr>
<th>bulletAppState.getPhysicsSpace() Method</th><th>Usage</th>
</tr>
</thead>
<tr>
<td>setGravity(new Vector3f(0, -9.81f, 0));</td><td>Specifies the global gravity.</td>
</tr>
<tr>
<td>setAccuracy(1f/60f);</td><td>Specifies physics accuracy. The higher the accuracy, the slower the game. Increase value if objects are passing through one another, or bounce oddly.</td>
<td>setAccuracy(1f/60f);</td><td>Specifies physics accuracy. The higher the accuracy, the slower the game. Decrease value if objects are passing through one another, or bounce oddly. (e.g. Change value from 1f/60f to something like 1f/80f.) </td>
</tr>
<tr>
<td>setMaxSubSteps(4);</td><td>Compensates low FPS: Specifies the maximum amount of extra steps that will be used to step the physics when the game fps is below the physics fps. This maintains determinism in physics in slow (low-fps) games. For example a maximum number of 2 can compensate for framerates as low as 30 fps (physics has a default accuracy of 60 fps). Note that setting this value too high can make the physics drive down its own fps in case its overloaded.</td>
@ -512,25 +497,25 @@ setWorldMin(new Vector3f(-10000f, -10000f, -10000f));</td><td>Specifies the size
<td>setCcdMotionThreshold()</td><td>The amount of motion in 1 physics tick to trigger the continuous motion detection in moving objects that push one another. Rarely used, but necessary if your moving objects get stuck or roll through one another.</td>
</tr>
</table></div>
<!-- EDIT18 TABLE [20171-21378] -->
<!-- EDIT18 TABLE [20171-21437] -->
</div>
<!-- EDIT17 SECTION "PhysicsSpace Code Samples" [19945-21379] -->
<h2><a>Specify Physical Properties</a></h2>
<!-- EDIT17 SECTION "PhysicsSpace Code Samples" [19945-21438] -->
<h2>Specify Physical Properties</h2>
<div>
<p>
After you have registered, attached, and added everything, you can adjust physical properties or apply forces.
</p>
<p>
On a RigidBodyControl, you can set the following physical properties.
</p>
<div><table>
<thead>
<tr>
<th> RigidBodyControl Method </th><th> Property </th><th> Examples </th>
</tr>
</thead>
<tr>
<td> setGravity(new Vector3f(0f,-9.81f,0f)) </td><td> You can change the gravity of individual physics objects after they were added to the PhysicsSpace. Gravity is a vector pointing from this Spatial towards the source of gravity. The longer the vector, the stronger is gravity. <br/>
If gravity is the same absolute direction for all objects (e.g. on a planet surface), set this vector globally on the PhysicsSpace object and not individually. <br/>
@ -554,16 +539,16 @@ This setting has an impact on performance, so use it sparingly. </td><td> Brick:
Rubber ball: 1.0f </td>
</tr>
</table></div>
<!-- EDIT20 TABLE [21604-23114] -->
<!-- EDIT20 TABLE [21663-23173] -->
<p>
On a RigidBodyControl, you can apply the following physical forces:
</p>
<div><table>
<thead>
<tr>
<th> RigidBodyControl Method </th><th> Motion </th>
</tr>
</thead>
<tr>
<td> setPhysicsLocation()</td><td>Positions the objects. Do not use setLocalTranslation() for physical objects. Important: Make certain not to make CollisionShapes overlap when positioning them. </td>
</tr>
@ -575,15 +560,14 @@ On a RigidBodyControl, you can apply the following physical forces:
(See detailed explanation below.) </td>
</tr>
</table></div>
<!-- EDIT21 TABLE [23185-23795] -->
<!-- EDIT21 TABLE [23244-23854] -->
</div>
<!-- EDIT19 SECTION "Specify Physical Properties" [21380-23795] -->
<h3><a>Kinematic vs Dynamic vs Static</a></h3>
<!-- EDIT19 SECTION "Specify Physical Properties" [21439-23854] -->
<h3>Kinematic vs Dynamic vs Static</h3>
<div>
<p>
All physical objects???
All physical objects…
</p>
<ul>
<li><div> must not overlap. </div>
@ -594,11 +578,13 @@ All physical objects???
</li>
</ul>
<div><table>
<thead>
<tr>
<td> Property </td><th> Static </th><th> Kinematic </th><th> Dynamic </th>
</tr>
</thead>
<tr>
<th> Examples</th><td>Immobile obstacles: Floors, walls, buildings, ???</td><td>Remote-controlled solid objects: Airships, meteorites, elevators, doors; networked or remote-controlled NPCs; invisible &quot;airhooks&quot; for hinges and joints.</td><td>Interactive objects: Rolling balls, movable crates, falling pillars, zero-g space ship???</td>
<th> Examples</th><td>Immobile obstacles: Floors, walls, buildings, </td><td>Remote-controlled solid objects: Airships, meteorites, elevators, doors; networked or remote-controlled NPCs; invisible “airhooks” for hinges and joints.</td><td>Interactive objects: Rolling balls, movable crates, falling pillars, zero-g space ship</td>
</tr>
<tr>
<th> Does it have a mass?</th><td>no, 0.0f</td><td>yes<sup><a href="#fn__1">1)</a></sup>, &gt;0.0f </td><td>yes, &gt;0.0f</td>
@ -627,42 +613,41 @@ setKinematic(true);</td><td>setMass(1f); <br/>
setKinematic(false);</td>
</tr>
</table></div>
<!-- EDIT23 TABLE [24032-25091] -->
<!-- EDIT23 TABLE [24091-25150] -->
</div>
<h4><a>When Do I Use Kinematic Objects?</a></h4>
<h4>When Do I Use Kinematic Objects?</h4>
<div>
<ul>
<li><div> Kinematics are solid and characters can &quot;stand&quot; on them.</div>
<li><div> Kinematics are solid and characters can “stand” on them.</div>
</li>
<li><div> When they collide, Kinematics push dynamic objects, but a dynamic object never pushes a Kinematic. </div>
</li>
<li><div> You can hang kinematics up &quot;in mid-air&quot; and attach other PhysicsControls to them using <a href="/com/jme3/gde/docs/jme3/advanced/hinges_and_joints.html">hinges and joints</a>. Picture them as &quot;air hooks&quot; for flying aircraft carriers, floating islands in the clouds, suspension bridges, swings, chains??? </div>
<li><div> You can hang kinematics up “in mid-air” and attach other PhysicsControls to them using <a href="/com/jme3/gde/docs/jme3/advanced/hinges_and_joints.html">hinges and joints</a>. Picture them as “air hooks” for flying aircraft carriers, floating islands in the clouds, suspension bridges, swings, chains… </div>
</li>
<li><div> You can use Kinematics to create mobile remote-controlled physical objects, such as moving elevator platforms, flying blimps/airships. You have full control how Kinematics move, they never &quot;fall&quot; or &quot;topple over&quot;.</div>
<li><div> You can use Kinematics to create mobile remote-controlled physical objects, such as moving elevator platforms, flying blimps/airships. You have full control how Kinematics move, they never “fall” or “topple over”.</div>
</li>
</ul>
<p>
<p><div>The position of a kinematic RigidBodyControl is updated automatically depending on its spatial&#039;s translation. You move Spatials with a kinematic RigidBodyControl programmatically, that means you write translation and rotation code in the update loop. You describe the motion of kinematic objects either by using methods such as <code>setLocalTranslation()</code> or <code>move()</code>, or by using a <a href="/com/jme3/gde/docs/jme3/advanced/motionpath.html">MotionPath</a>.
</div></p>
</p>
</div>
<!-- EDIT22 SECTION "Kinematic vs Dynamic vs Static" [23796-26197] -->
<h2><a>Forces: Moving Dynamic Objects</a></h2>
<!-- EDIT22 SECTION "Kinematic vs Dynamic vs Static" [23855-26256] -->
<h2>Forces: Moving Dynamic Objects</h2>
<div>
<p>
Use the following methods to move dynamic physical objects.
</p>
<div><table>
<thead>
<tr>
<th> PhysicsControl Method </th><th> Motion </th>
</tr>
</thead>
<tr>
<td> setLinearVelocity(new Vector3f(0f,0f,1f)) </td><td> Set the linear speed of this object. </td>
</tr>
@ -670,39 +655,39 @@ Use the following methods to move dynamic physical objects.
<td> setAngularVelocity(new Vector3f(0f,0f,1f)) </td><td> Set the rotational speed of the object; the x, y and z component are the speed of rotation around that axis. </td>
</tr>
<tr>
<td> applyCentralForce(???) </td><td> Move (push) the object once with a certain moment, expressed as a Vector3f. </td>
<td> applyCentralForce() </td><td> Move (push) the object once with a certain moment, expressed as a Vector3f. </td>
</tr>
<tr>
<td> applyForce(???) </td><td> Move (push) the object once with a certain moment, expressed as a Vector3f. Optionally, you can specify where on the object the pushing force hits. </td>
<td> applyForce() </td><td> Move (push) the object once with a certain moment, expressed as a Vector3f. Optionally, you can specify where on the object the pushing force hits. </td>
</tr>
<tr>
<td> applyTorque(???) </td><td> Rotate (twist) the object once around its axes, expressed as a Vector3f. </td>
<td> applyTorque() </td><td> Rotate (twist) the object once around its axes, expressed as a Vector3f. </td>
</tr>
<tr>
<td> applyImpulse(???) </td><td> An idealised change of momentum. This is the kind of push that you would use on a pool billiard ball. </td>
<td> applyImpulse() </td><td> An idealised change of momentum. This is the kind of push that you would use on a pool billiard ball. </td>
</tr>
<tr>
<td> applyTorqueImpulse(???) </td><td> An idealised change of momentum. This is the kind of push that you would use on a pool billiard ball. </td>
<td> applyTorqueImpulse() </td><td> An idealised change of momentum. This is the kind of push that you would use on a pool billiard ball. </td>
</tr>
<tr>
<td> clearForces()</td><td>Cancels out all forces (force, torque) etc and stops the motion.</td>
</tr>
</table></div>
<!-- EDIT25 TABLE [26303-27292] -->
<!-- EDIT25 TABLE [26362-27351] -->
<p>
<p><div>It is technically possible to position PhysicsControls using setLocalTranslation(), e.g. to place them in their start position in the scene. However you must be very careful not to cause an &quot;impossible state&quot; where one physical object overlaps with another! Within the game, you typically use the setters shown here exclusively.
<p><div>It is technically possible to position PhysicsControls using setLocalTranslation(), e.g. to place them in their start position in the scene. However you must be very careful not to cause an “impossible state” where one physical object overlaps with another! Within the game, you typically use the setters shown here exclusively.
</div></p>
</p>
<p>
PhysicsControls also support the following advanced features:
</p>
<div><table>
<thead>
<tr>
<th> PhysicsControl Method </th><th> Property </th>
</tr>
</thead>
<tr>
<td> setCollisionShape(collisionShape)</td><td>Changes the collision shape after creation.</td>
</tr>
@ -710,7 +695,7 @@ PhysicsControls also support the following advanced features:
<td> setCollideWithGroups() <br/>
setCollisionGroup() <br/>
addCollideWithGroup(COLLISION_GROUP_01) <br/>
removeCollideWithGroup(COLLISION_GROUP_01)</td><td>Collision Groups are integer bit masks ??? enums are available in the CollisionObject. All physics objects are by default in COLLISION_GROUP_01. Two objects collide when the collideWithGroups set of one contains the Collision Group of the other. Use this to improve performance by grouping objects that will never collide in different groups (the the engine saves times because it does not need to check on them).</td>
removeCollideWithGroup(COLLISION_GROUP_01)</td><td>Collision Groups are integer bit masks enums are available in the CollisionObject. All physics objects are by default in COLLISION_GROUP_01. Two objects collide when the collideWithGroups set of one contains the Collision Group of the other. Use this to improve performance by grouping objects that will never collide in different groups (the the engine saves times because it does not need to check on them).</td>
</tr>
<tr>
<td> setDamping(float, float)</td><td>The first value is the linear threshold and the second the angular. This simulates dampening of forces, for example for underwater scenes.</td>
@ -725,23 +710,22 @@ removeCollideWithGroup(COLLISION_GROUP_01)</td><td>Collision Groups are integer
<td> setCcdMotionThreshold(0f) </td><td>Sets the amount of motion that has to happen in one physics tick to trigger the continuous motion detection in moving objects that push one another. This avoids the problem of fast objects moving through other objects. Set to zero to disable (default).</td>
</tr>
<tr>
<td> setCcdSweptSphereRadius(.5f)</td><td>Bullet does not use the full collision shape for continuous collision detection, instead it uses a &quot;swept sphere&quot; shape to approximate a motion, which can be imprecise and cause strange behaviors such as objects passing through one another or getting stuck. Only relevant for fast moving dynamic bodies. </td>
<td> setCcdSweptSphereRadius(.5f)</td><td>Bullet does not use the full collision shape for continuous collision detection, instead it uses a “swept sphere” shape to approximate a motion, which can be imprecise and cause strange behaviors such as objects passing through one another or getting stuck. Only relevant for fast moving dynamic bodies. </td>
</tr>
</table></div>
<!-- EDIT26 TABLE [27710-29665] -->
<!-- EDIT26 TABLE [27769-29724] -->
<p>
<p><div> You can <code>setApplyPhysicsLocal(true)</code> for an object to make it move relatively to its local physics space. You would do that if you need a physics space that moves with a node (e.g. a spaceship with artificial gravity surrounded by zero-g space). By default, it&#039;s set to false, and all movement is relative to the world.
</div></p>
</p>
</div>
<!-- EDIT24 SECTION "Forces: Moving Dynamic Objects" [26198-30007] -->
<h2><a>Best Practices</a></h2>
<!-- EDIT24 SECTION "Forces: Moving Dynamic Objects" [26257-30066] -->
<h2>Best Practices</h2>
<div>
<ul>
<li><div> <strong>Multiple Objects Too Slow?</strong> Do not overuse PhysicsControls. Although PhysicsControls are put to ???sleep??? when they are not moving, creating a world solely out of dynamic physics objects will quickly bring you to the limits of your computer&#039;s capabilities. <br/>
<strong>Solution:</strong> Improve performance by replacing some physical Spatials with non-physical Spatials. Use the non-physical ones for non-solid things for which you do not need to detect collisions ??? foliage, plants, effects, ghosts, all remote or unreachable objects.</div>
<li><div> <strong>Multiple Objects Too Slow?</strong> Do not overuse PhysicsControls. Although PhysicsControls are put to “sleep” when they are not moving, creating a world solely out of dynamic physics objects will quickly bring you to the limits of your computer&#039;s capabilities. <br/>
<strong>Solution:</strong> Improve performance by replacing some physical Spatials with non-physical Spatials. Use the non-physical ones for non-solid things for which you do not need to detect collisions foliage, plants, effects, ghosts, all remote or unreachable objects.</div>
</li>
</ul>
<ul>
@ -750,7 +734,7 @@ removeCollideWithGroup(COLLISION_GROUP_01)</td><td>Collision Groups are integer
</li>
</ul>
<ul>
<li><div> <strong>Eject?</strong> If you have physical nodes jittering wildy and being ejected &quot;for no apparent reason&quot;, it means you have created an impossible state ??? solid objects overlapping. This can happen when you position solid spatials too close to other solid spatials, e.g. when moving them with setLocalTranslation(). <br/>
<li><div> <strong>Eject?</strong> If you have physical nodes jittering wildy and being ejected “for no apparent reason”, it means you have created an impossible state – solid objects overlapping. This can happen when you position solid spatials too close to other solid spatials, e.g. when moving them with setLocalTranslation(). <br/>
<strong>Solution:</strong> Use the debug mode to make CollisionShapes visible and verify that CollisionShapes do not overlap. <pre>bulletAppState.getPhysicsSpace&#40;&#41;.enableDebug&#40;assetManager&#41;;</pre>
</div>
</li>
@ -765,15 +749,14 @@ removeCollideWithGroup(COLLISION_GROUP_01)</td><td>Collision Groups are integer
<strong>Solution:</strong> To specify how the game responds to collisions, you use <a href="/com/jme3/gde/docs/jme3/advanced/physics_listeners.html">Physics Listeners</a>.</div>
</li>
</ul>
<div><span>
<a href="/wiki/doku.php/tag:physics?do=showtag&amp;tag=tag%3Aphysics">physics</a>,
<a href="/wiki/doku.php/tag:documentation?do=showtag&amp;tag=tag%3Adocumentation">documentation</a>,
<a href="/wiki/doku.php/tag:control?do=showtag&amp;tag=tag%3Acontrol">control</a>
</span></div>
<p>
<a href="nbdocs:/com/jme3/gde/docs/jme3:advanced/tag_physics_documentation_control">tag_physics_documentation_control</a>
</p>
</div>
<!-- EDIT27 SECTION "Best Practices" [30008-] --><div>
<!-- EDIT27 SECTION "Best Practices" [30067-] --><div>
<div><sup><a href="#fnt__1">1)</a></sup>
Inertia is calculated for kinematic objects, and you need mass to do that.</div>
</div>
<p><em><a href="http://hub.jmonkeyengine.org/wiki/doku.php/jme3:advanced:physics?do=export_xhtmlbody">view online version</a></em></p>
<p><em><a href="http://wiki.jmonkeyengine.org/doku.php/jme3:advanced:physics?do=export_xhtmlbody">view online version</a></em></p>

@ -1,5 +1,5 @@
<h1><a>Physics Listeners</a></h1>
<h1>Physics Listeners</h1>
<div>
<p>
@ -8,7 +8,7 @@ You can control physical objects (push them around) by applying physical forces
</div>
<!-- EDIT1 SECTION "Physics Listeners" [1-329] -->
<h2><a>Sample Code</a></h2>
<h2>Sample Code</h2>
<div>
<ul>
<li><div> <object classid="java:org.netbeans.modules.javahelp.BrowserDisplayer"><param name="content" value="http://code.google.com/p/jmonkeyengine/source/browse/trunk/engine/src/test/jme3test/bullet/TestCollisionListener.java"><param name="text" value="<html><u>TestCollisionListener.java</u></html>"><param name="textColor" value="blue"></object></div>
@ -21,11 +21,10 @@ You can control physical objects (push them around) by applying physical forces
</div>
<!-- EDIT2 SECTION "Sample Code" [330-809] -->
<h2><a>PhysicsGhostObjects</a></h2>
<h2>PhysicsGhostObjects</h2>
<div>
<p>
Attach a com.jme3.bullet.control.GhostControl to any Spatial to turn it into a PhysicsGhostObject. Ghost objects automatically follow their spatial and detect collisions. The attached ghost itself is invisible and non-solid (!) and doesn&#039;t interfere with your game otherwise, it only passively reports collisions.
</p>
@ -34,7 +33,7 @@ You can leave the GhostControl non-solid and invisible and attach it to an (invi
</p>
<p>
The shape of the ghost depends on the CollisionShape that you gave the GhostControl. This means that the GhostControl&#039;s shape can be different from the RigidBodyControl&#039;s shape. For example, the non-solid ghost shape can be bigger than the solid shape of the Spatial (so you can &quot;feel&quot; ahead).
The shape of the ghost depends on the CollisionShape that you gave the GhostControl. This means that the GhostControl&#039;s shape can be different from the RigidBodyControl&#039;s shape. For example, the non-solid ghost shape can be bigger than the solid shape of the Spatial (so you can “feel” ahead).
</p>
<pre>GhostControl ghost = new GhostControl&#40;
new BoxCollisionShape&#40;new Vector3f&#40;1,1,1&#41;&#41;&#41;; // a box-shaped ghost
@ -46,9 +45,11 @@ node.addControl&#40;ghost&#41;; // the ghost follows thi
rootNode.attachChild&#40;node&#41;;
getPhysicsSpace&#40;&#41;.add&#40;ghost&#41;;</pre>
<div><table>
<thead>
<tr>
<th>Ghost methods</th><th>Usage</th>
</tr>
</thead>
<tr>
<td>getOverlappingObjects()</td><td>Returns the List of objects that are currently colliding (overlapping) with the ghost.</td>
</tr>
@ -62,22 +63,20 @@ getPhysicsSpace&#40;&#41;.add&#40;ghost&#41;;</pre>
<!-- EDIT4 TABLE [2299-2565] -->
</div>
<!-- EDIT3 SECTION "PhysicsGhostObjects" [810-2566] -->
<h2><a>Physics Tick Listener</a></h2>
<h2>Physics Tick Listener</h2>
<div>
<p>
The jBullet Physics implementation is stepped at a constant 60 physics ticks per second frame rate.
Applying forces or checking for overlaps only has an effect right at a physics update cycle, which is not every frame. If you do physics interactions at arbitrary spots in the simpleUpdate() loop, calls will be dropped at irregular intervals, because they happen out of cycle.
</p>
</div>
<!-- EDIT5 SECTION "Physics Tick Listener" [2567-2979] -->
<h3><a>When (Not) to Use Tick Listener?</a></h3>
<h3>When (Not) to Use Tick Listener?</h3>
<div>
<p>
When you write game mechanics that apply forces, you must implement a tick listener (com.jme3.bullet.PhysicsTickListener) for it. The tick listener makes certain the forces are not dropped, but applied in time for the next physics tick.
</p>
@ -91,11 +90,10 @@ When your game mechanics however just poll the current state (e.g. getPhysicsLoc
</div>
<!-- EDIT6 SECTION "When (Not) to Use Tick Listener?" [2980-3836] -->
<h3><a>How to Listen to Physics Ticks</a></h3>
<h3>How to Listen to Physics Ticks</h3>
<div>
<p>
Here&#039;s is the declaration of an examplary Physics Control that listens to ticks. (The example shows a RigidBodyControl, but it can also be GhostControl.)
</p>
<pre>public class MyCustomControl
@ -125,17 +123,16 @@ public void physicsTick&#40;PhysicsSpace space, float tpf&#41;&#123;
</div>
<!-- EDIT7 SECTION "How to Listen to Physics Ticks" [3837-4856] -->
<h2><a>Physics Collision Listener</a></h2>
<h2>Physics Collision Listener</h2>
<div>
</div>
<!-- EDIT8 SECTION "Physics Collision Listener" [4857-4896] -->
<h3><a>When (Not) to Use Collision Listener</a></h3>
<h3>When (Not) to Use Collision Listener</h3>
<div>
<p>
If you do not implement the Collision Listener interface (com.jme3.bullet.collision.PhysicsCollisionListener), a collisions will just mean that physical forces between solid objects are applied automatically. If you just want &quot;Balls rolling, bricks falling&quot; you do not need a listener.
If you do not implement the Collision Listener interface (com.jme3.bullet.collision.PhysicsCollisionListener), a collisions will just mean that physical forces between solid objects are applied automatically. If you just want “Balls rolling, bricks falling” you do not need a listener.
</p>
<p>
@ -150,17 +147,16 @@ If however you want to respond to a collision event (com.jme3.bullet.collision.P
</li>
<li><div> Playing a sound (e.g. explosion, ouch)</div>
</li>
<li><div> ??? and countless more, depending on your game</div>
<li><div> and countless more, depending on your game</div>
</li>
</ul>
</div>
<!-- EDIT9 SECTION "When (Not) to Use Collision Listener" [4897-5699] -->
<h3><a>How to Listen to Collisions</a></h3>
<h3>How to Listen to Collisions</h3>
<div>
<p>
You need to add the PhysicsCollisionListener to the physics space before collisions will be listened for. Here&#039;s an example of a Physics Control that uses a collision listener. (The example shows a RigidBodyControl, but it can also be GhostControl.)
</p>
<pre>public class MyCustomControl extends RigidBodyControl
@ -188,24 +184,24 @@ After you identify the colliding nodes, specify the action to trigger when this
&#125;</pre>
<p>
<p><div>Note that after the collision() method ends, the PhysicsCollisionEvent is cleared. You must get all objects and values you need within the collision() method.
</div></p>
</p>
</div>
<!-- EDIT10 SECTION "How to Listen to Collisions" [5700-7311] -->
<h3><a>Reading Details From a PhysicsCollisionEvent</a></h3>
<h3>Reading Details From a PhysicsCollisionEvent</h3>
<div>
<p>
The PhysicsCollisionEvent <code>event</code> gives you access to detailed information about the collision. You already know the event objects can identify which nodes collided, but it even knows how hard they collided:
</p>
<div><table>
<thead>
<tr>
<th>Method </th><th>Purpose</th>
</tr>
</thead>
<tr>
<td> getObjectA() <br/>
getObjectB() </td><td> The two participants in the collision. You cannot know in advance whether some node will be recorded as A or B, you always have to consider both cases. </td>
@ -233,11 +229,10 @@ Note that after the collision method has been called the object is not valid any
</div>
<!-- EDIT11 SECTION "Reading Details From a PhysicsCollisionEvent" [7312-8416] -->
<h3><a>Collision Groups</a></h3>
<h3>Collision Groups</h3>
<div>
<p>
You can improve performance by resricting the number of tests that collision detection has to perform. If you have a case where you are only interested in collisions between certain objects but not others, you can assign sets of physical obejcts to different collision groups.
</p>
@ -246,14 +241,11 @@ For example, for a click-to-select, you only care if the selection ray collides
</p>
<pre>myNode.getControl&#40;RigidBodyControl.class&#41;.setCollisionGroup&#40;PhysicsCollisionObject.COLLISION_GROUP_02&#41;;
myNode.getControl&#40;RigidBodyControl.class&#41;.setCollideWithGroups&#40;PhysicsCollisionObject.COLLISION_GROUP_02&#41;;</pre>
<div><span>
<a href="/wiki/doku.php/tag:documentation?do=showtag&amp;tag=tag%3Adocumentation">documentation</a>,
<a href="/wiki/doku.php/tag:physics?do=showtag&amp;tag=tag%3Aphysics">physics</a>,
<a href="/wiki/doku.php/tag:collision?do=showtag&amp;tag=tag%3Acollision">collision</a>,
<a href="/wiki/doku.php/tag:forces?do=showtag&amp;tag=tag%3Aforces">forces</a>,
<a href="/wiki/doku.php/tag:interaction?do=showtag&amp;tag=tag%3Ainteraction">interaction</a>
</span></div>
<p>
<a href="nbdocs:/com/jme3/gde/docs/jme3:advanced/tag_documentation_physics_collision_forces_interaction">tag_documentation_physics_collision_forces_interaction</a>
</p>
</div>
<!-- EDIT13 SECTION "Collision Groups" [8417-] -->
<p><em><a href="http://hub.jmonkeyengine.org/wiki/doku.php/jme3:advanced:physics_listeners?do=export_xhtmlbody">view online version</a></em></p>
<p><em><a href="http://wiki.jmonkeyengine.org/doku.php/jme3:advanced:physics_listeners?do=export_xhtmlbody">view online version</a></em></p>

@ -1,10 +1,9 @@
<h1><a>Rendering Water as Post-Process Effect</a></h1>
<h1>Rendering Water as Post-Process Effect</h1>
<div>
<p>
The awesome SeaMonkey WaterFilter is highly configurable. It can render any type of water and also simulates the underwater part of the effect, including light effects called caustics. The effect is based on <object classid="java:org.netbeans.modules.javahelp.BrowserDisplayer"><param name="content" value="http://www.gamedev.net/page/reference/index.html/_//feature/fprogramming/rendering-water-as-a-post-process-effect-r2642"><param name="text" value="<html><u>Wojciech Toman???s Rendering Water as a Post-process Effect</u></html>"><param name="textColor" value="blue"></object> published on gamedev.net. Here&#039;s a video:
The awesome SeaMonkey WaterFilter is highly configurable. It can render any type of water and also simulates the underwater part of the effect, including light effects called caustics. The effect is based on <object classid="java:org.netbeans.modules.javahelp.BrowserDisplayer"><param name="content" value="http://www.gamedev.net/page/reference/index.html/_//feature/fprogramming/rendering-water-as-a-post-process-effect-r2642"><param name="text" value="<html><u>Wojciech Toman’s Rendering Water as a Post-process Effect</u></html>"><param name="textColor" value="blue"></object> published on gamedev.net. Here&#039;s a video:
</p>
<p>
@ -18,16 +17,15 @@ The awesome SeaMonkey WaterFilter is highly configurable. It can render any type
</div>
<!-- EDIT1 SECTION "Rendering Water as Post-Process Effect" [1-855] -->
<h2><a>The Theory</a></h2>
<h2>The Theory</h2>
<div>
<p>
The effect is part of a deferred rendering process, taking advantage of the pre-computed position buffer and back buffer (a texture representing the screen???s pixels position in view space, and a texture of the rendered scene).
The effect is part of a deferred rendering process, taking advantage of the pre-computed position buffer and back buffer (a texture representing the screen’s pixels position in view space, and a texture of the rendered scene).
</p>
<p>
After some calculation, this allows to reconstruct the position in world space for each pixel on the screen. &quot;If a pixel is under a given water height, let???s render it as a blue pixel!&quot; Blue pixel? Not exactly, we want waves, we want ripples, we want foam, we want reflection and refraction.
After some calculation, this allows to reconstruct the position in world space for each pixel on the screen. “If a pixel is under a given water height, let’s render it as a blue pixel!” Blue pixel? Not exactly, we want waves, we want ripples, we want foam, we want reflection and refraction.
</p>
<p>
@ -36,11 +34,10 @@ The GameDev.net article describes how those effects are achieved, but the main i
</div>
<!-- EDIT2 SECTION "The Theory" [856-1971] -->
<h2><a>How Did We Implement it in jME3?</a></h2>
<h2>How Did We Implement it in jME3?</h2>
<div>
<p>
jME3 default behavior is to use a forward rendering process, so there is no position buffer rendered that we can take advantage of. But while rendering the main scene to a frame buffer in the FilterPostPorcessor, we can write the hardware depth buffer to a texture, with nearly no additional cost.
</p>
@ -49,22 +46,20 @@ There are several ways of reconstructing the world space position of a pixel fro
</p>
<p>
Now we have the rendered scene in a texture, and we can reconstruct the position in world space of each pixel. We???re good to go!
Now we have the rendered scene in a texture, and we can reconstruct the position in world space of each pixel. Were good to go!
</p>
<p>
??? Nehon
Nehon
</p>
</div>
<!-- EDIT3 SECTION "How Did We Implement it in jME3?" [1972-2707] -->
<h2><a>Sample Code</a></h2>
<h2>Sample Code</h2>
<div>
<p>
There are two test cases in the jME3 repository:
</p>
<ul>
<li><div> <object classid="java:org.netbeans.modules.javahelp.BrowserDisplayer"><param name="content" value="http://code.google.com/p/jmonkeyengine/source/browse/trunk/engine/src/test/jme3test/water/TestPostWater.java"><param name="text" value="<html><u>jme3/src/test/jme3test/water/TestPostWater.java</u></html>"><param name="textColor" value="blue"></object> (ocean island)</div>
@ -77,11 +72,10 @@ There are two test cases in the jME3 repository:
</div>
<!-- EDIT4 SECTION "Sample Code" [2708-3399] -->
<h3><a>Using the Water Filter</a></h3>
<h3>Using the Water Filter</h3>
<div>
<p>
In the <code>simpleInitApp()</code> method, you attach your scene to the rootNode, typically a terrain with a sky. Remember to add a directional light, since the water relies on the light direction vector. The WaterFilter constructor expects a node with the scene attached that should be reflected in the water, and vector information from the light source&#039;s direction.
</p>
@ -110,11 +104,10 @@ Usually you make the water reflect everything attached to the rootNode. But you
</div>
<!-- EDIT5 SECTION "Using the Water Filter" [3400-4704] -->
<h3><a>Optional: Waves</a></h3>
<h3>Optional: Waves</h3>
<div>
<p>
If you want waves, set the water height in the update loop. We reuse the initialWaterHeight variable, and repeatedly reset the waterHeight value according to time. This causes the waves.
</p>
<pre>private float time = 0.0f;
@ -130,22 +123,22 @@ public void simpleUpdate&#40;float tpf&#41; &#123;
</div>
<!-- EDIT6 SECTION "Optional: Waves" [4705-5229] -->
<h3><a>Optional: Water Wave and Color Effects</a></h3>
<h3>Optional: Water Wave and Color Effects</h3>
<div>
<p>
<img src="nbdocs:/com/jme3/gde/docs/jme3/advanced/water-post-muddy.png">
</p>
<p>
All these effects are optional. Every setter also has a getter.
</p>
<div><table>
<thead>
<tr>
<th> Water method example</th><th>Effects: Waves </th><th>Default</th>
</tr>
</thead>
<tr>
<td>water.setWaterHeight(-6);</td><td>Use this waterheight method for causing waves.</td><td>0.0f</td>
</tr>
@ -163,11 +156,11 @@ All these effects are optional. Every setter also has a getter.
</tr>
<tr>
<td>water.setHeightTexture( (Texture2D) <br/>
manager.loadTexture(&quot;Textures/waveheight.png&quot;) )</td><td>This height map describes the shape of the waves</td><td>&quot;Common/MatDefs/Water/Textures/heightmap.jpg&quot;</td>
manager.loadTexture(“Textures/waveheight.png”) )</td><td>This height map describes the shape of the waves</td><td>“Common/MatDefs/Water/Textures/heightmap.jpg”</td>
</tr>
<tr>
<td>water.setNormalTexture( (Texture2D) <br/>
manager.loadTexture(&quot;Textures/wavenormals.png&quot;) )</td><td>This normal map describes the shape of the waves</td><td>&quot;Common/MatDefs/Water/Textures/gradient_map.jpg&quot;</td>
manager.loadTexture(“Textures/wavenormals.png”) )</td><td>This normal map describes the shape of the waves</td><td>“Common/MatDefs/Water/Textures/gradient_map.jpg”</td>
</tr>
<tr>
<td>water.setUseRipples(false);</td><td>Switches the ripples effect on or off.</td><td>true</td>
@ -177,9 +170,11 @@ manager.loadTexture(&quot;Textures/wavenormals.png&quot;) )</td><td>This normal
</tr>
</table></div>
<!-- EDIT8 TABLE [5396-6560] --><div><table>
<thead>
<tr>
<th> Water method example</th><th> Effects: Color</th><th>Default</th>
</tr>
</thead>
<tr>
<td>water.setLightDirection(new Vector3f(-0.37f,-0.50f,-0.78f))</td><td>Usually you set this to the same as the light source&#039;s direction. Use this to set the light direction if the sun is moving.</td><td>Value given to WaterFilter() constructor.</td>
</tr>
@ -198,13 +193,15 @@ ColorRGBA(0.0f, 0.0f,0.2f,1.0f)</td>
<td>water.setWaterTransparency(0.2f);</td><td>Sets how fast colors fade out. use this to control how clear (e.g. 0.05f) or muddy (0.2f) water is.</td><td> 0.1f </td>
</tr>
<tr>
<td>water.setColorExtinction(new Vector3f(10f,20f,30f));</td><td>Sets At what depth the refraction color extincts. The three values are RGB (red, green, blue) in this order. Play with these parameters to &quot;muddy&quot; the water.</td><td>Vector3f(5f,20f,30f)</td>
<td>water.setColorExtinction(new Vector3f(10f,20f,30f));</td><td>Sets At what depth the refraction color extincts. The three values are RGB (red, green, blue) in this order. Play with these parameters to “muddy” the water.</td><td>Vector3f(5f,20f,30f)</td>
</tr>
</table></div>
<!-- EDIT9 TABLE [6562-7568] --><div><table>
<thead>
<tr>
<th> Water method example</th><th> Effects: Shore</th><th>Default</th>
</tr>
</thead>
<tr>
<td>water.setCenter(Vector3f.ZERO); <br/>
water.setRadius(260);</td><td>Limit the water filter to a semisphere with the given center and radius. Use this for lakes and smaller bodies of water. Skip this for oceans.</td><td>unused</td>
@ -217,9 +214,11 @@ water.setRadius(260);</td><td>Limit the water filter to a semisphere with the gi
</tr>
</table></div>
<!-- EDIT10 TABLE [7570-8068] --><div><table>
<thead>
<tr>
<th> Water method example</th><th> Effects: Foam</th><th>Default</th>
</tr>
</thead>
<tr>
<td>water.setUseFoam(false);</td><td>Switches the white foam on or off</td><td>true</td>
</tr>
@ -231,13 +230,15 @@ water.setRadius(260);</td><td>Limit the water filter to a semisphere with the gi
</tr>
<tr>
<td>water.setFoamTexture( (Texture2D) <br/>
manager.loadTexture(&quot;Textures/foam.png&quot;) )</td><td>This foam texture will be used with WrapMode.Repeat</td><td>&quot;Common/MatDefs/Water/Textures/foam.jpg&quot;</td>
manager.loadTexture(“Textures/foam.png”) )</td><td>This foam texture will be used with WrapMode.Repeat</td><td>“Common/MatDefs/Water/Textures/foam.jpg”</td>
</tr>
</table></div>
<!-- EDIT11 TABLE [8070-8715] --><div><table>
<thead>
<tr>
<th> Water method example</th><th> Effects: Light</th><th>Default</th>
</tr>
</thead>
<tr>
<td>water.setSunScale(1f);</td><td>Sets how big the sun should appear in the light&#039;s specular effect on the water.</td><td>3.0f</td>
</tr>
@ -263,11 +264,10 @@ manager.loadTexture(&quot;Textures/foam.png&quot;) )</td><td>This foam texture w
<!-- EDIT12 TABLE [8717-9632] -->
</div>
<!-- EDIT7 SECTION "Optional: Water Wave and Color Effects" [5230-9634] -->
<h3><a>Sound Effects</a></h3>
<h3>Sound Effects</h3>
<div>
<p>
You should also add audio nodes with water sounds to complete the effect.
</p>
<pre>AudioNode waves = new AudioNode&#40;assetManager, &quot;Sounds/Environment/Ocean Waves.ogg&quot;, false&#41;;
@ -275,7 +275,6 @@ waves.setLooping&#40;true&#41;;
audioRenderer.playSource&#40;waves&#41;;</pre>
<p>
See also: <a href="/com/jme3/gde/docs/jme3/advanced/audio.html">audio</a>.
</p>
<hr />
@ -292,4 +291,4 @@ See also:
</div>
<!-- EDIT13 SECTION "Sound Effects" [9635-] -->
<p><em><a href="http://hub.jmonkeyengine.org/wiki/doku.php/jme3:advanced:post-processor_water?do=export_xhtmlbody">view online version</a></em></p>
<p><em><a href="http://wiki.jmonkeyengine.org/doku.php/jme3:advanced:post-processor_water?do=export_xhtmlbody">view online version</a></em></p>

@ -1,9 +1,8 @@
<h1><a>Ragdoll Physics</a></h1>
<h1>Ragdoll Physics</h1>
<div>
<p>
The jMonkeyEngine3 has built-in support for <object classid="java:org.netbeans.modules.javahelp.BrowserDisplayer"><param name="content" value="http://jbullet.advel.cz"><param name="text" value="<html><u>jBullet physics</u></html>"><param name="textColor" value="blue"></object> via the <code>com.jme3.bullet</code> package. Physics are not only responsible for handing collisions, but they also make <a href="/com/jme3/gde/docs/jme3/advanced/hinges_and_joints.html">hinges and joints</a> possible. One special example of physical joints are ragdoll physics, shown here.
</p>
@ -13,18 +12,18 @@ The jMonkeyEngine3 has built-in support for <object classid="java:org.netbeans.m
</div>
<!-- EDIT1 SECTION "Ragdoll Physics" [1-385] -->
<h2><a>Sample Code</a></h2>
<h2>Sample Code</h2>
<div>
<ul>
<li><div> <object classid="java:org.netbeans.modules.javahelp.BrowserDisplayer"><param name="content" value="http://code.google.com/p/jmonkeyengine/source/browse/trunk/engine/src/test/jme3test/bullet/TestRagDoll.java"><param name="text" value="<html><u>TestRagDoll.java</u></html>"><param name="textColor" value="blue"></object> (Tip: Click to pull the ragdoll up)</div>
</li>
<li><div> <object classid="java:org.netbeans.modules.javahelp.BrowserDisplayer"><param name="content" value="http://code.google.com/p/jmonkeyengine/source/browse/trunk/engine/src/test/jme3test/bullet/TestBoneRagdoll.java"><param name="text" value="<html><u>TestBoneRagdoll.java</u></html>"><param name="textColor" value="blue"></object> ??? This ragdoll replaces a rigged model of a character in the moment it is &quot;shot&quot; to simulate a collapsing person. (Also note DoF of the limbs.)</div>
<li><div> <object classid="java:org.netbeans.modules.javahelp.BrowserDisplayer"><param name="content" value="http://code.google.com/p/jmonkeyengine/source/browse/trunk/engine/src/test/jme3test/bullet/TestBoneRagdoll.java"><param name="text" value="<html><u>TestBoneRagdoll.java</u></html>"><param name="textColor" value="blue"></object> – This ragdoll replaces a rigged model of a character in the moment it is “shot” to simulate a collapsing person. (Also note DoF of the limbs.)</div>
</li>
</ul>
</div>
<!-- EDIT2 SECTION "Sample Code" [386-867] -->
<h2><a>Preparing the Physics Game</a></h2>
<h2>Preparing the Physics Game</h2>
<div>
<ol>
<li><div> Create a SimpleApplication with a <a href="/com/jme3/gde/docs/jme3/advanced/physics.html">BulletAppState</a></div>
@ -39,21 +38,19 @@ The jMonkeyEngine3 has built-in support for <object classid="java:org.netbeans.m
</div>
<!-- EDIT3 SECTION "Preparing the Physics Game" [868-1106] -->
<h2><a>Creating the Ragdoll</a></h2>
<h2>Creating the Ragdoll</h2>
<div>
<p>
A ragdoll is a simple &quot;person&quot; (dummy) that you build out of cylinder collision shapes. The ragdoll has 11 limbs: 1 for shoulders, 1 for the body, 1 for hips; plus 2 arms and 2 legs that are made up of two limbs each. In your game, you will likely replace the cylinders with your own (better looking) limb models. In this example here we just use simple cylinders.
A ragdoll is a simple “person” (dummy) that you build out of cylinder collision shapes. The ragdoll has 11 limbs: 1 for shoulders, 1 for the body, 1 for hips; plus 2 arms and 2 legs that are made up of two limbs each. In your game, you will likely replace the cylinders with your own (better looking) limb models. In this example here we just use simple cylinders.
</p>
</div>
<!-- EDIT4 SECTION "Creating the Ragdoll" [1107-1506] -->
<h3><a>Limbs</a></h3>
<h3>Limbs</h3>
<div>
<p>
Since you&#039;re just creating the ragdoll for this example, all the limbs have the same shape, and you can write a simple helper method to create them. The function returns a PhysicsControl with CollisionShape with the width, height, location, and rotation (vertical or horizontal) that you specify. You choose a CapsuleCollisionShape (a cylinder with rounded top and bottom) so the limbs collide smoothly against one another.
</p>
<pre>private Node createLimb&#40;float width, float height, Vector3f location, boolean rotate&#41; &#123;
@ -92,16 +89,15 @@ Node lLegL = createLimb&#40;0.2f, 0.5f, new Vector3f&#40;-0.25f,-2.2f, 0&#41
Node lLegR = createLimb&#40;0.2f, 0.5f, new Vector3f&#40; 0.25f,-2.2f, 0&#41;, false&#41;;</pre>
<p>
You now have the outline of a person. But if you ran the application now, the individual limbs would fall down independently of one another ??? the ragdoll is still lacking joints.
You now have the outline of a person. But if you ran the application now, the individual limbs would fall down independently of one another the ragdoll is still lacking joints.
</p>
</div>
<!-- EDIT5 SECTION "Limbs" [1507-3921] -->
<h3><a>Joints</a></h3>
<h3>Joints</h3>
<div>
<p>
As before, you write a small helper method. This time its purpose is to quickly join two limbs A and B at the connection point that we specify.
</p>
<ul>
@ -123,7 +119,6 @@ As before, you write a small helper method. This time its purpose is to quickly
</ul>
<p>
Use the helper method to connect all limbs with joints where they belong, at one end of the limb.
</p>
<pre>join&#40;body, shoulders, new Vector3f&#40; 0.00f, 1.4f, 0&#41;&#41;;
@ -143,11 +138,10 @@ Now the ragdoll is connected. If you ran the app now, the doll would collapse, b
</div>
<!-- EDIT6 SECTION "Joints" [3922-5767] -->
<h3><a>Attaching Everything to the Scene</a></h3>
<h3>Attaching Everything to the Scene</h3>
<div>
<p>
We create one (non-physical) Node named ragDoll, and attach all other nodes to it.
</p>
<pre>ragDoll.attachChild&#40;shoulders&#41;;
@ -170,48 +164,41 @@ bulletAppState.getPhysicsSpace&#40;&#41;.addAll&#40;ragDoll&#41;;</pre>
</div>
<!-- EDIT7 SECTION "Attaching Everything to the Scene" [5768-6426] -->
<h2><a>Applying Forces</a></h2>
<h2>Applying Forces</h2>
<div>
<p>
To pull the doll up, you could add an input handler that triggers the following action:
</p>
<pre>Vector3f upforce = new Vector3f&#40;0, 200, 0&#41;;
shoulders.applyContinuousForce&#40;true, upforce&#41;;</pre>
<p>
We can use the action to pick the doll up and put it back on its feet, or what ever. Read more about <a href="/com/jme3/gde/docs/jme3/advanced/physics#forcesmoving_physical_objects.html">Forces</a> here.
We can use the action to pick the doll up and put it back on its feet, or what ever. Read more about <a href="/com/jme3/gde/docs/jme3/advanced/physics.html#forcesmoving_physical_objects">Forces</a> here.
</p>
</div>
<!-- EDIT8 SECTION "Applying Forces" [6427-6828] -->
<h2><a>Detecting Collisions</a></h2>
<h2>Detecting Collisions</h2>
<div>
<p>
Read the <a href="/com/jme3/gde/docs/jme3/advanced/physics#responding_to_a_physicscollisionevent.html">Responding to a PhysicsCollisionEvent</a> chapter in the general physics documentation on how to detect collisions. You can detect collisions between limbs or between limbs and the floor, and trigger game events.
Read the <a href="/com/jme3/gde/docs/jme3/advanced/physics.html#responding_to_a_physicscollisionevent">Responding to a PhysicsCollisionEvent</a> chapter in the general physics documentation on how to detect collisions. You can detect collisions between limbs or between limbs and the floor, and trigger game events.
</p>
</div>
<!-- EDIT9 SECTION "Detecting Collisions" [6829-7146] -->
<h2><a>Best Practices</a></h2>
<h2>Best Practices</h2>
<div>
<p>
If you experience weird behaviour in a ragdoll – such as exploding into pieces and then reassembling – check your collision shapes. Verify you did not position the limbs too close to one another when assmebling the ragdoll. You typically see physical nodes being ejected when their collision shapes intersect, which puts physics in an impossible state.
</p>
If you experience weird behaviour in a ragdoll ??? such as exploding into pieces and then reassembling ??? check your collision shapes. Verify you did not position the limbs too close to one another when assmebling the ragdoll. You typically see physical nodes being ejected when their collision shapes intersect, which puts physics in an impossible state.
<p>
<a href="nbdocs:/com/jme3/gde/docs/jme3:advanced/tag_documentation_physics_character_npc_forces_collisions">tag_documentation_physics_character_npc_forces_collisions</a>
</p>
<div><span>
<a href="/wiki/doku.php/tag:documentation?do=showtag&amp;tag=tag%3Adocumentation">documentation</a>,
<a href="/wiki/doku.php/tag:physics?do=showtag&amp;tag=tag%3Aphysics">physics</a>,
<a href="/wiki/doku.php/tag:character?do=showtag&amp;tag=tag%3Acharacter">character</a>,
<a href="/wiki/doku.php/tag:npc?do=showtag&amp;tag=tag%3Anpc">NPC</a>,
<a href="/wiki/doku.php/tag:forces?do=showtag&amp;tag=tag%3Aforces">forces</a>,
<a href="/wiki/doku.php/tag:collisions?do=showtag&amp;tag=tag%3Acollisions">collisions</a>
</span></div>
</div>
<!-- EDIT10 SECTION "Best Practices" [7147-] -->
<p><em><a href="http://hub.jmonkeyengine.org/wiki/doku.php/jme3:advanced:ragdoll?do=export_xhtmlbody">view online version</a></em></p>
<p><em><a href="http://wiki.jmonkeyengine.org/doku.php/jme3:advanced:ragdoll?do=export_xhtmlbody">view online version</a></em></p>

@ -1,9 +1,8 @@
<h1><a>Read Graphic Card Capabilites</a></h1>
<h1>Read Graphic Card Capabilites</h1>
<div>
<p>
When different people test your new game, you may get feedback that the game doesn&#039;t run on their hardware, or that some details don&#039;t look as expected. You need to detect which fetaures the user&#039;s hardware supports, and offer a replacement for non-supported features on olde hardware (or deactivate them automatically).
</p>
@ -11,7 +10,7 @@ When different people test your new game, you may get feedback that the game doe
You can read (and print) the capabilities of the user&#039;s graphic card using the <code>com.jme3.renderer.Caps</code> class:
</p>
<pre>Collection&lt;Caps&gt; caps = renderer.getCaps&#40;&#41;;
Logger.getLogger&#40;HelloWorld.class.getName&#40;&#41;&#41;.log&#40;Level.INFO, ???Caps: &#123;0&#125;???, caps.toString&#40;&#41;&#41;;</pre>
Logger.getLogger&#40;HelloWorld.class.getName&#40;&#41;&#41;.log&#40;Level.INFO, “Caps: &#123;0&#125;, caps.toString&#40;&#41;&#41;;</pre>
<p>
<strong>Note:</strong> Replace <code>HelloWorld</code> by the name of the class where you are using this line.
@ -19,11 +18,10 @@ Logger.getLogger&#40;HelloWorld.class.getName&#40;&#41;&#41;.log&#40;Level.INFO,
</div>
<!-- EDIT1 SECTION "Read Graphic Card Capabilites" [1-731] -->
<h2><a>Examples</a></h2>
<h2>Examples</h2>
<div>
<p>
A newer graphic card has modern capabilities, for example OpenGL 2.1 and NonPowerOfTwoTextures:
</p>
<pre>INFO: Running on jMonkeyEngine 3.0.0
@ -61,7 +59,7 @@ VertexTextureFetch, FloatTexture,
TextureCompressionLATC, NonPowerOfTwoTextures]</pre>
<p>
This next example is lacking <code>NonPowerOfTwoTextures</code>, this tells you that this user&#039;s graphic card cannot handle textures with sizes that are not square powers of two (such as &quot;128x128&quot;).
This next example is lacking <code>NonPowerOfTwoTextures</code>, this tells you that this user&#039;s graphic card cannot handle textures with sizes that are not square powers of two (such as “128&times;128”).
</p>
<pre>INFO: Capabilities: [FrameBuffer, FrameBufferMRT, FrameBufferMultisample,
OpenGL20, ARBprogram, GLSL100, GLSL110, GLSL120,
@ -69,4 +67,4 @@ VertexTextureFetch, FloatTexture, TextureCompressionLATC]</pre>
</div>
<!-- EDIT2 SECTION "Examples" [732-] -->
<p><em><a href="http://hub.jmonkeyengine.org/wiki/doku.php/jme3:advanced:read_graphic_card_capabilites?do=export_xhtmlbody">view online version</a></em></p>
<p><em><a href="http://wiki.jmonkeyengine.org/doku.php/jme3:advanced:read_graphic_card_capabilites?do=export_xhtmlbody">view online version</a></em></p>

@ -1,14 +1,13 @@
<h1><a>Remote-Controlling the Camera</a></h1>
<h1>Remote-Controlling the Camera</h1>
<div>
</div>
<!-- EDIT1 SECTION "Remote-Controlling the Camera" [1-45] -->
<h2><a>Positioning the Camera</a></h2>
<h2>Positioning the Camera</h2>
<div>
<p>
You can steer the camera using <a href="/com/jme3/gde/docs/jme3/advanced/cinematics.html">Cinematics</a>:
</p>
<ol>
@ -19,14 +18,14 @@ You can steer the camera using <a href="/com/jme3/gde/docs/jme3/advanced/cinemat
</li>
<li><div> Position the camera node in its start location.</div>
</li>
<li><div> Use activateCamera() to give the control of the camera to this node. You now see the scene from this camera&#039;s point of view. For example to see through the camera node named &quot;topView&quot;, 6 seconds after the start of the cinematic, you&#039;d write <pre>cinematic.activateCamera&#40;6, &quot;topView&quot;&#41;;</pre>
<li><div> Use activateCamera() to give the control of the camera to this node. You now see the scene from this camera&#039;s point of view. For example to see through the camera node named “topView”, 6 seconds after the start of the cinematic, you&#039;d write <pre>cinematic.activateCamera&#40;6, &quot;topView&quot;&#41;;</pre>
</div>
</li>
</ol>
</div>
<!-- EDIT2 SECTION "Positioning the Camera" [46-714] -->
<h3><a>Code Sample</a></h3>
<h3>Code Sample</h3>
<div>
<pre>flyCam.setEnabled&#40;false&#41;;
Cinematic cinematic = new Cinematic&#40;rootNode, 20&#41;;
@ -41,19 +40,17 @@ camNodeSide.getControl&#40;0&#41;.setEnabled&#40;false&#41;;</pre>
</div>
<!-- EDIT3 SECTION "Code Sample" [715-1171] -->
<h2><a>Moving the Camera</a></h2>
<h2>Moving the Camera</h2>
<div>
<p>
If desired, attach the camNode to a MotionTrack to let it travel along waypoints. This is demonstrated in the <object classid="java:org.netbeans.modules.javahelp.BrowserDisplayer"><param name="content" value="http://code.google.com/p/jmonkeyengine/source/browse/trunk/engine/src/test/jme3test/animation/TestCinematic.java"><param name="text" value="<html><u>TestCameraMotionPath.java example</u></html>"><param name="textColor" value="blue"></object>.
</p>
<div><span>
<a href="/wiki/doku.php/tag:camera?do=showtag&amp;tag=tag%3Acamera">camera</a>,
<a href="/wiki/doku.php/tag:documentation?do=showtag&amp;tag=tag%3Adocumentation">documentation</a>,
<a href="/wiki/doku.php/tag:cinematics?do=showtag&amp;tag=tag%3Acinematics">cinematics</a>
</span></div>
<p>
<a href="nbdocs:/com/jme3/gde/docs/jme3:advanced/tag_camera_documentation_cinematics">tag_camera_documentation_cinematics</a>
</p>
</div>
<!-- EDIT4 SECTION "Moving the Camera" [1172-] -->
<p><em><a href="http://hub.jmonkeyengine.org/wiki/doku.php/jme3:advanced:remote-controlling_the_camera?do=export_xhtmlbody">view online version</a></em></p>
<p><em><a href="http://wiki.jmonkeyengine.org/doku.php/jme3:advanced:remote-controlling_the_camera?do=export_xhtmlbody">view online version</a></em></p>

@ -1,28 +1,27 @@
<h1><a>Saving and Loading Games (.j3o)</a></h1>
<h1>Saving and Loading Games (.j3o)</h1>
<div>
<p>
Spatials (that is Nodes and Geometries) can contain audio and light nodes, particle emitters, controls, and user data (player score, health, inventory, etc). For your game distribution, you must convert all original models to a faster binary format. You save individual Spatials as well as scenes using <code>com.jme3.export.binary.BinaryExporter</code>.
</p>
<p>
The jMonkeyEngine&#039;s binary file format is called <code>.j3o</code>. You can convert, view and edit .j3o files and their materials in the jMonkeyEngine <a href="/com/jme3/gde/docs/sdk.html">SDK</a> and compose scenes (this does not include editing meshes). For the conversion, you can either use the BinaryExporters, or a context menu in the <acronym title="Software Development Kit">SDK</acronym>.
The jMonkeyEngine&#039;s binary file format is called <code>.j3o</code>. You can convert, view and edit .j3o files and their materials in the jMonkeyEngine <a href="/com/jme3/gde/docs/sdk.html">SDK</a> and compose scenes (this does not include editing meshes). For the conversion, you can either use the BinaryExporters, or a context menu in the SDK.
</p>
<p>
<p><div>The jMonkeyEngine&#039;s serialization system is the <code>com.jme3.export.Savable</code> interface. JME3&#039;s BinaryExporter can write standard Java objects, JME3 objects, and primitive data types that are included in a <a href="/com/jme3/gde/docs/jme3/advanced/spatial.html">spatial&#039;s user data</a>. If you use custom game data classes, see below how to make them &quot;Savable&quot;.
<p><div>The jMonkeyEngine&#039;s serialization system is the <code>com.jme3.export.Savable</code> interface. JME3&#039;s BinaryExporter can write standard Java objects, JME3 objects, and primitive data types that are included in a <a href="/com/jme3/gde/docs/jme3/advanced/spatial.html">spatial&#039;s user data</a>. If you use custom game data classes, see below how to make them “Savable”.
</div></p>
</p>
<p>
There is also a com.jme3.export.xml.XMLExporter and com.jme3.export.xml.XMLImporter that similarly converts jme3 spatials to an <acronym title="Extensible Markup Language">XML</acronym> format. But you wouldn&#039;t use that to load models at runtime (quite slow).
There is also a com.jme3.export.xml.XMLExporter and com.jme3.export.xml.XMLImporter that similarly converts jme3 spatials to an XML format. But you wouldn&#039;t use that to load models at runtime (quite slow).
</p>
</div>
<!-- EDIT1 SECTION "Saving and Loading Games (.j3o)" [1-1239] -->
<h2><a>Sample Code</a></h2>
<h2>Sample Code</h2>
<div>
<ul>
<li><div> <object classid="java:org.netbeans.modules.javahelp.BrowserDisplayer"><param name="content" value="http://code.google.com/p/jmonkeyengine/source/browse/trunk/engine/src/test/jme3test/tools/TestSaveGame.java"><param name="text" value="<html><u>TestSaveGame.java</u></html>"><param name="textColor" value="blue"></object></div>
@ -31,24 +30,23 @@ There is also a com.jme3.export.xml.XMLExporter and com.jme3.export.xml.XMLImpor
</div>
<!-- EDIT2 SECTION "Sample Code" [1240-1397] -->
<h2><a>Saving a Node</a></h2>
<h2>Saving a Node</h2>
<div>
<p>
The following example overrides <code>stop()</code> in SimpleApplication to save the rootNode to a file when the user quits the application. The saved rootNode is a normal .j3o binary file that you can open in the <a href="/com/jme3/gde/docs/sdk.html">SDK</a>.
</p>
<p>
<p><div>Note that when you save a model that has textures, the references to those textures are stored as absolute paths, so when loading the j3o file again, the textures have to be accessible at the exact location (relative to the assetmanager root, by default the <code>assets</code> directory) they were loaded from. This is why the <acronym title="Software Development Kit">SDK</acronym> manages the conversion on the project level.
<p><div>Note that when you save a model that has textures, the references to those textures are stored as absolute paths, so when loading the j3o file again, the textures have to be accessible at the exact location (relative to the assetmanager root, by default the <code>assets</code> directory) they were loaded from. This is why the SDK manages the conversion on the project level.
</div></p>
</p>
<pre> /* This is called when the user quits the app. */
@Override
public void stop&#40;&#41; &#123;
String userHome = System.getProperty&#40;&quot;user.home&quot;&#41;;
System.getProperty&#40;&quot;user.home&quot;&#41;;
BinaryExporter exporter = BinaryExporter.getInstance&#40;&#41;;
File file = new File&#40;userHome+&quot;/Models/&quot;+&quot;MyModel.j3o&quot;&#41;;
File&#40;userHome+&quot;/Models/&quot;+&quot;MyModel.j3o&quot;&#41;;
try &#123;
exporter.save&#40;rootNode, file&#41;;
&#125; catch &#40;IOException ex&#41; &#123;
@ -59,16 +57,15 @@ The following example overrides <code>stop()</code> in SimpleApplication to save
</div>
<!-- EDIT3 SECTION "Saving a Node" [1398-2548] -->
<h2><a>Loading a Node</a></h2>
<h2>Loading a Node</h2>
<div>
<p>
The following example overrides <code>simpleInitApp()</code> in SimpleApplication to load <code>Models/MyModel.j3o</code> when the game is initialized.
</p>
<pre> @Override
public void simpleInitApp&#40;&#41; &#123;
String userHome = System.getProperty&#40;&quot;user.home&quot;&#41;;
System.getProperty&#40;&quot;user.home&quot;&#41;;
assetManager.registerLocator&#40;userHome, FileLocator.class&#41;;
Node loadedNode = &#40;Node&#41;assetManager.loadModel&#40;&quot;Models/MyModel.j3o&quot;&#41;;
loadedNode.setName&#40;&quot;loaded node&quot;&#41;;
@ -77,26 +74,24 @@ The following example overrides <code>simpleInitApp()</code> in SimpleApplicatio
&nbsp;</pre>
<p>
<p><div>Here you see why we save user data inside spatials ??? so it can be saved and loaded together with the .j3o file. If you have game data outside Spatials, you have to remember to save() and load(), and get() and set() it yourself.
<p><div>Here you see why we save user data inside spatials so it can be saved and loaded together with the .j3o file. If you have game data outside Spatials, you have to remember to save() and load(), and get() and set() it yourself.
</div></p>
</p>
</div>
<!-- EDIT4 SECTION "Loading a Node" [2549-3302] -->
<h2><a>Custom Savable Class</a></h2>
<h2>Custom Savable Class</h2>
<div>
<p>
JME&#039;s BinaryExporter can write standard Java objects (String, ArrayList, buffers, etc), JME objects (Savables, such as Material), and primitive data types (int, float, etc). If you are using any custom class together with a Spatial, then the custom class must implement the <code>com.jme3.export.Savable</code> interface. There are two common cases where this is relevant:
</p>
<ul>
<li><div> The Spatial is carrying any <a href="/com/jme3/gde/docs/jme3/advanced/custom_controls.html">Custom Controls</a>. <br/>
Example: You used something like <code>mySpatial.addControl(myControl);</code></div>
</li>
<li><div> The Spatial&#039;s user data can contain a custom Java object. <br/>
Example: You used something like <code>mySpatial.setUserData(&quot;inventory&quot;, myInventory);</code></div>
Example: You used something like <code>mySpatial.setUserData(“inventory”, myInventory);</code></div>
</li>
</ul>
@ -153,11 +148,11 @@ To make a custom class savable:
</li>
</ul>
</li>
<li><div> Add one line that <code>read???()</code>s the data to the JmeImport input capsule. </div>
<li><div> Add one line that <code>read()</code>s the data to the JmeImport input capsule. </div>
<ul>
<li><div> On the left side of the assignment, specify the class field that you are restoring</div>
</li>
<li><div> On the right side, use the appropriate <code>capsule.read???()</code> method for the data type. Specify the String name of the variable (must be the same as you used in the <code>write() method</code>), and again specify a default value.</div>
<li><div> On the right side, use the appropriate <code>capsule.read()</code> method for the data type. Specify the String name of the variable (must be the same as you used in the <code>write() method</code>), and again specify a default value.</div>
</li>
</ul>
</li>
@ -166,28 +161,14 @@ To make a custom class savable:
</ol>
<p>
<p><div>As with all serialization, remember that if you ever change data types in custom classes, the updated read() methods will no longer be able to read your old files. Also there has to be a constructor that takes no Parameters.
</div></p>
</p>
<div><span>
<a href="/wiki/doku.php/tag:convert?do=showtag&amp;tag=tag%3Aconvert">convert</a>,
<a href="/wiki/doku.php/tag:j3o?do=showtag&amp;tag=tag%3Aj3o">j3o</a>,
<a href="/wiki/doku.php/tag:models?do=showtag&amp;tag=tag%3Amodels">models</a>,
<a href="/wiki/doku.php/tag:load?do=showtag&amp;tag=tag%3Aload">load</a>,
<a href="/wiki/doku.php/tag:save?do=showtag&amp;tag=tag%3Asave">save</a>,
<a href="/wiki/doku.php/tag:documentation?do=showtag&amp;tag=tag%3Adocumentation">documentation</a>,
<a href="/wiki/doku.php/tag:serialization?do=showtag&amp;tag=tag%3Aserialization">serialization</a>,
<a href="/wiki/doku.php/tag:import?do=showtag&amp;tag=tag%3Aimport">import</a>,
<a href="/wiki/doku.php/tag:export?do=showtag&amp;tag=tag%3Aexport">export</a>,
<a href="/wiki/doku.php/tag:spatial?do=showtag&amp;tag=tag%3Aspatial">spatial</a>,
<a href="/wiki/doku.php/tag:node?do=showtag&amp;tag=tag%3Anode">node</a>,
<a href="/wiki/doku.php/tag:mesh?do=showtag&amp;tag=tag%3Amesh">mesh</a>,
<a href="/wiki/doku.php/tag:geometry?do=showtag&amp;tag=tag%3Ageometry">geometry</a>,
<a href="/wiki/doku.php/tag:scenegraph?do=showtag&amp;tag=tag%3Ascenegraph">scenegraph</a>,
<a href="/wiki/doku.php/tag:sdk?do=showtag&amp;tag=tag%3Asdk">sdk</a>
</span></div>
<p>
<a href="nbdocs:/com/jme3/gde/docs/jme3:advanced/tag_convert_j3o_models_load_save_documentation_serialization_import_export_spatial_node_mesh_geometry_scenegraph_sdk">tag_convert_j3o_models_load_save_documentation_serialization_import_export_spatial_node_mesh_geometry_scenegraph_sdk</a>
</p>
</div>
<!-- EDIT5 SECTION "Custom Savable Class" [3303-] -->
<p><em><a href="http://hub.jmonkeyengine.org/wiki/doku.php/jme3:advanced:save_and_load?do=export_xhtmlbody">view online version</a></em></p>
<p><em><a href="http://wiki.jmonkeyengine.org/doku.php/jme3:advanced:save_and_load?do=export_xhtmlbody">view online version</a></em></p>

@ -1,27 +1,24 @@
<h1><a>Taking Screenshots</a></h1>
<h1>Taking Screenshots</h1>
<div>
<p>
The com.jme3.app.state.ScreenshotAppState enables your users to take screenshots of the running game.
</p>
<p>
You activate this feature as follows in your simpleInitApp() method:
</p>
<pre>ScreenshotAppState screenShotState = new ScreenshotAppState&#40;&#41;;
this.stateManager.attach&#40;screenShotState&#41;;</pre>
<p>
The default screenshot key is KeyInput.KEY_SYSRQ, alos known as &quot;System Request / Print Screen&quot; key. On Mac keyboards, this key does not exist, so on Mac <acronym title="Operating System">OS</acronym> you take screenshots using Command+Shift+3 (fullscreen) or Command+Shift+4 (windowed: press space to select a window and then click).
The default screenshot key is KeyInput.KEY_SYSRQ, alos known as “System Request / Print Screen” key. On Mac keyboards, this key does not exist, so on Mac <abbr title="Operating System">OS</abbr> you take screenshots using Command+Shift+3 (fullscreen) or Command+Shift+4 (windowed: press space to select a window and then click).
</p>
<p>
The screenshot is saved to the user directory.
</p>
</div>
<p><em><a href="http://hub.jmonkeyengine.org/wiki/doku.php/jme3:advanced:screenshots?do=export_xhtmlbody">view online version</a></em></p>
<p><em><a href="http://wiki.jmonkeyengine.org/doku.php/jme3:advanced:screenshots?do=export_xhtmlbody">view online version</a></em></p>

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.7 KiB

After

Width:  |  Height:  |  Size: 20 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.5 KiB

After

Width:  |  Height:  |  Size: 20 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.7 KiB

After

Width:  |  Height:  |  Size: 19 KiB

Some files were not shown because too many files have changed in this diff Show More

Loading…
Cancel
Save