I’m developing a .net plugin, where i want to indicate the floor space a component occupies.
For testing purposes, i spawn a plane and set the size based on the current bounding box (this will be changed to data coming from a meta-model) .
This is the current code i use for this:
void SpawnSpatialDefinition()
{
IApplication app = IoC.Get<IApplication>();
VCCatalogue catalogue = (VCCatalogue)IoC.Get<ICatalogue>();
string id = "b52f40a6-51d9-4063-9473-d4ff6c6a152c"; //plane id
Item plane = catalogue.getVCItem(id);
ISimComponent component = app.LoadLayout(IoC.Get<IUrlHelper>().LocalPathToUrl(plane.FileUri, false)).FirstOrDefault();
component.Material = app.FindMaterial("yellow", false);
IBoundBox bb = _simComponent.BoundBox;
var min = bb.MinCorner;
var max = bb.MaxCorner;
component.CreateAndSetProperty("SizeX", Math.Abs(max.X - min.X).ToString());
component.CreateAndSetProperty("SizeY", Math.Abs(max.Y - min.Y).ToString());
//VisualComponents.Create3D.Matrix m = _simComponent.TransformationInWorld;
var n = _simComponent.TransformationInWorld.GetN();
var o = _simComponent.TransformationInWorld.GetO();
var a = _simComponent.TransformationInWorld.GetA();
var p = _simComponent.TransformationInWorld.GetP();
VisualComponents.Create3D.Matrix m = new Matrix(
n.X, n.Y,n.Z, n.W,
o.X, o.Y,o.Z, o.W,
a.X, a.Y,a.Z, a.W,
p.X, p.Y,p.Z, p.W
);
m.TranslateRelative(bb.Center);
m.Pz = 0;
component.TransformationInWorld = m;
component.RootNode.AttachTo(_simComponent.RootNode);
//_simComponent.RootNode.AttachTo(component.RootNode);
}
The problem i have is, that the plane is spawned correctly, as seen in the first picture below.
But when i move the component, the plane moves to a different location, and stays in this (relative) position towards to parent component.
i thought it had something to do with the Matrix, so i switched to a clean copy from the original one, but the situation still remains the same.