Assign texture to object

Discuss and ask questions about CAD VCL (Delphi and C++ Builder).

Moderators: SDS, support, admin

Post Reply
MikeD
Posts: 16
Joined: 27 Jan 2015, 17:45

Assign texture to object

Post by MikeD » 29 Jan 2015, 17:06

Hi,

is it possible to assign a texture to an object inside the 3d viewer?
If so, what workflow or what functions/procedures would I need for that?

-Mike

support
Posts: 3271
Joined: 30 Mar 2005, 11:36
Contact:

Re: Assign texture to object

Post by support » 02 Feb 2015, 17:24

Hello Mike,

It is possible to assign a material to facegroups (TsgMeshObject.FaceGroups). A facegroup is usually a mesh that shares the same texture. Have a look at the code example below to fugure out how to get mesh objects from a specified entity (TsgDXFEntity):

Code: Select all

type
  Tsg3DDrawingNavigatorAccess = class(Tsg3DDrawingNavigator);
...

function EntToMeshObjectList(A3DNavigator: Tsg3DDrawingNavigator; AEntity: TsgDXFEntity; var AMeshObjectsList: TList): Boolean;
var
  I, C: Integer;
  vNav3d: Tsg3DDrawingNavigatorAccess;
  vMesh: TObject;

  procedure AddMeshObjects(AInsert: TObject);
  var
    vMeshes: TList;
  begin
    vMeshes := vNav3d.GetInsertMeshes(AInsert);
    try
      AMeshObjectsList.Assign(vMeshes, laOr);
    finally
      vMeshes.Free;
    end;
  end;

begin
  vNav3d := Tsg3DDrawingNavigatorAccess(A3DNavigator);
  C := AMeshObjectsList.Count;
  case AEntity.EntType of
    ceInsert: AddMeshObjects(AEntity);
    ce3DSolid, ceStep, ceBrep, ceIges:
      begin
        for I := 0 to AEntity.Count - 1 do
          if AEntity.EntType = ceInsert then
            AddMeshObjects(AEntity);
      end;
  else
    vMesh := vNav3d.EntToGLObj(AEntity);
    if vMesh <> nil then
      AMeshObjectsList.Add(vMesh);
  end;
  Result := C <> AMeshObjectsList.Count;
end; 
Mikhail
Technical Support E-mail: support@cadsofttools.com
Chat support on Skype: cadsofttools.support

MikeD
Posts: 16
Joined: 27 Jan 2015, 17:45

Re: Assign texture to object

Post by MikeD » 02 Feb 2015, 18:31

Thanks a lot Mikhail, I will look into that.

-Mike

Post Reply