/// <summary> /// Sets the DTS shape for this object to render. /// </summary> /// <param name="shapeFile">The path to the DTS file.</param> /// <returns>True on successful load or false when failed or same DTS is already loaded.</returns> public bool SetShape(String shapeFile) { if (_shapeFile == shapeFile) return false; _shapeFile = shapeFile; // TODO: Hook in the shape manager here! // create the shape FileStream fs = null; try { fs = new FileStream(_shapeFile, FileMode.Open); } catch { return false; } ShapeReader reader = new ShapeReader(); Shape shape = reader.ReadShape(fs); fs.Close(); FileInfo fi = new FileInfo(_shapeFile); shape.FilePath = fi.DirectoryName; // remove executable directory so that path is relative to it shape.FilePath = shape.FilePath.Replace(TorqueEngineComponent.Instance.ExecutableDirectory + @"\", string.Empty); Shape = shape; return true; }
/// <summary> /// Loads a DSQ animation sequence file. /// </summary> /// <param name="dsqFilePath">The path to the DSQ file.</param> /// <param name="sequenceName">An optional name for the sequence or null to use the default.</param> public bool LoadSequence(String dsqFilePath, String sequenceName) { // Ignore it if we have no shape or sequence! if (_shapeInstance == null || dsqFilePath == null) return false; // import the sequence -- cafTODO: error checking...exception handling? Shape shape = _shapeInstance.GetShape(); FileStream fs = null; try { fs = new FileStream(dsqFilePath, FileMode.Open); } catch { return false; } ShapeReader reader = new GarageGames.Torque.TS.ShapeReader(shape); shape = reader.ImportSequence(fs, sequenceName); fs.Close(); return true; }