Material

FbxSaveOptions: com.aspose.threed.shading (aspose-3d-foss)

Aspose.3D FOSS for Java menyediakan dua kelas bahan:

  • Material: kelas asas abstrak untuk semua jenis bahan. Menyediakan nama dan koleksi sifat untuk parameter berangka dan warna.
  • PbrMaterial: bahan Physically Based Rendering dengan sifat metalness, roughness, albedo, dan emissive. Digunakan oleh glTF 2.0 dan format lain yang menyokong PBR.

Bahan-bahan diberikan kepada satu Node melalui node.setMaterial(material).


FbxSaveOptions

public abstract class Material extends A3DObject

FbxSaveOptions

A3DObject -> Material

Material adalah asas abstrak untuk semua jenis bahan. Ia menyediakan sifat nama dan satu Properties koleksi untuk metadata yang ditakrifkan pengguna. Anda tidak membuat contoh Material secara langsung; gunakan PbrMaterial sebagai gantinya.


PbrMaterial

public class PbrMaterial extends Material

FbxSaveOptions

A3DObject -> Material -> PbrMaterial

Bahan PBR (Physically Based Rendering). Digunakan oleh glTF 2.0 dan format lain yang menyokong PBR. Diberikan kepada satu Node melalui node.setMaterial(material).

FbxSaveOptions

PbrMaterial()
PbrMaterial(String name)
PbrMaterial(String name, Vector4 albedo)

FbxSaveOptions

NameTypeAccessDescription
MAP_SPECULARStringReadUsed in setTexture(java.lang.String, com.aspose.threed.TextureBase) to assign a specular texture mapping.
MAP_DIFFUSEStringReadUsed in setTexture(java.lang.String, com.aspose.threed.TextureBase) to assign a diffuse texture mapping.
MAP_EMISSIVEStringReadUsed in setTexture(java.lang.String, com.aspose.threed.TextureBase) to assign a emissive texture mapping.
MAP_AMBIENTStringReadUsed in setTexture(java.lang.String, com.aspose.threed.TextureBase) to assign a ambient texture mapping.
MAP_NORMALStringReadUsed in setTexture(java.lang.String, com.aspose.threed.TextureBase) to assign a normal texture mapping.
nameStringReadGets the name.
propertiesPropertyCollectionReadGets the properties.
SignatureDescription
getTexture(slotName: String)TextureBaseGets the texture from the specified slot, it can be material’s property name or shader’s parameter name.
setTexture(slotName: String, texture: TextureBase)Sets the texture to specified slot.
toString()StringFormats object to string.
iterator()Iterator<TextureSlot>Gets the enumerator to enumerate internal texture slots.
A3DObject()Parameterized Cylinder. It can also be used to represent a cone when one of radiusTop/radiusBottom is zero.
getName()StringThe segments of the curve.
setName(name: String)Constructs a CircleShape profile with specified radius.
getProperties()PropertyCollectionInitializes a new instance of Cylinder class.
findProperty(name: String)PropertyInitializes a new instance of the Bone class.
getProperty(name: String)ObjectGets the transform matrix of the node in current pose.
setProperty(name: String, value: Object)Gets the width segments.
removeProperty(name: String)booleanGets flip coordinate system of control points/normal during importing/exporting.

Contoh Penggunaan

import com.aspose.threed.*;
import com.aspose.threed.shading.PbrMaterial;

Scene scene = new Scene();

Mesh mesh = new Mesh();
mesh.getControlPoints().add(new Vector4(0, 0, 0, 1));
mesh.getControlPoints().add(new Vector4(1, 0, 0, 1));
mesh.getControlPoints().add(new Vector4(0.5, 1, 0, 1));
mesh.createPolygon(0, 1, 2);

PbrMaterial mat = new PbrMaterial("pbr-metal");
mat.setAlbedo(new Vector4(0.8, 0.6, 0.2, 1.0));    // gold-ish base color
mat.setMetallicFactor(0.9);
mat.setRoughnessFactor(0.2);

Node node = scene.getRootNode().createChildNode("mesh", mesh);
node.setMaterial(mat);

scene.save("pbr.glb");

Bahan PBR Separuh Lutsinar

import com.aspose.threed.shading.PbrMaterial;

PbrMaterial mat = new PbrMaterial("glass");
mat.setAlbedo(new Vector4(0.7, 0.9, 1.0, 1.0));
mat.setTransparency(0.7);   // 70% transparent
mat.setRoughnessFactor(0.1);

Baca Bahan dari Adegan Terimport

import com.aspose.threed.*;
import com.aspose.threed.shading.PbrMaterial;

Scene scene = new Scene();
scene.open("model.gltf");

inspectNode(scene.getRootNode());

static void inspectNode(Node node) {
    if (node.getMaterial() != null) {
        Material m = node.getMaterial();
        if (m instanceof PbrMaterial) {
            PbrMaterial pbr = (PbrMaterial) m;
            System.out.println("Node '" + node.getName() + "': PbrMaterial");
            System.out.println("  albedo=" + pbr.getAlbedo());
            System.out.println("  metallic=" + pbr.getMetallicFactor());
            System.out.println("  roughness=" + pbr.getRoughnessFactor());
        } else {
            System.out.println("Node '" + node.getName() + "': " + m.getClass().getSimpleName());
        }
    }
    for (Node child : node.getChildNodes()) {
        inspectNode(child);
    }
}

Lihat Juga

 Bahasa Melayu