Material

Properties: aspose.threed.shading (aspose-3d-foss)

Aspose.3D FOSS biedt twee materiaalklassen in de klassieke shading-hiërarchie:

  • LambertMaterial: diffuse matte shading (geen speculariteit)
  • PhongMaterial: breidt Lambert uit met speculaire highlights en glans

Beide worden toegewezen aan een Node via node.material. Kleuren worden ingesteld met Vector3(r, g, b) waar componenten in [0.0, 1.0].


LambertMaterial

class LambertMaterial(Material):

Properties

A3DObjectMaterialLambertMaterial

Properties

LambertMaterial(name: str = None)

Properties

NameTypeAccessDescription
namestrRead/WriteGets or sets the name.
propertiesPropertyCollectionReadGets the properties.

PhongMaterial

class PhongMaterial(LambertMaterial):

Properties

A3DObjectMaterialLambertMaterialPhongMaterial

Erft alles LambertMaterial eigenschappen en voegt toe:

Aanvullende eigenschappen

SignatureDescription
__init__(name: str)
get_texture(slot_name: str)Not implemented in the FOSS edition — throws at runtime. Retrieves the texture assigned to the specified slot name
set_texture(slot_name: str, texture)Not implemented in the FOSS edition — throws at runtime. Sets the texture value.
find_property(property_name: str)
get_property(property: str)
set_property(property: str, value)Sets the property value.
remove_property(property)

Voorbeelden

Lambert Mat Materiaal

from aspose.threed import Scene
from aspose.threed.entities import Mesh
from aspose.threed.shading import LambertMaterial
from aspose.threed.utilities import Vector3, Vector4

scene = Scene()

# Build a simple triangle mesh
mesh = Mesh()
mesh.control_points.append(Vector4(0, 0, 0, 1))
mesh.control_points.append(Vector4(1, 0, 0, 1))
mesh.control_points.append(Vector4(0.5, 1, 0, 1))
mesh.create_polygon(0, 1, 2)

# Create a matte red material
mat = LambertMaterial("red-matte")
mat.diffuse_color = Vector3(0.8, 0.1, 0.1)    # R, G, B in [0, 1]
mat.ambient_color = Vector3(0.1, 0.05, 0.05)

node = scene.root_node.create_child_node("triangle", mesh)
node.material = mat

scene.save("lambert.obj")

Phong Glanzend Materiaal

from aspose.threed import Scene
from aspose.threed.entities import Mesh
from aspose.threed.shading import PhongMaterial
from aspose.threed.utilities import Vector3, Vector4

scene = Scene()

mesh = Mesh()
mesh.control_points.append(Vector4(0, 0, 0, 1))
mesh.control_points.append(Vector4(1, 0, 0, 1))
mesh.control_points.append(Vector4(0.5, 1, 0, 1))
mesh.create_polygon(0, 1, 2)

mat = PhongMaterial("shiny-blue")
mat.diffuse_color = Vector3(0.1, 0.2, 0.8)   # blue
mat.specular_color = Vector3(1.0, 1.0, 1.0)  # white highlights
mat.specular_factor = 0.5
mat.shininess = 64.0                           # tight specular lobe
mat.ambient_color = Vector3(0.05, 0.05, 0.1)

node = scene.root_node.create_child_node("mesh", mesh)
node.material = mat

scene.save("phong.obj")

Halftransparant Materiaal

from aspose.threed.shading import LambertMaterial
from aspose.threed.utilities import Vector3

mat = LambertMaterial("glass")
mat.diffuse_color = Vector3(0.7, 0.9, 1.0)   # faint blue tint
mat.transparency = 0.7                         # 70% transparent

Materiaal lezen uit geïmporteerde scène

from aspose.threed import Scene
from aspose.threed.shading import LambertMaterial, PhongMaterial

scene = Scene()
scene.open("model.obj")

def inspect_node(node):
    if node.material:
        m = node.material
        kind = "Phong" if isinstance(m, PhongMaterial) else "Lambert"
        print(f"Node '{node.name}': {kind}: diffuse={m.diffuse_color}")
        if isinstance(m, PhongMaterial):
            print(f"  shininess={m.shininess}")
    for child in node.child_nodes:
        inspect_node(child)

inspect_node(scene.root_node)

PbrMaterial

class PbrMaterial(Material):

Properties

A3DObjectMaterialPbrMaterial

PBR (Physically Based Rendering) materiaal. Gebruikt door glTF 2.0 en andere PBR-compatibele formaten. Toegewezen aan een Node via node.material.

Properties

PbrMaterial(name: str = None, albedo: Vector3 = None)

Properties

Klassenmethode

Gebruikvoorbeeld

from aspose.threed import Scene
from aspose.threed.entities import Mesh
from aspose.threed.shading import PbrMaterial
from aspose.threed.utilities import Vector3, Vector4

scene = Scene()

mesh = Mesh()
mesh.control_points.append(Vector4(0, 0, 0, 1))
mesh.control_points.append(Vector4(1, 0, 0, 1))
mesh.control_points.append(Vector4(0.5, 1, 0, 1))
mesh.create_polygon(0, 1, 2)

mat = PbrMaterial("pbr-metal")
mat.albedo = Vector3(0.8, 0.6, 0.2)    # gold-ish base color
mat.metallic_factor = 0.9
mat.roughness_factor = 0.2

node = scene.root_node.create_child_node("mesh", mesh)
node.material = mat

scene.save("pbr.glb")

Zie ook

 Nederlands