Fehler im Importer behoben - weitere Models importiert
This commit is contained in:
@@ -6805,15 +6805,14 @@ public class EditorApp extends Application {
|
||||
modelImportLod2StatusLabel.setText("(nicht gesetzt)");
|
||||
});
|
||||
|
||||
// ── Export ────────────────────────────────────────────────────────────
|
||||
Label exportTitle = new Label("Export");
|
||||
exportTitle.setStyle("-fx-font-weight:bold; -fx-text-fill:#ccc;");
|
||||
|
||||
Label assetNameLabel = new Label("Asset-Name:");
|
||||
assetNameLabel.setStyle("-fx-text-fill:#aaa;");
|
||||
// ── Dateiname ──────────────────────────────────────────────────────────
|
||||
Label fileNameLabel = new Label("Dateiname:");
|
||||
fileNameLabel.setStyle("-fx-font-weight:bold; -fx-text-fill:#ccc;");
|
||||
TextField nameTF = new TextField(suggestedName);
|
||||
nameTF.setStyle("-fx-background-color:#3a3a4e; -fx-text-fill:#eee;");
|
||||
nameTF.setPromptText("asset-name");
|
||||
|
||||
// ── Export ────────────────────────────────────────────────────────────
|
||||
modelImportExportStatusLabel = new Label("");
|
||||
modelImportExportStatusLabel.setStyle("-fx-text-fill:#8cf; -fx-font-size:11;");
|
||||
modelImportExportStatusLabel.setWrapText(true);
|
||||
@@ -6840,6 +6839,8 @@ public class EditorApp extends Application {
|
||||
panel.getChildren().addAll(
|
||||
title,
|
||||
new Separator(),
|
||||
fileNameLabel, nameTF,
|
||||
new Separator(),
|
||||
scaleTitle, modelEditorUniformCB, scaleGrid, modelEditorDimLabel, modelEditorPolyLabel,
|
||||
new Separator(),
|
||||
algoTitle, algoBlightRB, algoJmeRB,
|
||||
@@ -6848,8 +6849,7 @@ public class EditorApp extends Application {
|
||||
new Separator(),
|
||||
lod2Title, lod2MeshRB, lod2FileRB, lod2GenBtn, modelImportLod2StatusLabel, modelImportLod2ClearBtn,
|
||||
new Separator(),
|
||||
exportTitle, assetNameLabel, nameTF, modelImportExportStatusLabel,
|
||||
exportBtn, cancelBtn
|
||||
modelImportExportStatusLabel, exportBtn, cancelBtn
|
||||
);
|
||||
return panel;
|
||||
}
|
||||
|
||||
@@ -762,6 +762,7 @@ public class ModelEditorState extends BaseAppState {
|
||||
embeddedLodSpatials[0].setCullHint(Spatial.CullHint.Inherit);
|
||||
}
|
||||
|
||||
if (embeddedLodSpatials == null) return;
|
||||
boolean anyLodLeft = false;
|
||||
for (int i = 1; i < embeddedLodSpatials.length; i++) {
|
||||
if (embeddedLodSpatials[i] != null) { anyLodLeft = true; break; }
|
||||
|
||||
@@ -36,9 +36,12 @@ import com.jme3.texture.Image;
|
||||
import com.jme3.texture.Texture2D;
|
||||
import com.jme3.util.BufferUtils;
|
||||
|
||||
import de.blight.common.ModelMeta;
|
||||
import de.blight.common.ModelMetaIO;
|
||||
import de.blight.editor.SharedInput;
|
||||
import de.blight.editor.util.ImpostorUtil;
|
||||
import de.blight.editor.util.MeshUtils;
|
||||
import de.blight.editor.state.ThumbnailRenderer;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
@@ -353,9 +356,12 @@ public class ModelImportState extends BaseAppState {
|
||||
lod0.updateGeometricState();
|
||||
|
||||
float translationY = 0f;
|
||||
boolean solid = true;
|
||||
com.jme3.bounding.BoundingVolume bv = lod0.getWorldBound();
|
||||
if (bv instanceof com.jme3.bounding.BoundingBox bb) {
|
||||
translationY = -(bb.getCenter().y - bb.getYExtent()) + pivotY;
|
||||
// Extents sind Halbmaße → volle Größe = 2×Extent; Grenze 25cm = 0.125f Halbmaß
|
||||
solid = !(bb.getXExtent() < 0.125f && bb.getYExtent() < 0.125f && bb.getZExtent() < 0.125f);
|
||||
}
|
||||
lod0.setLocalTranslation(0f, translationY, 0f);
|
||||
ModelExportUtil.bakeTransform(lod0, new Matrix4f());
|
||||
@@ -406,6 +412,28 @@ public class ModelImportState extends BaseAppState {
|
||||
BinaryExporter.getInstance().save(root, outFile);
|
||||
log.info("[ModelImport] Exportiert: {}", outFile.getAbsolutePath());
|
||||
|
||||
// Meta-Datei mit Auto-Kollision anlegen (überschreibbar im Model-Editor)
|
||||
try {
|
||||
ModelMeta def = ModelMeta.defaults(fileName + ".j3o");
|
||||
ModelMeta meta = new ModelMeta(
|
||||
def.name(), def.category(), def.tags(),
|
||||
def.scaleX(), def.scaleY(), def.scaleZ(),
|
||||
def.uniformScale(), def.pivotOffsetY(), def.placementOffsetY(),
|
||||
solid, def.castShadow(), def.receiveShadow(),
|
||||
def.randomScaleMin(), def.randomScaleMax(),
|
||||
def.lod1Path(), def.lod2Path(),
|
||||
def.lod1Distance(), def.lod2Distance(), def.cullDistance(),
|
||||
def.attachedLights(), def.attachedEmitters(),
|
||||
def.interactableType(),
|
||||
def.interactableOffsetX(), def.interactableOffsetY(),
|
||||
def.interactableOffsetZ(), def.interactableRotY(),
|
||||
def.footstepSurface());
|
||||
ModelMetaIO.save(meta, outFile.toPath());
|
||||
log.info("[ModelImport] Meta erstellt: solid={}", solid);
|
||||
} catch (IOException e) {
|
||||
log.warn("[ModelImport] Meta konnte nicht erstellt werden: {}", e.getMessage());
|
||||
}
|
||||
|
||||
String relPath = "Models/imported/" + fileName + ".j3o";
|
||||
|
||||
// Asset-Cache invalidieren: JME cached geladene Modelle. Ohne diesen
|
||||
@@ -414,6 +442,22 @@ public class ModelImportState extends BaseAppState {
|
||||
// nach einem Editor-Neustart oder im Spiel (dort kein Cache vorhanden).
|
||||
assets.deleteFromCache(new com.jme3.asset.ModelKey(relPath));
|
||||
|
||||
// Zwischendatei löschen wenn der Nutzer einen anderen Dateinamen gewählt hat.
|
||||
// SceneObjectState hat die Quelldatei unter dem originalen Dateinamen als .j3o
|
||||
// gespeichert; erst performExport() bäckt Scale + Pivot in die Ziel-Datei.
|
||||
String intermediateRel = input.modelEditorOpenPath != null
|
||||
? input.modelEditorOpenPath.replace('\\', '/') : null;
|
||||
if (intermediateRel != null && !intermediateRel.equals(relPath)) {
|
||||
Path intermediateAbs = ASSET_ROOT.resolve(intermediateRel);
|
||||
try {
|
||||
Files.deleteIfExists(intermediateAbs);
|
||||
assets.deleteFromCache(new com.jme3.asset.ModelKey(intermediateRel));
|
||||
Files.deleteIfExists(ThumbnailRenderer.sidecarPath(intermediateAbs, ASSET_ROOT));
|
||||
} catch (IOException ex) {
|
||||
log.warn("[ModelImport] Zwischendatei konnte nicht gelöscht werden: {}", ex.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
input.modelImportExportStatus = "Gespeichert: " + relPath;
|
||||
input.refreshAssets = true;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user