/// <summary> /// Inserts one new child node to this parent node. /// </summary> /// <param name="ch">Child node to add.</param> /// <param name="toParent">Transform from local space of the child to the parent's space.</param> public virtual void InsertChild( ISceneNode ch, Matrix4d toParent ) { children.AddLast( ch ); ch.ToParent = toParent; toParent.Invert(); ch.FromParent = toParent; ch.Parent = this; }
/// <summary> /// Complete non-mandatory (deferred) values in the Intersection instance. /// </summary> public void Complete() { if ( Solid != null ) { // world coordinates: LocalToWorld = Solid.ToWorld(); WorldToLocal = LocalToWorld; WorldToLocal.Invert(); Vector3d.TransformPosition( ref CoordLocal, ref LocalToWorld, out CoordWorld ); // object coordinates: LocalToObject = Solid.ToObject(); Vector3d.TransformPosition( ref CoordLocal, ref LocalToObject, out CoordObject ); // appearance: ReflectanceModel = (IReflectanceModel)Solid.GetAttribute( PropertyName.REFLECTANCE_MODEL ); if ( ReflectanceModel == null ) ReflectanceModel = new PhongModel(); Material = (IMaterial)Solid.GetAttribute( PropertyName.MATERIAL ); if ( Material == null ) Material = ReflectanceModel.DefaultMaterial(); double[] col = (double[])Solid.GetAttribute( PropertyName.COLOR ); SurfaceColor = (double[])((col != null) ? col.Clone() : Material.Color.Clone()); Textures = Solid.GetTextures(); // Solid is responsible for completing remaining values: Solid.CompleteIntersection( this ); Normal.Normalize(); if ( Enter != Front ) Vector3d.Multiply( ref Normal, -1.0, out Normal ); } if ( SurfaceColor == null ) SurfaceColor = new double[] { 0.0, 0.2, 0.3 }; }