C4D SDK学习-Tool部分

移动,缩放,选区这些都是Tool的范畴,C4D也可以自己开发Tool类型插件。

Command类插件主要是有Execute方法,所以叫做命令类插件更好一些。

而Tool类插件更侧重鼠标,键盘事件。

==============================================

 

这次研究Tool部分的EdgeCutTool例子。

 

这个例子通过监听鼠标输入消息,去给模型切割。

Tool类型插件的基类ToolData,提供了基本的鼠标键盘消息方法。

也有提供Draw方法,绘制一些2D光标图像。

 

return RegisterToolPlugin(ID_MODELING_EDGECUT_TOOL_SDK, GeLoadString(IDS_EDGECUT_SDK), 0, nullptr, GeLoadString(IDS_HLP_EDGECUT_SDK), NewObjClear(EdgeCutTool));


Tool类的注册和Menu很像,不太明白,为什么Object类插件的注册差别这么大。

 

这里发现一个C4D Debug命令:

GeOutString("Debug!", GEMB_OK);

非常好用,弹出窗。

 

获得鼠标坐标:(Gui类常量都在BFM类别下)

x = msg.GetInt32(BFM_INPUT_X);

y = msg.GetInt32(BFM_INPUT_Y);

 

 检测键盘输入

Int32     key = msg.GetData(BFM_INPUT_CHANNEL).GetInt32();

    

    if (key == KEY_ESC)

    {

        // do what you want



        // return true to signal that the key is processed!

        return true;

    }

 

 

原来所有的全局信息都是通过msg获得的,看了下msg的一些接口,全部通过基本数据类型的。

Bool GetBool         (Int32 id, Bool preset = false) const { return BcCall(GetBool) (id, preset); }

    Int32    GetInt32        (Int32 id, Int32 preset = 0) const { return BcCall(GetInt32) (id, preset); }

    UInt32 GetUInt32     (Int32 id, UInt32 preset = 0) const { return BcCall(GetUInt32) (id, preset); }

    Int64    GetInt64        (Int32 id, Int64 preset = 0) const { return BcCall(GetInt64) (id, preset); }

    UInt64 GetUInt64     (Int32 id, UInt64 preset = 0) const { return BcCall(GetUInt64) (id, preset); }

    Float    GetFloat        (Int32 id, Float preset = 0.0) const { return BcCall(GetFloat) (id, preset); }

    void*                                    GetVoid            (Int32 id, void* preset = nullptr) const { return BcCall(GetVoid) (id, preset); }

    void*                                    GetMemoryAndRelease    (Int32 id, Int& count, void* preset = nullptr) { return BcCall(GetMemoryAndRelease) (id, count, preset); }

    void*                                    GetMemory        (Int32 id, Int& count, void* preset = nullptr) const { return BcCall(GetMemory) (id, count, preset); }

    Vector GetVector     (Int32 id, const Vector& preset = Vector()) const { return BcCall(GetVector) (id, preset); }

    Matrix GetMatrix     (Int32 id, const Matrix& preset = Matrix()) const { return BcCall(GetMatrix) (id, preset); }

    String GetString     (Int32 id, const String& preset = String()) const { return BcCall(GetString) (id, preset); }

    C4DUuid    GetUuid            (Int32 id, const C4DUuid& preset = C4DUuid(DC)) const { return BcCall(GetUuid) (id, preset); }

    Filename GetFilename (Int32 id, const Filename& preset = Filename()) const { return BcCall(GetFilename) (id, preset); }

    
View Code

 

 

Gui类常量都在BFM类别下,包括鼠标左键单击,中键等。

常规API在c4d_general.h下,包括操作系统类型,帧率等等。
 

你可能感兴趣的:(tool)