1. 製品
  2.   3D
  3.   Python
  4.   Aspose.3D for Python via .NET

Aspose.3D for Python via .NET

 
 

3D モデルを作成、編集、変換するための Python API

FBX、STL、Discreet3DS、Universal3D、Collada などへの変換を含む、3D ファイル形式と 3D シーンの作成、編集、処理に役立つ Python ライブラリ。

Aspose.3D for Python via .NET とは何ですか?

Aspose.3D for Python via .NET は、包括的で安定したライブラリであり、3D モデリングやレンダリング ソフトウェアをインストールせずに、Python アプリケーション内で 3D ファイルやモデルを操作できるようにします。このライブラリは、ソフトウェア開発者が FBX、3DS、U3D、DAE、glTF、OBJ、STL、DRC、PDF、AMF、PLY など多数のファイル形式の 3D モデルを簡単に作成、読み取り、レンダリング、操作、変換できるアプリケーションを作成するのに役立ちます。また、ライブラリはさまざまな手法を用いて、巨大で複雑な 3D モデルでも効率的かつ高速に 3D 操作が行えるようにしています。

Aspose.3D for Python via .NET は、3D アニメーションの作成や操作、キーフレーム アニメーション、スケルトン アニメーション、モーフ アニメーションなど、3D アニメーションに関するいくつかの重要な機能を含んでいます。これにより、魅力的でインタラクティブな 3D アプリケーションやゲームを簡単に作成できます。また、ライブラリは 3D モデルの操作に必要な幅広いツールと機能も提供します。これには、3D モデルのインポートとエクスポート、作成と編集、スケーリング、回転、平行移動などのさまざまな操作が含まれます。

Aspose.3D for Python via .NET は .NET フレームワーク上に構築されており、Python の .NET 実装である IronPython を使用して Python と共に利用できます。幅広い 3D ファイル形式のサポートと、3D モデルの操作やアニメーション化のための豊富な機能により、アプリケーションで 3D コンテンツを扱う必要がある開発者にとって優れた選択肢です。

Previous Next

Aspose.3D for Python via .NET の開始方法

Aspose.3D for Python via .NET の安定版をインストールする最も簡単な方法は pip を使用することです。スムーズなインストールのために、以下のコマンドをご利用ください。

pip を使用して .NET 経由で Python 用 Aspose.3D をインストールする

pip install aspose-3d 
直接Aspose 製品ページからダウンロードすることもできます。

Python API を使用して 3D シーンを生成およびロードする

Aspose.3D for Python via .NET は、Python コマンドを使用してゼロから新しい 3D シーンを作成し、サポートされている任意のファイル形式で保存する完全なサポートを備えています。また、既存の 3D シーンの読み取り、既存の 3D の変更、3D シーンを PDF に保存、パスワードで保護された PDF から既存シーンを開く、ファイル形式の検出、PDF ファイルから 3D コンテンツを抽出、3D Obj ファイルを読み込む前にロードオプションを設定するなど、多くの機能も提供しています。

Python API を使用して 3D シーン ドキュメントを作成する方法は?

import aspose.threed as a3d

# For complete examples and data files, please go to https://github.com/aspose-3d/Aspose.3D-for-.NET

# The path to the documents directory.

# Create an object of the Scene class

scene = a3d.Scene()

# Save 3D scene document

scene.Save("document.fbx", a3d.FileFormat.FBX7500ASCII)

Python API を使用した 3D シーンのレンダリング

Aspose.3D for Python via .NET は、ソフトウェア開発者が独自の Python アプリケーション内で 3D シーンをロードおよびレンダリングできるようにします。ライブラリは、アンチエイリアシング、被写界深度、モーションブラーなどを含む高品質な 3D シーンのレンダリングをサポートします。また、FBX、OBJ、STL、3DS などのさまざまな 3D ファイル形式のインポートとエクスポートもサポートしています。これにより、既存の 3D モデルをシーンに簡単にインポートしたり、3D シーンを互換性のある形式でエクスポートしたりできます。3D ジオメトリに対するキャストシャドウと受信シャドウ、ハードウェアベースの 3D ジオメトリのレンダリング、カメラからの画像形式での 3D ビューのレンダリング、3D シーンのパノラマビューのレンダリングなどの機能をサポートしています。以下のコード例は、ソフトウェア開発者が 3D シーンのパノラマビューをレンダリングし、画像形式で保存する方法を示しています。

Python を使用して 3D シーンのパノラマビューをレンダリングし、画像形式で保存する方法は?

from aspose.pydrawing.imaging import ImageFormat
from aspose.pydrawing import Color
import aspose.threed as a3d

# load the scene

scene = Scene.from_file("vc.glb")

# create a camera for capturing the cube map

cam = a3d.entities.Camera(a3d.entities.ProjectionType.PERSPECTIVE)
cam.near_plane = 0.1
cam.far_plane = 200
cam.rotation_mode = a3d.entities.RotationMode.FIXED_DIRECTION
scene.root_node.create_child_node(cam).transform.set_translation(5, 6, 0);

# create two lights to illuminate the scene

