[FIXED] FC#3006: PartDesign Mirrored bugs

About the development of the Part Design module/workbench. PLEASE DO NOT POST HELP REQUESTS HERE!
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
abdullah
Veteran
Posts: 4935
Joined: Sun May 04, 2014 3:16 pm
Contact:

Re: FC#3006: PartDesign Mirrored bugs

Post by abdullah »

It is the transformation/inter-matrix-format-conversion itself what makes the colors go:
multi_transform_no_checkintersection4.png
multi_transform_no_checkintersection4.png (3.46 KiB) Viewed 2536 times
test code:

Code: Select all

            double trsl=0;
            
            std::list<gp_Trsf>::const_iterator trsf = (o->second).begin();
            for (unsigned int i=0; i < (o->second).size(); i++,trsf++) {
                trsl+=40;
                /*Base::Matrix4D mat;
                Part::TopoShape::convertToMatrix(*trsf,mat);*/
                Base::Matrix4D mat;
                mat.setToUnity();
                mat.move(0,trsl,0);
                mats[i] = convert(mat);
            }
abdullah
Veteran
Posts: 4935
Joined: Sun May 04, 2014 3:16 pm
Contact:

Re: FC#3006: PartDesign Mirrored bugs

Post by abdullah »

I have tried among others removing different types of transparency, removing the transparency.

I think it is a problem of the transformation and the light. I do not have enough rendering knowledge to be sure, but I think this happens because the transformation is a mirrored transformation, so it is not just a rotation and scaling, but a multiplication by a negative value.

In my test:

