Esempio n. 1
0
 // Return a node object by name and type.
 //
 // This function performs a recursive search for the specified node.
 // Both name and type must match.
 //
 // \param node The parent node for the search
 // \param name The target node name.
 // \param type The target node type
 //
 // \return A pointer to the first matching node, or NULL if not found.
 public static Lib3dsNode lib3ds_node_by_name(Lib3dsNode node, string name, Lib3dsNodeType type)
 {
     foreach (Lib3dsNode p in node.childs)
     {
         if (p.type == type && p.name == name)
         {
             return(p);
         }
         Lib3dsNode q = lib3ds_node_by_name(p, name, type);
         if (q != null)
         {
             return(q);
         }
     }
     return(null);
 }
Esempio n. 2
0
		// Return a node object by name and type.
		//
		// This function performs a recursive search for the specified node.
		// Both name and type must match.
		//
		// \param node The parent node for the search
		// \param name The target node name.
		// \param type The target node type
		//
		// \return A pointer to the first matching node, or NULL if not found.
		public static Lib3dsNode lib3ds_node_by_name(Lib3dsNode node, string name, Lib3dsNodeType type)
		{
			foreach(Lib3dsNode p in node.childs)
			{
				if(p.type==type&&p.name==name) return p;
				Lib3dsNode q=lib3ds_node_by_name(p, name, type);
				if(q!=null) return q;
			}
			return null;
		}
Esempio n. 3
0
		// Create and return a new node object.
		//
		// The node is returned with an identity matrix. All other fields
		// are zero.
		//
		// \return Lib3dsNode
		public static Lib3dsNode lib3ds_node_new(Lib3dsNodeType type)
		{
			Lib3dsNode node=null;
			switch(type)
			{
				case Lib3dsNodeType.LIB3DS_NODE_AMBIENT_COLOR:
					{
						Lib3dsAmbientColorNode n=new Lib3dsAmbientColorNode();
						node=n;
						node.name="$AMBIENT$";
						n.color_track.type=Lib3dsTrackType.LIB3DS_TRACK_VECTOR;
						break;
					}
				case Lib3dsNodeType.LIB3DS_NODE_MESH_INSTANCE:
					{
						Lib3dsMeshInstanceNode n=new Lib3dsMeshInstanceNode();
						node=n;
						node.name="$$$DUMMY";
						n.pos_track.type=Lib3dsTrackType.LIB3DS_TRACK_VECTOR;
						n.scl_track.type=Lib3dsTrackType.LIB3DS_TRACK_VECTOR;
						n.rot_track.type=Lib3dsTrackType.LIB3DS_TRACK_QUAT;
						n.hide_track.type=Lib3dsTrackType.LIB3DS_TRACK_BOOL;
						break;
					}
				case Lib3dsNodeType.LIB3DS_NODE_CAMERA:
					{
						Lib3dsCameraNode n=new Lib3dsCameraNode();
						node=n;
						n.pos_track.type=Lib3dsTrackType.LIB3DS_TRACK_VECTOR;
						n.fov_track.type=Lib3dsTrackType.LIB3DS_TRACK_FLOAT;
						n.roll_track.type=Lib3dsTrackType.LIB3DS_TRACK_FLOAT;
						break;
					}
				case Lib3dsNodeType.LIB3DS_NODE_CAMERA_TARGET:
					{
						Lib3dsTargetNode n=new Lib3dsTargetNode();
						node=n;
						n.pos_track.type=Lib3dsTrackType.LIB3DS_TRACK_VECTOR;
						break;
					}
				case Lib3dsNodeType.LIB3DS_NODE_OMNILIGHT:
					{
						Lib3dsOmnilightNode n=new Lib3dsOmnilightNode();
						node=n;
						n.pos_track.type=Lib3dsTrackType.LIB3DS_TRACK_VECTOR;
						n.color_track.type=Lib3dsTrackType.LIB3DS_TRACK_VECTOR;
						break;
					}
				case Lib3dsNodeType.LIB3DS_NODE_SPOTLIGHT:
					{
						Lib3dsSpotlightNode n=new Lib3dsSpotlightNode();
						node=n;
						n.pos_track.type=Lib3dsTrackType.LIB3DS_TRACK_VECTOR;
						n.color_track.type=Lib3dsTrackType.LIB3DS_TRACK_VECTOR;
						n.hotspot_track.type=Lib3dsTrackType.LIB3DS_TRACK_FLOAT;
						n.falloff_track.type=Lib3dsTrackType.LIB3DS_TRACK_FLOAT;
						n.roll_track.type=Lib3dsTrackType.LIB3DS_TRACK_FLOAT;
						break;
					}
				case Lib3dsNodeType.LIB3DS_NODE_SPOTLIGHT_TARGET:
					{
						Lib3dsTargetNode n=new Lib3dsTargetNode();
						node=n;
						n.pos_track.type=Lib3dsTrackType.LIB3DS_TRACK_VECTOR;
						break;
					}
				default: Debug.Assert(false); return null;
			}

			node.type=type;
			node.node_id=65535;
			node.parent_id=65535;
			lib3ds_matrix_identity(node.matrixNode);
			return node;
		}
