SHARE
TWEET

Untitled

a guest Apr 18th, 2015 192 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #define ID_HELLOTEST 1111111
  2. // unique ID for this plugin
  3.  
  4. #include "c4d.h"
  5. #include "lib_modeling.h"
  6. #include "c4d_symbols.h"
  7. #include <string>
  8. #include <sstream>
  9.  
  10.  
  11. class HelloWorldTest : public CommandData
  12. {
  13. public:
  14.         virtual Bool Execute(BaseDocument *doc)
  15.         {
  16.                 PolygonObject *obj = (PolygonObject *) doc->GetActiveObject();
  17.                
  18.                 const Vector *points = obj->GetPointR();
  19.                 const CPolygon *faces = obj->GetPolygonR();
  20.  
  21.                 AutoAlloc<Modeling> krnl;
  22.                 krnl->InitObject(obj);
  23.  
  24.                 std::stringstream sstream;
  25.  
  26.                 for (UInt i = 0; i < obj->GetPointCount(); i++) {
  27.                         sstream << "v " << points[i].x << " " << points[i].y << " " << points[i].z << "\n";
  28.                 }
  29.  
  30.                 Vector n;
  31.                 for (UInt i = 0; i < obj->GetPolygonCount(); i++){
  32.                         krnl->GetNgonNormal(obj, i, &n);
  33.                         sstream << "n " << n.x << " " << n.y << " " << n.z << "\n";
  34.                 }
  35.  
  36.                 for (UInt i = 0; i < obj->GetPolygonCount(); i++) {
  37.                         CPolygon c = *(faces + i);
  38.                         sstream << "f " << c.a << " " << c.b << " " << c.c << " " << (c.IsTriangle() ? -1 : c.d) << "\n";
  39.                 }
  40.  
  41.                 String str(sstream.str().c_str() );
  42.                 MessageDialog(str);
  43.  
  44.                 return TRUE;
  45.         }
  46. };
  47.  
  48. Bool PluginStart(void)
  49. {
  50.         return RegisterCommandPlugin(ID_HELLOTEST, "Generate eobj",
  51.                 0, NULL, String("Generate eobj"),
  52.                 new HelloWorldTest);
  53. }
  54.  
  55. void PluginEnd(void)
  56. {
  57. }
  58.  
  59. Bool PluginMessage(Int32 id, void *data)
  60. {
  61.         return false;
  62. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top