Plugin Cafe Homepage
Forum Home Forum Home > Plugin Cafe > SDK Help
  New Posts New Posts
  FAQ FAQ  Forum Search

Document Project Settings

Author
Message
  Topic Search Topic Search
ScottA View Drop Down
Member
Member


Joined: 2011 Jan 07
Online Status: Offline
Posts: 2288
Direct Link To This Post Topic: Document Project Settings
    Posted: 2011 Jun 09 at 9:58am

User Information:

Cinema 4D Version:   12 
Platform:   Windows  ;   
Language(s):     C++  ;   

---------

Here is the list of all the project settings so users can quickly look them up if needed:
//Reference files:
//DOCUMENTSETTINGS_GENERAL:General settings: See ddoc.h.
//DOCUMENTSETTINGS_MODELING:Modeler settings: See MDATA_Options and toolsnapping.h.
//DOCUMENTSETTINGS_TOOLS: See Tool settings




//// Scene Scale & Units optoptions

BaseContainer *bc = doc->GetSettingsInstance(DOCUMENTSETTINGS_DOCUMENT);
UnitScaleData *usd = (UnitScaleData*)bc->GetCustomDataType(DOCUMENT_DOCUNIT, CUSTOMDATATYPE_UNITSCALE);
if (!usd) return FALSE;

usd->SetUnitScale(1.0, DOCUMENT_UNIT_CM);// SceneScale & Units options = DOCUMENT_UNIT_UNDEF, DOCUMENT_UNIT_KM, DOCUMENT_UNIT_M, DOCUMENT_UNIT_CM,
                                         //DOCUMENT_UNIT_MM, DOCUMENT_UNIT_MICRO, DOCUMENT_UNIT_MILE, DOCUMENT_UNIT_YARD,DOCUMENT_UNIT_FOOT, DOCUMENT_UNIT_INCH
bc->SetData(DOCUMENT_DOCUNIT, GeData(CUSTOMDATATYPE_UNITSCALE, *usd));
doc->Message(MSG_UPDATE);              
EventAdd();



//// Project Settings

//First set up BaseTime so we can use it later on in the attributes
BaseTime time = doc->GetTime(); // assigns the basetime class to a variable
Real fps = doc->GetFps();       // Gets the frames per second value
Real frame = time.GetFrame(fps);// The current frame the slider is on

doc->SetParameter(DOCUMENT_FPS, GeData(30), DESCFLAGS_SET_0);               // Sets the FPS attribute
doc->SetParameter(DOCUMENT_TIME, GeData(BaseTime(0, fps)), DESCFLAGS_SET_0); // The frame where the scrubber starts
doc->SetParameter(DOCUMENT_MINTIME, GeData(BaseTime(0, fps)), DESCFLAGS_SET_0);//The start frame value
doc->SetParameter(DOCUMENT_MAXTIME, GeData(BaseTime(90, fps)), DESCFLAGS_SET_0);//The end Frame value
doc->SetParameter(DOCUMENT_LOOPMINTIME, GeData(BaseTime(0, fps)), DESCFLAGS_SET_0);//The Preview option Start time
doc->SetParameter(DOCUMENT_LOOPMAXTIME, GeData(BaseTime(90, fps)), DESCFLAGS_SET_0);//The Preview option End time
doc->SetParameter(DOCUMENT_LOD, GeData(1.0), DESCFLAGS_SET_0);            // Level of Detail       
doc->SetParameter(DOCUMENT_RENDERLOD, GeData(FALSE), DESCFLAGS_SET_0);    // Render LOD in Editor
doc->SetParameter(DOCUMENT_USEANIMATION, GeData(TRUE), DESCFLAGS_SET_0);  // Use Animation
doc->SetParameter(DOCUMENT_USEEXPRESSIONS, GeData(TRUE), DESCFLAGS_SET_0);// Use Expressions
doc->SetParameter(DOCUMENT_USEGENERATORS, GeData(TRUE), DESCFLAGS_SET_0); // Use Generators
doc->SetParameter(DOCUMENT_USEDEFORMERS, GeData(TRUE), DESCFLAGS_SET_0);  // Use Deformers
doc->SetParameter(DOCUMENT_USEMOTIONSYSTEM, GeData(TRUE), DESCFLAGS_SET_0); // Use Motion System
doc->SetParameter(DOCUMENT_DEFAULTMATERIAL_TYPE, GeData(1), DESCFLAGS_SET_0);// 0=WHITE, 1=GREY-BLUE, 2=USER
doc->SetParameter(DOCUMENT_CLIPPING_PRESET, GeData(1), DESCFLAGS_SET_0); // 3=TINY, 0=SMALL, 1=MEDIUM, 2=LARGE, 4=HUGE, 5=CUSTOM
doc->SetParameter(DOCUMENT_CLIPPING_PRESET_NEAR, GeData(1.0), DESCFLAGS_SET_0); //Sets the Near clipping value
doc->SetParameter(DOCUMENT_CLIPPING_PRESET_FAR, GeData(100000.0), DESCFLAGS_SET_0); //Sets the Far clipping value
doc->SetParameter(DOCUMENT_LINEARWORKFLOW, GeData(TRUE), DESCFLAGS_SET_0); // Use Linear Workflow
doc->SetParameter(DOCUMENT_COLORPROFILE, GeData(1), DESCFLAGS_SET_0);//  0=SRGB, 1=LINEAR, 2=DISABLED;
EventAdd();




