
Aspose.3D สำหรับ Python ผ่าน .NET
API ของ Python เพื่อสร้าง, แก้ไขและแปลงโมเดล 3 มิติ
ไลบรารี Python ที่มีประโยชน์สำหรับการสร้าง, แก้ไข, ประมวลผลรูปแบบไฟล์ 3 มิติและฉาก 3 มิติ รวมถึงการแปลงเป็น FBX, STL, Discreet3DS, Universal3D, Collada และอื่น ๆ
Aspose.3D สำหรับ Python ผ่าน .NET คืออะไร?
Aspose.3D for Python via .NET เป็นไลบรารีที่ครอบคลุมและเสถียร ซึ่งช่วยให้นักพัฒนาซอฟต์แวร์สามารถทำงานกับไฟล์และโมเดล 3D ภายในแอปพลิเคชัน Python ได้โดยไม่ต้องติดตั้งซอฟต์แวร์การสร้างโมเดลและการเรนเดอร์ 3D ไลบรารีนี้ช่วยนักพัฒนาซอฟต์แวร์สร้างแอปพลิเคชันที่สามารถสร้าง อ่าน เรนเดอร์ ปรับแต่ง และแปลงโมเดล 3D ในรูปแบบไฟล์ต่าง ๆ ได้อย่างง่ายดาย รวมถึง FBX, 3DS, U3D, DAE, glTF, OBJ, STL, DRC, PDF, AMF, PLY และอื่น ๆ อีกมากมาย ไลบรารีใช้เทคนิคหลากหลายเพื่อให้การดำเนินการ 3D ทำได้อย่างมีประสิทธิภาพและรวดเร็ว แม้กับโมเดล 3D ขนาดใหญ่และซับซ้อน
Aspose.3D สำหรับ Python ผ่าน .NET ได้รวมคุณลักษณะสำคัญหลายอย่างสำหรับการทำงานกับแอนิเมชัน 3 มิติ เช่น การสร้างและจัดการแอนิเมชัน 3 มิติ เช่น แอนิเมชันแบบคีย์เฟรม, แอนิเมชันโครงกระดูก, และแอนิเมชันมอร์ฟ ทำให้การสร้างแอปพลิเคชันและเกม 3 มิติที่น่าสนใจและโต้ตอบได้ง่ายขึ้น ไลบรารีนี้ยังให้เครื่องมือและคุณลักษณะหลากหลายสำหรับการจัดการโมเดล 3 มิติ ซึ่งรวมถึงความสามารถในการนำเข้าและส่งออกโมเดล 3 มิติ, สร้างและแก้ไขโมเดล 3 มิติ, และทำการดำเนินการต่าง ๆ บนโมเดล 3 มิติ เช่น การปรับขนาด, การหมุน, และการแปลตำแหน่ง
Aspose.3D สำหรับ Python ผ่าน .NET ถูกสร้างขึ้นบนพื้นฐานของเฟรมเวิร์ก .NET และสามารถใช้ร่วมกับ Python ผ่าน IronPython ซึ่งเป็นการนำภาษา Python ไปใช้บน .NET ด้วย การสนับสนุนรูปแบบไฟล์ 3 มิติหลายประเภทและชุดคุณลักษณะที่ครอบคลุมสำหรับการจัดการและทำแอนิเมชันโมเดล 3 มิติ ทำให้เป็นตัวเลือกที่ยอดเยี่ยมสำหรับนักพัฒนาที่ต้องทำงานกับเนื้อหา 3 มิติในแอปพลิเคชันของตน
เริ่มต้นใช้งาน Aspose.3D สำหรับ Python ผ่าน .NET
วิธีที่ง่ายที่สุดในการติดตั้ง Aspose.3D สำหรับ Python ผ่าน .NET รุ่นเสถียรคือการใช้ pip. โปรดใช้คำสั่งต่อไปนี้เพื่อการติดตั้งที่ราบรื่น.
ติดตั้ง Aspose.3D สำหรับ Python ผ่าน .NET ผ่าน pip
pip install aspose-3d คุณยังสามารถดาวน์โหลดได้โดยตรงจาก หน้าผลิตภัณฑ์ของ Aspose.สร้างและโหลดฉาก 3D ผ่าน API ของ Python
Aspose.3D สำหรับ Python ผ่าน .NET มีการสนับสนุนเต็มรูปแบบสำหรับการสร้างฉาก 3D ใหม่ตั้งแต่เริ่มต้นและจากนั้นบันทึกเป็นรูปแบบไฟล์ที่รองรับใด ๆ ด้วยคำสั่ง Python. ไลบรารีนี้ยังให้การสนับสนุนในการอ่านฉาก 3D ที่มีอยู่, ทำการเปลี่ยนแปลงใน 3D ที่มีอยู่, บันทึกฉาก 3D เป็น PDF, เปิดฉากที่มีอยู่จาก PDF ที่ป้องกันด้วยรหัสผ่าน, ตรวจจับรูปแบบไฟล์, ดึงเนื้อหา 3D จากไฟล์ PDF, ตั้งค่าตัวเลือกการโหลดก่อนโหลดไฟล์ Obj 3D และอื่น ๆ อีกมากมาย.
วิธีสร้างเอกสารฉาก 3D ผ่าน Python API?
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)
การเรนเดอร์ฉาก 3D ผ่าน API ของ Python
Aspose.3D for Python via .NET ช่วยให้ผู้พัฒนาซอฟต์แวร์สามารถโหลดและเรนเดอร์ฉาก 3 มิติภายในแอปพลิเคชัน Python ของตนเองได้ ไลบรารีนี้รองรับการเรนเดอร์คุณภาพสูงของฉาก 3 มิติ รวมถึงการตัดขอบหยัก (anti-aliasing), ความลึกของสนาม (depth of field), การเบลอการเคลื่อนไหว (motion blur) และอื่น ๆ อีกมาก มันยังรองรับการนำเข้าและส่งออกรูปแบบไฟล์ 3 มิติต่าง ๆ เช่น FBX, OBJ, STL, และ 3DS ซึ่งหมายความว่าคุณสามารถนำเข้ารุ่น 3 มิติที่มีอยู่แล้วเข้าสู่ฉากของคุณหรือส่งออกฉาก 3 มิติของคุณเป็นรูปแบบที่เข้ากันได้ มันสนับสนุนคุณลักษณะเช่น การสร้างเงาและรับเงาบนเรขาคณิต 3 มิติ, การเรนเดอร์โดยใช้ฮาร์ดแวร์ของเรขาคณิต 3 มิติ, การเรนเดอร์มุมมอง 3 มิติเป็นรูปภาพจากกล้อง, การเรนเดอร์มุมมองพาโนรามาของฉาก 3 มิติ, เป็นต้น ตัวอย่างโค้ดต่อไปนี้แสดงให้เห็นว่าผู้พัฒนาซอฟต์แวร์สามารถเรนเดอร์มุมมองพาโนรามาของฉาก 3 มิติและบันทึกเป็นรูปภาพได้อย่างไร
วิธีเรนเดอร์มุมมองพาโนรามาของฉาก 3D & บันทึกเป็นรูปภาพผ่าน Python?
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 สำหรับ Python ผ่าน .NET ให้ความสามารถแก่ผู้พัฒนาซอฟต์แวร์ในการสร้างและทำงานกับแอนิเมชันภายในเอกสาร 3D ด้วยไลบรารี Python ไลบรารีนี้รวมคุณลักษณะหลายอย่างสำหรับการทำงานกับแอนิเมชัน เช่น การเรนเดอร์ฉากที่เคลื่อนไหว การตั้งค่ากล้องเป้าหมายในไฟล์ 3D การสร้างแอนิเมชันโครงกระดูก การทำงานกับ morph targets และการผสมหลายแอนิเมชัน ตัวอย่างต่อไปนี้แสดงวิธีสร้างแอนิเมชันง่าย ๆ ด้วยคำสั่ง 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)
ทำงานกับโพลิกอนโดยใช้ API ของ Python
Aspose.3D สำหรับ Python ผ่าน .NET ช่วยให้ผู้พัฒนาซอฟต์แวร์สามารถเพิ่มและจัดการโพลิกอนเมช์ในโมเดล 3D ของพวกเขาภายในแอปพลิเคชัน Python ไลบรารีนี้รวมการสนับสนุนคุณลักษณะต่าง ๆ ที่เกี่ยวข้องกับการจัดการโพลิกอนเมช์ เช่น การโหลดโพลิกอนเมช์จากไฟล์ การสร้างโพลิกอนเมช์ การแปลงโพลิกอนทั้งหมดเป็นสามเหลี่ยมในโมเดล 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)
