use of com.jme3.math.Vector2f in project jmonkeyengine by jMonkeyEngine.
the class TestBrickWall method simpleInitApp.
@Override
public void simpleInitApp() {
bulletAppState = new BulletAppState();
bulletAppState.setThreadingType(BulletAppState.ThreadingType.PARALLEL);
stateManager.attach(bulletAppState);
bullet = new Sphere(32, 32, 0.4f, true, false);
bullet.setTextureMode(TextureMode.Projected);
bulletCollisionShape = new SphereCollisionShape(0.4f);
brick = new Box(bLength, bHeight, bWidth);
brick.scaleTextureCoordinates(new Vector2f(1f, .5f));
initMaterial();
initWall();
initFloor();
initCrossHairs();
this.cam.setLocation(new Vector3f(0, 6f, 6f));
cam.lookAt(Vector3f.ZERO, new Vector3f(0, 1, 0));
cam.setFrustumFar(15);
inputManager.addMapping("shoot", new MouseButtonTrigger(MouseInput.BUTTON_LEFT));
inputManager.addListener(actionListener, "shoot");
inputManager.addMapping("gc", new KeyTrigger(KeyInput.KEY_X));
inputManager.addListener(actionListener, "gc");
rootNode.setShadowMode(ShadowMode.Off);
bsr = new BasicShadowRenderer(assetManager, 256);
bsr.setDirection(new Vector3f(-1, -1, -1).normalizeLocal());
viewPort.addProcessor(bsr);
}
use of com.jme3.math.Vector2f in project jmonkeyengine by jMonkeyEngine.
the class TestFancyCar method findGeom.
// public void setupFloor() {
// Material mat = assetManager.loadMaterial("Textures/Terrain/BrickWall/BrickWall.j3m");
// mat.getTextureParam("DiffuseMap").getTextureValue().setWrap(WrapMode.Repeat);
//// mat.getTextureParam("NormalMap").getTextureValue().setWrap(WrapMode.Repeat);
//// mat.getTextureParam("ParallaxMap").getTextureValue().setWrap(WrapMode.Repeat);
//
// Box floor = new Box(Vector3f.ZERO, 140, 1f, 140);
// floor.scaleTextureCoordinates(new Vector2f(112.0f, 112.0f));
// Geometry floorGeom = new Geometry("Floor", floor);
// floorGeom.setShadowMode(ShadowMode.Receive);
// floorGeom.setMaterial(mat);
//
// PhysicsNode tb = new PhysicsNode(floorGeom, new MeshCollisionShape(floorGeom.getMesh()), 0);
// tb.setLocalTranslation(new Vector3f(0f, -6, 0f));
//// tb.attachDebugShape(assetManager);
// rootNode.attachChild(tb);
// getPhysicsSpace().add(tb);
// }
private Geometry findGeom(Spatial spatial, String name) {
if (spatial instanceof Node) {
Node node = (Node) spatial;
for (int i = 0; i < node.getQuantity(); i++) {
Spatial child = node.getChild(i);
Geometry result = findGeom(child, name);
if (result != null) {
return result;
}
}
} else if (spatial instanceof Geometry) {
if (spatial.getName().startsWith(name)) {
return (Geometry) spatial;
}
}
return null;
}
use of com.jme3.math.Vector2f in project jmonkeyengine by jMonkeyEngine.
the class TestBatchNodeTower method initFloor.
public void initFloor() {
Box floorBox = new Box(10f, 0.1f, 5f);
floorBox.scaleTextureCoordinates(new Vector2f(3, 6));
Geometry floor = new Geometry("floor", floorBox);
floor.setMaterial(mat3);
floor.setShadowMode(ShadowMode.Receive);
floor.setLocalTranslation(0, 0, 0);
floor.addControl(new RigidBodyControl(0));
this.rootNode.attachChild(floor);
this.getPhysicsSpace().add(floor);
}
use of com.jme3.math.Vector2f in project jmonkeyengine by jMonkeyEngine.
the class TangentBinormalGenerator method linkVertices.
private static ArrayList<VertexInfo> linkVertices(Mesh mesh, boolean splitMirrored) {
ArrayList<VertexInfo> vertexMap = new ArrayList<VertexInfo>();
FloatBuffer vertexBuffer = mesh.getFloatBuffer(Type.Position);
FloatBuffer normalBuffer = mesh.getFloatBuffer(Type.Normal);
FloatBuffer texcoordBuffer = mesh.getFloatBuffer(Type.TexCoord);
Vector3f position = new Vector3f();
Vector3f normal = new Vector3f();
Vector2f texCoord = new Vector2f();
final int size = vertexBuffer.limit() / 3;
for (int i = 0; i < size; i++) {
populateFromBuffer(position, vertexBuffer, i);
populateFromBuffer(normal, normalBuffer, i);
populateFromBuffer(texCoord, texcoordBuffer, i);
boolean found = false;
//separate vertice should have separate tangent space
if (!splitMirrored) {
for (int j = 0; j < vertexMap.size(); j++) {
VertexInfo vertexInfo = vertexMap.get(j);
if (approxEqual(vertexInfo.position, position) && approxEqual(vertexInfo.normal, normal) && approxEqual(vertexInfo.texCoord, texCoord)) {
vertexInfo.indices.add(i);
found = true;
break;
}
}
}
if (!found) {
VertexInfo vertexInfo = new VertexInfo(position.clone(), normal.clone(), texCoord.clone());
vertexInfo.indices.add(i);
vertexMap.add(vertexInfo);
}
}
return vertexMap;
}
use of com.jme3.math.Vector2f in project jmonkeyengine by jMonkeyEngine.
the class TangentBinormalGenerator method processTriangleFan.
private static List<VertexData> processTriangleFan(Mesh mesh, int[] index, Vector3f[] v, Vector2f[] t) {
IndexBuffer indexBuffer = mesh.getIndexBuffer();
FloatBuffer vertexBuffer = (FloatBuffer) mesh.getBuffer(Type.Position).getData();
FloatBuffer textureBuffer = (FloatBuffer) mesh.getBuffer(Type.TexCoord).getData();
List<VertexData> vertices = initVertexData(vertexBuffer.limit() / 3);
index[0] = indexBuffer.get(0);
index[1] = indexBuffer.get(1);
populateFromBuffer(v[0], vertexBuffer, index[0]);
populateFromBuffer(v[1], vertexBuffer, index[1]);
populateFromBuffer(t[0], textureBuffer, index[0]);
populateFromBuffer(t[1], textureBuffer, index[1]);
for (int i = 2; i < vertexBuffer.limit() / 3; i++) {
index[2] = indexBuffer.get(i);
populateFromBuffer(v[2], vertexBuffer, index[2]);
populateFromBuffer(t[2], textureBuffer, index[2]);
TriangleData triData = processTriangle(index, v, t);
vertices.get(index[0]).triangles.add(triData);
vertices.get(index[1]).triangles.add(triData);
vertices.get(index[2]).triangles.add(triData);
Vector3f vTemp = v[1];
v[1] = v[2];
v[2] = vTemp;
Vector2f tTemp = t[1];
t[1] = t[2];
t[2] = tTemp;
index[1] = index[2];
}
return vertices;
}
Aggregations