Esempio n. 4
0
		// Return a node object by name and type.
		//
		// This function performs a recursive search for the specified node.
		// Both name and type must match.
		//
		// \param file The Lib3dsFile to be searched.
		// \param name The target node name.
		// \param type The target node type
		//
		// \return A pointer to the first matching node, or NULL if not found.
		//
		// \see lib3ds_node_by_name
		public static Lib3dsNode lib3ds_file_node_by_name(Lib3dsFile file, string name, Lib3dsNodeType type)
		{
			Debug.Assert(file!=null);
			foreach(Lib3dsNode p in file.nodes)
			{
				if(p.type==type&&p.name==name) return p;
				Lib3dsNode q=lib3ds_node_by_name(p, name, type);
				if(q!=null) return q;
			}
			return null;
		}
Esempio n. 5
0
        // Create and return a new node object.
        //
        // The node is returned with an identity matrix. All other fields
        // are zero.
        //
        // \return Lib3dsNode
        public static Lib3dsNode lib3ds_node_new(Lib3dsNodeType type)
        {
            Lib3dsNode node = null;

            switch (type)
            {
            case Lib3dsNodeType.LIB3DS_NODE_AMBIENT_COLOR:
            {
                Lib3dsAmbientColorNode n = new Lib3dsAmbientColorNode();
                node               = n;
                node.name          = "$AMBIENT$";
                n.color_track.type = Lib3dsTrackType.LIB3DS_TRACK_VECTOR;
                break;
            }

            case Lib3dsNodeType.LIB3DS_NODE_MESH_INSTANCE:
            {
                Lib3dsMeshInstanceNode n = new Lib3dsMeshInstanceNode();
                node              = n;
                node.name         = "$$$DUMMY";
                n.pos_track.type  = Lib3dsTrackType.LIB3DS_TRACK_VECTOR;
                n.scl_track.type  = Lib3dsTrackType.LIB3DS_TRACK_VECTOR;
                n.rot_track.type  = Lib3dsTrackType.LIB3DS_TRACK_QUAT;
                n.hide_track.type = Lib3dsTrackType.LIB3DS_TRACK_BOOL;
                break;
            }

            case Lib3dsNodeType.LIB3DS_NODE_CAMERA:
            {
                Lib3dsCameraNode n = new Lib3dsCameraNode();
                node              = n;
                n.pos_track.type  = Lib3dsTrackType.LIB3DS_TRACK_VECTOR;
                n.fov_track.type  = Lib3dsTrackType.LIB3DS_TRACK_FLOAT;
                n.roll_track.type = Lib3dsTrackType.LIB3DS_TRACK_FLOAT;
                break;
            }

            case Lib3dsNodeType.LIB3DS_NODE_CAMERA_TARGET:
            {
                Lib3dsTargetNode n = new Lib3dsTargetNode();
                node             = n;
                n.pos_track.type = Lib3dsTrackType.LIB3DS_TRACK_VECTOR;
                break;
            }

            case Lib3dsNodeType.LIB3DS_NODE_OMNILIGHT:
            {
                Lib3dsOmnilightNode n = new Lib3dsOmnilightNode();
                node               = n;
                n.pos_track.type   = Lib3dsTrackType.LIB3DS_TRACK_VECTOR;
                n.color_track.type = Lib3dsTrackType.LIB3DS_TRACK_VECTOR;
                break;
            }

            case Lib3dsNodeType.LIB3DS_NODE_SPOTLIGHT:
            {
                Lib3dsSpotlightNode n = new Lib3dsSpotlightNode();
                node                 = n;
                n.pos_track.type     = Lib3dsTrackType.LIB3DS_TRACK_VECTOR;
                n.color_track.type   = Lib3dsTrackType.LIB3DS_TRACK_VECTOR;
                n.hotspot_track.type = Lib3dsTrackType.LIB3DS_TRACK_FLOAT;
                n.falloff_track.type = Lib3dsTrackType.LIB3DS_TRACK_FLOAT;
                n.roll_track.type    = Lib3dsTrackType.LIB3DS_TRACK_FLOAT;
                break;
            }

            case Lib3dsNodeType.LIB3DS_NODE_SPOTLIGHT_TARGET:
            {
                Lib3dsTargetNode n = new Lib3dsTargetNode();
                node             = n;
                n.pos_track.type = Lib3dsTrackType.LIB3DS_TRACK_VECTOR;
                break;
            }

            default: Debug.Assert(false); return(null);
            }

            node.type      = type;
            node.node_id   = 65535;
            node.parent_id = 65535;
            lib3ds_matrix_identity(node.matrixNode);
            return(node);
        }
Esempio n. 6
0
 // Return a node object by name and type.
 //
 // This function performs a recursive search for the specified node.
 // Both name and type must match.
 //
 // \param file The Lib3dsFile to be searched.
 // \param name The target node name.
 // \param type The target node type
 //
 // \return A pointer to the first matching node, or NULL if not found.
 //
 // \see lib3ds_node_by_name
 public static Lib3dsNode lib3ds_file_node_by_name(Lib3dsFile file, string name, Lib3dsNodeType type)
 {
     Debug.Assert(file != null);
     foreach (Lib3dsNode p in file.nodes)
     {
         if (p.type == type && p.name == name)
         {
             return(p);
         }
         Lib3dsNode q = lib3ds_node_by_name(p, name, type);
         if (q != null)
         {
             return(q);
         }
     }
     return(null);
 }