use of com.jme3.math.Vector2f in project jmonkeyengine by jMonkeyEngine.
the class TestRagdollCharacter method initWall.
public void initWall(float bLength, float bWidth, float bHeight) {
Box brick = new Box(bLength, bHeight, bWidth);
brick.scaleTextureCoordinates(new Vector2f(1f, .5f));
Material mat2 = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md");
TextureKey key = new TextureKey("Textures/Terrain/BrickWall/BrickWall.jpg");
key.setGenerateMips(true);
Texture tex = assetManager.loadTexture(key);
mat2.setTexture("ColorMap", tex);
float startpt = bLength / 4;
float height = -5;
for (int j = 0; j < 15; j++) {
for (int i = 0; i < 4; i++) {
Vector3f ori = new Vector3f(i * bLength * 2 + startpt, bHeight + height, -10);
Geometry reBoxg = new Geometry("brick", brick);
reBoxg.setMaterial(mat2);
reBoxg.setLocalTranslation(ori);
//for geometry with sphere mesh the physics system automatically uses a sphere collision shape
reBoxg.addControl(new RigidBodyControl(1.5f));
reBoxg.setShadowMode(ShadowMode.CastAndReceive);
reBoxg.getControl(RigidBodyControl.class).setFriction(0.6f);
this.rootNode.attachChild(reBoxg);
this.getPhysicsSpace().add(reBoxg);
}
startpt = -startpt;
height += 2 * bHeight;
}
}
use of com.jme3.math.Vector2f in project jmonkeyengine by jMonkeyEngine.
the class TestWalkingChar method createWall.
private void createWall() {
float xOff = -144;
float zOff = -40;
float startpt = bLength / 4 - xOff;
float height = 6.1f;
brick = new Box(bLength, bHeight, bWidth);
brick.scaleTextureCoordinates(new Vector2f(1f, .5f));
for (int j = 0; j < 15; j++) {
for (int i = 0; i < 4; i++) {
Vector3f vt = new Vector3f(i * bLength * 2 + startpt, bHeight + height, zOff);
addBrick(vt);
}
startpt = -startpt;
height += 1.01f * bHeight;
}
}
use of com.jme3.math.Vector2f in project jmonkeyengine by jMonkeyEngine.
the class FbxMesh method toIRMesh.
/**
* Convert FBXMesh to IRMesh.
*/
public IrMesh toIRMesh() {
IrMesh newMesh = new IrMesh();
newMesh.polygons = new IrPolygon[polygons.length];
int polygonVertexIndex = 0;
int positionIndex = 0;
FbxLayer layer0 = layers[0];
FbxLayer layer1 = layers.length > 1 ? layers[1] : null;
for (int i = 0; i < polygons.length; i++) {
FbxPolygon polygon = polygons[i];
IrPolygon irPolygon = new IrPolygon();
irPolygon.vertices = new IrVertex[polygon.indices.length];
for (int j = 0; j < polygon.indices.length; j++) {
positionIndex = polygon.indices[j];
IrVertex irVertex = new IrVertex();
irVertex.pos = positions[positionIndex];
if (layer0 != null) {
irVertex.norm = (Vector3f) layer0.getVertexData(FbxLayerElement.Type.Normal, i, polygonVertexIndex, positionIndex, 0);
irVertex.tang = (Vector3f) layer0.getVertexData(FbxLayerElement.Type.Tangent, i, polygonVertexIndex, positionIndex, 0);
irVertex.bitang = (Vector3f) layer0.getVertexData(FbxLayerElement.Type.Binormal, i, polygonVertexIndex, positionIndex, 0);
irVertex.uv0 = (Vector2f) layer0.getVertexData(FbxLayerElement.Type.UV, i, polygonVertexIndex, positionIndex, 0);
irVertex.color = (ColorRGBA) layer0.getVertexData(FbxLayerElement.Type.Color, i, polygonVertexIndex, positionIndex, 0);
irVertex.material = (Integer) layer0.getVertexData(FbxLayerElement.Type.Material, i, polygonVertexIndex, positionIndex, 0);
irVertex.smoothing = (Integer) layer0.getVertexData(FbxLayerElement.Type.Smoothing, i, polygonVertexIndex, positionIndex, 0);
}
if (layer1 != null) {
irVertex.uv1 = (Vector2f) layer1.getVertexData(FbxLayerElement.Type.UV, i, polygonVertexIndex, positionIndex, 0);
}
if (boneIndices != null) {
ArrayList<Integer> boneIndicesForVertex = boneIndices[positionIndex];
ArrayList<Float> boneWeightsForVertex = boneWeights[positionIndex];
if (boneIndicesForVertex != null) {
irVertex.boneWeightsIndices = toBoneWeightIndices(boneIndicesForVertex, boneWeightsForVertex);
}
}
irPolygon.vertices[j] = irVertex;
polygonVertexIndex++;
}
newMesh.polygons[i] = irPolygon;
}
// Ensure "inspection vertex" specifies that mesh has bone indices / weights
if (boneIndices != null && newMesh.polygons[0].vertices[0] == null) {
newMesh.polygons[0].vertices[0].boneWeightsIndices = new IrBoneWeightIndex[0];
}
return newMesh;
}
use of com.jme3.math.Vector2f in project jmonkeyengine by jMonkeyEngine.
the class TestBrickTower method simpleInitApp.
@Override
public void simpleInitApp() {
bulletAppState = new BulletAppState();
bulletAppState.setThreadingType(BulletAppState.ThreadingType.PARALLEL);
// bulletAppState.setEnabled(false);
stateManager.attach(bulletAppState);
bullet = new Sphere(32, 32, 0.4f, true, false);
bullet.setTextureMode(TextureMode.Projected);
bulletCollisionShape = new SphereCollisionShape(0.4f);
brick = new Box(brickWidth, brickHeight, brickDepth);
brick.scaleTextureCoordinates(new Vector2f(1f, .5f));
//bulletAppState.getPhysicsSpace().enableDebug(assetManager);
initMaterial();
initTower();
initFloor();
initCrossHairs();
this.cam.setLocation(new Vector3f(0, 25f, 8f));
cam.lookAt(Vector3f.ZERO, new Vector3f(0, 1, 0));
cam.setFrustumFar(80);
inputManager.addMapping("shoot", new MouseButtonTrigger(MouseInput.BUTTON_LEFT));
inputManager.addListener(actionListener, "shoot");
rootNode.setShadowMode(ShadowMode.Off);
bsr = new PssmShadowRenderer(assetManager, 1024, 2);
bsr.setDirection(new Vector3f(-1, -1, -1).normalizeLocal());
bsr.setLambda(0.55f);
bsr.setShadowIntensity(0.6f);
bsr.setCompareMode(CompareMode.Hardware);
bsr.setFilterMode(FilterMode.PCF4);
viewPort.addProcessor(bsr);
}
use of com.jme3.math.Vector2f in project jmonkeyengine by jMonkeyEngine.
the class TestBrickTower 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);
}
Aggregations