///// Info Settings

doc->SetParameter(DOCUMENT_INFO_AUTHOR, GeData(""), DESCFLAGS_SET_0);    //Type your name in here
doc->SetParameter(DOCUMENT_INFO_COPYRIGHT, GeData(""), DESCFLAGS_SET_0); //Type your copyright info here
doc->SetParameter(DOCUMENT_INFO_README, GeData(""), DESCFLAGS_SET_0);   // Type your notes here
EventAdd();





//// Dynamics Settings
//Make sure to use this include:
#include "../../modules/dynamics2/res/description/dynworldobject.h"

 //GENERAL
BaseSceneHook *sh = doc->FindSceneHook(180000100);
if (!sh) return FALSE;

sh->SetParameter(DescID(WORLD_ENABLED), GeData(TRUE), DESCFLAGS_SET_0);            // Enabled
sh->SetParameter(DescID(WORLD_DISABLE_DURING_LEAP), GeData(TRUE), DESCFLAGS_SET_0);// Disable on Skip Frame
sh->SetParameter(DescID(WORLD_TIMESCALE), GeData(BaseTime(0, fps)), DESCFLAGS_SET_0);// Time Scale       
sh->SetParameter(DescID(WORLD_GRAVITY), GeData(1000.0), DESCFLAGS_SET_0);          // Gravity value   
sh->SetParameter(DescID(WORLD_DENSITY), GeData(1.0), DESCFLAGS_SET_0);             // Density value
EventAdd();


 //CACHE
BaseSceneHook *sh = doc->FindSceneHook(180000100);
if (!sh) return FALSE;

sh->SetParameter(DescID(WORLD_CACHE_BAKE), GeData(1.0), DESCFLAGS_SET_0);                    //...See Button code below
sh->SetParameter(DescID(WORLD_CACHE_CLEAR), GeData(1.0), DESCFLAGS_SET_0);                   //...See Button code below
sh->SetParameter(DescID(WORLD_CACHE_USE), GeData(FALSE), DESCFLAGS_SET_0);                   //Use cached data
sh->SetParameter(DescID(WORLD_CACHE_DISABLE_BAKED_OBJECTS), GeData(FALSE), DESCFLAGS_SET_0); //Disable cached objects
sh->SetParameter(DescID(WORLD_CACHE_USE_TIME), GeData(FALSE), DESCFLAGS_SET_0);              //Use time stops to control cached playback
sh->SetParameter(DescID(WORLD_CACHE_TIME), GeData(BaseTime(0, fps)), DESCFLAGS_SET_0);       //time stops frame value
EventAdd();


 //EXPERT
BaseSceneHook *sh = doc->FindSceneHook(180000100);
if (!sh) return FALSE;

sh->SetParameter(DescID(WORLD_MARGIN), GeData(1.0), DESCFLAGS_SET_0);                        //Collision Margin
sh->SetParameter(DescID(WORLD_SCALE), GeData(1.0), DESCFLAGS_SET_0);                        // Scale
sh->SetParameter(DescID(WORLD_CONTACT_RESTITUTION_LIFETIME), GeData(5.0), DESCFLAGS_SET_0); // Resting Contact
sh->SetParameter(DescID(WORLD_SEED), GeData(0.0), DESCFLAGS_SET_0);                         // Random Seed
sh->SetParameter(DescID(WORLD_SUBSTEPS), GeData(5.0), DESCFLAGS_SET_0);                     // Steps per frame
sh->SetParameter(DescID(WORLD_ITERATIONS), GeData(10.0), DESCFLAGS_SET_0);                  // Max Iterations per step
sh->SetParameter(DescID(WORLD_ERROR_THRESHOLD), GeData(10.0), DESCFLAGS_SET_0);             // Error threshold
EventAdd();



 //VISUALIZATION
BaseSceneHook *sh = doc->FindSceneHook(180000100);
if (!sh) return FALSE;

sh->SetParameter(DescID(WORLD_VISUALIZE), GeData(FALSE), DESCFLAGS_SET_0);               // Enable
sh->SetParameter(DescID(WORLD_VISUALIZE_SHAPES), GeData(TRUE), DESCFLAGS_SET_0);         // Collision Shapes
sh->SetParameter(DescID(WORLD_VISUALIZE_AABBS), GeData(TRUE), DESCFLAGS_SET_0);          // Bounding Boxes
sh->SetParameter(DescID(WORLD_VISUALIZE_CONTACT_POINTS), GeData(TRUE), DESCFLAGS_SET_0); // Contact Points
sh->SetParameter(DescID(WORLD_VISUALIZE_CONSTRAINTS), GeData(TRUE), DESCFLAGS_SET_0);    // Connectors
EventAdd();




