<blockquote> <p>如此著名的Havok物理模拟引擎,就不说了。简单配置一下Havok,尝尝鲜。</p> <p>1.下载Havok:Havok_Physics_Animation_2012-1-0_PC_XS_win32_VS2010_keycode_perpetual_20120831.zip</p> <p>解压到某个目录下/hk2012_1_0_r1。</p> <p>2.在计算机属性->高级系统设置->环境变量->系统变量中新建变量</p> <p>名字比如HAVOK_SDK,值是刚才的解压路径xxxx/hk_2012_1_0_r1</p> <p>3.VS2010新建空工程,添加main.cpp文件。</p> <p>只使用了一下Havok的hkVector,如果想深入学习可看它的doc和demo</p> <p>4.将$(HAVOK_SDK)\Source和$(HAVOK_SDK)\Lib\win32_vs2010\debug_multithreaded加入工程的VC++目录中的</p> <p>包含目录和库目录中,将hkBase.lib加入链接器->输入->附件依赖项中。</p> <p>5.main文件中键入内如如下:</p> <p>#include <Windows.h> <br />#include <iostream> <br />#include "Common/Base/hkBase.h" <br />//#include "Common/Base/Math/hkMath.h"</p> <p>using namespace std;</p> <p>int main(int argc, int argv) <br />{ <br />    hkVector4 pos(10, 10, 10); <br />    hkVector4 tr(20, 0, -14);</p> <p>    pos.add(tr);</p> <p>    cout << pos(0) << ", " << pos(1) << ", " << pos(2) << ", " << pos(3) << endl;</p> <p>    system("pause"); <br />    return 0; <br />}</p> <p>// Keycode <br />#include <Common/Base/keycode.cxx></p> <p>// Productfeatures <br />// we're not using anything product specific yet. We undef these so we don't get the usual <br />// product initialization for the products. <br />//#undef HK_FEATURE_PRODUCT_AI <br />//#undef HK_FEATURE_PRODUCT_ANIMATION <br />//#undef HK_FEATURE_PRODUCT_CLOTH <br />//#undef HK_FEATURE_PRODUCT_DESTRUCTION <br />//#undef HK_FEATURE_PRODUCT_BEHAVIOR <br />#undef HK_FEATURE_PRODUCT_PHYSICS <br />//#undef HK_FEATURE_PRODUCT_NEW_PHYSICS</p> <p>// Also we're not using any serialization/versioning so we don't need any of these. <br />#define HK_EXCLUDE_FEATURE_SerializeDeprecatedPre700 <br />#define HK_EXCLUDE_FEATURE_RegisterVersionPatches <br />#define HK_EXCLUDE_FEATURE_RegisterReflectedClasses <br />#define HK_EXCLUDE_FEATURE_MemoryTracker</p> <p>// This include generates an initialization function based on the products <br />// and the excluded features. <br />#include <Common/Base/Config/hkProductFeatures.cxx></p> <p>/* <br />* Havok SDK - NO SOURCE PC DOWNLOAD, BUILD(#20120831) <br />* <br />* Confidential Information of Havok.  (C) Copyright 1999-2012 <br />* Telekinesys Research Limited t/a Havok. All Rights Reserved. The Havok <br />* Logo, and the Havok buzzsaw logo are trademarks of Havok.  Title, ownership <br />* rights, and intellectual property rights in the Havok software remain in <br />* Havok and/or its suppliers. <br />* <br />* Use of this software for evaluation purposes is subject to and indicates <br />* acceptance of the End User licence Agreement for this product. A copy of <br />* the license is included with this software and is also available at www.havok.com/tryhavok. <br />* <br />*/</p> </blockquote> <blockquote> <p>其中hkMath.h已经包含在hkBase.h中,所以注释掉。main函数后面是从它的demo中拷贝过来的,不然编译不过。</p> <p>上面#undef HK_FEATURE_PRODUCT_PHYSICS该宏不可注释,否则会链接失败,主要是hkProductFeatures.cxx中若是启用该宏</p> <p>则调用了其他的注册代码。</p> <p>而后面的四个宏用于排除一下不用的特征,最后一个文件用于Havok环境的配置。</p> <p>在网上搜了下,没什么太多学习Havok的中文资料。不过它的自带文档还可以。</p></blockquote>
转载于:https://my.oschina.net/u/146803/blog/125989