Skip to content

Commit

Permalink
u1/ut99/uc2/ut2003/4->ut4: mover brushes are now converted into stati…
Browse files Browse the repository at this point in the history
…cmeshes
  • Loading branch information
xtremexp committed Jan 25, 2023
1 parent 1594b75 commit df260eb
Show file tree
Hide file tree
Showing 13 changed files with 366 additions and 162 deletions.
14 changes: 12 additions & 2 deletions src/main/java/org/xtx/ut4converter/MapConverter.java
Original file line number Diff line number Diff line change
Expand Up @@ -851,7 +851,7 @@ private String listMatAndGetNewMatName(final String matName) {
return null;
}

private File getDummyUAssetFile(){
public File getDummyUAssetFile(){
// TODO for UE5, make custom dummy uasset file
return new File(outputGame.getPath() + "/UnrealTournament/Content/RestrictedAssets/Blueprints/Lift/Curves/EaseIn-Out.uasset");
}
Expand Down Expand Up @@ -1146,7 +1146,17 @@ private static File getBaseConvertFolder() {
* @return <UT4ConverterFolder>/Converted/<MapName>
*/
public File getMapConvertFolder() {
return new File(getBaseConvertFolder() + File.separator + getInMap().getName().split("\\.")[0]);
return new File(getBaseConvertFolder() + File.separator + getInMapAsPackageName());
}

/**
* Return map file as package name.
* E.G: 'Passage.unr' -> 'Passage'
*
* @return Map as package name
*/
public String getInMapAsPackageName() {
return getInMap().getName().split("\\.")[0];
}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/org/xtx/ut4converter/SupportedClasses.java
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ private void initialize() {
final boolean useUbClasses = mapConverter.isUseUbClasses() && mapConverter.isFrom(UnrealEngine.UE1, UnrealEngine.UE2);

registerUClass(mapConverter.isFrom(UnrealEngine.UE1) ? T3DMover.class : T3DMoverSM.class, "Mover", "AttachMover", "AssertMover", "RotatingMover", "ElevatorMover", "MixMover", "GradualMover",
"LoopMover", "InterpActor");
"LoopMover", "InterpActor", "ClientMover");

if(useUbClasses) {
registerUClass(T3DGradualMover.class, "GradualMover");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,6 @@ public Set<File> extract(UPackageRessource ressource, boolean forceExport, boole

for (String logLine : logLines) {

System.out.println(logLine);
logger.log(Level.FINE, logLine);

if (logLine.startsWith("Exporting") && !logLine.startsWith("Exporting objects")) {
Expand Down
39 changes: 17 additions & 22 deletions src/main/java/org/xtx/ut4converter/t3d/MoverProperties.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public class MoverProperties implements T3D {
* Sounds used by movers when it started moving, is moving ... TODO make a
* list of UPackageRessource binded with some property name
*/
private UPackageRessource closedSound, closingSound, openedSound, openingSound, moveAmbientSound;
protected UPackageRessource closedSound, closingSound, openedSound, openingSound, moveAmbientSound;

/**
* CHECK usage?
Expand Down Expand Up @@ -59,19 +59,19 @@ public class MoverProperties implements T3D {
/**
* How long it takes for the mover to get to next position
*/
private Double moveTime;
protected double moveTime;

/**
* How long the mover stay static in his final position before returning to
* home
*/
private Double stayOpenTime;
protected double stayOpenTime;

/**
* How long time the mover is available again after getting back to home
* position
*/
private Double delayTime;
protected Double delayTime;

private final T3DActor mover;

Expand All @@ -86,9 +86,9 @@ public class MoverProperties implements T3D {

private BumpType bumpType;

private MoverEncroachType moverEncroachType;
protected MoverEncroachType moverEncroachType;

private MoverGlideType moverGlideType;
protected MoverGlideType moverGlideType;

/**
* Default number of keys a mover has assuming, first key is initial position
Expand Down Expand Up @@ -118,6 +118,13 @@ public MoverProperties(T3DActor mover, MapConverter mapConverter) {
mover.registerSimpleProperty("OtherTime", Float.class);
mover.registerSimpleProperty("PlayerBumpEvent", String.class);
mover.registerSimpleProperty("AttachTag", String.class);

// UE1/UE2 default values
// UE3 no default values since movement is managed via matinee
this.moveTime = 1d;
this.stayOpenTime = 4d;
this.moverEncroachType = MoverEncroachType.ME_ReturnWhenEncroach;
this.moverGlideType = MoverGlideType.MV_GlideByTime;
}

enum BumpType {
Expand Down Expand Up @@ -330,9 +337,7 @@ public void writeUT4MoverActor(final StringBuilder sbf) {
sbf.append(IDT).append("\tScene1=Scene\n");
sbf.append(IDT).append("\tRootComponent=Scene1\n");

if (moveTime != null) {
sbf.append(IDT).append("\tLift Time=").append(moveTime).append("\n");
}
sbf.append(IDT).append("\tLift Time=").append(moveTime).append("\n");

// TODO handle multi position / rotation later
// because we use last position but there might more than one position !
Expand Down Expand Up @@ -418,9 +423,7 @@ public void writeUT4MoverActor(final StringBuilder sbf) {
sbf.append(IDT).append("\tMoveLoopSound=None\n");
}

if (stayOpenTime != null) {
sbf.append(IDT).append("\tWait at top time=").append(stayOpenTime).append("\n");
}
sbf.append(IDT).append("\tWait at top time=").append(stayOpenTime).append("\n");

if (delayTime != null) {
sbf.append(IDT).append("\tRetrigger Delay=").append(delayTime).append("\n");
Expand Down Expand Up @@ -453,11 +456,9 @@ public void writeUT4MoverActor(final StringBuilder sbf) {
sbf.append(IDT).append("\tLift Mesh=StaticMesh'").append(moverSm.getStaticMesh().getConvertedName()).append("'\n");
}
}
/*
* disabled until mesh is good
else if (mover instanceof T3DMover moverBrush) {
sbf.append(IDT).append("\tLift Mesh=StaticMesh'").append(moverBrush.getStaticMeshReference()).append("'\n");
}*/
}

mover.writeSimpleProperties();

Expand All @@ -471,12 +472,6 @@ public void convert() {
// A_Movers.Movers.Elevator01.Loop -> A_Movers.Movers.Elevator01.LoopCue
final boolean isFromUe3 = mapConverter.isFrom(UnrealEngine.UE3);

if(stayOpenTime == null){
// default stay open time with UE1 (TODO check UE2/UE3)
stayOpenTime = 4d;
}


if(mapConverter.convertSounds()) {
if (openingSound != null) {
openingSound.export(UTPackageExtractor.getExtractor(mover.mapConverter, openingSound), !isFromUe3);
Expand Down Expand Up @@ -509,7 +504,7 @@ public void convert() {
// as see, with Dig (Unreal 1 map)
// if movetime = 0, then mover won't move at all
// so need to force to some tiny value
if(moveTime != null && moveTime == 0d){
if (moveTime == 0d) {
moveTime = 0.1d;
}

Expand Down
2 changes: 1 addition & 1 deletion src/main/java/org/xtx/ut4converter/t3d/T3DBrush.java
Original file line number Diff line number Diff line change
Expand Up @@ -699,7 +699,7 @@ else if (brushClass == BrushClass.UTSlimeVolume || brushClass == BrushClass.UTLa
* Rotate) * PostScale PrePivot = PrePivot * Rotation Normal = Normal *
* Rotation MainScale * Vector -> Rotation * Vector -> PostScale * Vector
*/
private void transformPermanently() {
public void transformPermanently() {

if (prePivot != null) {
Geometry.transformPermanently(prePivot, mainScale, rotation, postScale, false);
Expand Down
112 changes: 60 additions & 52 deletions src/main/java/org/xtx/ut4converter/t3d/T3DMover.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
import java.io.File;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.nio.file.StandardCopyOption;

/**
* Unreal Engine 1 only
Expand Down Expand Up @@ -64,23 +64,22 @@ public void scale(double newScale) {
super.scale(newScale);
}

public String toT3d(){
// no generic mover actor for UE4 but UT4 with Lift blueprint
// UE3 movers are InterpActors
if (mapConverter.getOutputGame().getShortName().equals(UTGames.UTGame.UT4.shortName) || mapConverter.isTo(UnrealEngine.UE3)) {

if (mapConverter.getOutputGame().getShortName().equals(UTGames.UTGame.UT4.shortName)) {
moverProperties.writeUT4MoverActor(sbf);
}
// UE3
else {
moverProperties.writeUE3MoverActor(sbf);
}
/**
* Disabled until mesh is good
* Convert to t3d this mover
* @return String value
*/
public String toT3d() {

// TODO for UT4 make converter from brush to .fbx Autodesk file and
// transform into StaticMesh
// TODO for UT3 make converter from brush to .ase file and transform
// into StaticMesh
// UT4 - Convert to Lift actor
if (mapConverter.getOutputGame().getShortName().equals(UTGames.UTGame.UT4.shortName)) {
moverProperties.writeUT4MoverActor(sbf);
}
// UE3, movers not yet converted to staticmesh
// writting the original brush as well
else if (mapConverter.isTo(UnrealEngine.UE3)) {
moverProperties.writeUE3MoverActor(sbf);

// Write the mover as brush as well so we can convert it in
// staticmesh in UE4 Editor ...
Expand All @@ -101,29 +100,6 @@ public String toT3d(){

return sbf.toString();
}
else {
return super.toString();
}
}

/**
* Disabled until mesh is good
* Convert to t3d this mover
* @return String value
*/
public String toT3dTest() {

// UT4 - Convert to Lift actor
if (mapConverter.getOutputGame().getShortName().equals(UTGames.UTGame.UT4.shortName)) {
moverProperties.writeUT4MoverActor(sbf);
}
// UE4/UE5 - TODO Convert to generic StaticMesh actor (No UT4 Lift actor)
//else if (mapConverter.isTo(UnrealEngine.UE4, UnrealEngine.UE5)) {
//}
// UE3 - Convert to InterpActor
else if (mapConverter.isTo(UnrealEngine.UE3)) {
moverProperties.writeUE3MoverActor(sbf);
}

return sbf.toString();
}
Expand All @@ -137,22 +113,54 @@ public void convert() {
super.convert();


// TODO for UE3 make brush to .t3d or .ase conversion (.obj not supported)
// TODO UE3 make brush to .t3d or .ase conversion (.obj not supported by editor)
// convert brush to .obj staticmesh
// disabled for now until mesh is well oriented
if (false && mapConverter.isTo(UnrealEngine.UE4, UnrealEngine.UE5)) {
if (mapConverter.isTo(UnrealEngine.UE4, UnrealEngine.UE5)) {
try {
Files.createDirectories(Paths.get(this.mapConverter.getOutPath() + "/StaticMesh/"));
File smMoversFolder;

// E.G: \UT4X-Converter\Converted\Passage\StaticMesh
if (mapConverter.getExportOption() == MapConverter.ExportOption.BY_TYPE) {
smMoversFolder = new File(this.mapConverter.getOutPath() + "/StaticMesh/");
}
// E.G: \UT4X-Converter\Converted\Passage\Passage[MapPackageName]
else {
smMoversFolder = new File(this.mapConverter.getOutPath() + File.separator + mapConverter.getInMapAsPackageName() + "/");
}

if (!smMoversFolder.exists()) {
Files.createDirectories(smMoversFolder.toPath());
}

// super.convert changes name to "name_tag->event" which is incompatible with a filename
// so need to use the original name
String baseName = this.originalName;

// e.g: '/Game/Converted/Unreal1/Movers/Passage/Mover0.Mover0'
// TODO create intermediate folders and copy .uasset file for folder visibility in UE4
this.staticMeshReference = mapConverter.getUt4ReferenceBaseFolder() + "/Movers/" + mapConverter.getOutMapName() + "/" + baseName + "." + baseName;

File mtlFile = new File(this.mapConverter.getOutPath() + "/Movers/" + baseName + ".mtl");
File objFile = new File(this.mapConverter.getOutPath() + "/Movers/" + baseName + ".obj");
// E.G: /Game/Converted/Passage-U1/Mover0.Mover0
if (mapConverter.getExportOption() == MapConverter.ExportOption.BY_TYPE) {
this.staticMeshReference = mapConverter.getUt4ReferenceBaseFolder() + "/" + baseName + "." + baseName;
}
// Export by package
else {
// E.G: /Game/Converted/Passage-U1/Passage/Mover0.Mover0
this.staticMeshReference = mapConverter.getUt4ReferenceBaseFolder() + "/" + mapConverter.getInMapAsPackageName() + "/" + baseName + "." + baseName;

// E.G: /UnrealTournamentEditor/Content/Converted/Passage-U1/Passage/Mover0.Mover0
File dummyUAssetFileForPackage = new File(mapConverter.getUt4ReferenceBaseFolderFile() + "/" + mapConverter.getInMapAsPackageName() + "/" + mapConverter.getDummyUAssetFile().getName());
System.out.println(dummyUAssetFileForPackage);

if (!dummyUAssetFileForPackage.exists()) {
Files.createDirectories(dummyUAssetFileForPackage.toPath().getParent());
Files.createFile(dummyUAssetFileForPackage.toPath());

Files.copy(mapConverter.getDummyUAssetFile().toPath(), dummyUAssetFileForPackage.toPath(), StandardCopyOption.REPLACE_EXISTING);
}
}

final File mtlFile = new File(smMoversFolder + "/" + baseName + ".mtl");
final File objFile = new File(smMoversFolder + "/" + baseName + ".obj");

ObjStaticMesh.writeMtlObjFile(this, mtlFile, mapConverter.isTestMode);
ObjStaticMesh.writeObj(this, objFile, mtlFile);

Expand All @@ -161,10 +169,6 @@ public void convert() {
// scaled 3d is null, init to 1X so the upcoming super.scale() function will scale it correctly
// Seems all is fliped by Y axis
this.scale3d = new Vector3d(1, -1, 1);

for( Vector3d position : this.moverProperties.getPositions().values() ) {
position.y = -position.y;
}
} catch (IOException e) {
throw new RuntimeException(e);
}
Expand All @@ -174,4 +178,8 @@ public void convert() {
public String getStaticMeshReference() {
return staticMeshReference;
}

public MoverProperties getMoverProperties() {
return moverProperties;
}
}
Loading

0 comments on commit df260eb

Please sign in to comment.