Results 1 to 7 of 7

Thread: How to add 3D object

  1. #1
    Join Date
    Jun 2015
    Posts
    109
    Thanks
    20
    Qt products
    Qt5
    Platforms
    Unix/X11 Windows

    Default How to add 3D object

    Hi,

    I have a 3D object but didn't find a proper way to add it.
    I'm not using any qml file for development.

    I got some examples like Qt3DRender::QMesh, but they have explained it will XML file, and I'm not using any XML file.

    Please suggest me an example or your suggestions for this.

    Thanks

  2. #2
    Join Date
    Jun 2015
    Posts
    109
    Thanks
    20
    Qt products
    Qt5
    Platforms
    Unix/X11 Windows

    Default Re: How to add 3D object

    Hi,

    I'm using the viewer as pcl::visualization::PCLVisualizer, and I want to add this 3D object over that viewer.
    I've done this below, but not sure does it right or wrong, and now want to add this Vehicle.obj 3D object over the viewer
    Qt Code:
    1. vtkWidget = new QVTKWidget(this);
    2.  
    3. viewer = pcl::visualization::PCLVisualizer("viewer", false);
    4.  
    5. vtkWidget->SetRenderWindow(viewer->getRenderWindow());
    6.  
    7. QHBoxLayout *layout = new QHBoxLayout(this);
    8. layout->addWidget(vtkWidget);
    9.  
    10. // Root entity
    11. Qt3DCore::QEntity *rootEntity = new Qt3DCore::QEntity;
    12.  
    13. // Material
    14. Qt3DRender::QMaterial *material = new Qt3DExtras::QPhongMaterial(rootEntity);
    15.  
    16. // Chest Entity
    17. Qt3DCore::QEntity *Entity = new Qt3DCore::QEntity(rootEntity);
    18. Qt3DRender::QMesh *Mesh = new Qt3DRender::QMesh(rootEntity);
    19. Mesh->setSource(QUrl("qrc:/Vehicle.obj"));
    20.  
    21. Entity->addComponent(Mesh);
    22. Entity->addComponent(material);
    23.  
    24. Qt3DCore::QEntity *scene = rootEntity;
    25.  
    26. Qt3DExtras::Qt3DWindow view;
    27. view.setRootEntity(scene);
    To copy to clipboard, switch view to plain text mode 
    ]

    Please help me out here, I didn't find a piece of proper information over google.

    Thanks in advance!

  3. #3
    Join Date
    Jun 2015
    Posts
    109
    Thanks
    20
    Qt products
    Qt5
    Platforms
    Unix/X11 Windows

    Default Re: How to add 3D object

    Hi,

    Still, I'm on the same page, please help me with some findings.

    Thanks

  4. #4
    Join Date
    Jan 2008
    Location
    Alameda, CA, USA
    Posts
    5,229
    Thanks
    302
    Thanked 864 Times in 851 Posts
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: How to add 3D object

    I think you are trying to mix apples, oranges, and maybe some other kind of fruit together and the blend isn't working. VTK and Qt3D might all be using OpenGL for display purposes, but each is using a different object model, transformations, and other things which probably are not compatible.

    Qt3DExtras::Qt3DWindow view;
    What do you think happens to this view instance once the code where this variable lives goes out of scope?
    <=== The Great Pumpkin says ===>
    Please use CODE tags when posting source code so it is more readable. Click "Go Advanced" and then the "#" icon to insert the tags. Paste your code between them.

  5. #5
    Join Date
    Jun 2015
    Posts
    109
    Thanks
    20
    Qt products
    Qt5
    Platforms
    Unix/X11 Windows

    Default Re: How to add 3D object

    Thanks for the reply,

    I agreed with your point, I just want to ensure this thing, because I was not sure about it.
    Using this approach is because I want to insert a 3D model on the PCL view. I have tried with the below code and its working in windows only, in Linux it's crashing. So just looking for another approach.
    Qt Code:
    1. boost::shared_ptr<pcl::visualization::PCLVisualizer> viewer
    2. pcl::PolygonMesh polymesh;
    3. pcl::io::loadPolygonFile("Vehicle.obj", polymesh);
    4. viewer->addPolygonMesh(polymesh, "meshes", 0);
    To copy to clipboard, switch view to plain text mode 

    I have using PCL-1.8, boost-1_64, VTK-8.1

    Does update the PCL library to 1.9 will work?

    Please suggest me.

    Thanks in advanced.

  6. #6
    Join Date
    Jun 2015
    Posts
    109
    Thanks
    20
    Qt products
    Qt5
    Platforms
    Unix/X11 Windows

    Default Re: How to add 3D object

    I have updated my Ubuntu to 18.2 LTS.

    As soon as I used this (pcl::io::loadPolygonFile("Vehicle.obj", polymesh);) code get crashed and give error as,
    double free or corruption (out)
    Over google, I found some issues related to this, and they seem to be fixed somewhere.
    https://github.com/PointCloudLibrary/pcl/issues/2013 or https://github.com/PointCloudLibrary/pcl/issues/1889).

    The errors say that memory, which was allocated, it is tried to free it twice.

    Suggest me, if any code hack will solve this, or only tried with update PCL-1.9 library will solve this issue?

    Thanks

  7. #7
    Join Date
    Jan 2008
    Location
    Alameda, CA, USA
    Posts
    5,229
    Thanks
    302
    Thanked 864 Times in 851 Posts
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: How to add 3D object

    You are asking these questions on the wrong forum. PCL is out of scope here; you need to find a PCL forum to post your questions. You might be the only person here who is using PCL, and even if you aren't you are probably the only one who is trying to use it in this way.
    <=== The Great Pumpkin says ===>
    Please use CODE tags when posting source code so it is more readable. Click "Go Advanced" and then the "#" icon to insert the tags. Paste your code between them.

Similar Threads

  1. Replies: 1
    Last Post: 13th December 2018, 18:24
  2. TypeError: Object [object Object] has no method 'sendData'
    By TheIndependentAquarius in forum Qt Quick
    Replies: 2
    Last Post: 30th November 2013, 06:54
  3. How to call a function in the mother object from a child object?
    By Momergil in forum General Programming
    Replies: 4
    Last Post: 18th December 2011, 16:49
  4. Replies: 1
    Last Post: 8th November 2011, 23:27
  5. Replies: 4
    Last Post: 15th July 2011, 19:31

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.