Add black border around polygons

I’m trying to add a black border around my polygons. What I use to dram them is:

public static void DrawBox(double startX, double startY, double startZ, double length, double width, double heigth, Color color)
{
var outputDir = System.Environment.GetEnvironmentVariable(“OuputDir”);
var outputFileName = System.Environment.GetEnvironmentVariable(“OutputFileName”);

        Scene scene = new Scene(outputDir + outputFileName);
        Node cubeNode = new Node("cube");
        cubeNode.Material = new PhongMaterial() { DiffuseColor = new Vector3(color) };
        Mesh mesh = Common.CreateMeshUsingPolygonBuilder(startX, startY, startZ, length, heigth, width);
        mesh.CastShadows = false;
        RotateNode(cubeNode);
        cubeNode.Entity = mesh;
        scene.RootNode.ChildNodes.Add(cubeNode);

        // Save 3D scene in the supported file formats
        scene.Save(outputDir + outputFileName, FileFormat.FBX7400ASCII);
    }

    public static Mesh CreateMeshUsingPolygonBuilder(double startX, double startY, double startZ, double length, double height, double width)
    {
        Vector4[] controlPoints = DefineControlPoints(startX, startY, startZ, length, height, width);
        Mesh mesh = new Mesh();
        mesh.ControlPoints.AddRange(controlPoints);

        int[] indices = new int[]
        {
            0,1,2,3, // Front face (Z+)
            1,5,6,2, // Right side (X+)
            5,4,7,6, // Back face (Z-)
            4,0,3,7, // Left side (X-)
            0,4,5,1, // Bottom face (Y-)
            3,2,6,7 // Top face (Y+)
        };

        int vertexId = 0;
        PolygonBuilder builder = new PolygonBuilder(mesh);
        for (int face = 0; face < 6; face++)
        {
            builder.Begin();
            for (int v = 0; v < 4; v++)
            {
                builder.AddVertex(indices[vertexId++]);
            }

            builder.End();
        }

        return mesh;
    }

I end up with a picture like this:
image.png (23.9 KB)

I need to have a thick black border around my boxes. How can I do that ?

@salazarkn1

We have logged an investigation ticket as THREEDNET-878 in our issue tracking system. We will further look into details of this case and let you know as soon as the logged ticket is resolved. Please be patient and spare us some time.

We apologize for the inconvenience.

1 Like

@salazarkn1

Could you please share how you are getting the image? from Aspose.3D renderer or from other tools?

None of the 3D formats supports a black border definition.

It’s usually implemented by the renderer itself, not the file format, Aspose.3D built-in renderer does not support that right now, but we can try to implement it in the future version(s).

This is a new file that I’m creating from scratch. I am trying to visualize the loading of boxes into a container step by step but I need to be able to set a border around the boxes, so that we can see where individual packages from specific group are placed. Each group is colored differently but individual packages from the same group are colored in the same way. We need to see as different objects those individual packages.
This is how I create the main container:

public static void DrawContainer(double length, double heigth, double width)
{
Scene scene = new Scene();
Node cubeNode = new Node(“cube”);

        Mesh mesh = Common.CreateContainer(0.0, 0.0, 0.0, length, heigth, width);
        mesh.CastShadows = false;
        RotateNode(cubeNode);
        cubeNode.Entity = mesh;
        scene.RootNode.ChildNodes.Add(cubeNode);

        // Save 3D scene in the supported file formats
        scene.Save(System.Environment.GetEnvironmentVariable("OuputDir") + System.Environment.GetEnvironmentVariable("OutputFileName"), 
            FileFormat.FBX7400ASCII);
    }

This is how I draw boxes:

   public static void DrawBox(double startX, double startY, double startZ, double length, double width, double heigth, Color color)
    {
        var outputDir = System.Environment.GetEnvironmentVariable("OuputDir");
        var outputFileName = System.Environment.GetEnvironmentVariable("OutputFileName");

        Scene scene = new Scene(outputDir + outputFileName);
        Node cubeNode = new Node("cube");
        cubeNode.Material = new PhongMaterial() { DiffuseColor = new Vector3(color) };
        Mesh mesh = Common.CreateMeshUsingPolygonBuilder(startX, startY, startZ, length, heigth, width);
        mesh.CastShadows = false;
        RotateNode(cubeNode);
        cubeNode.Entity = mesh;
        scene.RootNode.ChildNodes.Add(cubeNode);

        // Save 3D scene in the supported file formats
        scene.Save(outputDir + outputFileName, FileFormat.FBX7400ASCII);
    }

And this is the create mesh:

public static Mesh CreateMeshUsingPolygonBuilder(double startX, double startY, double startZ, double length, double height, double width)
{
Vector4[] controlPoints = DefineControlPoints(startX, startY, startZ, length, height, width);
Mesh mesh = new Mesh();
mesh.ControlPoints.AddRange(controlPoints);

        int[] indices = new int[]
        {
            0,1,2,3, // Front face (Z+)
            1,5,6,2, // Right side (X+)
            5,4,7,6, // Back face (Z-)
            4,0,3,7, // Left side (X-)
            0,4,5,1, // Bottom face (Y-)
            3,2,6,7 // Top face (Y+)
        };

        int vertexId = 0;
        PolygonBuilder builder = new PolygonBuilder(mesh);
        for (int face = 0; face < 6; face++)
        {
            builder.Begin();
            for (int v = 0; v < 4; v++)
            {
                builder.AddVertex(indices[vertexId++]);
            }

            builder.End();
        }

        return mesh;
    }

It’s very important that we have a border around each package or some other way to distinguish where one box ends and another start. Otherwise we won’t be able to use this tool to visualize it properly.

Thank you for your help!

@salazarkn1

Thanks for providing the requested details.

We have updated the information of the logged ticket and will inform you as soon as it is resolved.

@salazarkn1

The provided details have been checked and we found that they were not enough to carry out the investigation. Please share how you are getting the rendered image? You cannot have a 3D file with customized border style in any 3D file formats, that is the feature of renderer, not file formats.

@asad.ali
I’m not getting a rendered image, I’m creating a new 3d image and then draw objects one by one.

Scene scene = new Scene();
Node cubeNode = new Node(“cube”);

When I call this:
scene.Save(".\output\CubeScene.fbx", FileFormat.FBX7400ASCII);

it will create a new file.
My question is when I draw the individual items, how do I add thick border around them?
I use this for drawing objects and call it many times based on the boxes I want to draw:

public static void DrawBox(double startX, double startY, double startZ, double length, double width, double heigth, Color color)
{
//string outputDir = SettingsConfigHelper.AppSetting(“MySettings:OutputDir”);
//string outputFileName = SettingsConfigHelper.AppSetting(“MySettings:OutputFileName”);

        Scene scene = new Scene(".\\output\\CubeScene.fbx");
        Node cubeNode = new Node("cube");
        cubeNode.Material = new PhongMaterial() { DiffuseColor = new Vector3(color) };
        Mesh mesh = Common.CreateMeshUsingPolygonBuilder(startX, startY, startZ, length, heigth, width);
        mesh.CastShadows = false;
        RotateNode(cubeNode);
        cubeNode.Entity = mesh;
        scene.RootNode.ChildNodes.Add(cubeNode);

        // Save 3D scene in the supported file formats
        scene.Save(".\\output\\CubeScene.fbx", FileFormat.FBX7400ASCII);
    }

@salazarkn1

Regretfully, there is no way to achieve your requirements. The 3D files like FBX do not store border definition. But you will see thick border in some tools, because it is rendering feature of these tools and cannot be done through some files.

Thank you, @asad.ali
Is there any way to convert the fbx file to png/jpeg or other format and see the borders there?

@salazarkn1

We are afraid that this may also not be possible. However, we are checking further and will let you know in a while.

Ok, thank you!

@salazarkn1

We will try to add new feature to display border in our renderer. We will further inform you in case of additional updates.

Hi @asad.ali,

Is there any cleanerness on if this is possible and when it will be integrated in prod version?

Thank you!

@salazarkn1

At the moment, the earlier logged ticket is under the phase of investigation and as soon as it is analyzed, we will be in a position to share some ETA with you. We will definitely let you know about the additional updates as soon as the ticket is fully investigated. Please be patient and spare us some time.

We are sorry for the inconvenience.