Add functionality to synchronise rendered terrain to position of the geom
This commit is contained in:
@@ -36,8 +36,11 @@ public class MjHeightFieldShape : IMjShape
|
||||
|
||||
public void ToMjcf(XmlElement mjcf, Transform transform){
|
||||
ExportHeightMap();
|
||||
if(terrain.transform.parent != transform) Debug.LogWarning($"The terrain of heightfield {transform.name} needs to be parented to the Geom for proper rendering.");
|
||||
else terrain.transform.localPosition = new Vector3(-HeightMapHeight*HeightMapScale.x / 2, terrain.transform.localPosition.y, -HeightMapWidth*HeightMapScale.z / 2);
|
||||
var scene = MjScene.Instance;
|
||||
var assetName = scene.GenerationContext.AddHeightFieldAsset(this);
|
||||
|
||||
mjcf.SetAttribute("hfield", assetName);
|
||||
}
|
||||
|
||||
@@ -59,7 +62,7 @@ public class MjHeightFieldShape : IMjShape
|
||||
}
|
||||
|
||||
public Tuple<Vector3[], int[]> BuildMesh(){
|
||||
return Tuple.Create(new Vector3[]{}, new int[]{});
|
||||
return null;
|
||||
}
|
||||
|
||||
public void DebugDraw(Transform transform){
|
||||
|
||||
@@ -121,7 +121,7 @@ public class MjcfGenerationContext {
|
||||
mjcf.SetAttribute("content_type", "image/png");
|
||||
mjcf.SetAttribute("file", hFieldComponent.FullHeightMapPath);
|
||||
|
||||
mjcf.SetAttribute("size", MjEngineTool.MakeLocaleInvariant($"{hFieldComponent.HeightMapScale.x*hFieldComponent.HeightMapHeight/2} {hFieldComponent.HeightMapScale.z * hFieldComponent.HeightMapWidth/2} {hFieldComponent.HeightMapScale.y*2} {hFieldComponent.terrain.transform.position.y}"));
|
||||
mjcf.SetAttribute("size", MjEngineTool.MakeLocaleInvariant($"{hFieldComponent.HeightMapScale.x*hFieldComponent.HeightMapHeight/2} {hFieldComponent.HeightMapScale.z * hFieldComponent.HeightMapWidth/2} {hFieldComponent.HeightMapScale.y} {hFieldComponent.terrain.transform.localPosition.y}"));
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user