SharpGL: how to add a solid object to a scene
-
I am using SharpGL to add a solid object to a scene by clicking a button. private void InitElements(Scene scene) { var objectRoot = new SharpGL.SceneGraph.Primitives.Folder() { Name = "Root" }; scene.SceneContainer.AddChild(objectRoot); // This implements free rotation(with translation and rotation). var camera = GetCamera(); float cmX = camera.Position.X; float cmY = camera.Position.Y; float cmZ = camera.Position.Z; float tgX = camera.Target.X; float tgY = camera.Target.Y; float tgZ = camera.Target.Z; float upX = camera.UpVector.X; float upY = camera.UpVector.Y; float upZ = camera.UpVector.Z; objectArcBallEffect = new ArcBallEffect(cmX, cmY, cmZ, tgX, tgY, tgZ, upX, upY, upZ); objectRoot.AddEffect(objectArcBallEffect); var axisRoot = new SharpGL.SceneGraph.Primitives.Folder() { Name = "axis root" }; scene.SceneContainer.AddChild(axisRoot); axisArcBallEffect = new ArcBallEffect(cmX, cmY, cmZ, tgX, tgY, tgZ, upX, upY, upZ); axisRoot.AddEffect(axisArcBallEffect); InitLight(objectRoot); InitAxis(objectRoot); InitAxis(axisRoot); InitFrameElement(6, 24, 7, objectRoot); } After I initiate the solid elements in scene, I would like to add a solid object to that scene by clicking a button. I successfully add it in scene. But I cannot drag and rotate it with the initial elements in the scene. It means I didn't successfully add it to the same scene. Thanks in advance. private void btnAddEllement_Click(object sender, EventArgs e) { var objectRoot = new SharpGL.SceneGraph.Primitives.Folder() { Name = "Root" }; var scene = this.sceneControl1.Scene; addCylinder(objectRoot, 50, 30, 100, 5); scene.SceneContainer.AddChild(objectRoot); }
-
I am using SharpGL to add a solid object to a scene by clicking a button. private void InitElements(Scene scene) { var objectRoot = new SharpGL.SceneGraph.Primitives.Folder() { Name = "Root" }; scene.SceneContainer.AddChild(objectRoot); // This implements free rotation(with translation and rotation). var camera = GetCamera(); float cmX = camera.Position.X; float cmY = camera.Position.Y; float cmZ = camera.Position.Z; float tgX = camera.Target.X; float tgY = camera.Target.Y; float tgZ = camera.Target.Z; float upX = camera.UpVector.X; float upY = camera.UpVector.Y; float upZ = camera.UpVector.Z; objectArcBallEffect = new ArcBallEffect(cmX, cmY, cmZ, tgX, tgY, tgZ, upX, upY, upZ); objectRoot.AddEffect(objectArcBallEffect); var axisRoot = new SharpGL.SceneGraph.Primitives.Folder() { Name = "axis root" }; scene.SceneContainer.AddChild(axisRoot); axisArcBallEffect = new ArcBallEffect(cmX, cmY, cmZ, tgX, tgY, tgZ, upX, upY, upZ); axisRoot.AddEffect(axisArcBallEffect); InitLight(objectRoot); InitAxis(objectRoot); InitAxis(axisRoot); InitFrameElement(6, 24, 7, objectRoot); } After I initiate the solid elements in scene, I would like to add a solid object to that scene by clicking a button. I successfully add it in scene. But I cannot drag and rotate it with the initial elements in the scene. It means I didn't successfully add it to the same scene. Thanks in advance. private void btnAddEllement_Click(object sender, EventArgs e) { var objectRoot = new SharpGL.SceneGraph.Primitives.Folder() { Name = "Root" }; var scene = this.sceneControl1.Scene; addCylinder(objectRoot, 50, 30, 100, 5); scene.SceneContainer.AddChild(objectRoot); }