Ditt första Aspose.3D-program
Contents
[
Hide
]
Den här handledningen förklarar hur ditt första program skapas med Aspose.3Ds enkla API. Detta enkla program skapar en 3D-fil i en angiven 3D-scen.
Hur man skapar programmet
Stegen nedan skapar programmet med Aspose.3D API:
- Skapa en instans av Scene-klassen.
- Om du har en licens, då Tillämpa den. Om du använder utvärderingsversionen, hoppa över licensrelaterade kodlinjer.
- Skapa en ny 3D-fil, eller öppna en befintlig 3D-fil.
- Åtkomst till innehållet i filen 3D.
- Skapa den ändrade 3D-filen.
Genomförandet av ovanstående steg visas i exemplen nedan.
Hur man skapar ett nytt scendokument
Följande exempel skapar en ny 3D scenefil från början. Skapa först en 3D-scen och sedan spara filen i FBX-format.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// The path to the documents directory. | |
String MyDir = RunExamples.getDataDir(); | |
MyDir = MyDir + "document.fbx"; | |
// Create an object of the Scene class | |
Scene scene = new Scene(); | |
// Save 3D scene document | |
scene.save(MyDir, FileFormat.FBX7500ASCII); |
Hur man öppnar en befintlig fil
The following example opens an existing 3D template file named “document.fbx” and then saves the 3D scene or document to a stream in various supported 3D formats.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// The path to the documents directory. | |
String MyDir = RunExamples.getDataDir(); | |
// Load a 3D document into Aspose.3D | |
Scene scene = new Scene(); | |
// Open an existing 3D scene | |
scene.open(MyDir + "document.fbx"); | |
// Save Scene to a stream | |
try (MemoryStream dstStream = new MemoryStream()) { | |
scene.save(dstStream, FileFormat.FBX7500ASCII); | |
} | |
// Save Scene to a local path | |
scene.save(MyDir + "output_out.fbx", FileFormat.FBX7500ASCII); |