scene.root_node.create_child_node(a3d.entities.Light("", a3d.entities.LightType.POINT).transform.set_translation(-10, 7, -10)
light = a3d.entities.Light()
light.color = Color.cadet_blue
scene.root_node.create_child_node(light).transform.set_translation(49, 0, 49)

# create a renderer

# Create a cube map render target with depth texture, depth is required when rendering a scene.

rt = renderer.render_factory.create_cube_render_texture(a3d.render.RenderParameters(False), 512, 512)

# create a 2D texture render target with no depth texture used for image processing
final = renderer.render_factory.CreateRenderTexture(a3d.render.RenderParameters(False, 32, 0, 0), 1024 * 3 , 1024)

# a viewport is required on the render target

rt.create_viewport(cam, a3d.utilities.RelativeRectangle.from_scale(0, 0, 1, 1))
renderer.render(rt)

# execute the equirectangular projection post-processing with the previous rendered cube map as input

equirectangular = renderer.get_post_processing("equirectangular")

# Specify the cube map rendered from the scene as this post processing's input

equirectangular.input = rt.targets[0]

# Execute the post processing effect and save the result to render target final

renderer.execute(equirectangular, final)

# save the texture into disk

final.targets[0].save("panorama.png", ImageFormat.PNG)

3D ドキュメントでアニメーションを操作する

Aspose.3D for Python via .NET は、Python ライブラリを使用して 3D ドキュメント内でアニメーションを作成および操作できるように、ソフトウェア開発者に提供します。ライブラリには、アニメーションシーンのレンダリング、3D ファイル内のターゲットカメラの設定、スケルトン アニメーションの作成、モーフ ターゲットの操作、複数アニメーションのブレンドなど、アニメーション操作に関する多数の機能が含まれています。以下の例は、Python コマンドを使用してシンプルなアニメーションを作成する方法を示しています。

Python API を使用してシンプルなアニメーションを作成する方法は?

import clr
clr.AddReference("Aspose.3D")
from Aspose.ThreeD import *

# create a new scene
scene = Scene()

# create a new camera
camera = Camera()
camera.Name = "Camera"
scene.RootNode.CreateChildNode(camera)

# create a new mesh
mesh = Mesh()
mesh.Name = "Mesh"
vertices = Vector3[]
vertices.append(Vector3(0, 0, 0))
vertices.append(Vector3(0, 1, 0))
vertices.append(Vector3(1, 1, 0))
vertices.append(Vector3(1, 0, 0))
mesh.Vertices = vertices
mesh.Triangles = [0, 1, 2, 0, 2, 3]

# create a new node for the mesh
meshNode = Node()
meshNode.Name = "MeshNode"
meshNode.Translation = Vector3(0, 0, 0)
meshNode.CreateChildNode(mesh)

# add the mesh node to the scene
scene.RootNode.CreateChildNode(meshNode)

# create a new animation track for the mesh node
track = AnimationTrack(meshNode, AnimationTargetType.Translation)

# create a new keyframe at time 0
keyframe1 = Keyframe()
keyframe1.Time = 0
keyframe1.Value = Vector3(0, 0, 0)
track.Keyframes.Add(keyframe1)

# create a new keyframe at time 1
keyframe2 = Keyframe()
keyframe2.Time = 1
keyframe2.Value = Vector3(0, 0, 5)
track.Keyframes.Add(keyframe2)

# create a new animation clip
clip = AnimationClip("Clip")
clip.Duration = 1
clip.Tracks.Add(track)

# add the animation clip to the scene
scene.Animations.Add(clip)

# save the scene to a file
scene.Save("animation.fbx", FileFormat.FBX7400ASCII)

Python API を使用してポリゴンを操作する

Aspose.3D for Python via .NET は、Python アプリケーション内で 3D モデルにポリゴン メッシュを追加および管理できるように、ソフトウェア開発者を支援します。ライブラリには、ファイルからポリゴン メッシュを読み込む、ポリゴン メッシュを作成する、3D モデル内のすべてのポリゴンを三角形に変換する、ポリゴン メッシュをファイルへエクスポートするなど、ポリゴン メッシュ管理に関連するさまざまな機能が含まれています。以下の例は、Mesh オブジェクトを作成し、頂点と面を追加することでポリゴン メッシュを作成する方法を示しています。

Python API を使用してポリゴン メッシュを作成する方法は?

# Create a mesh
mesh = Mesh()

# Add vertices
mesh.Vertices.Add(Vector3(0, 0, 0))
mesh.Vertices.Add(Vector3(0, 0, 1))
mesh.Vertices.Add(Vector3(0, 1, 0))
mesh.Vertices.Add(Vector3(1, 0, 0))

# Add faces
mesh.Faces.AddPolygonFace(0, 1, 2)
mesh.Faces.AddPolygonFace(0, 1, 3)
mesh.Faces.AddPolygonFace(0, 2, 3)
mesh.Faces.AddPolygonFace(1, 2, 3)

# Export the polygon mesh to a file

# Create a scene and add the mesh to it
scene = Scene()
scene.RootNode.CreateChildNode(mesh)

# Save the scene to a file
scene.Save("mesh.obj", FileFormat.WavefrontOBJ)

 日本