[vtkusers] 3ds import

Axel Steuwer steuwer at ill.fr
Thu Dec 9 11:40:39 EST 2004


hi,

there's a useful tool for getting to know vtk called vtkGUI.
if you download & start it, chose 3DSImporter from
the sources menu, point it to an example 3ds file, and
set the renderWindow to the RenderWindow , it will show
the 3ds model. From the File menu you can then export
the code to c++, or save it as as tcl script.
if you do the c++ export, you'll end up with something like
the code below. hope that helps

axel

// ----------------------------------
// File: 3dsimporter.cxx
// Created by vtkgui v 1.0
// ----------------------------------

// ------------------------------------------------------------
// Call the VTK header files to make available all VTK commands
// ------------------------------------------------------------

#include "vtk3DSImporter.h"
#include "vtkCamera.h"
#include "vtkGenericRenderWindowInteractor.h"
#include "vtkInteractorStyleTrackballCamera.h"
#include "vtkLight.h"
#include "vtkPropPicker.h"
#include "vtkRenderWindow.h"
#include "vtkRenderer.h"

int main( int argc, char *argv[] ) {

// --------------------------------------------------------------
// Create a Renderer, a RenderWindow and a RenderWindowInteractor
// --------------------------------------------------------------

vtkRenderer *R = vtkRenderer::New();
   R->SetBackground(0.5 , 0.5 , 0.5);
   R->SetLightFollowCamera(1);

vtkRenderWindow *RW = vtkRenderWindow::New();
   RW->AddRenderer(R);
   RW->AddRenderer(R);
   RW->SetSize(500 , 406);

vtkRenderWindowInteractor *RWI = vtkRenderWindowInteractor::New();
   RWI->SetRenderWindow(RW);
   RWI->SetLightFollowCamera(1);


// -----------------------
// Create the VTK pipeline
// -----------------------

vtk3DSImporter *3DSI = vtk3DSImporter::New();
   3DSI->SetRenderWindow(RW);
   3DSI->SetFileName("C:/test.3DS");
   3DSI->Read();


// -------------------------------
// Reset the camera and initialize
// -------------------------------

R->ResetCamera();
R->ResetCameraClippingRange();
RW->Render();
RWI->Initialize();
RWI->Start();

// ----------------------------------------
// Perform cleanup of created VTK instances
// ----------------------------------------

3DSI->Delete();
R->Delete();
RW->Delete();
RWI->Delete();

   return 0;
}


>
> dear vtkusers,
>
> i'm new to this and c++ as well but i need to handle a project that
> deals with 3ds files (3D Studio). currently i need to import one CAD
> file and i read from the vtk book that it can be done. however, as i'm
> new to this, i'm not sure of how to write a simple program to import
> the file.
>
> Would greatly appreciate it if someone could help and guide me.
>
> Many thanks,
> Kangjun
>
>
> --------------------------------------------------------------------------------
>
>
> _______________________________________________
> This is the private VTK discussion list.
> Please keep messages on-topic. Check the FAQ at:
> http://www.vtk.org/Wiki/VTK_FAQ Follow this link to
> subscribe/unsubscribe:
> http://www.vtk.org/mailman/listinfo/vtkusers






More information about the vtkusers mailing list