mirror of
https://github.com/LazyDuchess/OpenTS2.git
synced 2025-01-23 00:31:47 -05:00
Merge branch 'master' of https://github.com/LazyDuchess/OpenTS2
This commit is contained in:
commit
61b578cd4f
2 changed files with 23 additions and 11 deletions
|
@ -26,10 +26,20 @@ namespace OpenTS2.Content.DBPF.Scenegraph
|
|||
var shape = ContentProvider.Get().GetAsset<ScenegraphShapeAsset>(shapeKey);
|
||||
|
||||
shape.LoadModelsAndMaterials();
|
||||
|
||||
var gameObject = new GameObject(resourceName, typeof(MeshFilter), typeof(MeshRenderer), typeof(AssetReferenceComponent));
|
||||
|
||||
var gameObject = new GameObject(resourceName, typeof(AssetReferenceComponent));
|
||||
|
||||
// Apply a transformation to convert from the sims coordinate space to unity.
|
||||
gameObject.transform.Rotate(-90, 0, 0);
|
||||
gameObject.transform.localScale = new Vector3(1, -1, 1);
|
||||
|
||||
// Keeps a strong reference to the Shape asset.
|
||||
gameObject.GetComponent<AssetReferenceComponent>().AddReference(shape);
|
||||
|
||||
// This is the component that holds rotations from sims space. All rotations from the game such as applying
|
||||
// quaternions and angles should be performed on it or components under it.
|
||||
var simsRotation = new GameObject("simsRotations");
|
||||
|
||||
// Render out each model.
|
||||
foreach (var model in shape.Models)
|
||||
{
|
||||
|
@ -40,7 +50,6 @@ namespace OpenTS2.Content.DBPF.Scenegraph
|
|||
{
|
||||
transform =
|
||||
{
|
||||
parent = gameObject.transform,
|
||||
rotation = shapeTransform.Rotation,
|
||||
position = shapeTransform.Transform
|
||||
}
|
||||
|
@ -51,13 +60,12 @@ namespace OpenTS2.Content.DBPF.Scenegraph
|
|||
{
|
||||
primitiveObject.GetComponent<MeshRenderer>().material = material.GetAsUnityMaterial();
|
||||
}
|
||||
|
||||
primitiveObject.transform.SetParent(simsRotation.transform);
|
||||
}
|
||||
}
|
||||
// TODO: Models in the game use a different up-axis, adjusting for that here right now. See if there's a
|
||||
// better spot.
|
||||
gameObject.transform.Rotate(-90, 0, 0);
|
||||
gameObject.transform.localScale = new Vector3(1, -1, 1);
|
||||
|
||||
simsRotation.transform.SetParent(gameObject.transform, worldPositionStays:false);
|
||||
return gameObject;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -37,9 +37,9 @@ namespace OpenTS2.Scenes
|
|||
var bridgeObject = model.CreateGameObjectForShape();
|
||||
bridgeObject.transform.position = (bridge.Road.Position.Position + bridge.PositionOffset);
|
||||
|
||||
// TODO: this is a temporary hack to fix bridge orientation, there's something weird going on with one
|
||||
// of our axes that we need to do this...
|
||||
bridgeObject.transform.rotation *= new Quaternion(bridge.ModelOrientation.x, -bridge.ModelOrientation.y, -bridge.ModelOrientation.z, bridge.ModelOrientation.w);
|
||||
// TODO: put this in a helper MonoBehavior or something.
|
||||
var simsRotation = bridgeObject.transform.Find("simsRotations");
|
||||
simsRotation.localRotation = bridge.ModelOrientation;
|
||||
|
||||
// Parent to this component.
|
||||
bridgeObject.transform.parent = transform;
|
||||
|
@ -61,7 +61,11 @@ namespace OpenTS2.Scenes
|
|||
|
||||
var decorationObject = model.CreateGameObjectForShape();
|
||||
decorationObject.transform.position = decoration.Position.Position;
|
||||
decorationObject.transform.Rotate(0, 0, -decoration.Rotation);
|
||||
|
||||
// TODO: put this in a helper MonoBehavior or something.
|
||||
var simsRotation = decorationObject.transform.Find("simsRotations");
|
||||
simsRotation.Rotate(0, 0, decoration.Rotation);
|
||||
|
||||
// Parent to this component.
|
||||
decorationObject.transform.parent = transform;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue