Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #define ID_HELLOTEST 1111111
- // unique ID for this plugin
- #include "c4d.h"
- #include "lib_modeling.h"
- #include "c4d_symbols.h"
- #include <string>
- #include <sstream>
- class HelloWorldTest : public CommandData
- {
- public:
- virtual Bool Execute(BaseDocument *doc)
- {
- PolygonObject *obj = (PolygonObject *) doc->GetActiveObject();
- const Vector *points = obj->GetPointR();
- const CPolygon *faces = obj->GetPolygonR();
- AutoAlloc<Modeling> krnl;
- krnl->InitObject(obj);
- std::stringstream sstream;
- for (UInt i = 0; i < obj->GetPointCount(); i++) {
- sstream << "v " << points[i].x << " " << points[i].y << " " << points[i].z << "\n";
- }
- Vector n;
- for (UInt i = 0; i < obj->GetPolygonCount(); i++){
- krnl->GetNgonNormal(obj, i, &n);
- sstream << "n " << n.x << " " << n.y << " " << n.z << "\n";
- }
- for (UInt i = 0; i < obj->GetPolygonCount(); i++) {
- CPolygon c = *(faces + i);
- sstream << "f " << c.a << " " << c.b << " " << c.c << " " << (c.IsTriangle() ? -1 : c.d) << "\n";
- }
- String str(sstream.str().c_str() );
- MessageDialog(str);
- return TRUE;
- }
- };
- Bool PluginStart(void)
- {
- return RegisterCommandPlugin(ID_HELLOTEST, "Generate eobj",
- 0, NULL, String("Generate eobj"),
- new HelloWorldTest);
- }
- void PluginEnd(void)
- {
- }
- Bool PluginMessage(Int32 id, void *data)
- {
- return false;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement