hueshift.cpp 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678
  1. /*
  2. ** Command & Conquer Renegade(tm)
  3. ** Copyright 2025 Electronic Arts Inc.
  4. **
  5. ** This program is free software: you can redistribute it and/or modify
  6. ** it under the terms of the GNU General Public License as published by
  7. ** the Free Software Foundation, either version 3 of the License, or
  8. ** (at your option) any later version.
  9. **
  10. ** This program is distributed in the hope that it will be useful,
  11. ** but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. ** GNU General Public License for more details.
  14. **
  15. ** You should have received a copy of the GNU General Public License
  16. ** along with this program. If not, see <http://www.gnu.org/licenses/>.
  17. */
  18. //
  19. // skeleton.cpp : Defines the entry point for the application.
  20. //
  21. // Skeleton WW3D code, Hector Yee, 8/31/00
  22. #include "resource.h"
  23. #include "wwmath.h"
  24. #include "ww3d.h"
  25. #include "scene.h"
  26. #include "rendobj.h"
  27. #include "camera.h"
  28. #include "enbassetmgr.H"
  29. #include "msgloop.h"
  30. #include "part_ldr.h"
  31. #include "rendobj.h"
  32. #include "hanim.h"
  33. #include "dx8wrapper.h"
  34. #include "dx8indexbuffer.h"
  35. #include "dx8vertexbuffer.h"
  36. #include "dx8fvf.h"
  37. #include "vertmaterial.h"
  38. #include "font3d.h"
  39. #include "render2d.h"
  40. #include "textdraw.h"
  41. #include "rect.h"
  42. #include "mesh.h"
  43. #include "meshmdl.h"
  44. #include "vector2i.h"
  45. #include "bmp2d.h"
  46. #include "decalsys.h"
  47. #include "shattersystem.h"
  48. #include "light.h"
  49. #include "keyboard.h"
  50. #include "wwmouse.h"
  51. #include "predlod.h"
  52. #include "sphere.h"
  53. #include <stdio.h>
  54. #include "dx8renderer.h"
  55. #include "ini.h"
  56. #define MAX_LOADSTRING 100
  57. static void Log_Statistics();
  58. static void Init_3D_Scene();
  59. // Global Variables:
  60. HINSTANCE hInst; // current instance
  61. TCHAR szTitle[MAX_LOADSTRING]; // The title bar text
  62. TCHAR szWindowClass[MAX_LOADSTRING]; // The title bar text
  63. WW3DAssetManager * AssetManager=NULL;
  64. SimpleSceneClass * my_scene = NULL;
  65. CameraClass * my_camera = NULL;
  66. Render2DTextClass * mytext = NULL;
  67. RenderObjClass * orig_object = NULL;
  68. RenderObjClass * shift_object = NULL;
  69. HAnimClass * my_anim = NULL;
  70. Font3DInstanceClass *my_font_a=NULL;
  71. Font3DInstanceClass *my_font_b=NULL;
  72. DecalSystemClass TheDecalSystem;
  73. bool running=true;
  74. bool rotate=false;
  75. bool staticsort=true;
  76. bool sort=true;
  77. float sep;
  78. // Foward declarations of functions included in this code module:
  79. ATOM MyRegisterClass(HINSTANCE hInstance);
  80. LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM);
  81. LRESULT CALLBACK About(HWND, UINT, WPARAM, LPARAM);
  82. void Render();
  83. void WWDebug_Message_Callback(DebugType type, const char * message);
  84. void WWAssert_Callback(const char * message);
  85. void Debug_Refs(void);
  86. void LoadAssets();
  87. // ----------------------------------------------------------------------------
  88. //
  89. // FPS counter class counts how many times Update() has been called during the
  90. // last second. The fps counter caps at MAX_FPS which is the maximum fps count
  91. // that can be measured.
  92. //
  93. // ----------------------------------------------------------------------------
  94. const unsigned MAX_FPS=2000;
  95. class FPSCounterClass
  96. {
  97. unsigned frame_times[MAX_FPS];
  98. unsigned frame_time_count;
  99. public:
  100. FPSCounterClass();
  101. void Update();
  102. unsigned Get_FPS();
  103. };
  104. static FPSCounterClass fps_counter;
  105. // ----------------------------------------------------------------------------
  106. FPSCounterClass::FPSCounterClass()
  107. :
  108. frame_time_count(0)
  109. {
  110. }
  111. // ----------------------------------------------------------------------------
  112. void FPSCounterClass::Update()
  113. {
  114. unsigned frame_time=timeGetTime();
  115. unsigned limit=frame_time-1000;
  116. for (unsigned i=0;i<frame_time_count;++i) {
  117. if (frame_times[i]<limit) {
  118. frame_times[i]=frame_times[frame_time_count-1];
  119. frame_time_count--;
  120. }
  121. }
  122. if (frame_time_count<MAX_FPS) {
  123. frame_times[frame_time_count++]=frame_time;
  124. }
  125. }
  126. // ----------------------------------------------------------------------------
  127. unsigned FPSCounterClass::Get_FPS()
  128. {
  129. return frame_time_count;
  130. }
  131. // ----------------------------------------------------------------------------
  132. //
  133. //
  134. //
  135. // ----------------------------------------------------------------------------
  136. int APIENTRY WinMain(HINSTANCE hInstance,
  137. HINSTANCE hPrevInstance,
  138. LPSTR lpCmdLine,
  139. int nCmdShow)
  140. {
  141. HACCEL hAccelTable;
  142. hAccelTable = LoadAccelerators(hInstance, (LPCTSTR)IDC_SKELETON);
  143. // install debug callbacks
  144. WWDebug_Install_Message_Handler(WWDebug_Message_Callback);
  145. WWDebug_Install_Assert_Handler(WWAssert_Callback);
  146. // Initialize global strings
  147. LoadString(hInstance, IDS_APP_TITLE, szTitle, MAX_LOADSTRING);
  148. LoadString(hInstance, IDC_SKELETON, szWindowClass, MAX_LOADSTRING);
  149. MyRegisterClass(hInstance);
  150. // Perform application initialization:
  151. hInst = hInstance; // Store instance handle in our global variable
  152. HWND hWnd = CreateWindow(
  153. szWindowClass,
  154. szTitle,
  155. WS_OVERLAPPEDWINDOW,
  156. CW_USEDEFAULT,
  157. 0,
  158. CW_USEDEFAULT,
  159. 0,
  160. NULL,
  161. NULL,
  162. hInstance,
  163. NULL);
  164. ShowWindow(hWnd, nCmdShow);
  165. UpdateWindow(hWnd);
  166. // WW Inits
  167. WWMath::Init ();
  168. AssetManager=new ENBAssetManager;
  169. AssetManager->Register_Prototype_Loader(&_ParticleEmitterLoader);
  170. WW3D::Init(hWnd);
  171. WW3D::Set_Texture_Thumbnail_Mode(WW3D::TEXTURE_THUMBNAIL_MODE_ON);
  172. // WW3D::Set_Prelit_Mode(WW3D::PRELIT_MODE_VERTEX);
  173. WW3D::Set_Prelit_Mode(WW3D::PRELIT_MODE_LIGHTMAP_MULTI_PASS);
  174. // WW3D::Set_Prelit_Mode(WW3D::PRELIT_MODE_LIGHTMAP_MULTI_TEXTURE);
  175. WW3D::Set_Collision_Box_Display_Mask(0xFF);
  176. if (WW3D::Set_Render_Device(0,800,600,32,1,true)!=WW3D_ERROR_OK) {
  177. WW3D::Shutdown();
  178. WWMath::Shutdown ();
  179. Debug_Refs();
  180. return 0;
  181. }
  182. Init_3D_Scene();
  183. WW3D::Enable_Static_Sort_Lists(staticsort);
  184. WW3D::Enable_Sorting(sort);
  185. // main loop
  186. int time=timeGetTime();
  187. float theta = 0.0f;
  188. while (running)
  189. {
  190. if (rotate) {
  191. theta += DEG_TO_RADF(0.5f);
  192. Matrix3D tm(1);
  193. tm.Rotate_Z(theta);
  194. if (orig_object) orig_object->Set_Transform(tm);
  195. if (shift_object) shift_object->Set_Transform(tm);
  196. const SphereClass &sp1=shift_object->Get_Bounding_Sphere();
  197. const SphereClass &sp2=orig_object->Get_Bounding_Sphere();
  198. shift_object->Set_Position(Vector3(0,sep,0));
  199. orig_object->Set_Position(Vector3(0,-sep,0));
  200. }
  201. Render();
  202. Windows_Message_Handler();
  203. WW3D::Sync(timeGetTime()-time);
  204. Log_Statistics();
  205. }
  206. REF_PTR_RELEASE(my_scene);
  207. REF_PTR_RELEASE(my_camera);
  208. delete mytext;
  209. REF_PTR_RELEASE(my_font_a);
  210. REF_PTR_RELEASE(my_font_b);
  211. REF_PTR_RELEASE(orig_object);
  212. REF_PTR_RELEASE(shift_object);
  213. REF_PTR_RELEASE(my_anim);
  214. PredictiveLODOptimizerClass::Free();
  215. // shutdown
  216. AssetManager->Free_Assets ();
  217. delete AssetManager;
  218. WW3D::Shutdown ();
  219. WWMath::Shutdown ();
  220. Debug_Refs();
  221. return 0;
  222. }
  223. // ----------------------------------------------------------------------------
  224. //
  225. // Render everything. Rendering stars with Begin_Scene() and ends to End_Scene().
  226. //
  227. // ----------------------------------------------------------------------------
  228. void Render()
  229. {
  230. // Predictive LOD optimizer optimizes the mesh LOD levels to match the given polygon budget
  231. my_scene->Visibility_Check(my_camera);
  232. PredictiveLODOptimizerClass::Optimize_LODs(150000);
  233. WW3D::Begin_Render(true,true,Vector3(0.5f,0.5f,0.5f));
  234. // Render 3D scene
  235. WW3D::Render(my_scene,my_camera);
  236. if (mytext) mytext->Render();
  237. WW3D::End_Render();
  238. fps_counter.Update();
  239. }
  240. // ----------------------------------------------------------------------------
  241. //
  242. // FUNCTION: MyRegisterClass()
  243. //
  244. // PURPOSE: Registers the window class.
  245. //
  246. // COMMENTS:
  247. //
  248. // This function and its usage is only necessary if you want this code
  249. // to be compatible with Win32 systems prior to the 'RegisterClassEx'
  250. // function that was added to Windows 95. It is important to call this function
  251. // so that the application will get 'well formed' small icons associated
  252. // with it.
  253. //
  254. // ----------------------------------------------------------------------------
  255. ATOM MyRegisterClass(HINSTANCE hInstance)
  256. {
  257. WNDCLASSEX wcex;
  258. wcex.cbSize = sizeof(WNDCLASSEX);
  259. wcex.style = CS_HREDRAW | CS_VREDRAW;
  260. wcex.lpfnWndProc = (WNDPROC)WndProc;
  261. wcex.cbClsExtra = 0;
  262. wcex.cbWndExtra = 0;
  263. wcex.hInstance = hInstance;
  264. wcex.hIcon = LoadIcon(hInstance, (LPCTSTR)IDI_SKELETON);
  265. wcex.hCursor = LoadCursor(NULL, IDC_ARROW);
  266. wcex.hbrBackground = (HBRUSH)(COLOR_WINDOW+1);
  267. wcex.lpszMenuName = (LPCSTR)IDC_SKELETON;
  268. wcex.lpszClassName = szWindowClass;
  269. wcex.hIconSm = LoadIcon(wcex.hInstance, (LPCTSTR)IDI_SMALL);
  270. return RegisterClassEx(&wcex);
  271. }
  272. // ----------------------------------------------------------------------------
  273. //
  274. // FUNCTION: WndProc(HWND, unsigned, WORD, LONG)
  275. //
  276. // PURPOSE: Processes messages for the main window.
  277. //
  278. // WM_COMMAND - process the application menu
  279. // WM_PAINT - Paint the main window
  280. // WM_DESTROY - post a quit message and return
  281. //
  282. //
  283. // ----------------------------------------------------------------------------
  284. LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
  285. {
  286. int wmId, wmEvent;
  287. PAINTSTRUCT ps;
  288. HDC hdc;
  289. switch (message)
  290. {
  291. case WM_COMMAND:
  292. wmId = LOWORD(wParam);
  293. wmEvent = HIWORD(wParam);
  294. // Parse the menu selections:
  295. switch (wmId)
  296. {
  297. case IDM_ABOUT:
  298. DialogBox(hInst, (LPCTSTR)IDD_ABOUTBOX, hWnd, (DLGPROC)About);
  299. break;
  300. case IDM_EXIT:
  301. DestroyWindow(hWnd);
  302. break;
  303. case IDM_RELOAD:
  304. LoadAssets();
  305. break;
  306. default:
  307. return DefWindowProc(hWnd, message, wParam, lParam);
  308. }
  309. break;
  310. case WM_ACTIVATEAPP:
  311. if (wParam) WW3D::On_Activate_App();
  312. else WW3D::On_Deactivate_App();
  313. return DefWindowProc(hWnd, message, wParam, lParam);
  314. case WM_PAINT:
  315. hdc = BeginPaint(hWnd, &ps);
  316. // TODO: Add any drawing code here...
  317. EndPaint(hWnd, &ps);
  318. break;
  319. case WM_DESTROY:
  320. running=false;
  321. PostQuitMessage(0);
  322. break;
  323. case WM_KEYUP:
  324. if ((wParam&0xff)==VK_ESCAPE) {
  325. DestroyWindow(hWnd);
  326. return 0;
  327. }
  328. return DefWindowProc(hWnd, message, wParam, lParam);
  329. case WM_CHAR:
  330. {
  331. char key=LOWORD(wParam);
  332. switch (key)
  333. {
  334. case '-':
  335. WW3D::Make_Screen_Shot("screen");
  336. break;
  337. case '+':
  338. WW3D::Toggle_Movie_Capture();
  339. break;
  340. case ' ':
  341. rotate=!rotate;
  342. break;
  343. case 's':
  344. staticsort=!staticsort;
  345. WW3D::Enable_Static_Sort_Lists(staticsort);
  346. break;
  347. case 'S':
  348. sort=!sort;
  349. WW3D::Enable_Sorting(sort);
  350. break;
  351. case 'm':
  352. {
  353. SceneClass::PolyRenderType type = my_scene->Get_Polygon_Mode();
  354. type = (type == SceneClass::POINT) ? SceneClass::LINE : ((type == SceneClass::LINE) ? SceneClass::FILL : SceneClass::POINT);
  355. my_scene->Set_Polygon_Mode(type);
  356. }
  357. break;
  358. }
  359. }
  360. default:
  361. return DefWindowProc(hWnd, message, wParam, lParam);
  362. }
  363. return 0;
  364. }
  365. // Mesage handler for about box.
  366. LRESULT CALLBACK About(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
  367. {
  368. switch (message)
  369. {
  370. case WM_INITDIALOG:
  371. return TRUE;
  372. case WM_COMMAND:
  373. if (LOWORD(wParam) == IDOK || LOWORD(wParam) == IDCANCEL)
  374. {
  375. EndDialog(hDlg, LOWORD(wParam));
  376. return TRUE;
  377. }
  378. break;
  379. }
  380. return FALSE;
  381. }
  382. // ----------------------------------------------------------------------------
  383. //
  384. // WWDebug message callback defines the behavior of WWDEBUG_SAY().
  385. //
  386. // ----------------------------------------------------------------------------
  387. void WWDebug_Message_Callback(DebugType type, const char * message)
  388. {
  389. OutputDebugString(message);
  390. }
  391. // ----------------------------------------------------------------------------
  392. //
  393. // WWAssert callback defines the behavior of WWASSERT().
  394. //
  395. // ----------------------------------------------------------------------------
  396. void WWAssert_Callback(const char * message)
  397. {
  398. OutputDebugString(message);
  399. _asm int 0x03
  400. }
  401. // ----------------------------------------------------------------------------
  402. void Debug_Refs(void)
  403. {
  404. #ifdef _DEBUG
  405. WWDEBUG_SAY(("Dumping Un-Released Ref-Counted objects...\r\n"));
  406. RefBaseNodeClass * first = RefBaseClass::ActiveRefList.First();
  407. RefBaseNodeClass * node = first;
  408. while (node->Is_Valid())
  409. {
  410. RefBaseClass * obj = node->Get();
  411. ActiveRefStruct * ref = &(obj->ActiveRefInfo);
  412. bool display = true;
  413. int count = 0;
  414. RefBaseNodeClass * search = first;
  415. while (search->Is_Valid()) {
  416. if (search == node) { // if this is not the first one
  417. if (count != 0) {
  418. display = false;
  419. break;
  420. }
  421. }
  422. RefBaseClass * search_obj = search->Get();
  423. ActiveRefStruct * search_ref = &(search_obj->ActiveRefInfo);
  424. if ( ref->File && search_ref->File &&
  425. !strcmp(search_ref->File, ref->File) &&
  426. (search_ref->Line == ref->Line) ) {
  427. count++;
  428. } else if ( (ref->File == NULL) && (search_ref->File == NULL) ) {
  429. count++;
  430. }
  431. search = search->Next();
  432. }
  433. if ( display ) {
  434. WWDEBUG_SAY(( "%d Active Ref: %s %d %p\n", count, ref->File,ref->Line,obj));
  435. static int num_printed = 0;
  436. if (++num_printed > 20) {
  437. WWDEBUG_SAY(( "And Many More......\n"));
  438. break;
  439. }
  440. }
  441. node = node->Next();
  442. }
  443. WWDEBUG_SAY(("Done.\r\n"));
  444. #endif
  445. }
  446. // ----------------------------------------------------------------------
  447. //
  448. // Ugly statistics block!!!
  449. //
  450. // ----------------------------------------------------------------------
  451. void Log_Statistics()
  452. {
  453. StringClass format(255,true);
  454. StringClass status_text(500,true);
  455. // static unsigned last_frame_time=0;
  456. // unsigned frame_time=timeGetTime();
  457. // unsigned time=frame_time-last_frame_time;
  458. // last_frame_time=frame_time;
  459. // if (time>1000) time=1000;
  460. // float fps=1000.0f/float(time);
  461. // static float time_fps;
  462. // static float current_fps;
  463. // static unsigned fps_count;
  464. // time_fps+=fps;
  465. // fps_count++;
  466. // if (fps_count==20) {
  467. // fps_count=0;
  468. // current_fps=time_fps/20.0f;
  469. // time_fps=0.0f;
  470. // }
  471. unsigned current_fps=fps_counter.Get_FPS();
  472. static unsigned stats_mode;
  473. static bool tab_pressed;
  474. if (GetAsyncKeyState(VK_TAB)) {
  475. if (!tab_pressed) {
  476. stats_mode++;
  477. stats_mode%=3;
  478. }
  479. tab_pressed=true;
  480. }
  481. else {
  482. tab_pressed=false;
  483. }
  484. switch (stats_mode) {
  485. case 0:
  486. Debug_Statistics::Record_Texture_Mode(Debug_Statistics::RECORD_TEXTURE_NONE);
  487. break;
  488. case 1:
  489. Debug_Statistics::Record_Texture_Mode(Debug_Statistics::RECORD_TEXTURE_NONE);
  490. format.Format("%d FPS\n",current_fps);
  491. status_text+=format;
  492. format.Format("%d Polys/frame (%dk pps)\n",Debug_Statistics::Get_DX8_Polygons(),unsigned(Debug_Statistics::Get_DX8_Polygons()*float(current_fps))/1000);
  493. status_text+=format;
  494. break;
  495. case 2:
  496. Debug_Statistics::Record_Texture_Mode(Debug_Statistics::RECORD_TEXTURE_NONE);
  497. format.Format("%d FPS\n",current_fps);
  498. status_text+=format;
  499. format.Format("%d Polys/frame (%dk pps)\n",Debug_Statistics::Get_DX8_Polygons(),unsigned(Debug_Statistics::Get_DX8_Polygons()*float(current_fps))/1000);
  500. status_text+=format;
  501. format.Format("%d Verts/frame (%dk vps)\n",Debug_Statistics::Get_DX8_Vertices(),unsigned(Debug_Statistics::Get_DX8_Vertices()*float(current_fps))/1000);
  502. status_text+=format;
  503. format.Format("%d DX8 calls\n",DX8Wrapper::Get_Last_Frame_DX8_Calls());
  504. status_text+=format;
  505. format.Format("%d VB changes\n",DX8Wrapper::Get_Last_Frame_Vertex_Buffer_Changes());
  506. status_text+=format;
  507. format.Format("%d IB changes\n",DX8Wrapper::Get_Last_Frame_Index_Buffer_Changes());
  508. status_text+=format;
  509. format.Format("%d texture changes\n",DX8Wrapper::Get_Last_Frame_Texture_Changes());
  510. status_text+=format;
  511. format.Format("%d material changes\n",DX8Wrapper::Get_Last_Frame_Material_Changes());
  512. status_text+=format;
  513. format.Format("%d light changes\n",DX8Wrapper::Get_Last_Frame_Light_Changes());
  514. status_text+=format;
  515. format.Format("%d RS changes\n",DX8Wrapper::Get_Last_Frame_Render_State_Changes());
  516. status_text+=format;
  517. format.Format("%d TSS changes\n",DX8Wrapper::Get_Last_Frame_Texture_Stage_State_Changes());
  518. status_text+=format;
  519. format.Format("%d Mtx changes\n",DX8Wrapper::Get_Last_Frame_Matrix_Changes());
  520. status_text+=format;
  521. if (sort)
  522. format.Format("Sorting On\n");
  523. else
  524. format.Format("Sorting Off\n");
  525. status_text+=format;
  526. if (staticsort)
  527. format.Format("Static Sorting On\n");
  528. else
  529. format.Format("Static Sorting Off\n");
  530. status_text+=format;
  531. break;
  532. }
  533. mytext->Reset();
  534. mytext->Set_Location(Vector2(0.0,0.0));
  535. mytext->Draw_Text(status_text,0xffff0000);
  536. }
  537. void LoadAssets()
  538. {
  539. if (shift_object)
  540. {
  541. my_scene->Remove_Render_Object(shift_object);
  542. REF_PTR_RELEASE(shift_object);
  543. }
  544. if (orig_object)
  545. {
  546. my_scene->Remove_Render_Object(orig_object);
  547. REF_PTR_RELEASE(orig_object);
  548. }
  549. INIClass ini;
  550. ini.Load("hueshift.ini");
  551. StringClass asset=ini.Get_String("GENERAL","ASSET");
  552. float scale=ini.Get_Float("GENERAL","SCALE",1.0f);
  553. Vector3 hsv;
  554. hsv.X=ini.Get_Float("GENERAL","HUE",0.0f);
  555. hsv.Y=ini.Get_Float("GENERAL","SAT",1.0f);
  556. hsv.Z=ini.Get_Float("GENERAL","VAL",1.0f);
  557. AssetManager->Load_3D_Assets(asset+".w3d");
  558. shift_object = ((ENBAssetManager*)AssetManager)->Create_Render_Obj(asset,scale,hsv);
  559. orig_object = AssetManager->Create_Render_Obj(asset);
  560. if (shift_object && orig_object)
  561. {
  562. const SphereClass &sp1=shift_object->Get_Bounding_Sphere();
  563. const SphereClass &sp2=orig_object->Get_Bounding_Sphere();
  564. my_scene->Add_Render_Object(shift_object);
  565. my_scene->Add_Render_Object(orig_object);
  566. sep=WWMath::Max(sp1.Radius,sp2.Radius);
  567. shift_object->Set_Position(Vector3(0,sep,0));
  568. orig_object->Set_Position(Vector3(0,-sep,0));
  569. }
  570. Matrix3D camtransform(1);
  571. camtransform.Look_At(Vector3(3*sep,0,3*sep),Vector3(0,0,0),0);
  572. my_camera->Set_Transform(camtransform);
  573. my_camera->Set_Clip_Planes(1.0f,8*sep);
  574. }
  575. void Init_3D_Scene()
  576. {
  577. my_font_a = AssetManager->Get_Font3DInstance("font12x16.tga");
  578. my_font_b = AssetManager->Get_Font3DInstance("fontnew4.tga");
  579. mytext=new Render2DTextClass(my_font_a);
  580. mytext->Set_Coordinate_Range( Render2DClass::Get_Screen_Resolution() );
  581. // build scene
  582. my_scene=NEW_REF(SimpleSceneClass,());
  583. my_scene->Set_Ambient_Light(Vector3(1.0f,1.0f,1.0f));
  584. my_camera=NEW_REF(CameraClass,());
  585. LoadAssets();
  586. }