微软 Windows 开发

内容表

要求

注意
推荐始终使用给定 Visual Studio 发行的最新版本。

在微软 Windows 的插件开发仅支持微软 Visual Studio。支持的版本:

  • Cinema 4D S22 SDK : Visual Studio 2019
  • Cinema 4D R21 SDK : Visual Studio 2017**
  • Cinema 4D R20 SDK : Visual Studio 2015*
  • Cinema 4D R19 SDK : Visual Studio 2015
  • Cinema 4D R18 SDK : Visual Studio 2013
  • Cinema 4D R17 SDK : Visual Studio 2013
  • Cinema 4D R16 SDK : Visual Studio 2012
  • Cinema 4D R15 SDK : Visual Studio 2012
  • Cinema 4D R14 SDK : Visual Studio 2010
  • Cinema 4D R13 SDK : Visual Studio 2005

(*) 使用 Visual Studio 2017 for Cinema 4D R20 SDK 仅支持 Windows 10。必须手动适配工程文件。

(**) Cinema 4D R21.0 SDK (修复于 Cinema 4D R21.1 SDK) 默认启用 AVX (高级向量扩展) 支持。要禁用 AVX 支持,移除相应行从 frameworks\settings\Base.props 文件:

<EnableEnhancedInstructionSet>AdvancedVectorExtensions</EnableEnhancedInstructionSet>

开发环境

SDK 包括几种数据类型的 Natvis 文件。文件:

The files can simply be copied to the local "Documents\\Visual Studio 2015\\Visualizers" folder.

Alternatively, it is possible to include the Natvis files in a solution using AdditionalSolutionFiles :

// Configuration of a custom solution in the projectdefinition.txt file

// support Windows and macOS Platform=Win64; OSX

// this is a solution Type=Solution

// included plugin projects Solution=\ plugins/pluginA;\ plugins/pluginB

// include natvis files in Visual Studio solution file AdditionalSolutionFiles=\ ..\..\frameworks\core.framework\project\typeviewer\msvc\maxon.natvis;\ ..\..\frameworks\cinema.framework\project\typeviewer\msvc\c4dapi.natvis

最佳实践

Windows 特定代码

Windows specific code can be guarded with the macro MAXON_TARGET_WINDOWS:

#ifdef MAXON_TARGET_WINDOWS

#endif

Windows 包括

If a source code file includes Windows header files it must also include undef_win_macros.h to un-define certain macros.

#ifdef MAXON_TARGET_WINDOWS #include <wtypes.h> #include " maxon/utilities/undef_win_macros.h " #endif
注意
An addtional #undef COMPONENT may be needed, depending on the Windows header files involved. This will be added to the undef_win_macros.h header in a later release.

运行插件

It is possible to start Cinema 4D from Visual Studio to run and debug a plugin:

The Cinema 4D executable must find the compiled plugins. The plugin location can be set with the g_additionalModulePath command line argument. One can also use "$(ProjectDir)..\.." instead of the absolute path.

Additional command line arguments can be set (e.g. to run unit tests). See Unit Tests Manual and Configuration Variables .

调试

The 输出 console displays messages printed with DiagnosticOutput() 。见 Debug and Output Functions .

For general information on debugging see 调试 .

自动化流程

The execution of the Project Tool can easily be automated using Windows batch files.

This batch file executes the Project Tool on the given location of the SDK and starts Visual Studio to open the solution file:

REM Build SDK CD /D C:\development\project_tool kernel_app_64bit.exe g_updateproject=C:/development/sdk_extracted CD /D C:\programs\vs17\Common7\IDE devenv.exe C:\development\sdk_extracted\plugins\project\plugins.sln

This batch file starts Cinema 4D with the location of the plugins:

REM run C4D CD /D C:\programs\cinema_4d "CINEMA 4D.exe" g_additionalModulePath=C:\development\sdk_extracted\plugins

Additionally one can set the command line argument g_runUnitTests to automatically execute custom unit tests.

Cinema 4D can be informed on the type of license model to use - which can be helpful in certain automated tasks - by using:

DLLs

DLLs needed by a plugin can be placed in myplugin\res\libs\win64 .

部署

The final plugin build for deployment should be created using the "Release" build target.

注意
Make sure your plugin includes all needed dependecies including Microsoft Visual C++ redistributables. Redistributables installed with Cinema 4D change with every release.

延伸阅读

C4D
C4D
定义: lib_net.h:673
undef_win_macros.h
OSX
OSX
OS X.
定义: ge_prepass.h:3324

Copyright  © 2014-2025 乐数软件    

工业和信息化部: 粤ICP备14079481号-1