// Execute Dynamics Cache Button

BaseSceneHook *sh = doc->FindSceneHook(180000100);
if (!sh) return FALSE;

BaseContainer msg(BFM_ACTION);
msg.SetLong(BFM_ACTION_ID, 1440);
msg.SetLong(BFM_ACTION_VALUE, TRUE);

DescriptionCommand dc;
dc.id = DescID(DescLevel(WORLD_CACHE_BAKE, DTYPE_BUTTON, sh->GetType()));
DescriptionCheckUpdate du;
du.doc = doc;
du.descid = &dc.id;
du.drawflags = 0;

sh->Message(MSG_DESCRIPTION_COMMAND, (void*)&dc);
sh->Message(MSG_DESCRIPTION_CHECKUPDATE, (void*)&du);
EventAdd();




// Execute Dynamics Clear Cache Button

BaseSceneHook *sh = doc->FindSceneHook(180000100);
if (!sh) return FALSE;

BaseContainer msg(BFM_ACTION);
msg.SetLong(BFM_ACTION_ID, 1440);
msg.SetLong(BFM_ACTION_VALUE, TRUE);

DescriptionCommand dc;
dc.id = DescID(DescLevel(WORLD_CACHE_CLEAR, DTYPE_BUTTON, sh->GetType()));
DescriptionCheckUpdate du;
du.doc = doc;
du.descid = &dc.id;
du.drawflags = 0;

sh->Message(MSG_DESCRIPTION_COMMAND, (void*)&dc);
sh->Message(MSG_DESCRIPTION_CHECKUPDATE, (void*)&du);
EventAdd();


-ScottA


Edited by ScottA - 2011 Jun 10 at 7:22am
Back to Top
Matthias Bober View Drop Down
Forum Moderator
Forum Moderator


Joined: 2006 Oct 16
Location: Germany
Online Status: Offline
Posts: 2204
Direct Link To This Post Posted: 2011 Jun 09 at 1:14pm
Originally posted by ScottA

But I'm having trouble with the document scale & Unit's attributes.
If someone can tell me how to edit those settings.


Since R12 CINEMA supports true units which required each document to have a unit scale. Its data type is UnitScaleData. Please check the docs for a detailed description.

cheers,
Matthias

MAXON
developer support
Back to Top
ScottA View Drop Down
Member
Member


Joined: 2011 Jan 07
Online Status: Offline
Posts: 2288
Direct Link To This Post Posted: 2011 Jun 09 at 4:43pm
The SDK does a good job explaining the methods and their parameters.
But it assumes that the reader knows how to construct the correct path to the proper owner of these methods(in this case the document).

Here's my crude attempt:
#include "customgui_unitscale.h"
    UnitScaleData *data;
    data->SetUnitScale(1, DOCUMENT_UNIT_KM);    
    doc->SetParameter(DescID(DOCUMENT_DOCUNIT), GeData(data), DESCFLAGS_SET_0); //<--This is definitely wrong


I'm still not very good at understanding the SDK yet.
I'm hoping if I get enough examples under my belt. I will get to a point where I can use it much better.

-ScottA


Edited by ScottA - 2011 Jun 09 at 4:54pm
Back to Top
Matthias Bober View Drop Down
Forum Moderator
Forum Moderator


Joined: 2006 Oct 16
Location: Germany
Online Status: Offline
Posts: 2204
Direct Link To This Post Posted: 2011 Jun 10 at 2:08am
You can set custom data like this:

BaseContainer *bc = doc->GetSettingsInstance(DOCUMENTSETTINGS_DOCUMENT);

UnitScaleData *usd = (UnitScaleData*)bc->GetCustomDataType(DOCUMENT_DOCUNIT, CUSTOMDATATYPE_UNITSCALE);
if (!usd) return FALSE;

usd->SetUnitScale(10.0, DOCUMENT_UNIT_KM);

bc->SetData(DOCUMENT_DOCUNIT, GeData(CUSTOMDATATYPE_UNITSCALE, *usd));

doc->Message(MSG_UPDATE);

EventAdd();


cheers,
Matthias

MAXON
developer support
Back to Top
ScottA View Drop Down
Member
Member


Joined: 2011 Jan 07
Online Status: Offline
Posts: 2288
Direct Link To This Post Posted: 2011 Jun 10 at 7:25am
Thank you sir.Beer
I added it to the list. Now it should be complete.


-ScottA
Back to Top

Forum Jump Forum Permissions View Drop Down

Bulletin Board Software by Web Wiz Forums® version 9.61 [Free Express Edition]
Copyright ©2001-2009 Web Wiz

This page was generated in 0.156 seconds.