Code: Select all

            double trsl=0;
            
            std::list<gp_Trsf>::const_iterator trsf = (o->second).begin();
            for (unsigned int i=0; i < (o->second).size(); i++,trsf++) {
                trsl+=9;
                 
                Base::Matrix4D mat;
                mat.setToUnity();
                mat.scale(-1.0,-1.0,-1.0);
                mat.move(0,trsl,0);
                //Part::TopoShape::convertToMatrix(*trsf,mat);

without the "scale" line, the cubes are red, with it they are black.

I think it might be related to the direction of the normal of the faces of the mesh after transformation. However, as I said, it is pure speculation as I deeply ignore this topic. Maybe somebody more knowledgeable can throw some light (at least to the cube so that it shines red :lol: ).
ickby
Veteran
Posts: 3116
Joined: Wed Oct 05, 2011 7:36 am

Re: FC#3006: PartDesign Mirrored bugs

Post by ickby »

If the normals of the cubes triangles point to the inside their back would be exposed, which is normally not exposed to light, hence black. To test the you can go to the preferences and enable backlight with a certain Colour. If black changes.to that colour your are.sure.that those are.triangle backsides and that somewhere a invertion has happened.
abdullah
Veteran
Posts: 4935
Joined: Sun May 04, 2014 3:16 pm
Contact:

Re: FC#3006: PartDesign Mirrored bugs

Post by abdullah »

ickby wrote: Fri Jun 09, 2017 3:30 am If the normals of the cubes triangles point to the inside their back would be exposed, which is normally not exposed to light, hence black. To test the you can go to the preferences and enable backlight with a certain Colour. If black changes.to that colour your are.sure.that those are.triangle backsides and that somewhere a invertion has happened.
It seems like some faces have changed color...
multi_transform_no_checkintersection5.png
multi_transform_no_checkintersection5.png (6.09 KiB) Viewed 2530 times
abdullah
Veteran
Posts: 4935
Joined: Sun May 04, 2014 3:16 pm
Contact:

Re: FC#3006: PartDesign Mirrored bugs

Post by abdullah »

Well, quite confirmed it is the normals, I just inverted the normals and I get:
multi_transform_no_checkintersection6.png
multi_transform_no_checkintersection6.png (3.38 KiB) Viewed 2526 times
so red goes black, and black goes red.

The problem: if SoMultipleCopy does not have an option to change the direction of the normals of one or more copies, then we might end up adding multiple copies, so repeating the objects, at least if we want it to be red instead of black/red. I do not know if this can be considered to be a Coin3d bug.
User avatar
kkremitzki
Veteran
Posts: 2509
Joined: Thu Mar 03, 2016 9:52 pm
Location: Illinois

Re: FC#3006: PartDesign Mirrored bugs

Post by kkremitzki »

abdullah wrote: Fri Jun 09, 2017 4:41 am Well, quite confirmed it is the normals, I just inverted the normals and I get:

multi_transform_no_checkintersection6.png

so red goes black, and black goes red.

The problem: if SoMultipleCopy does not have an option to change the direction of the normals of one or more copies, then we might end up adding multiple copies, so repeating the objects, at least if we want it to be red instead of black/red. I do not know if this can be considered to be a Coin3d bug.
Yep, I was poking around with the rejectedMaterial definition trying out some other options as well:
material_change.png
material_change.png (26.1 KiB) Viewed 2521 times
I know it's probably the wrong solution, but it should be possible to define a material that looks the same from "inside" and "outside" right?
Like my FreeCAD work? I'd appreciate any level of support via Patreon, Liberapay, or PayPal! Read more about what I do at my blog.
abdullah
Veteran
Posts: 4935
Joined: Sun May 04, 2014 3:16 pm
Contact:

Re: FC#3006: PartDesign Mirrored bugs

Post by abdullah »

kkremitzki wrote: Fri Jun 09, 2017 5:34 am I know it's probably the wrong solution, but it should be possible to define a material that looks the same from "inside" and "outside" right?
I was thinking making two either colocated or slightly separated faces with normals in the opposite direction, so that when it is inverted the innerface has the right normal. Something like a reversible jacket...
abdullah
Veteran
Posts: 4935
Joined: Sun May 04, 2014 3:16 pm
Contact:

Re: FC#3006: PartDesign Mirrored bugs

Post by abdullah »

In fact after some testing, and googling, I have come to the same conclusion:

https://grey.colorado.edu/coin3d/classS ... ceSet.html
A fairly common request when rendering facesets is how to display a set of faces with different colors on the backside versus the frontside. There is not direct support for this in the API, but it can easily be implemented by duplicating all faces in both the SoShapeHints::COUNTERCLOCKWISE and the SoShapeHints::CLOCKWISE order. Here is a simple usage example, showing the technique for a single polygon, using two SoFaceSet nodes for rendering the same polygon from both sides:

#Inventor V2.1 ascii

Separator {
Coordinate3 { point [ 0 0 0, 1 0 0, 1 1 0 ] }

Separator {
Material { diffuseColor [ 1 1 0 ] }
ShapeHints {
vertexOrdering COUNTERCLOCKWISE
shapeType SOLID
}
FaceSet { numVertices [ 3 ] }
}

Separator {
Material { diffuseColor [ 1 0 0 ] }
ShapeHints {
vertexOrdering CLOCKWISE
shapeType SOLID
}
FaceSet { numVertices [ 3 ] }
}
}


The same effect can also be done in the following manner, using an SoIndexedFaceSet to explicitly render the polygon coordinates in both directions (clockwise and counterclockwise):

#Inventor V2.1 ascii

Separator {
Coordinate3 { point [ 0 0 0, 1 0 0, 1 1 0 ] }

Material { diffuseColor [ 1 0 0, 1 1 0 ] }
MaterialBinding { value PER_FACE_INDEXED }

ShapeHints {
vertexOrdering COUNTERCLOCKWISE
shapeType SOLID
}

IndexedFaceSet {
coordIndex [ 0, 1, 2, -1, 2, 1, 0, -1 ]
materialIndex [ 0, 1 ]
}
}
abdullah
Veteran
Posts: 4935
Joined: Sun May 04, 2014 3:16 pm
Contact:

Re: FC#3006: PartDesign Mirrored bugs

Post by abdullah »

kkremitzki wrote: Fri Jun 09, 2017 5:34 am I know it's probably the wrong solution, but it should be possible to define a material that looks the same from "inside" and "outside" right?
Not necessarily. What did you change so that you can see the cubes with light/dark red?

EDIT: I guess you set an emissiveColor.
User avatar
kkremitzki
Veteran
Posts: 2509
Joined: Thu Mar 03, 2016 9:52 pm
Location: Illinois

Re: FC#3006: PartDesign Mirrored bugs

Post by kkremitzki »

abdullah wrote: Sat Jun 10, 2017 5:30 am
kkremitzki wrote: Fri Jun 09, 2017 5:34 am I know it's probably the wrong solution, but it should be possible to define a material that looks the same from "inside" and "outside" right?
Not necessarily. What did you change so that you can see the cubes with light/dark red?

EDIT: I guess you set an emissiveColor.
That's right, I was messing around with the different types of color that could be set, and I think in that screenshot it was emissiveColor.
Like my FreeCAD work? I'd appreciate any level of support via Patreon, Liberapay, or PayPal! Read more about what I do at my blog.
Post Reply