- Update SDK manual git-svn-id: https://jmonkeyengine.googlecode.com/svn/trunk@10104 75d07b2b-3a1a-0410-a2c5-0572b91ccdca3.0
After Width: | Height: | Size: 166 KiB |
After Width: | Height: | Size: 121 KiB |
After Width: | Height: | Size: 131 KiB |
After Width: | Height: | Size: 32 KiB |
After Width: | Height: | Size: 47 KiB |
After Width: | Height: | Size: 27 KiB |
After Width: | Height: | Size: 134 KiB |
After Width: | Height: | Size: 113 KiB |
After Width: | Height: | Size: 105 KiB |
After Width: | Height: | Size: 25 KiB |
After Width: | Height: | Size: 103 KiB |
After Width: | Height: | Size: 106 KiB |
After Width: | Height: | Size: 53 KiB |
After Width: | Height: | Size: 35 KiB |
@ -0,0 +1,616 @@ |
||||
|
||||
<h1><a>3ds Max Bone Animation to JME3 using OgreMax plugin</a></h1> |
||||
<div> |
||||
|
||||
</div> |
||||
<!-- EDIT1 SECTION "3ds Max Bone Animation to JME3 using OgreMax plugin" [1-67] --> |
||||
<h2><a>Asset Management</a></h2> |
||||
<div> |
||||
|
||||
<p> |
||||
For the managing of assets in general, be sure to read the <a href="/com/jme3/gde/core/docs/jme3/intermediate/multi-media_asset_pipeline.html">Asset Pipeline Documentation</a>. It contains vital information on how to manage your asset files. |
||||
</p> |
||||
|
||||
</div> |
||||
<!-- EDIT2 SECTION "Asset Management" [68-300] --> |
||||
<h2><a>Creating models in 3dsMax</a></h2> |
||||
<div> |
||||
|
||||
<p> |
||||
For this tutorial I used 3D Studio Max 2012 and OgreMax 2.4.3 free edition |
||||
</p> |
||||
|
||||
</div> |
||||
<!-- EDIT3 SECTION "Creating models in 3dsMax" [301-414] --> |
||||
<h3><a>Create Model and Bones</a></h3> |
||||
<div> |
||||
<ul> |
||||
<li><div> Create a new file</div> |
||||
</li> |
||||
<li><div> Select the ???Create??? tab > ???Geometry??? > ???Cylinder???</div> |
||||
</li> |
||||
</ul> |
||||
|
||||
<p> |
||||
<img src="nbdocs:/com/jme3/gde/core/docs/jme3/external/3dsmax-0.png"> |
||||
</p> |
||||
<ul> |
||||
<li><div> Draw a cylinder, lets say with 8 height segments (must be enough for a smooth deformation)</div> |
||||
</li> |
||||
<li><div> Also check ???Generate Mapping Coords.???</div> |
||||
</li> |
||||
</ul> |
||||
|
||||
<p> |
||||
<img src="nbdocs:/com/jme3/gde/core/docs/jme3/external/3dsmax-1.png"> |
||||
</p> |
||||
<ul> |
||||
<li><div> Click ???Create??? tab > ???Systems??? > ???Bones???</div> |
||||
</li> |
||||
</ul> |
||||
|
||||
<p> |
||||
<img src="nbdocs:/com/jme3/gde/core/docs/jme3/external/3dsmax-2.png"> |
||||
</p> |
||||
<ul> |
||||
<li><div> Add some bones in the center of the cylinder</div> |
||||
</li> |
||||
</ul> |
||||
|
||||
<p> |
||||
<img src="nbdocs:/com/jme3/gde/core/docs/jme3/external/3dsmax-3.png"> |
||||
</p> |
||||
<ul> |
||||
<li><div> Select the cylinder, right click it and click ???Convert To:??? > ???Convert to Editable Mesh??? to prevent issues with OgreMax</div> |
||||
</li> |
||||
<li><div> Click the ???Modify??? tab > ???Modifier List??? and add the ???Skin??? modifier</div> |
||||
</li> |
||||
</ul> |
||||
|
||||
<p> |
||||
<img src="nbdocs:/com/jme3/gde/core/docs/jme3/external/3dsmax-4.png"> |
||||
</p> |
||||
<ul> |
||||
<li><div> Beneath ???Bones:??? click ???Add??? and select all of your bones</div> |
||||
</li> |
||||
</ul> |
||||
|
||||
<p> |
||||
<img src="nbdocs:/com/jme3/gde/core/docs/jme3/external/3dsmax-5.png"> |
||||
</p> |
||||
<ul> |
||||
<li><div> You may also edit the envelopes, but for a small test the default settings are ok</div> |
||||
</li> |
||||
</ul> |
||||
|
||||
</div> |
||||
<!-- EDIT4 SECTION "Create Model and Bones" [415-1354] --> |
||||
<h3><a>Create the animation</a></h3> |
||||
<div> |
||||
<ul> |
||||
<li><div> Select the cylinder, and click ???Display??? tab > ???Freeze Selected??? so it is easier to select the bones during animation</div> |
||||
</li> |
||||
<li><div> Select the two top bones and enable the ???Auto Key??? mode</div> |
||||
</li> |
||||
</ul> |
||||
|
||||
<p> |
||||
<img src="nbdocs:/com/jme3/gde/core/docs/jme3/external/3dsmax-6.png"> |
||||
</p> |
||||
<ul> |
||||
<li><div> The first key frame will be created automatically. Move the animation track slider to frame 5</div> |
||||
</li> |
||||
<li><div> Move the selected bones a bit. The cylinder mesh will be deformed. Because you are in the ???Auto Key??? mode, a key frame will be created</div> |
||||
</li> |
||||
</ul> |
||||
|
||||
<p> |
||||
<img src="nbdocs:/com/jme3/gde/core/docs/jme3/external/3dsmax-7.png"> |
||||
</p> |
||||
<ul> |
||||
<li><div> Create some additional key frames. You may also select more bones and move or rotate them. I???ve created 25 frames and the last key frame equals the first, so the animation is loopable</div> |
||||
</li> |
||||
<li><div> After creating the animation, disable the ???Auto Key??? mode</div> |
||||
</li> |
||||
</ul> |
||||
|
||||
</div> |
||||
<!-- EDIT5 SECTION "Create the animation" [1355-2141] --> |
||||
<h3><a>OgreMax settings</a></h3> |
||||
<div> |
||||
<ul> |
||||
<li><div> Open the ???OgreMax Scene Settings??? dialog from the menu</div> |
||||
</li> |
||||
<li><div> In the ???Meshes??? tab, enable ???Export <acronym title="Extensible Markup Language">XML</acronym> Files??? and disable ???Export Binary Files??? as well as ???Export Vertex Colors???</div> |
||||
</li> |
||||
</ul> |
||||
|
||||
<p> |
||||
<img src="nbdocs:/com/jme3/gde/core/docs/jme3/external/3dsmax-8.png"> |
||||
</p> |
||||
<ul> |
||||
<li><div> Click the ???Environment??? tab and uncheck ???Export Environment Settings???. Otherwise the JME importer will throw a NullPointerException</div> |
||||
</li> |
||||
</ul> |
||||
|
||||
<p> |
||||
<img src="nbdocs:/com/jme3/gde/core/docs/jme3/external/3dsmax-9.png"> |
||||
</p> |
||||
<ul> |
||||
<li><div> If you have textured your model, you may also check ???Copy Bitmaps to Export Directory??? in the ???Bitmaps??? tab</div> |
||||
</li> |
||||
<li><div> Unfreeze the cylinder by clicking ???Display??? tab > ???Unfreeze All??? and select it</div> |
||||
</li> |
||||
<li><div> While having the cylinder selected, open the ???OgreMax Object Settings??? dialog from the menu</div> |
||||
</li> |
||||
<li><div> Open the ???Mesh Animations??? tab and select type ???Skeleton???, ???Export Skeleton??? : ???Yes???</div> |
||||
</li> |
||||
<li><div> Below ???Mesh Animations??? hit the ???Add?????? button</div> |
||||
</li> |
||||
<li><div> Assign a name to the track, maybe ???wobble???. The track type must be ???Skin. Set the right ???Start/End Frames??? for your animation</div> |
||||
</li> |
||||
</ul> |
||||
|
||||
<p> |
||||
<img src="nbdocs:/com/jme3/gde/core/docs/jme3/external/3dsmax-10.png"> |
||||
</p> |
||||
<ul> |
||||
<li><div> Hit ok and you will see the animation in the table. You may add additional animations by selecting other frame ranges, if desired</div> |
||||
</li> |
||||
</ul> |
||||
|
||||
<p> |
||||
<img src="nbdocs:/com/jme3/gde/core/docs/jme3/external/3dsmax-11.png"> |
||||
</p> |
||||
|
||||
</div> |
||||
<!-- EDIT6 SECTION "OgreMax settings" [2142-3395] --> |
||||
<h3><a>Export and Import</a></h3> |
||||
<div> |
||||
<ul> |
||||
<li><div> When all animations are in the list, select ???OgreMax??? > ???Export??? > ???Export Scene??? and name the file ???worm.scene???</div> |
||||
</li> |
||||
<li><div> Create a JME test class that imports the file, get the animation controller and start the ???wobble??? animation</div> |
||||
</li> |
||||
</ul> |
||||
<pre>import com.jme3.animation.AnimChannel; |
||||
import com.jme3.animation.AnimControl; |
||||
import com.jme3.animation.Skeleton; |
||||
import com.jme3.app.SimpleApplication; |
||||
import com.jme3.asset.plugins.FileLocator; |
||||
import com.jme3.light.AmbientLight; |
||||
import com.jme3.light.PointLight; |
||||
import com.jme3.material.Material; |
||||
import com.jme3.math.ColorRGBA; |
||||
import com.jme3.scene.Geometry; |
||||
import com.jme3.scene.Node; |
||||
import com.jme3.scene.Spatial; |
||||
import com.jme3.scene.control.LodControl; |
||||
import com.jme3.scene.debug.SkeletonDebugger; |
||||
|
||||
<span>/** |
||||
* This is a test class for loading a Ogre XML scene exported by OgreMax. |
||||
* |
||||
* @author Stephan Dreyer |
||||
* |
||||
*/</span> |
||||
public class TestOgreMaxImport extends SimpleApplication { |
||||
|
||||
@Override |
||||
public void simpleInitApp() { |
||||
assetManager.registerLocator("Assets/model/ogre/test/", FileLocator.class); |
||||
|
||||
// create the geometry and attach it |
||||
final Node model = (Node) assetManager.loadModel("worm.scene"); |
||||
// resize it, because of the large 3dsmax scales |
||||
model.setLocalScale(.001f); |
||||
|
||||
// attach to root node |
||||
rootNode.attachChild(model); |
||||
addLodControl(model); |
||||
|
||||
final AnimControl ac = findAnimControl(model); |
||||
|
||||
try { |
||||
// add a skeleton debugger to make bones visible |
||||
final Skeleton skel = ac.getSkeleton(); |
||||
final SkeletonDebugger skeletonDebug = new SkeletonDebugger("skeleton", |
||||
skel); |
||||
final Material mat = new Material(assetManager, |
||||
"Common/MatDefs/Misc/Unshaded.j3md"); |
||||
mat.setColor("Color", ColorRGBA.Green); |
||||
mat.getAdditionalRenderState().setDepthTest(false); |
||||
skeletonDebug.setMaterial(mat); |
||||
model.attachChild(skeletonDebug); |
||||
|
||||
// create a channel and start the wobble animation |
||||
final AnimChannel channel = ac.createChannel(); |
||||
channel.setAnim("wobble"); |
||||
} catch (final Exception e) { |
||||
e.printStackTrace(); |
||||
} |
||||
|
||||
// add some lights |
||||
rootNode.addLight(new AmbientLight()); |
||||
rootNode.addLight(new PointLight()); |
||||
} |
||||
|
||||
public void addLodControl(final Spatial parent) { |
||||
if (parent instanceof Node) { |
||||
for (final Spatial s : ((Node) parent).getChildren()) { |
||||
addLodControl(s); |
||||
} |
||||
} else if (parent instanceof Geometry) { |
||||
final LodControl lc = new LodControl(); |
||||
lc.setDistTolerance(1f); |
||||
parent.addControl(lc); |
||||
} |
||||
} |
||||
|
||||
<span>/** |
||||
* Method to find the animation control, because it is not on the models root |
||||
* node. |
||||
* |
||||
* @param parent |
||||
* The spatial to search. |
||||
* @return The {@link AnimControl} or null if it does not exist. |
||||
*/</span> |
||||
public AnimControl findAnimControl(final Spatial parent) { |
||||
final AnimControl animControl = parent.getControl(AnimControl.class); |
||||
if (animControl != null) { |
||||
return animControl; |
||||
} |
||||
|
||||
if (parent instanceof Node) { |
||||
for (final Spatial s : ((Node) parent).getChildren()) { |
||||
final AnimControl animControl2 = findAnimControl(s); |
||||
if (animControl2 != null) { |
||||
return animControl2; |
||||
} |
||||
} |
||||
} |
||||
|
||||
return null; |
||||
} |
||||
|
||||
public static void main(final String[] args) { |
||||
new TestOgreMaxImport().start(); |
||||
} |
||||
}</pre> |
||||
|
||||
<p> |
||||
You will see your worms strange movements. Have fun! |
||||
</p> |
||||
|
||||
<p> |
||||
<img src="nbdocs:/com/jme3/gde/core/docs/jme3/external/3dsmax-12.png"> |
||||
</p> |
||||
|
||||
</div> |
||||
<!-- EDIT7 SECTION "Export and Import" [3396-6885] --> |
||||
<h1><a>3ds Max Biped Animation to JME3</a></h1> |
||||
<div> |
||||
|
||||
<p> |
||||
|
||||
You can also use the biped operator to animate models, but you have to consider a lot of things. |
||||
</p> |
||||
|
||||
</div> |
||||
<!-- EDIT8 SECTION "3ds Max Biped Animation to JME3" [6886-7030] --> |
||||
<h3><a>Creating a character in 3dsMax</a></h3> |
||||
<div> |
||||
|
||||
<p> |
||||
|
||||
I will not tell you in detail how to model a character. There I many good tutorials on the web, I used <object classid="java:org.netbeans.modules.javahelp.BrowserDisplayer"><param name="content" value="http://majoh.deviantart.com/art/Mandi-s-3dsmax-Biped-Tutorial-26515784"><param name="text" value="<html><u>that one</u></html>"><param name="textColor" value="blue"></object>. |
||||
|
||||
</p> |
||||
<ul> |
||||
<li><div> You may create a biped before you start modeling, so it is quite easier to fit the proportions of the biped.</div> |
||||
</li> |
||||
<li><div> After creating a model and a biped I got something like that:</div> |
||||
</li> |
||||
</ul> |
||||
|
||||
<p> |
||||
|
||||
<img src="nbdocs:/com/jme3/gde/core/docs/jme3/external/1.png"> |
||||
|
||||
</p> |
||||
<ul> |
||||
<li><div> I added the "Meshmooth" modifier with 2 iterations and got this result:</div> |
||||
</li> |
||||
</ul> |
||||
|
||||
<p> |
||||
|
||||
<img src="nbdocs:/com/jme3/gde/core/docs/jme3/external/3dsmax_biped_2.png"> |
||||
|
||||
</p> |
||||
<ul> |
||||
<li><div> After smoothing your mesh you could correct vertices with the "Edit Mesh" modifier. Finally you add the "Physique" modifier.</div> |
||||
</li> |
||||
<li><div> Now you can edit your envelopes to fit your model.</div> |
||||
</li> |
||||
</ul> |
||||
|
||||
</div> |
||||
<!-- EDIT9 SECTION "Creating a character in 3dsMax" [7031-7770] --> |
||||
<h3><a>Creating a simple walk animation</a></h3> |
||||
<div> |
||||
<ul> |
||||
<li><div> Select the chest of your biped, choose "Motion" (1) tab > "Foot Step Mode" (2) > "Create Multiple Footsteps" (3)</div> |
||||
</li> |
||||
<li><div> You need to select the "In Place Mode" (4), so the character moves in place without changing its location.</div> |
||||
</li> |
||||
</ul> |
||||
|
||||
<p> |
||||
|
||||
<img src="nbdocs:/com/jme3/gde/core/docs/jme3/external/3dsmax_biped_3_1.png"> |
||||
|
||||
</p> |
||||
<ul> |
||||
<li><div> You can now play a bit with the settings, I adjusted "Actual Stride Length" and "Actual Stride Height". </div> |
||||
</li> |
||||
<li><div> For the "Number of Footsteps" 6 will be sufficient because the animation is cycled later.</div> |
||||
</li> |
||||
<li><div> <strong>Note:</strong> You can also create or edit footsteps by hand and move or rotate them.</div> |
||||
</li> |
||||
<li><div> After all footsteps are created, hit the "Create Keys for Inactive Footsteps" button in the "Footstep Operations" panel</div> |
||||
</li> |
||||
<li><div> You can now check your animation by pressing the "Play" button in the timeline.</div> |
||||
</li> |
||||
</ul> |
||||
|
||||
</div> |
||||
<!-- EDIT10 SECTION "Creating a simple walk animation" [7771-8582] --> |
||||
<h3><a>Preparing the export and setting up OgreMax</a></h3> |
||||
<div> |
||||
<ul> |
||||
<li><div> The "OgreMax Scene Settings" should be the same as shown above.</div> |
||||
</li> |
||||
<li><div> Because you want your animation to be looped, you've got to find two key frames where the legs are nearly in the same position. For my settings I've chosen the frames 48-78 for the walk animation.</div> |
||||
</li> |
||||
<li><div> Select the character mesh and open the "OgreMax Scene Settings" dialog. </div> |
||||
</li> |
||||
<li><div> Open the ???Mesh Animations??? tab and select type ???Skeleton???, ???Export Skeleton??? : ???Yes???</div> |
||||
</li> |
||||
<li><div> Below ???Mesh Animations??? hit the ???Add?????? button</div> |
||||
</li> |
||||
</ul> |
||||
|
||||
<p> |
||||
|
||||
<img src="nbdocs:/com/jme3/gde/core/docs/jme3/external/3dsmax_biped_4.png"> |
||||
|
||||
</p> |
||||
<ul> |
||||
<li><div> Enter a name for the track, e.g. "walk".</div> |
||||
</li> |
||||
<li><div> Assure the track type is set to "Physique".</div> |
||||
</li> |
||||
<li><div> Set the start and end frames, for me it is 48-78.</div> |
||||
</li> |
||||
<li><div> Close the dialog by pushing "Ok".</div> |
||||
</li> |
||||
<li><div> <strong>Note:</strong> It could be useful to create also a track "start_run", that blends between the stand and walk animation. I would use frame 0-47 for that.</div> |
||||
</li> |
||||
<li><div> Because you have a smooth model with a lot of polygons, it may be useful to create <a href="/com/jme3/gde/core/docs/jme3/advanced/mesh.html">levels of detail (LOD)</a>. When the camera is farther away, a low-poly mesh of your character will be rendered.</div> |
||||
</li> |
||||
</ul> |
||||
|
||||
<p> |
||||
|
||||
<img src="nbdocs:/com/jme3/gde/core/docs/jme3/external/3dsmax_biped_5.png"> |
||||
|
||||
</p> |
||||
<ul> |
||||
<li><div> Open the "Mesh LOD" tab in object settings.</div> |
||||
</li> |
||||
<li><div> It will suffice to select the "Automatic" setting, but if your animation starts to look weird, you can create them by hand.</div> |
||||
</li> |
||||
<li><div> I used 4 levels of LOD with a distance of 1. Don't worry about the distance setting, you can change it later in JME.</div> |
||||
</li> |
||||
<li><div> For the level reduction, I used 20 percent, which produce good results. You may adjust all the settings depending on your needs.</div> |
||||
</li> |
||||
<li><div> Close the dialoque by clicking "Ok".</div> |
||||
</li> |
||||
</ul> |
||||
|
||||
</div> |
||||
<!-- EDIT11 SECTION "Preparing the export and setting up OgreMax" [8583-10257] --> |
||||
<h3><a>Fixing the location</a></h3> |
||||
<div> |
||||
<ul> |
||||
<li><div> Before you export you need to do a little fix, because your model is not really located where you see it. JME will get into a lot of trouble, if you don't change that.</div> |
||||
</li> |
||||
<li><div> Assure to save the max file. Sometimes OgreMax crashes the whole application during export. If you want to change the animation after export, you should reload this file because fixing the location changes something I can't really figure out.</div> |
||||
</li> |
||||
</ul> |
||||
|
||||
<p> |
||||
|
||||
<img src="nbdocs:/com/jme3/gde/core/docs/jme3/external/3dsmax_biped_6.png"> |
||||
|
||||
</p> |
||||
<ul> |
||||
<li><div> Right click the "Select and Move" tool in the upper toolbar. A dialog will pop up.</div> |
||||
</li> |
||||
<li><div> Set the X and Y location to 0 and close the dialog.</div> |
||||
</li> |
||||
<li><div> There is another way to achieve this. If you have scaled, moved or rotated your model, just open the "Hierarchy" tab and click "Transform" and "Scale" on the "Reset" panel.</div> |
||||
</li> |
||||
</ul> |
||||
|
||||
</div> |
||||
<!-- EDIT12 SECTION "Fixing the location" [10258-11067] --> |
||||
<h3><a>Export and Import</a></h3> |
||||
<div> |
||||
<ul> |
||||
<li><div> Now you can export your scene. Select only the mesh and use "Export selected objects". You will not need the whole scene including the biped object, but the bones are created automatically during export.</div> |
||||
</li> |
||||
<li><div> Create a JME test class for the scene import.</div> |
||||
</li> |
||||
</ul> |
||||
|
||||
<p> |
||||
|
||||
For that, I extended the first class: |
||||
</p> |
||||
<pre>import com.jme3.animation.AnimChannel; |
||||
import com.jme3.animation.AnimControl; |
||||
import com.jme3.animation.Skeleton; |
||||
import com.jme3.app.SimpleApplication; |
||||
import com.jme3.asset.plugins.FileLocator; |
||||
import com.jme3.light.AmbientLight; |
||||
import com.jme3.light.PointLight; |
||||
import com.jme3.material.Material; |
||||
import com.jme3.math.ColorRGBA; |
||||
import com.jme3.math.Vector3f; |
||||
import com.jme3.scene.Geometry; |
||||
import com.jme3.scene.Node; |
||||
import com.jme3.scene.Spatial; |
||||
import com.jme3.scene.control.LodControl; |
||||
import com.jme3.scene.debug.SkeletonDebugger; |
||||
import com.jme3.scene.shape.Box; |
||||
|
||||
<span>/** |
||||
* This is a test class for loading a Ogre XML scene exported by OgreMax. |
||||
* |
||||
* @author Stephan Dreyer |
||||
* |
||||
*/</span> |
||||
public class TestOgreMaxImport extends SimpleApplication { |
||||
|
||||
@Override |
||||
public void simpleInitApp() { |
||||
assetManager.registerLocator("Assets/model/ogre/test/", FileLocator.class); |
||||
|
||||
// create the geometry and attach it |
||||
final Node model = (Node) assetManager.loadModel("guy.scene"); |
||||
// resize it, because of the large 3dsmax scales |
||||
model.setLocalScale(.02f); |
||||
|
||||
// attach to root node |
||||
rootNode.attachChild(model); |
||||
addLodControl(model); |
||||
|
||||
final AnimControl ac = findAnimControl(model); |
||||
|
||||
try { |
||||
// add a skeleton debugger to make bones visible |
||||
final Skeleton skel = ac.getSkeleton(); |
||||
final SkeletonDebugger skeletonDebug = new SkeletonDebugger("skeleton", |
||||
skel); |
||||
final Material mat = new Material(assetManager, |
||||
"Common/MatDefs/Misc/Unshaded.j3md"); |
||||
mat.setColor("Color", ColorRGBA.Green); |
||||
mat.getAdditionalRenderState().setDepthTest(false); |
||||
skeletonDebug.setMaterial(mat); |
||||
// model.attachChild(skeletonDebug); |
||||
|
||||
// create a channel and start the walk animation |
||||
final AnimChannel channel = ac.createChannel(); |
||||
channel.setAnim("walk"); |
||||
} catch (final Exception e) { |
||||
e.printStackTrace(); |
||||
} |
||||
|
||||
flyCam.setMoveSpeed(40f); |
||||
cam.setLocation(new Vector3f(15, 10, 15)); |
||||
cam.lookAt(Vector3f.ZERO, Vector3f.UNIT_Y); |
||||
cam.setFrustumNear(1f); |
||||
|
||||
// add some lights |
||||
rootNode.addLight(new AmbientLight()); |
||||
|
||||
final PointLight pl = new PointLight(); |
||||
pl.setPosition(new Vector3f(-3f, 3f, 1f)); |
||||
rootNode.addLight(pl); |
||||
|
||||
// add a box as floor |
||||
final Box b = new Box(100f, 0.1f, 100f); |
||||
final Geometry geo = new Geometry("floor", b); |
||||
|
||||
final Material mat = new Material(assetManager, |
||||
"Common/MatDefs/Misc/Unshaded.j3md"); |
||||
mat.setColor("Color", ColorRGBA.LightGray); |
||||
geo.setMaterial(mat); |
||||
|
||||
rootNode.attachChild(geo); |
||||
} |
||||
|
||||
<span>/** |
||||
* Method to traverse through the scene graph and add a {@link LodControl} to |
||||
* the mesh. |
||||
* |
||||
* @param parent |
||||
* The Node to add the control to. |
||||
*/</span> |
||||
public void addLodControl(final Spatial parent) { |
||||
if (parent instanceof Node) { |
||||
for (final Spatial s : ((Node) parent).getChildren()) { |
||||
addLodControl(s); |
||||
} |
||||
} else if (parent instanceof Geometry) { |
||||
final LodControl lc = new LodControl(); |
||||
|
||||
// the distance for LOD changes is set here, you may adjust this |
||||
lc.setDistTolerance(1f); |
||||
parent.addControl(lc); |
||||
} |
||||
} |
||||
|
||||
<span>/** |
||||
* Method to find the animation control, because it is not on the models root |
||||
* node. |
||||
* |
||||
* @param parent |
||||
* The spatial to search. |
||||
* @return The {@link AnimControl} or null if it does not exist. |
||||
*/</span> |
||||
public AnimControl findAnimControl(final Spatial parent) { |
||||
final AnimControl animControl = parent.getControl(AnimControl.class); |
||||
if (animControl != null) { |
||||
return animControl; |
||||
} |
||||
|
||||
if (parent instanceof Node) { |
||||
for (final Spatial s : ((Node) parent).getChildren()) { |
||||
final AnimControl animControl2 = findAnimControl(s); |
||||
if (animControl2 != null) { |
||||
return animControl2; |
||||
} |
||||
} |
||||
} |
||||
|
||||
return null; |
||||
} |
||||
|
||||
public static void main(final String[] args) { |
||||
new TestOgreMaxImport().start(); |
||||
} |
||||
}</pre> |
||||
|
||||
<p> |
||||
After starting the class, you can see a nice smooth walk animation (if it's not smooth, you need to adjust your track frames): |
||||
</p> |
||||
|
||||
<p> |
||||
<img src="nbdocs:/com/jme3/gde/core/docs/jme3/external/3dsmax_biped_7.png"> |
||||
</p> |
||||
|
||||
<p> |
||||
As you can see, the LOD is working: |
||||
</p> |
||||
|
||||
<p> |
||||
<img src="nbdocs:/com/jme3/gde/core/docs/jme3/external/3dsmax_biped_8.png"> |
||||
|
||||
</p> |
||||
|
||||
</div> |
||||
<!-- EDIT13 SECTION "Export and Import" [11068-] --> |
||||
<p><em><a href="http://jmonkeyengine.org/wiki/doku.php/jme3:external:3dsmax?do=export_xhtmlbody">view online version</a></em></p> |
After Width: | Height: | Size: 179 KiB |
After Width: | Height: | Size: 126 KiB |
After Width: | Height: | Size: 32 KiB |
After Width: | Height: | Size: 26 KiB |
After Width: | Height: | Size: 207 KiB |
After Width: | Height: | Size: 83 KiB |
After Width: | Height: | Size: 25 KiB |