use of com.jme3.asset.AssetManager in project jmonkeyengine by jMonkeyEngine.
the class TestOgreComplexAnim method simpleInitApp.
@Override
public void simpleInitApp() {
flyCam.setMoveSpeed(10f);
cam.setLocation(new Vector3f(6.4013605f, 7.488437f, 12.843031f));
cam.setRotation(new Quaternion(-0.060740203f, 0.93925786f, -0.2398315f, -0.2378785f));
DirectionalLight dl = new DirectionalLight();
dl.setDirection(new Vector3f(-0.1f, -0.7f, -1).normalizeLocal());
dl.setColor(new ColorRGBA(1f, 1f, 1f, 1.0f));
rootNode.addLight(dl);
Node model = (Node) assetManager.loadModel("Models/Oto/Oto.mesh.xml");
control = model.getControl(AnimControl.class);
AnimChannel feet = control.createChannel();
AnimChannel leftHand = control.createChannel();
AnimChannel rightHand = control.createChannel();
// feet will dodge
feet.addFromRootBone("hip.right");
feet.addFromRootBone("hip.left");
feet.setAnim("Dodge");
feet.setSpeed(2);
feet.setLoopMode(LoopMode.Cycle);
// will blend over 15 seconds to stand
feet.setAnim("Walk", 15);
feet.setSpeed(0.25f);
feet.setLoopMode(LoopMode.Cycle);
// left hand will pull
leftHand.addFromRootBone("uparm.right");
leftHand.setAnim("pull");
leftHand.setSpeed(.5f);
// will blend over 15 seconds to stand
leftHand.setAnim("stand", 15);
// right hand will push
rightHand.addBone("spinehigh");
rightHand.addFromRootBone("uparm.left");
rightHand.setAnim("push");
SkeletonDebugger skeletonDebug = new SkeletonDebugger("skeleton", control.getSkeleton());
Material mat = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md");
mat.getAdditionalRenderState().setWireframe(true);
mat.setColor("Color", ColorRGBA.Green);
mat.getAdditionalRenderState().setDepthTest(false);
skeletonDebug.setMaterial(mat);
model.attachChild(skeletonDebug);
rootNode.attachChild(model);
}
use of com.jme3.asset.AssetManager in project jmonkeyengine by jMonkeyEngine.
the class TestSkeletonControlRefresh method setupFloor.
public void setupFloor() {
Quad q = new Quad(20, 20);
q.scaleTextureCoordinates(Vector2f.UNIT_XY.mult(10));
Geometry geom = new Geometry("floor", q);
Material mat = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md");
mat.setColor("Color", ColorRGBA.White);
geom.setMaterial(mat);
geom.rotate(-FastMath.HALF_PI, 0, 0);
geom.center();
geom.move(0, -0.3f, 0);
geom.setShadowMode(RenderQueue.ShadowMode.Receive);
rootNode.attachChild(geom);
}
use of com.jme3.asset.AssetManager in project jmonkeyengine by jMonkeyEngine.
the class TestBillboard method simpleInitApp.
public void simpleInitApp() {
flyCam.setMoveSpeed(10);
Quad q = new Quad(2, 2);
Geometry g = new Geometry("Quad", q);
Material mat = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md");
mat.setColor("Color", ColorRGBA.Blue);
g.setMaterial(mat);
Quad q2 = new Quad(1, 1);
Geometry g3 = new Geometry("Quad2", q2);
Material mat2 = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md");
mat2.setColor("Color", ColorRGBA.Yellow);
g3.setMaterial(mat2);
g3.setLocalTranslation(.5f, .5f, .01f);
Box b = new Box(.25f, .5f, .25f);
Geometry g2 = new Geometry("Box", b);
g2.setLocalTranslation(0, 0, 3);
g2.setMaterial(mat);
Node bb = new Node("billboard");
BillboardControl control = new BillboardControl();
bb.addControl(control);
bb.attachChild(g);
bb.attachChild(g3);
n = new Node("parent");
n.attachChild(g2);
n.attachChild(bb);
rootNode.attachChild(n);
n2 = new Node("parentParent");
n2.setLocalTranslation(Vector3f.UNIT_X.mult(5));
n2.attachChild(n);
rootNode.attachChild(n2);
// rootNode.attachChild(bb);
// rootNode.attachChild(g2);
}
use of com.jme3.asset.AssetManager in project jmonkeyengine by jMonkeyEngine.
the class TestBox method simpleInitApp.
@Override
public void simpleInitApp() {
Box b = new Box(1, 1, 1);
Geometry geom = new Geometry("Box", b);
Material mat = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md");
mat.setTexture("ColorMap", assetManager.loadTexture("Interface/Logo/Monkey.jpg"));
geom.setMaterial(mat);
rootNode.attachChild(geom);
}
use of com.jme3.asset.AssetManager in project jmonkeyengine by jMonkeyEngine.
the class TestCustomMesh method simpleInitApp.
@Override
public void simpleInitApp() {
Mesh m = new Mesh();
// Vertex positions in space
Vector3f[] vertices = new Vector3f[4];
vertices[0] = new Vector3f(0, 0, 0);
vertices[1] = new Vector3f(3, 0, 0);
vertices[2] = new Vector3f(0, 3, 0);
vertices[3] = new Vector3f(3, 3, 0);
// Texture coordinates
Vector2f[] texCoord = new Vector2f[4];
texCoord[0] = new Vector2f(0, 0);
texCoord[1] = new Vector2f(1, 0);
texCoord[2] = new Vector2f(0, 1);
texCoord[3] = new Vector2f(1, 1);
// Indexes. We define the order in which mesh should be constructed
short[] indexes = { 2, 0, 1, 1, 3, 2 };
// Setting buffers
m.setBuffer(Type.Position, 3, BufferUtils.createFloatBuffer(vertices));
m.setBuffer(Type.TexCoord, 2, BufferUtils.createFloatBuffer(texCoord));
m.setBuffer(Type.Index, 1, BufferUtils.createShortBuffer(indexes));
m.updateBound();
// *************************************************************************
// First mesh uses one solid color
// *************************************************************************
// Creating a geometry, and apply a single color material to it
Geometry geom = new Geometry("OurMesh", m);
Material mat = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md");
mat.setColor("Color", ColorRGBA.Blue);
geom.setMaterial(mat);
// Attaching our geometry to the root node.
rootNode.attachChild(geom);
// *************************************************************************
// Second mesh uses vertex colors to color each vertex
// *************************************************************************
Mesh cMesh = m.clone();
Geometry coloredMesh = new Geometry("ColoredMesh", cMesh);
Material matVC = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md");
matVC.setBoolean("VertexColor", true);
//We have 4 vertices and 4 color values for each of them.
//If you have more vertices, you need 'new float[yourVertexCount * 4]' here!
float[] colorArray = new float[4 * 4];
int colorIndex = 0;
//Set custom RGBA value for each Vertex. Values range from 0.0f to 1.0f
for (int i = 0; i < 4; i++) {
// Red value (is increased by .2 on each next vertex here)
colorArray[colorIndex++] = 0.1f + (.2f * i);
// Green value (is reduced by .2 on each next vertex)
colorArray[colorIndex++] = 0.9f - (0.2f * i);
// Blue value (remains the same in our case)
colorArray[colorIndex++] = 0.5f;
// Alpha value (no transparency set here)
colorArray[colorIndex++] = 1.0f;
}
// Set the color buffer
cMesh.setBuffer(Type.Color, 4, colorArray);
coloredMesh.setMaterial(matVC);
// move mesh a bit so that it doesn't intersect with the first one
coloredMesh.setLocalTranslation(4, 0, 0);
rootNode.attachChild(coloredMesh);
// /** Alternatively, you can show the mesh vertixes as points
// * instead of coloring the faces. */
// cMesh.setMode(Mesh.Mode.Points);
// cMesh.setPointSize(10f);
// cMesh.updateBound();
// cMesh.setStatic();
// Geometry points = new Geometry("Points", m);
// points.setMaterial(mat);
// rootNode.attachChild(points);
// *************************************************************************
// Third mesh will use a wireframe shader to show wireframe
// *************************************************************************
Mesh wfMesh = m.clone();
Geometry wfGeom = new Geometry("wireframeGeometry", wfMesh);
Material matWireframe = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md");
matWireframe.setColor("Color", ColorRGBA.Green);
matWireframe.getAdditionalRenderState().setWireframe(true);
wfGeom.setMaterial(matWireframe);
wfGeom.setLocalTranslation(4, 4, 0);
rootNode.attachChild(wfGeom);
}
Aggregations