Bugfixes, weitere Vegetationsgeneratoren hinzugefügt

This commit is contained in:
2026-07-25 20:16:13 +02:00
parent 574bad3d67
commit d7aeb890c9
66 changed files with 2379 additions and 173 deletions

View File

@@ -59,14 +59,14 @@ public class AmbientParticlesState extends BaseAppState {
private float scanTimer = 0f;
private static final String[] LEAF_TEX_PATHS = {
"Textures/internal/leavesfilter/leaf1.png",
"Textures/internal/leavesfilter/leaf2.png",
"Textures/internal/leavesfilter/leaf3.png",
"Textures/internal/leavesfilter/leaf4.png",
"Textures/internal/leavesfilter/leaf5.png",
"Textures/internal/leavesfilter/leaf6.png",
"Textures/internal/leavesfilter/leaf7.png",
"Textures/internal/leavesfilter/leaf8.png",
"Textures/internal/leafFilter/leaf1.png",
"Textures/internal/leafFilter/leaf2.png",
"Textures/internal/leafFilter/leaf3.png",
"Textures/internal/leafFilter/leaf4.png",
"Textures/internal/leafFilter/leaf5.png",
"Textures/internal/leafFilter/leaf6.png",
"Textures/internal/leafFilter/leaf7.png",
"Textures/internal/leafFilter/leaf8.png",
};
@SuppressWarnings("deprecation") private ParticleEmitter[] leafEmitters;

View File

@@ -8,6 +8,7 @@ import com.jme3.asset.plugins.FileLocator;
import com.jme3.bullet.BulletAppState;
import com.jme3.bullet.collision.shapes.CapsuleCollisionShape;
import com.jme3.bullet.collision.shapes.CompoundCollisionShape;
import com.jme3.bullet.collision.shapes.MeshCollisionShape;
import com.jme3.bullet.control.RigidBodyControl;
import com.jme3.bullet.util.CollisionShapeFactory;
import com.jme3.bounding.BoundingBox;
@@ -108,7 +109,22 @@ public class WorldObjectsState extends BaseAppState {
// Baum-Stammkollision: Capsule statt Vollmesh (Blätter ausgeschlossen)
String objPath = m.modelPath() != null ? m.modelPath() : "";
if (objPath.startsWith("Models/trees/") && bulletAppState != null) {
if (objPath.contains("/grapevine/") && bulletAppState != null) {
try {
s.updateGeometricState();
if (s instanceof Node vineNode) {
CompoundCollisionShape compound = new CompoundCollisionShape();
collectGrapevineShapes(vineNode, compound);
if (!compound.getChildren().isEmpty()) {
RigidBodyControl rbc = new RigidBodyControl(compound, 0f);
s.addControl(rbc);
bulletAppState.getPhysicsSpace().add(rbc);
}
}
} catch (Exception pe) {
log.warn("[WorldObjects] Grapevine-Physik für '{}' nicht erzeugbar: {}", m.modelPath(), pe.getMessage());
}
} else if (objPath.startsWith("Models/trees/") && bulletAppState != null) {
try {
s.updateGeometricState();
float treeHeight = 6f;
@@ -549,4 +565,18 @@ public class WorldObjectsState extends BaseAppState {
mat.setFloat("Wetness", w);
}
}
/** Sammelt Bark- und Wire-Geometrien der Grapevine als exakte Mesh-Shapes. */
private static void collectGrapevineShapes(Node node, CompoundCollisionShape compound) {
for (Spatial child : node.getChildren()) {
if (child instanceof Geometry geo) {
String n = geo.getName();
if ("bark".equals(n) || "wires".equals(n)) {
compound.addChildShape(new MeshCollisionShape(geo.getMesh()), Vector3f.ZERO);
}
} else if (child instanceof Node sub) {
collectGrapevineShapes(sub, compound);
}
}
}
}