All Products
Search
Document Center

PolarDB:ST_ImportObj

Last Updated:Apr 16, 2024

This function imports an OBJ file that is stored in an Object Storage Service (OSS) bucket or memory into a database.

Syntax

boolean ST_ImportObj(text table_name,  text url,   text id,  text options default '{}');
boolean ST_ImportObj(text table_name,  bytea content,   text id,  text options default '{}');

Return values

Return value

Description

true

The file is imported.

false

The file failed to be imported.

Parameters

Parameter

Description

table_name

The name of the OBJ table and the prefix of the corresponding sharded table.

url

The path of the file in an Object Storage Service (OSS) bucket.

id

The ID of the OBJ file in strings.

content

The OBJ file in the binary stream format.

options

The options for the import. Valid values:

  • schema

  • search_path

  • ignore_missing

  • force_triangulate

  • metallic_roughness

  • obj_data_column

  • obj_id_column

Limits and options

  • Data limits:

    Only the textures files of the diffusetexture type are supported. The texture files of other types are ignored.

  • Options for the import:

    Option

    Type

    Description

    Default value

    Example

    schema

    String

    The schema of the required table.

    public

    postgres

    search_path

    String

    The search path of the material or texture.

    If the OBJ file is specified by using a URL, the parent path of the OBJ file is used. Otherwise, this parameter is left empty.

    OSS://foo/bar

    ignore_missing

    Boolean

    Specifies whether to ignore the error when no material or texture files are obtained.

    true

    false

    force_triangulate

    Boolean

    Specifies whether to forcibly triangulate non-triangular faces.

    true

    false

    metallic_roughness

    Boolean

    Specifies whether to parse the OBJ file as a material of the metallic_roughness type. If this parameter is set to false, the OBJ file is parsed as a material of the specular_glossiness type.

    true

    false

    obj_data_column

    String

    The data field of the primary table.

    obj_data

    my_data

    obj_id_column

    String

    The data ID field of the primary table.

    obj_id

    my_id

    The following table describes the schema of the primary table.

    Field

    Type

    Description

    Comment

    id

    serial

    The ID of the primary table.

    The primary key of the primary table.

    [obj_id_column]

    text

    The ID of the data record.

    You can specify this field. The default field name is obj_id, which is specified by the system based on the value specified by the user.

    [obj_data_column]

    sfmesh

    The data.

    You can specify this field. The default value of this field is obj_data.

    The following table describes the schema of the component table.

    Field

    Type

    Description

    Comment

    id

    serial

    The ID of the component table.

    The primary key of the component table.

    obj_id

    text

    The ID of the data record.

    The field name is fixed to obj_id, which is specified by the system based on the value specified by the user.

    component_id

    text

    The component ID.

    The sequence number of the component in the original OBJ file.

    name

    text

    The component name.

    The group or object name of the OBJ file. If multiple group or object names exist, the first name is used as the value. Otherwise, the field is set to Mesh_[object sequence number].

    tags

    jsonb

    The tags of the OBJ file.

    component

    sfmesh

    The component name.

    -

    The following table describes the schema of the texture table.

    Field

    Type

    Description

    Comment

    id

    serial

    The ID of the texture table.

    The primary key of the texture table.

    obj_id

    text

    The ID of the data record.

    The field name is fixed to obj_id, which is specified by the system based on the value specified by the user.

    texture_id

    text

    The ID of the texture.

    The sequence number of the texture in the original OBJ file.

    name

    text

    The texture name.

    The file name of the texture.

    texture

    texture

    The texture name.

    -

Examples

SELECT ST_ImportObj('test_obj', 'OSS://<ak>:<ak_secret>@oss-cn-beijing-internal.aliyuncs.com/mybucket/path_to_obj.obj');

---------
t

Disable forced triangulation import.

SELECT ST_ImportObj('test_obj', 'OSS://<ak>:<ak_secret>@oss-cn-beijing-internal.aliyuncs.com/mybucket/path_to_obj.obj', '{"force_triangulate": false}');

---------
t