访问ILPanel和ILCamera中的形状

时间:2013-09-02 08:19:05

标签: c# ilnumerics

关于ILNumerics中的ILPanel我有三个问题:

  1. 如何禁用ILPanel的双击交互以重置视图。
  2. 如何使用右键单击并拖动来提高平移速度。平移非常慢,特别是当形状变化很大时。
  3. 如何访问我添加到相机并修改它们的元素。
  4. 这是一个简单的例子。两个球体添加到相机中,ILLable“Hello”位于其中一个(蓝色)之上。如果我用鼠标旋转场景并且绿色球体变得更接近相机和签证,我希望“Hello”标签跳到绿色球体的顶部。而且,如何通过单击按钮更改球体的颜色?

     private void ilPanel1_Load(object sender, EventArgs e)
     {
            var scene = new ILScene();
            var cam = scene.Camera;
            var Sphere1 = new ILSphere();
            Sphere1.Wireframe.Visible = true;
            Sphere1.Fill.Color = Color.Blue;
            Sphere1.Wireframe.Color = Color.Blue;
            Sphere1.Transform = Matrix4.Translation(0, 0, 0);
            var Sphere2 = new ILSphere();
            Sphere2.Wireframe.Visible = true;
            Sphere2.Transform = Matrix4.Translation(2, 0, 0);
            cam.Add(Sphere1);
            cam.Add(Sphere2);
            cam.Add(new ILLabel("Hello")
            {
                Font = new System.Drawing.Font(FontFamily.GenericSansSerif, 8),
                Position = new Vector3(0, 0, 1.1),
                Anchor = new PointF(0, 1),
            });
            ilPanel1.Scene = scene;
     }
    

    enter image description here

1 个答案:

答案 0 :(得分:2)

创建一个始终位于其他3D对象之上的标签

cam.Add(
        new ILScreenObject() {
            Location = new PointF(0.5f, 0.5f),
            Children = {
                new ILLabel("Hello") 
            }
        });

另请参阅:http://ilnumerics.net/world3d-and-screen2d-nodes.html

关于“跳跃球体”示例:如果您希望标签在运行时跳转到另一个组(实际上是球体组),则必须将该逻辑实现为在运行时调用的函数。 ilPanel1.BeginRenderFrame可能是检查此类更新的好地方。

禁用第一台摄像头的默认行为:

scene.Camera.MouseDoubleClick += (_, arg) => {
    arg.Cancel = true;
};

请参阅:http://ilnumerics.net/mouse-events.html

按下按钮时发生反应:

button1.Click += (_,args) => {
    ilPanel1.Scene.First<ILSphere>().Fill.Color = Color.Red; 
    ilPanel1.Refresh(); 
};

在场景中查找对象: 见:http://ilnumerics.net/nodes-accessing-managing.html

控制平移速度:

目前没有简单的方法来配置速度。最好的方法是自己实现相应的鼠标处理程序:

  1. 覆盖相机节点的MouseMove。

  2. 实现与ILNumerics中的方式类似的平移(参见:来源中的ILCamera.OnMouseMove)。

  3. 增加比例因子。

  4. 不要忘记在处理程序结束时取消事件处理。