GLS.SceneRegister.pas 62 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860
  1. //
  2. // The graphics GaLaXy Engine. The unit of GLScene
  3. //
  4. unit GLS.SceneRegister;
  5. (*
  6. Registration unit for library components, property editors and IDE experts.
  7. *)
  8. interface
  9. {$I Stage.Defines.inc}
  10. uses
  11. WinApi.Windows,
  12. System.Classes,
  13. System.SysUtils,
  14. System.TypInfo,
  15. VCL.Forms,
  16. VCL.Dialogs,
  17. VCL.Controls,
  18. VCL.StdCtrls,
  19. VCL.Graphics,
  20. ToolsAPI,
  21. DesignIntf,
  22. DesignEditors,
  23. VCLEditors,
  24. GLS.Context,
  25. GLS.Scene,
  26. GLS.Color,
  27. GLS.ImageUtils,
  28. GLS.ObjectManager,
  29. Stage.Strings;
  30. type
  31. TGLLibMaterialNameProperty = class(TStringProperty)
  32. public
  33. function GetAttributes: TPropertyAttributes; override;
  34. procedure Edit; override;
  35. end;
  36. TGLSceneViewerEditor = class(TComponentEditor)
  37. public
  38. procedure ExecuteVerb(Index: Integer); override;
  39. function GetVerb(Index: Integer): string; override;
  40. function GetVerbCount: Integer; override;
  41. end;
  42. TGLSceneEditor = class(TComponentEditor)
  43. public
  44. procedure Edit; override;
  45. procedure ExecuteVerb(Index: Integer); override;
  46. function GetVerb(Index: Integer): string; override;
  47. function GetVerbCount: Integer; override;
  48. end;
  49. TGLResolutionProperty = class(TPropertyEditor)
  50. public
  51. function GetAttributes: TPropertyAttributes; override;
  52. function GetValue: string; override;
  53. procedure GetValues(Proc: TGetStrProc); override;
  54. procedure SetValue(const Value: string); override;
  55. end;
  56. TGLTextureProperty = class(TClassProperty)
  57. public
  58. function GetAttributes: TPropertyAttributes; override;
  59. end;
  60. TGLTextureImageProperty = class(TClassProperty)
  61. public
  62. function GetAttributes: TPropertyAttributes; override;
  63. procedure Edit; override;
  64. end;
  65. TGLImageClassProperty = class(TClassProperty)
  66. public
  67. function GetAttributes: TPropertyAttributes; override;
  68. procedure GetValues(Proc: TGetStrProc); override;
  69. function GetValue: string; override;
  70. procedure SetValue(const Value: string); override;
  71. end;
  72. TGLColorProperty = class(TClassProperty, ICustomPropertyDrawing,
  73. ICustomPropertyListDrawing)
  74. protected
  75. function ColorToBorderColor(aColor: TGLColorVector; selected: Boolean): TColor;
  76. public
  77. function GetAttributes: TPropertyAttributes; override;
  78. procedure GetValues(Proc: TGetStrProc); override;
  79. procedure Edit; override;
  80. // ICustomPropertyListDrawing stuff
  81. procedure ListMeasureHeight(const Value: string; ACanvas: TCanvas; var AHeight: Integer);
  82. procedure ListMeasureWidth(const Value: string; ACanvas: TCanvas; var AWidth: Integer);
  83. procedure ListDrawValue(const Value: string; ACanvas: TCanvas; const ARect: TRect; ASelected: Boolean);
  84. // CustomPropertyDrawing
  85. procedure PropDrawName(ACanvas: TCanvas; const ARect: TRect; ASelected: Boolean);
  86. procedure PropDrawValue(ACanvas: TCanvas; const ARect: TRect; ASelected: Boolean);
  87. function GetValue: string; override;
  88. procedure SetValue(const Value: string); override;
  89. end;
  90. TGLSoundFileProperty = class(TClassProperty)
  91. public
  92. function GetAttributes: TPropertyAttributes; override;
  93. function GetValue: string; override;
  94. procedure Edit; override;
  95. end;
  96. TGLSoundNameProperty = class(TStringProperty)
  97. public
  98. function GetAttributes: TPropertyAttributes; override;
  99. procedure GetValues(Proc: TGetStrProc); override;
  100. end;
  101. TGLCoordinatesProperty = class(TClassProperty)
  102. public
  103. function GetAttributes: TPropertyAttributes; override;
  104. procedure Edit; override;
  105. end;
  106. TGLMaterialProperty = class(TClassProperty)
  107. public
  108. function GetAttributes: TPropertyAttributes; override;
  109. procedure Edit; override;
  110. end;
  111. TGLGUILayoutEditor = class(TComponentEditor)
  112. public
  113. procedure Edit; override;
  114. procedure ExecuteVerb(Index: Integer); override;
  115. function GetVerb(Index: Integer): string; override;
  116. function GetVerbCount: Integer; override;
  117. end;
  118. (* Editor copied from DsgnIntf.
  119. Could have been avoided, if only that guy at Borland didn't chose to
  120. publish only half of the stuff (and that's not the only class with that problem,
  121. most of the subitems handling code in TGLSceneBaseObject is here for the same reason...),
  122. the "protected" wasn't meant just to lure programmers into code they can't reuse...
  123. Arrr! and he did that again in D7! Grrr... *)
  124. TGLReuseableDefaultEditor = class(TComponentEditor, IDefaultEditor)
  125. protected
  126. FFirst: IProperty;
  127. FBest: IProperty;
  128. FContinue: Boolean;
  129. procedure CheckEdit(const Prop: IProperty);
  130. procedure EditProperty(const Prop: IProperty; var Continue: Boolean); virtual;
  131. public
  132. procedure Edit; override;
  133. end;
  134. // Editor for material library.
  135. TGLMaterialLibraryEditor = class(TGLReuseableDefaultEditor, IDefaultEditor)
  136. protected
  137. procedure EditProperty(const Prop: IProperty; var Continue: Boolean); override;
  138. public
  139. procedure ExecuteVerb(Index: Integer); override;
  140. function GetVerb(Index: Integer): string; override;
  141. function GetVerbCount: Integer; override;
  142. end;
  143. TGLAnimationNameProperty = class(TStringProperty)
  144. public
  145. function GetAttributes: TPropertyAttributes; override;
  146. procedure GetValues(Proc: TGetStrProc); override;
  147. end;
  148. (* Selection editor for TGLSoundLibrary
  149. Allows units to be added to the uses clause automatically when
  150. sound files are loaded into a TGLSoundLibrary at design-time. *)
  151. TGLSoundLibrarySelectionEditor = class(TSelectionEditor)
  152. public
  153. procedure RequiresUnits(Proc: TGetStrProc); override;
  154. end;
  155. (* Selection editor for TGLBaseSceneObject.
  156. Allows units to be added to the uses clause automatically when
  157. behaviours/effects are added to a TGLBaseSceneObject at design-time. *)
  158. TGLBaseSceneObjectSelectionEditor = class(TSelectionEditor)
  159. public
  160. procedure RequiresUnits(Proc: TGetStrProc); override;
  161. end;
  162. // Editor for Archive Manager
  163. TGLSArchiveManagerEditor = class(TGLReuseableDefaultEditor, IDefaultEditor)
  164. protected
  165. procedure EditProperty(const Prop: IProperty; var Continue: Boolean); override;
  166. public
  167. procedure ExecuteVerb(Index: Integer); override;
  168. function GetVerb(Index: Integer): string; override;
  169. function GetVerbCount: Integer; override;
  170. end;
  171. TGLMaterialComponentNameProperty = class(TStringProperty)
  172. public
  173. function GetAttributes: TPropertyAttributes; override;
  174. procedure Edit; override;
  175. end;
  176. TGLLibTextureNameProperty = class(TGLMaterialComponentNameProperty)
  177. public
  178. procedure GetValues(Proc: TGetStrProc); override;
  179. end;
  180. TGLLibSamplerNameProperty = class(TGLMaterialComponentNameProperty)
  181. public
  182. procedure GetValues(Proc: TGetStrProc); override;
  183. end;
  184. TGLLibCombinerNameProperty = class(TGLMaterialComponentNameProperty)
  185. public
  186. procedure GetValues(Proc: TGetStrProc); override;
  187. end;
  188. TGLLibShaderNameProperty = class(TGLMaterialComponentNameProperty)
  189. public
  190. procedure GetValues(Proc: TGetStrProc); override;
  191. end;
  192. TGLLibAttachmentNameProperty = class(TGLMaterialComponentNameProperty)
  193. public
  194. procedure GetValues(Proc: TGetStrProc); override;
  195. end;
  196. TGLLibAsmProgNameProperty = class(TGLMaterialComponentNameProperty)
  197. public
  198. procedure GetValues(Proc: TGetStrProc); override;
  199. end;
  200. TPictureFileProperty = class(TStringProperty)
  201. public
  202. function GetAttributes: TPropertyAttributes; override;
  203. procedure Edit; override;
  204. end;
  205. TShaderFileProperty = class(TStringProperty)
  206. public
  207. function GetAttributes: TPropertyAttributes; override;
  208. procedure Edit; override;
  209. end;
  210. TAsmProgFileProperty = class(TStringProperty)
  211. public
  212. function GetAttributes: TPropertyAttributes; override;
  213. procedure Edit; override;
  214. end;
  215. TUniformAutoSetProperty = class(TPropertyEditor)
  216. private
  217. procedure PassUniform(const S: string);
  218. public
  219. function GetAttributes: TPropertyAttributes; override;
  220. procedure Edit; override;
  221. end;
  222. TGLShaderEditorProperty = class(TClassProperty)
  223. protected
  224. function GetStrings: TStrings;
  225. procedure SetStrings(const Value: TStrings);
  226. procedure OnShaderCheck(Sender: TObject);
  227. public
  228. function GetAttributes: TPropertyAttributes; override;
  229. procedure Edit; override;
  230. end;
  231. // Register Components
  232. procedure Register;
  233. // Auto-create for object manager
  234. function ObjectManager: TGLObjectManager;
  235. // ------------------------------------------------------------------
  236. implementation
  237. // ------------------------------------------------------------------
  238. uses
  239. FmLibMaterialPicker,
  240. FmGUILayoutEditor,
  241. FmMaterialEditor,
  242. FmShaderMemo,
  243. FmShaderUniformEditor,
  244. FmVectorEditor,
  245. FmSceneEditor,
  246. GLS.ApplicationFileIO,
  247. Stage.VectorGeometry,
  248. GLS.ScriptBase,
  249. GLS.AnimatedSprite,
  250. GLS.AsyncHDS,
  251. GLS.AsyncTimer,
  252. GLS.Atmosphere,
  253. GLS.AVIRecorder,
  254. GLS.BaseClasses,
  255. GLS.BitmapFont,
  256. GLS.Blur,
  257. GLS.BumpMapHDS,
  258. GLS.Cadencer,
  259. GLS.CameraController,
  260. GLS.Collision,
  261. GLS.CompositeImage,
  262. GLS.Console,
  263. GLS.Coordinates,
  264. GLS.DCE,
  265. GLS.DynamicTexture,
  266. GLS.EParticleMasksManager,
  267. GLS.ExplosionFx,
  268. GLS.Extrusion,
  269. GLS.FBORenderer,
  270. GLS.Feedback,
  271. GLS.FireFX,
  272. GLS.FPSMovement,
  273. GLS.GameMenu,
  274. GLS.GeomObjects,
  275. GLS.Gizmo,
  276. GLS.Graph,
  277. GLS.Graphics,
  278. GLS.Gui,
  279. GLS.HeightData,
  280. GLS.HeightTileFileHDS,
  281. GLS.HudObjects,
  282. GLS.Imposter,
  283. GLS.LensFlare,
  284. GLS.LinePFX,
  285. GLS.Material,
  286. GLS.MaterialEx,
  287. GLS.MaterialMultiProxy,
  288. GLS.MaterialScript,
  289. GLS.Mesh,
  290. GLS.Mirror,
  291. GLS.MultiPolygon,
  292. GLS.MultiProxy,
  293. GLS.Navigator,
  294. GLS.Nodes,
  295. GLS.Objects,
  296. GLS.ParticleFX,
  297. GLS.Particles,
  298. GLS.Perlin,
  299. GLS.PerlinPFX,
  300. GLS.Portal,
  301. GLS.Screen,
  302. GLS.ShadowHDS,
  303. GLS.ShadowPlane,
  304. GLS.ShadowVolume,
  305. GLS.SimpleNavigation,
  306. GLS.SkyDome,
  307. GLS.ProxyObjects,
  308. GLS.RenderContextInfo,
  309. GLS.ArchiveManager,
  310. GLS.Memo,
  311. GLS.SmoothNavigator,
  312. Stage.Utils,
  313. GLSL.AsmShader,
  314. GLSL.BumpShaders,
  315. GLSL.ShapeShaders,
  316. GLSL.LineShaders,
  317. GLSL.ShaderCombiner,
  318. GLSL.PhongShader,
  319. GLSL.PostEffects,
  320. GLSL.ProjectedTextures,
  321. GLSL.DiffuseSpecularShader,
  322. GLSL.MultiMaterialShader,
  323. GLSL.PostShaders,
  324. GLSL.Shader,
  325. GLSL.TextureShaders,
  326. GLSL.UserShader,
  327. GLS.ProjectedTextures,
  328. GLS.State,
  329. GLS.TerrainRenderer,
  330. GLS.TexLensFlare,
  331. GLS.Texture,
  332. GLS.TexturedHDS,
  333. GLS.TextureImageEditors,
  334. GLS.ThorFX,
  335. GLS.TilePlane,
  336. GLS.TimeEventsMgr,
  337. GLS.Trail,
  338. GLS.Tree,
  339. GLS.VectorFileObjects,
  340. GLS.SceneViewer,
  341. GLS.WaterPlane,
  342. GLS.Windows,
  343. GLS.WindowsFont,
  344. GLS.zBuffer,
  345. //----------------- File formats -------------------------------
  346. GLS.FileVfsPAK,
  347. //------------ Vector file formats
  348. GLS.File3DS,
  349. GLS.FileASE,
  350. GLS.FileB3D,
  351. GLS.FileGL2,
  352. GLS.FileGLTF,
  353. GLS.FileGTS,
  354. GLS.FileLMTS,
  355. GLS.FileLWO,
  356. GLS.FileMD2,
  357. GLS.FileMD3,
  358. GLS.FileMD5,
  359. GLS.FileMDC,
  360. GLS.FileMS3D,
  361. GLS.FileNMF,
  362. GLS.FileNurbs,
  363. GLS.FileObj,
  364. GLS.FileOCT,
  365. GLS.FilePLY,
  366. GLS.FileQ3BSP,
  367. GLS.FileSMD,
  368. GLS.FileSTL,
  369. GLS.FileVRML,
  370. //----------------- Sound file formats
  371. GLS.FileWAV,
  372. GLS.FileMP3,
  373. //----------------- Raster file format
  374. GLS.FileDDS,
  375. GLS.FileHDR,
  376. GLS.FileJPEG,
  377. GLS.FilePNG,
  378. GLS.FileBMP,
  379. GLS.FileTGA,
  380. GLS.SoundManager,
  381. GLS.SoundFileObjects,
  382. GLS.SpaceText,
  383. GLS.Joystick,
  384. GLS.ScreenSaver,
  385. GLS.FullScreenViewer,
  386. Stage.Logger;
  387. var
  388. vObjectManager: TGLObjectManager;
  389. function ObjectManager: TGLObjectManager;
  390. begin
  391. if not Assigned(vObjectManager) then
  392. vObjectManager := TGLObjectManager.Create(nil);
  393. Result := vObjectManager;
  394. end;
  395. //----------------- TGLSceneViewerEditor ---------------------------------------
  396. procedure TGLSceneViewerEditor.ExecuteVerb(Index: Integer);
  397. var
  398. source: TGLSceneViewer;
  399. begin
  400. source := Component as TGLSceneViewer;
  401. case Index of
  402. 0: source.Buffer.ShowInfo;
  403. end;
  404. end;
  405. function TGLSceneViewerEditor.GetVerb(Index: Integer): string;
  406. begin
  407. case Index of
  408. 0: Result := 'Show context info';
  409. end;
  410. end;
  411. function TGLSceneViewerEditor.GetVerbCount: Integer;
  412. begin
  413. Result := 1;
  414. end;
  415. //----------------- TGLSceneEditor ---------------------------------------------
  416. procedure TGLSceneEditor.Edit;
  417. begin
  418. with GLSceneEditorForm do
  419. begin
  420. SetScene(Self.Component as TGLScene, Self.Designer);
  421. Show;
  422. end;
  423. end;
  424. procedure TGLSceneEditor.ExecuteVerb(Index: Integer);
  425. begin
  426. case Index of
  427. 0: Edit;
  428. end;
  429. end;
  430. function TGLSceneEditor.GetVerb(Index: Integer): string;
  431. begin
  432. case Index of
  433. 0: Result := 'Show Scene Editor';
  434. end;
  435. end;
  436. function TGLSceneEditor.GetVerbCount: Integer;
  437. begin
  438. Result := 1;
  439. end;
  440. //----------------- TGLResolutionProperty ----------------------------------------
  441. function TGLResolutionProperty.GetAttributes: TPropertyAttributes;
  442. begin
  443. Result := [paValueList];
  444. end;
  445. function TGLResolutionProperty.GetValue: string;
  446. begin
  447. Result := vVideoModes[GetOrdValue].Description;
  448. end;
  449. procedure TGLResolutionProperty.GetValues(Proc: TGetStrProc);
  450. var
  451. i: Integer;
  452. begin
  453. for i := 0 to vNumberVideoModes - 1 do
  454. Proc(vVideoModes[i].Description);
  455. end;
  456. procedure TGLResolutionProperty.SetValue(const Value: string);
  457. const
  458. Nums = ['0' .. '9'];
  459. var
  460. XRes, YRes, BPP: Integer;
  461. Pos, SLength: Integer;
  462. TempStr: string;
  463. begin
  464. if CompareText(Value, 'default') <> 0 then
  465. begin
  466. // initialize scanning
  467. TempStr := Trim(Value) + '|'; // ensure at least one delimiter
  468. SLength := Length(TempStr);
  469. XRes := 0;
  470. YRes := 0;
  471. BPP := 0;
  472. // contains the string something?
  473. if SLength > 1 then
  474. begin
  475. // determine first number
  476. for Pos := 1 to SLength do
  477. if not(AnsiChar(TempStr[Pos]) in Nums) then
  478. Break;
  479. if Pos <= SLength then
  480. begin
  481. // found a number?
  482. XRes := StrToInt(Copy(TempStr, 1, Pos - 1));
  483. // search for following non-numerics
  484. for Pos := Pos to SLength do
  485. if AnsiChar(TempStr[Pos]) in Nums then
  486. Break;
  487. Delete(TempStr, 1, Pos - 1); // take it out of the String
  488. SLength := Length(TempStr); // rest length of String
  489. if SLength > 1 then // something to scan?
  490. begin
  491. // determine second number
  492. for Pos := 1 to SLength do
  493. if not(AnsiChar(TempStr[Pos]) in Nums) then
  494. Break;
  495. if Pos <= SLength then
  496. begin
  497. YRes := StrToInt(Copy(TempStr, 1, Pos - 1));
  498. // search for following non-numerics
  499. for Pos := Pos to SLength do
  500. if AnsiChar(TempStr[Pos]) in Nums then
  501. Break;
  502. Delete(TempStr, 1, Pos - 1); // take it out of the String
  503. SLength := Length(TempStr); // rest length of String
  504. if SLength > 1 then
  505. begin
  506. for Pos := 1 to SLength do
  507. if not(AnsiChar(TempStr[Pos]) in Nums) then
  508. Break;
  509. if Pos <= SLength then
  510. BPP := StrToInt(Copy(TempStr, 1, Pos - 1));
  511. end;
  512. end;
  513. end;
  514. end;
  515. end;
  516. SetOrdValue(GetIndexFromResolution(XRes, YRes, BPP));
  517. end
  518. else
  519. SetOrdValue(0);
  520. end;
  521. //----------------- TGLTextureProperty -----------------------------------------
  522. function TGLTextureProperty.GetAttributes: TPropertyAttributes;
  523. begin
  524. Result := [paSubProperties];
  525. end;
  526. //----------------- TGLTextureImageProperty ------------------------------------
  527. function TGLTextureImageProperty.GetAttributes: TPropertyAttributes;
  528. begin
  529. Result := [paDialog];
  530. end;
  531. procedure TGLTextureImageProperty.Edit;
  532. begin
  533. if EditGLTextureImage(TGLTextureImage(GetOrdValue)) then
  534. Designer.Modified;
  535. end;
  536. //----------------- TGLImageClassProperty --------------------------------------
  537. function TGLImageClassProperty.GetAttributes: TPropertyAttributes;
  538. begin
  539. Result := [paValueList];
  540. end;
  541. procedure TGLImageClassProperty.GetValues(Proc: TGetStrProc);
  542. var
  543. i: Integer;
  544. sl: TStrings;
  545. begin
  546. sl := GetGLTextureImageClassesAsStrings;
  547. try
  548. for i := 0 to sl.Count - 1 do
  549. Proc(sl[i]);
  550. finally
  551. sl.Free;
  552. end;
  553. end;
  554. function TGLImageClassProperty.GetValue: string;
  555. begin
  556. Result := FindGLTextureImageClass(GetStrValue).FriendlyName;
  557. end;
  558. procedure TGLImageClassProperty.SetValue(const Value: string);
  559. var
  560. tic: TGLTextureImageClass;
  561. begin
  562. tic := FindGLTextureImageClassByFriendlyName(Value);
  563. if Assigned(tic) then
  564. SetStrValue(tic.ClassName)
  565. else
  566. SetStrValue('');
  567. Modified;
  568. end;
  569. //----------------- TGLColorproperty --------------------------------------------------------------
  570. procedure TGLColorProperty.Edit;
  571. var
  572. colorDialog: TColorDialog;
  573. GLColor: TGLColor;
  574. begin
  575. colorDialog := TColorDialog.Create(nil);
  576. try
  577. GLColor := TGLColor(GetOrdValue);
  578. colorDialog.Options := [cdFullOpen];
  579. colorDialog.Color := ConvertColorVector(GLColor.Color);
  580. if colorDialog.Execute then
  581. begin
  582. GLColor.Color := ConvertWinColor(colorDialog.Color);
  583. Modified;
  584. end;
  585. finally
  586. colorDialog.Free;
  587. end;
  588. end;
  589. function TGLColorProperty.GetAttributes: TPropertyAttributes;
  590. begin
  591. Result := [paSubProperties, paValueList, paDialog];
  592. end;
  593. procedure TGLColorProperty.GetValues(Proc: TGetStrProc);
  594. begin
  595. ColorManager.EnumColors(Proc);
  596. end;
  597. function TGLColorProperty.GetValue: string;
  598. begin
  599. Result := ColorManager.GetColorName(TGLColor(GetOrdValue).Color);
  600. end;
  601. procedure TGLColorProperty.SetValue(const Value: string);
  602. begin
  603. TGLColor(GetOrdValue).Color := ColorManager.GetColor(Value);
  604. Modified;
  605. end;
  606. function TGLColorProperty.ColorToBorderColor(aColor: TGLColorVector; selected: Boolean): TColor;
  607. begin
  608. if (aColor.X > 0.75) or (aColor.Y > 0.75) or (aColor.Z > 0.75) then
  609. Result := clBlack
  610. else if selected then
  611. Result := clWhite
  612. else
  613. Result := ConvertColorVector(aColor);
  614. end;
  615. procedure TGLColorProperty.PropDrawValue(ACanvas: TCanvas; const ARect: TRect;
  616. ASelected: Boolean);
  617. begin
  618. if GetVisualValue <> '' then
  619. ListDrawValue(GetVisualValue, ACanvas, ARect, True)
  620. else
  621. DefaultPropertyDrawValue(Self, ACanvas, ARect);
  622. end;
  623. procedure TGLColorProperty.ListDrawValue(const Value: string; ACanvas: TCanvas;
  624. const ARect: TRect; ASelected: Boolean);
  625. var
  626. vRight: Integer;
  627. vOldPenColor, vOldBrushColor: TColor;
  628. Color: TGLColorVector;
  629. begin
  630. vRight := (ARect.Bottom - ARect.Top) + ARect.Left;
  631. with ACanvas do
  632. try
  633. vOldPenColor := Pen.Color;
  634. vOldBrushColor := Brush.Color;
  635. Pen.Color := Brush.Color;
  636. Rectangle(ARect.Left, ARect.Top, vRight, ARect.Bottom);
  637. Color := ColorManager.GetColor(Value);
  638. Brush.Color := ConvertColorVector(Color);
  639. Pen.Color := ColorToBorderColor(Color, ASelected);
  640. Rectangle(ARect.Left + 1, ARect.Top + 1, vRight - 1, ARect.Bottom - 1);
  641. Brush.Color := vOldBrushColor;
  642. Pen.Color := vOldPenColor;
  643. finally
  644. DefaultPropertyListDrawValue(Value, ACanvas,
  645. Rect(vRight, ARect.Top, ARect.Right, ARect.Bottom), ASelected);
  646. end;
  647. end;
  648. procedure TGLColorProperty.ListMeasureWidth(const Value: string;
  649. ACanvas: TCanvas; var AWidth: Integer);
  650. begin
  651. AWidth := AWidth + ACanvas.TextHeight('M');
  652. end;
  653. procedure TGLColorProperty.ListMeasureHeight(const Value: string;
  654. ACanvas: TCanvas; var AHeight: Integer);
  655. begin
  656. // Nothing
  657. end;
  658. procedure TGLColorProperty.PropDrawName(ACanvas: TCanvas; const ARect: TRect;
  659. ASelected: Boolean);
  660. begin
  661. DefaultPropertyDrawName(Self, ACanvas, ARect);
  662. end;
  663. //----------------- TGLSoundFileProperty -----------------------------------------
  664. function TGLSoundFileProperty.GetAttributes: TPropertyAttributes;
  665. begin
  666. Result := [paDialog];
  667. end;
  668. function TGLSoundFileProperty.GetValue: string;
  669. var
  670. sample: TGLSoundSample;
  671. begin
  672. sample := GetComponent(0) as TGLSoundSample;
  673. if sample.Data <> nil then
  674. Result := '(' + sample.Data.ClassName + ')'
  675. else
  676. Result := '(empty)';
  677. end;
  678. procedure TGLSoundFileProperty.Edit;
  679. var
  680. ODialog: TOpenDialog;
  681. sample: TGLSoundSample;
  682. Desc, F: string;
  683. begin
  684. sample := GetComponent(0) as TGLSoundSample;
  685. ODialog := TOpenDialog.Create(nil);
  686. try
  687. GetGLSoundFileFormats.BuildFilterStrings(TGLSoundFile, Desc, F);
  688. ODialog.Filter := Desc;
  689. if ODialog.Execute then
  690. begin
  691. sample.LoadFromFile(ODialog.FileName);
  692. Modified;
  693. end;
  694. finally
  695. ODialog.Free;
  696. end;
  697. end;
  698. //----------------- TGLSoundNameProperty -----------------------------------------
  699. function TGLSoundNameProperty.GetAttributes: TPropertyAttributes;
  700. begin
  701. Result := [paValueList];
  702. end;
  703. procedure TGLSoundNameProperty.GetValues(Proc: TGetStrProc);
  704. var
  705. i: Integer;
  706. source: TGLBaseSoundSource;
  707. begin
  708. source := (GetComponent(0) as TGLBaseSoundSource);
  709. if Assigned(source.SoundLibrary) then
  710. with source.SoundLibrary do
  711. for i := 0 to Samples.Count - 1 do
  712. Proc(Samples[i].Name);
  713. end;
  714. //----------------- TGLCoordinatesProperty -------------------------------------
  715. function TGLCoordinatesProperty.GetAttributes: TPropertyAttributes;
  716. begin
  717. Result := [paDialog, paSubProperties];
  718. end;
  719. procedure TGLCoordinatesProperty.Edit;
  720. var
  721. glc: TGLCoordinates;
  722. x, y, z: Single;
  723. begin
  724. glc := TGLCoordinates(GetOrdValue);
  725. x := glc.x;
  726. y := glc.y;
  727. z := glc.z;
  728. if GLVectorEditorForm.Execute(x, y, z) then
  729. begin
  730. glc.AsVector := VectorMake(x, y, z);
  731. Modified;
  732. end;
  733. end;
  734. //----------------- TGLGUILayoutEditor -------------------------------
  735. procedure TGLGUILayoutEditor.Edit;
  736. begin
  737. GUILayoutEditorForm.Execute(TGLGuiLayout(Self.Component));
  738. end;
  739. procedure TGLGUILayoutEditor.ExecuteVerb(Index: Integer);
  740. begin
  741. case Index of
  742. 0: Edit;
  743. end;
  744. end;
  745. function TGLGUILayoutEditor.GetVerb(Index: Integer): string;
  746. begin
  747. case Index of
  748. 0:
  749. Result := 'Show Layout Editor';
  750. end;
  751. end;
  752. function TGLGUILayoutEditor.GetVerbCount: Integer;
  753. begin
  754. Result := 1;
  755. end;
  756. //----------------- TGLReuseableDefaultEditor --------------------------
  757. procedure TGLReuseableDefaultEditor.CheckEdit(const Prop: IProperty);
  758. begin
  759. if FContinue then
  760. EditProperty(Prop, FContinue);
  761. end;
  762. procedure TGLReuseableDefaultEditor.EditProperty(const Prop: IProperty;
  763. var Continue: Boolean);
  764. var
  765. PropName: string;
  766. BestName: string;
  767. MethodProperty: IMethodProperty;
  768. procedure ReplaceBest;
  769. begin
  770. FBest := Prop;
  771. if FFirst = FBest then
  772. FFirst := nil;
  773. end;
  774. begin
  775. if not Assigned(FFirst) and Supports(Prop, IMethodProperty, MethodProperty)
  776. then
  777. FFirst := Prop;
  778. PropName := Prop.GetName;
  779. BestName := '';
  780. if Assigned(FBest) then
  781. BestName := FBest.GetName;
  782. if CompareText(PropName, 'ONCREATE') = 0 then
  783. ReplaceBest
  784. else if CompareText(BestName, 'ONCREATE') <> 0 then
  785. if CompareText(PropName, 'ONCHANGE') = 0 then
  786. ReplaceBest
  787. else if CompareText(BestName, 'ONCHANGE') <> 0 then
  788. if CompareText(PropName, 'ONCLICK') = 0 then
  789. ReplaceBest;
  790. end;
  791. procedure TGLReuseableDefaultEditor.Edit;
  792. var
  793. Components: IDesignerSelections;
  794. begin
  795. Components := TDesignerSelections.Create;
  796. FContinue := True;
  797. Components.Add(Component);
  798. FFirst := nil;
  799. FBest := nil;
  800. try
  801. GetComponentProperties(Components, tkAny, Designer, CheckEdit);
  802. if FContinue then
  803. if Assigned(FBest) then
  804. FBest.Edit
  805. else if Assigned(FFirst) then
  806. FFirst.Edit;
  807. finally
  808. FFirst := nil;
  809. FBest := nil;
  810. end;
  811. end;
  812. //----------------- TGLMaterialLibraryEditor ----------------------------------
  813. procedure TGLMaterialLibraryEditor.EditProperty(const Prop: IProperty; var Continue: Boolean);
  814. begin
  815. if CompareText(Prop.GetName, 'MATERIALS') = 0 then
  816. begin
  817. FBest := Prop;
  818. end;
  819. end;
  820. procedure TGLMaterialLibraryEditor.ExecuteVerb(Index: Integer);
  821. begin
  822. case Index of
  823. 0: Edit;
  824. end;
  825. end;
  826. function TGLMaterialLibraryEditor.GetVerb(Index: Integer): string;
  827. begin
  828. case Index of
  829. 0: Result := 'Show Material Library Editor';
  830. end;
  831. end;
  832. function TGLMaterialLibraryEditor.GetVerbCount: Integer;
  833. begin
  834. Result := 1
  835. end;
  836. //----------------- TGLMaterialProperty -------------------------------
  837. function TGLMaterialProperty.GetAttributes: TPropertyAttributes;
  838. begin
  839. Result := [paDialog, paSubProperties];
  840. end;
  841. procedure TGLMaterialProperty.Edit;
  842. var
  843. buf: string;
  844. ml: TGLAbstractMaterialLibrary;
  845. obj: TPersistent;
  846. Int: IGLMaterialLibrarySupported;
  847. begin
  848. if FmMaterialEditor.GLMaterialEditorForm.Execute(TGLMaterial(GetOrdValue)) then
  849. Modified;
  850. end;
  851. //----------------- TGLLibMaterialNameProperty ---------------------------------
  852. function TGLLibMaterialNameProperty.GetAttributes: TPropertyAttributes;
  853. begin
  854. Result := [paDialog];
  855. end;
  856. procedure TGLLibMaterialNameProperty.Edit;
  857. var
  858. buf: string;
  859. ml: TGLAbstractMaterialLibrary;
  860. obj: TPersistent;
  861. Int: IGLMaterialLibrarySupported;
  862. begin
  863. buf := GetStrValue;
  864. obj := GetComponent(0);
  865. if Supports(obj, IGLMaterialLibrarySupported, Int) then
  866. ml := Int.GetMaterialLibrary
  867. else
  868. begin
  869. ml := nil;
  870. Assert(False, 'oops, unsupported...');
  871. end;
  872. if not Assigned(ml) then
  873. ShowMessage('Select the material library first.')
  874. else
  875. if GLLibMaterialPickerForm.Execute(buf, ml) then
  876. SetStrValue(buf);
  877. end;
  878. //----------------- TGLAnimationNameProperty -----------------------------------
  879. function TGLAnimationNameProperty.GetAttributes: TPropertyAttributes;
  880. begin
  881. Result := [paValueList];
  882. end;
  883. procedure TGLAnimationNameProperty.GetValues(Proc: TGetStrProc);
  884. var
  885. i: Integer;
  886. animControler: TGLAnimationControler;
  887. actor: TGLActor;
  888. begin
  889. animControler := (GetComponent(0) as TGLAnimationControler);
  890. if Assigned(animControler) then
  891. begin
  892. actor := animControler.actor;
  893. if Assigned(actor) then
  894. with actor.Animations do
  895. begin
  896. for i := 0 to Count - 1 do
  897. Proc(Items[i].Name);
  898. end;
  899. end;
  900. end;
  901. //---------------- TGLBaseSceneObjectSelectionEditor -----------------------
  902. procedure TGLBaseSceneObjectSelectionEditor.RequiresUnits(Proc: TGetStrProc);
  903. var
  904. i, j: Integer;
  905. comp: TGLBaseSceneObject;
  906. begin
  907. if (Designer = nil) or (Designer.Root = nil) then
  908. Exit;
  909. for i := 0 to Designer.Root.ComponentCount - 1 do
  910. begin
  911. if (Designer.Root.Components[i] is TGLBaseSceneObject) then
  912. begin
  913. comp := TGLBaseSceneObject(Designer.Root.Components[i]);
  914. for j := 0 to comp.Behaviours.Count - 1 do
  915. Proc(FindUnitName(comp.Behaviours[j]));
  916. for j := 0 to comp.Effects.Count - 1 do
  917. Proc(FindUnitName(comp.Effects[j]));
  918. end;
  919. end;
  920. end;
  921. //---------------------------- TGLSoundLibrarySelectionEditor -----------------------
  922. procedure TGLSoundLibrarySelectionEditor.RequiresUnits(Proc: TGetStrProc);
  923. var
  924. i, j: Integer;
  925. comp: TGLSoundLibrary;
  926. begin
  927. if (Designer = nil) or (Designer.Root = nil) then
  928. Exit;
  929. for i := 0 to Designer.Root.ComponentCount - 1 do
  930. begin
  931. if (Designer.Root.Components[i] is TGLSoundLibrary) then
  932. begin
  933. comp := TGLSoundLibrary(Designer.Root.Components[i]);
  934. for j := 0 to comp.Samples.Count - 1 do
  935. if Assigned(comp.Samples[j].Data) then
  936. Proc(FindUnitName(comp.Samples[j].Data));
  937. end;
  938. end;
  939. end;
  940. //-------------------- TGLSArchiveManagerEditor -----------------------
  941. procedure TGLSArchiveManagerEditor.EditProperty(const Prop: IProperty;
  942. var Continue: Boolean);
  943. begin
  944. if CompareText(Prop.GetName, 'ARCHIVES') = 0 then
  945. begin
  946. FBest := Prop;
  947. end;
  948. end;
  949. procedure TGLSArchiveManagerEditor.ExecuteVerb(Index: Integer);
  950. begin
  951. case Index of
  952. 0: Edit;
  953. end;
  954. end;
  955. function TGLSArchiveManagerEditor.GetVerb(Index: Integer): string;
  956. begin
  957. case Index of
  958. 0: Result := 'Show Archive Manager Editor';
  959. end;
  960. end;
  961. function TGLSArchiveManagerEditor.GetVerbCount: Integer;
  962. begin
  963. Result := 1
  964. end;
  965. //--------------------- TGLMaterialComponentNameProperty ------------------
  966. procedure TGLMaterialComponentNameProperty.Edit;
  967. var
  968. LOwner: IGLMaterialLibrarySupported;
  969. LItem: TGLBaseMaterialCollectionItem;
  970. begin
  971. if Supports(GetComponent(0), IGLMaterialLibrarySupported, LOwner) then
  972. begin
  973. LItem := TGLMaterialLibraryEx(LOwner.GetMaterialLibrary)
  974. .Components.GetItemByName(GetStrValue);
  975. if Assigned(LItem) then
  976. Designer.SelectComponent(LItem);
  977. Modified;
  978. end;
  979. end;
  980. function TGLMaterialComponentNameProperty.GetAttributes: TPropertyAttributes;
  981. begin
  982. Result := [paValueList];
  983. end;
  984. //------------------------ TGLLibTextureNameProperty --------------------------
  985. procedure TGLLibTextureNameProperty.GetValues(Proc: TGetStrProc);
  986. var
  987. LOwner: IGLMaterialLibrarySupported;
  988. begin
  989. if Supports(GetComponent(0), IGLMaterialLibrarySupported, LOwner) then
  990. begin
  991. TGLMaterialLibraryEx(LOwner.GetMaterialLibrary)
  992. .GetNames(Proc, TGLTextureImageEx);
  993. TGLMaterialLibraryEx(LOwner.GetMaterialLibrary)
  994. .GetNames(Proc, TGLFrameBufferAttachment);
  995. end;
  996. end;
  997. //------------------- TGLLibSamplerNameProperty -------------------------
  998. procedure TGLLibSamplerNameProperty.GetValues(Proc: TGetStrProc);
  999. var
  1000. LOwner: IGLMaterialLibrarySupported;
  1001. begin
  1002. if Supports(GetComponent(0), IGLMaterialLibrarySupported, LOwner) then
  1003. TGLMaterialLibraryEx(LOwner.GetMaterialLibrary)
  1004. .GetNames(Proc, TGLTextureSampler);
  1005. end;
  1006. //------------------- TGLLibCombinerNameProperty -------------------------
  1007. procedure TGLLibCombinerNameProperty.GetValues(Proc: TGetStrProc);
  1008. var
  1009. LOwner: IGLMaterialLibrarySupported;
  1010. begin
  1011. if Supports(GetComponent(0), IGLMaterialLibrarySupported, LOwner) then
  1012. TGLMaterialLibraryEx(LOwner.GetMaterialLibrary)
  1013. .GetNames(Proc, TGLTextureCombiner);
  1014. end;
  1015. procedure TGLLibShaderNameProperty.GetValues(Proc: TGetStrProc);
  1016. var
  1017. LOwner: IGLMaterialLibrarySupported;
  1018. begin
  1019. if Supports(GetComponent(0), IGLMaterialLibrarySupported, LOwner) then
  1020. TGLMaterialLibraryEx(LOwner.GetMaterialLibrary).GetNames(Proc, TGLShaderEx);
  1021. end;
  1022. procedure TGLLibAttachmentNameProperty.GetValues(Proc: TGetStrProc);
  1023. var
  1024. LOwner: IGLMaterialLibrarySupported;
  1025. begin
  1026. if Supports(GetComponent(0), IGLMaterialLibrarySupported, LOwner) then
  1027. TGLMaterialLibraryEx(LOwner.GetMaterialLibrary)
  1028. .GetNames(Proc, TGLFrameBufferAttachment);
  1029. end;
  1030. //------------------------- TGLLibAsmProgNameProperty ---------------------------
  1031. procedure TGLLibAsmProgNameProperty.GetValues(Proc: TGetStrProc);
  1032. var
  1033. LOwner: IGLMaterialLibrarySupported;
  1034. begin
  1035. if Supports(GetComponent(0), IGLMaterialLibrarySupported, LOwner) then
  1036. TGLMaterialLibraryEx(LOwner.GetMaterialLibrary)
  1037. .GetNames(Proc, TGLASMVertexProgram);
  1038. end;
  1039. //------------------------- TPictureFileProperty --------------------------------
  1040. function TPictureFileProperty.GetAttributes: TPropertyAttributes;
  1041. begin
  1042. Result := [paDialog];
  1043. end;
  1044. procedure TPictureFileProperty.Edit;
  1045. var
  1046. LFileName: string;
  1047. begin
  1048. if OpenPictureDialog(LFileName) then
  1049. begin
  1050. SetStrValue(RelativePath(LFileName));
  1051. end;
  1052. Modified;
  1053. end;
  1054. // -------------------- TShaderFileProperty ------------------------------
  1055. procedure TShaderFileProperty.Edit;
  1056. var
  1057. ODialog: TOpenDialog;
  1058. begin
  1059. ODialog := TOpenDialog.Create(nil);
  1060. try
  1061. ODialog.Filter := '*.glsl';
  1062. if ODialog.Execute then
  1063. begin
  1064. SetStrValue(RelativePath(ODialog.FileName));
  1065. Modified;
  1066. end;
  1067. finally
  1068. ODialog.Free;
  1069. end;
  1070. end;
  1071. function TShaderFileProperty.GetAttributes: TPropertyAttributes;
  1072. begin
  1073. Result := [paDialog];
  1074. end;
  1075. //----------------------- TAsmProgFileProperty ----------------------------------
  1076. procedure TAsmProgFileProperty.Edit;
  1077. var
  1078. ODialog: TOpenDialog;
  1079. begin
  1080. ODialog := TOpenDialog.Create(nil);
  1081. try
  1082. ODialog.Filter := '*.asm';
  1083. if ODialog.Execute then
  1084. begin
  1085. SetStrValue(RelativePath(ODialog.FileName));
  1086. Modified;
  1087. end;
  1088. finally
  1089. ODialog.Free;
  1090. end;
  1091. end;
  1092. function TAsmProgFileProperty.GetAttributes: TPropertyAttributes;
  1093. begin
  1094. Result := [paDialog];
  1095. end;
  1096. //------------------------ TUniformAutoSetProperty ----------------------------
  1097. function TUniformAutoSetProperty.GetAttributes: TPropertyAttributes;
  1098. begin
  1099. Result := [paDialog, paFullWidthName];
  1100. end;
  1101. procedure TUniformAutoSetProperty.PassUniform(const S: string);
  1102. begin
  1103. GLShaderUniformEditor.AddUniform(TGLBaseShaderModel(GetComponent(0))
  1104. .Uniforms[S]);
  1105. end;
  1106. procedure TUniformAutoSetProperty.Edit;
  1107. var
  1108. LOwner: TGLBaseShaderModel;
  1109. begin
  1110. LOwner := TGLBaseShaderModel(GetComponent(0));
  1111. if LOwner.Enabled and LOwner.IsValid then
  1112. begin
  1113. with GLShaderUniformEditor do
  1114. begin
  1115. Clear;
  1116. LOwner.MaterialLibrary.GetNames(AddTextureName, TGLTextureImageEx);
  1117. LOwner.MaterialLibrary.GetNames(AddTextureName, TGLFrameBufferAttachment);
  1118. LOwner.MaterialLibrary.GetNames(AddSamplerName, TGLTextureSampler);
  1119. LOwner.GetUniformNames(PassUniform);
  1120. Execute;
  1121. end;
  1122. end;
  1123. end;
  1124. //----------------------- TGLShaderEditorProperty -----------------------------
  1125. function TGLShaderEditorProperty.GetAttributes: TPropertyAttributes;
  1126. begin
  1127. Result := inherited GetAttributes + [paDialog] - [paSubProperties];
  1128. end;
  1129. function TGLShaderEditorProperty.GetStrings: TStrings;
  1130. begin
  1131. Result := TStrings(GetOrdValue);
  1132. end;
  1133. procedure TGLShaderEditorProperty.OnShaderCheck(Sender: TObject);
  1134. var
  1135. LShader: TGLShaderEx;
  1136. LContext: TGLContext;
  1137. begin
  1138. SetStrings(GLShaderEditorForm.GLSLMemo.Lines);
  1139. LShader := TGLShaderEx(GetComponent(0));
  1140. LContext := LShader.Handle.RenderingContext;
  1141. if Assigned(LContext) then
  1142. begin
  1143. LContext.Activate;
  1144. try
  1145. LShader.DoOnPrepare(LContext);
  1146. GLShaderEditorForm.CompilatorLog.Lines.Add(LShader.InfoLog);
  1147. finally
  1148. LContext.Deactivate;
  1149. end;
  1150. end
  1151. else
  1152. GLShaderEditorForm.CompilatorLog.Lines.Add
  1153. ('There is no any rendering context for work with OpenGL');
  1154. end;
  1155. procedure TGLShaderEditorProperty.SetStrings(const Value: TStrings);
  1156. begin
  1157. SetOrdValue(Longint(Value));
  1158. end;
  1159. procedure TGLShaderEditorProperty.Edit;
  1160. begin
  1161. with GLShaderEditorForm do
  1162. begin
  1163. OnCheck := OnShaderCheck;
  1164. GLSLMemo.Lines.Assign(GetStrings);
  1165. GLSLMemo.CurX := 0;
  1166. GLSLMemo.CurY := 0;
  1167. if ShowModal = mrOk then
  1168. begin
  1169. SetStrings(GLSLMemo.Lines);
  1170. Modified;
  1171. end;
  1172. end;
  1173. end;
  1174. // *************************************************************************
  1175. // Register Properties
  1176. //**************************************************************************
  1177. procedure GLSceneRegisterPropertiesInCategories;
  1178. begin
  1179. // property types
  1180. // ScreenDepth in FullScreenViewer
  1181. RegisterPropertiesInCategory(strOpenGLCategoryName,
  1182. [TypeInfo(TGLCamera), TypeInfo(TGLSceneBuffer), TypeInfo(TGLVSyncMode), TypeInfo(TGLScreenDepth)]);
  1183. // GLS.SceneViewer
  1184. RegisterPropertiesInCategory(strOpenGLCategoryName, TGLSceneViewer, ['*Render']);
  1185. // GLS.Scene
  1186. RegisterPropertiesInCategory(strOpenGLCategoryName,
  1187. [TypeInfo(TGLObjectsSorting), TypeInfo(TGLProgressEvent),
  1188. TypeInfo(TGLBehaviours), TypeInfo(TGLEffects),
  1189. TypeInfo(TGLDirectRenderEvent), TypeInfo(TGLCameraStyle),
  1190. TypeInfo(TOnCustomPerspective), TypeInfo(TGLScene)]);
  1191. RegisterPropertiesInCategory(strLayoutCategoryName,
  1192. [TypeInfo(TGLObjectsSorting), TypeInfo(TGLNormalDirection)]);
  1193. RegisterPropertiesInCategory(strVisualCategoryName,
  1194. [TypeInfo(TGLVisibilityCulling), TypeInfo(TGLLightStyle), TypeInfo(TGLColor),
  1195. TypeInfo(TGLNormalDirection), TypeInfo(TGLCameraStyle)]);
  1196. RegisterPropertiesInCategory(strVisualCategoryName, TGLBaseSceneObject,
  1197. ['Rotation', 'Direction', 'Position', 'Up', 'Scale', '*Angle', 'ShowAxes', 'FocalLength']);
  1198. RegisterPropertiesInCategory(strVisualCategoryName, TGLSceneObject, ['Parts']);
  1199. RegisterPropertiesInCategory(strOpenGLCategoryName, TGLDirectOpenGL, ['UseBuildList']);
  1200. RegisterPropertiesInCategory(strOpenGLCategoryName, [TypeInfo(TGLProxyObjectOptions)]);
  1201. RegisterPropertiesInCategory(strVisualCategoryName, TGLLightSource, ['*Attenuation', 'Shining', 'Spot*']);
  1202. RegisterPropertiesInCategory(strOpenGLCategoryName, TGLCamera, ['TargetObject']);
  1203. RegisterPropertiesInCategory(strVisualCategoryName, TGLCamera, ['DepthOfView', 'SceneScale']);
  1204. RegisterPropertiesInCategory(strOpenGLCategoryName, TGLNonVisualViewer, ['*Render']);
  1205. // GLS.Objects
  1206. RegisterPropertiesInCategory(strOpenGLCategoryName,
  1207. [TypeInfo(TGLLinesNodes), TypeInfo(TGLLineNodesAspect),
  1208. TypeInfo(TGLLineSplineMode), TypeInfo(TGLLinesOptions)]);
  1209. RegisterPropertiesInCategory(strLayoutCategoryName, TGLDummyCube, ['VisibleAtRunTime']);
  1210. RegisterPropertiesInCategory(strVisualCategoryName, TGLDummyCube, ['CubeSize', 'VisibleAtRunTime']);
  1211. RegisterPropertiesInCategory(strVisualCategoryName, TGLPlane, ['*Offset', '*Tiles']);
  1212. RegisterPropertiesInCategory(strOpenGLCategoryName, TGLSprite, ['NoZWrite']);
  1213. RegisterPropertiesInCategory(strLayoutCategoryName, TGLSprite, ['NoZWrite']);
  1214. RegisterPropertiesInCategory(strVisualCategoryName, TGLSprite, ['AlphaChannel', 'Rotation']);
  1215. RegisterPropertiesInCategory(strVisualCategoryName, TGLNode, ['X', 'Y', 'Z']);
  1216. RegisterPropertiesInCategory(strVisualCategoryName, TGLLines,
  1217. ['Antialiased', 'Division', 'Line*', 'NodeSize']);
  1218. RegisterPropertiesInCategory(strVisualCategoryName, TGLCube, ['Cube*']);
  1219. RegisterPropertiesInCategory(strVisualCategoryName, TGLFrustrum, ['ApexHeight', 'Base*']);
  1220. // GLS.SpaceText
  1221. RegisterPropertiesInCategory(strLayoutCategoryName, [TypeInfo(TGLTextAdjust)]);
  1222. RegisterPropertiesInCategory(strLocalizableCategoryName, [TypeInfo(TGLSpaceTextCharRange)]);
  1223. RegisterPropertiesInCategory(strVisualCategoryName, [TypeInfo(TGLLineSplineMode),
  1224. TypeInfo(TGLCapType), TypeInfo(TGLNormalSmoothing),
  1225. TypeInfo(TGLArrowHeadStyle), TypeInfo(TGLTextAdjust)]);
  1226. RegisterPropertiesInCategory(strVisualCategoryName, TGLSpaceText,
  1227. ['AllowedDeviation', 'AspectRatio', 'Extrusion', 'Oblique', 'TextHeight']);
  1228. RegisterPropertiesInCategory(strVisualCategoryName, TGLSphere,
  1229. ['Bottom', 'Radius', 'Slices', 'Stacks', 'Start', 'Stop']);
  1230. RegisterPropertiesInCategory(strVisualCategoryName, TGLDisk,
  1231. ['*Radius', 'Loops', 'Slices']);
  1232. RegisterPropertiesInCategory(strVisualCategoryName, TGLCone,
  1233. ['BottomRadius', 'Loops', 'Slices', 'Stacks']);
  1234. RegisterPropertiesInCategory(strVisualCategoryName, TGLCylinder,
  1235. ['*Radius', 'Loops', 'Slices', 'Stacks']);
  1236. RegisterPropertiesInCategory(strVisualCategoryName, TGLCapsule,
  1237. ['*Radius', 'Loops', 'Slices', 'Stacks']);
  1238. RegisterPropertiesInCategory(strVisualCategoryName, TGLAnnulus,
  1239. ['Bottom*', 'Loops', 'Slices', 'Stacks', 'Top*']);
  1240. RegisterPropertiesInCategory(strVisualCategoryName, TGLTorus,
  1241. ['*Radius', 'Rings', 'Sides']);
  1242. RegisterPropertiesInCategory(strVisualCategoryName, TGLArrowLine,
  1243. ['Bottom*', 'Loops', 'Slices', 'Stacks', 'Top*']);
  1244. RegisterPropertiesInCategory(strVisualCategoryName, TGLPolygon, ['Division']);
  1245. // GLS.MultiPolygon
  1246. RegisterPropertiesInCategory(strVisualCategoryName, TGLContour, ['Division']);
  1247. RegisterPropertiesInCategory(strOpenGLCategoryName, [TypeInfo(TGLContourNodes), TypeInfo(TGLContours)]);
  1248. // GLS.Extrusion
  1249. RegisterPropertiesInCategory(strVisualCategoryName, TGLExtrusionSolid, ['Stacks']);
  1250. RegisterPropertiesInCategory(strVisualCategoryName, TGLPipeNode, ['RadiusFactor']);
  1251. RegisterPropertiesInCategory(strVisualCategoryName, TGLPipe, ['Division', 'Radius', 'Slices']);
  1252. RegisterPropertiesInCategory(strVisualCategoryName, [TypeInfo(TGLNodes), TypeInfo(TPipeNodesColorMode)]);
  1253. RegisterPropertiesInCategory(strVisualCategoryName, TGLRevolutionSolid, ['Division', 'Slices', 'YOffsetPerTurn']);
  1254. // GLS.VectorFileObjects
  1255. RegisterPropertiesInCategory(strOpenGLCategoryName, [TypeInfo(TGLActorAnimationMode), TypeInfo(TGLActorAnimations),
  1256. TypeInfo(TGLMeshAutoCenterings), TypeInfo(TGLActorFrameInterpolation),
  1257. TypeInfo(TGLActorAnimationReference), TypeInfo(TGLActor)]);
  1258. RegisterPropertiesInCategory(strLayoutCategoryName, [TypeInfo(TGLMeshNormalsOrientation)]);
  1259. RegisterPropertiesInCategory(strVisualCategoryName, [TypeInfo(TGLMeshAutoCenterings), TypeInfo(TGLActorAnimationReference),
  1260. TypeInfo(TGLMeshNormalsOrientation)]);
  1261. RegisterPropertiesInCategory(strOpenGLCategoryName, TGLFreeForm, ['UseMeshmaterials']);
  1262. RegisterPropertiesInCategory(strOpenGLCategoryName, TGLAnimationControler, ['AnimationName']);
  1263. RegisterPropertiesInCategory(sLinkageCategoryName, TGLAnimationControler, ['AnimationName']);
  1264. RegisterPropertiesInCategory(strOpenGLCategoryName, TGLActorAnimation, ['*Frame']);
  1265. RegisterPropertiesInCategory(strOpenGLCategoryName, TGLActor,
  1266. ['*Frame*', 'Interval', 'OverlaySkeleton', 'UseMeshmaterials']);
  1267. RegisterPropertiesInCategory(strVisualCategoryName, TGLActor, ['OverlaySkeleton']);
  1268. // GLS.Mesh
  1269. RegisterPropertiesInCategory(strOpenGLCategoryName, [TypeInfo(TGLMeshMode), TypeInfo(TGLVertexMode)]);
  1270. // GLS.Graph
  1271. RegisterPropertiesInCategory(strOpenGLCategoryName, [TypeInfo(TGLHeightFieldOptions)]);
  1272. RegisterPropertiesInCategory(strVisualCategoryName, [TypeInfo(TGLHeightFieldColorMode), TypeInfo(TGLSamplingScale),
  1273. TypeInfo(TGLXYZGridLinesStyle), TypeInfo(TGLXYZGridParts)]);
  1274. RegisterPropertiesInCategory(strOpenGLCategoryName, TGLXYZGrid, ['Antialiased']);
  1275. RegisterPropertiesInCategory(strVisualCategoryName, TGLXYZGrid, ['Antialiased', 'Line*']);
  1276. // GLS.Particles
  1277. RegisterPropertiesInCategory(strLayoutCategoryName, TGLParticles, ['VisibleAtRunTime']);
  1278. RegisterPropertiesInCategory(strVisualCategoryName, TGLParticles, ['*Size', 'VisibleAtRunTime']);
  1279. // GLS.Skydome
  1280. RegisterPropertiesInCategory(strOpenGLCategoryName,
  1281. [TypeInfo(TGLSkyDomeBands), TypeInfo(TGLSkyDomeOptions), TypeInfo(TGLSkyDomeStars)]);
  1282. RegisterPropertiesInCategory(strVisualCategoryName, TGLSkyDomeBand, ['Slices', 'Stacks', '*Angle']);
  1283. RegisterPropertiesInCategory(strVisualCategoryName, TGLSkyDomeStar, ['Dec', 'Magnitude', 'RA']);
  1284. RegisterPropertiesInCategory(strOpenGLCategoryName, TGLEarthSkyDome,
  1285. ['Slices', 'Stacks', 'SunElevation', 'Turbidity']);
  1286. // GLS.Mirror
  1287. RegisterPropertiesInCategory(strOpenGLCategoryName,
  1288. [TypeInfo(TGLMirrorOptions), TypeInfo(TGLBaseSceneObject)]);
  1289. // GLS.ParticleFX
  1290. RegisterPropertiesInCategory(strOpenGLCategoryName, [TypeInfo(TGLBlendingMode)]);
  1291. RegisterPropertiesInCategory(strVisualCategoryName,
  1292. [TypeInfo(TGLBlendingMode), TypeInfo(TPFXLifeColors), TypeInfo(TSpriteColorMode)]);
  1293. RegisterPropertiesInCategory(strOpenGLCategoryName, TGLParticleFXRenderer, ['ZWrite']);
  1294. RegisterPropertiesInCategory(strVisualCategoryName, TGLParticleFXRenderer, ['ZWrite']);
  1295. RegisterPropertiesInCategory(strOpenGLCategoryName, TPFXLifeColor, ['LifeTime']);
  1296. RegisterPropertiesInCategory(strVisualCategoryName, TPFXLifeColor, ['LifeTime']);
  1297. RegisterPropertiesInCategory(strVisualCategoryName, TGLLifeColoredPFXManager, ['Acceleration', 'ParticleSize']);
  1298. RegisterPropertiesInCategory(strVisualCategoryName, TGLPolygonPFXManager, ['NbSides']);
  1299. RegisterPropertiesInCategory(strVisualCategoryName, TGLPointLightPFXManager, ['TexMapSize']);
  1300. // GLS.TerrainRenderer
  1301. RegisterPropertiesInCategory(strOpenGLCategoryName, [TypeInfo(TGLHeightDataSource)]);
  1302. RegisterPropertiesInCategory(strVisualCategoryName, TGLTerrainRenderer, ['*CLOD*', 'QualityDistance', 'Tile*']);
  1303. // GLS.zBuffer
  1304. RegisterPropertiesInCategory(strOpenGLCategoryName, [TypeInfo(TGLMemoryViewer),
  1305. TypeInfo(TGLSceneViewer), TypeInfo(TOptimise)]);
  1306. RegisterPropertiesInCategory(strVisualCategoryName, [TypeInfo(TOptimise)]);
  1307. RegisterPropertiesInCategory(strVisualCategoryName, TGLZShadows, ['DepthFade', '*Shadow', 'Soft', 'Tolerance']);
  1308. // GLS.HUDObjects
  1309. RegisterPropertiesInCategory(strLayoutCategoryName, [TypeInfo(TTextLayout)]);
  1310. RegisterPropertiesInCategory(strVisualCategoryName, [TypeInfo(TGLBitmapFont), TypeInfo(TTextLayout)]);
  1311. RegisterPropertiesInCategory(strLocalizableCategoryName,[TypeInfo(TGLBitmapFont)]);
  1312. // GLS.Texture
  1313. RegisterPropertiesInCategory(strOpenGLCategoryName, [TypeInfo(TGLMaterial), TypeInfo(TGLMaterialLibrary),
  1314. TypeInfo(TGLLibMaterials), TypeInfo(TGLTextureNeededEvent)]);
  1315. RegisterPropertiesInCategory(strOpenGLCategoryName, TGLLibMaterial, ['Texture2Name']);
  1316. RegisterPropertiesInCategory(strVisualCategoryName, TGLLibMaterial, ['TextureOffset', 'TextureScale']);
  1317. RegisterPropertiesInCategory(strOpenGLCategoryName, TGLMaterialLibrary, ['TexturePaths']);
  1318. // GLS.Cadencer
  1319. RegisterPropertiesInCategory(strOpenGLCategoryName, [TypeInfo(TGLCadencer)]);
  1320. // GLS.Collision
  1321. RegisterPropertiesInCategory(strOpenGLCategoryName, [TypeInfo(TObjectCollisionEvent)]);
  1322. // GLS.FireFX
  1323. RegisterPropertiesInCategory(strOpenGLCategoryName, TGLFireFXManager,
  1324. ['MaxParticles', 'NoZWrite', 'Paused', 'UseInterval']);
  1325. RegisterPropertiesInCategory(strVisualCategoryName, TGLFireFXManager,
  1326. ['Fire*', 'InitialDir', 'NoZWrite', 'Particle*', 'Paused']);
  1327. // GLS.ThorFX
  1328. RegisterPropertiesInCategory(strOpenGLCategoryName, [TypeInfo(TCalcPointEvent)]);
  1329. RegisterPropertiesInCategory(strOpenGLCategoryName, TGLThorFXManager,
  1330. ['Maxpoints', 'Paused']);
  1331. RegisterPropertiesInCategory(strVisualCategoryName, TGLThorFXManager,
  1332. ['Core', 'Glow*', 'Paused', 'Target', 'Vibrate', 'Wildness']);
  1333. // GLS.BitmapFont
  1334. RegisterPropertiesInCategory(strOpenGLCategoryName, [TypeInfo(TGLMagFilter), TypeInfo(TGLMinFilter)]);
  1335. RegisterPropertiesInCategory(strLocalizableCategoryName, [TypeInfo(TGLBitmapFontRanges)]);
  1336. RegisterPropertiesInCategory(strLocalizableCategoryName, TGLBitmapFontRange, ['*ASCII']);
  1337. RegisterPropertiesInCategory(strLayoutCategoryName, TGLBitmapFont, ['Char*', '*Interval*', '*Space']);
  1338. RegisterPropertiesInCategory(strLocalizableCategoryName, TGLBitmapFont, ['Glyphs']);
  1339. RegisterPropertiesInCategory(strVisualCategoryName, TGLBitmapFont,
  1340. ['Char*', '*Interval*', '*Space', 'Glyphs']);
  1341. // GLS.HeightData
  1342. RegisterPropertiesInCategory(strOpenGLCategoryName, TGLBitmapHDS, ['MaxPoolSize']);
  1343. RegisterPropertiesInCategory(strVisualCategoryName, TGLBitmapHDS, ['Picture']);
  1344. end;
  1345. //**************************************************************************
  1346. // Register Components
  1347. //**************************************************************************
  1348. procedure Register;
  1349. begin
  1350. RegisterComponents('GLScene', [TGLScene, TGLSceneViewer, TGLMemoryViewer,
  1351. TGLMaterialLibrary, TGLMaterialLibraryEx, TGLCadencer, TGLGuiLayout,
  1352. TGLBitmapFont, TGLWindowsBitmapFont, TGLScriptLibrary, TGLSoundLibrary,
  1353. TGLFullScreenViewer]);
  1354. RegisterComponents('GLScene PFX',
  1355. [TGLCustomPFXManager, TGLPolygonPFXManager,
  1356. TGLPointLightPFXManager, TGLCustomSpritePFXManager, TGLPerlinPFXManager,
  1357. TGLLinePFXManager, TGLFireFXManager, TGLThorFXManager,
  1358. TGLEParticleMasksManager]);
  1359. RegisterComponents('GLScene Utils', [TGLAsyncTimer, TGLStaticImposterBuilder,
  1360. TGLCollisionManager, TGLAnimationControler, TGLAVIRecorder, TGLDCEManager,
  1361. TGLFPSMovementManager, TGLMaterialScripter, TGLUserInterface, TGLNavigator,
  1362. TGLSmoothNavigator, TGLSmoothUserInterface, TGLTimeEventsMGR,
  1363. TGLApplicationFileIO, TGLVfsPAK, TGLSimpleNavigation, TGLGizmo,
  1364. TGLCameraController, TGLSLogger, TGLSArchiveManager, TGLJoystick, TGLScreenSaver, TGLSSynHiMemo]);
  1365. RegisterComponents('GLScene Terrain', [TGLBitmapHDS, TGLCustomHDS,
  1366. TGLHeightTileFileHDS, TGLBumpmapHDS, TGLPerlinHDS, TGLTexturedHDS,
  1367. TGLAsyncHDS, TGLShadowHDS]);
  1368. RegisterComponents('GLScene Shaders', [TGLTexCombineShader, TGLPhongShader,
  1369. TGLUserShader, TGLHiddenLineShader, TGLCelShader, TGLOutlineShader,
  1370. TGLMultiMaterialShader, TGLBumpShader, TGLSLShader,
  1371. TGLSLDiffuseSpecularShader, TGLSLBumpShader, TGLAsmShader,
  1372. TGLShaderCombiner, TGLTextureSharingShader, TGLSLPostBlurShader,
  1373. TGLSLPostThermalVisionShader, TGLSLPostDreamVisionShader, TGLSLPostNightVisionShader,
  1374. TGLSLPostPixelateShader, TGLSLPostPosterizeShader, TGLSLPostFrostShader,
  1375. TGLSLPostTroubleShader]);
  1376. RegisterComponentEditor(TGLSceneViewer, TGLSceneViewerEditor);
  1377. RegisterComponentEditor(TGLScene, TGLSceneEditor);
  1378. RegisterComponentEditor(TGLMaterialLibrary, TGLMaterialLibraryEditor);
  1379. RegisterComponentEditor(TGLMaterialLibraryEx, TGLMaterialLibraryEditor);
  1380. RegisterComponentEditor(TGLSArchiveManager, TGLSArchiveManagerEditor);
  1381. GLSceneRegisterPropertiesInCategories;
  1382. RegisterPropertyEditor(TypeInfo(TResolution), nil, '', TGLResolutionProperty);
  1383. RegisterPropertyEditor(TypeInfo(TGLTexture), TGLMaterial, '', TGLTextureProperty);
  1384. RegisterPropertyEditor(TypeInfo(TGLTextureImage), TGLTexture, '', TGLTextureImageProperty);
  1385. RegisterPropertyEditor(TypeInfo(string), TGLTexture, 'ImageClassName', TGLImageClassProperty);
  1386. RegisterPropertyEditor(TypeInfo(TGLSoundFile), TGLSoundSample, '', TGLSoundFileProperty);
  1387. RegisterPropertyEditor(TypeInfo(string), TGLBaseSoundSource, 'SoundName', TGLSoundNameProperty);
  1388. RegisterPropertyEditor(TypeInfo(TGLCoordinates), nil, '', TGLCoordinatesProperty);
  1389. RegisterPropertyEditor(TypeInfo(TGLColor), nil, '', TGLColorProperty);
  1390. RegisterPropertyEditor(TypeInfo(TGLMaterial), nil, '', TGLMaterialProperty);
  1391. RegisterComponentEditor(TGLGuiLayout, TGLGUILayoutEditor);
  1392. RegisterPropertyEditor(TypeInfo(TGLLibMaterialName), TGLMaterial, '', TGLLibMaterialNameProperty);
  1393. RegisterPropertyEditor(TypeInfo(TGLLibMaterialName), TGLLibMaterial, 'Texture2Name', TGLLibMaterialNameProperty);
  1394. RegisterPropertyEditor(TypeInfo(TGLLibMaterialName), TGLSkyBox, '', TGLLibMaterialNameProperty);
  1395. RegisterPropertyEditor(TypeInfo(TGLLibMaterialName), TGLEParticleMask, '', TGLLibMaterialNameProperty);
  1396. RegisterPropertyEditor(TypeInfo(TGLLibMaterialName), TGLGameMenu, '', TGLLibMaterialNameProperty);
  1397. RegisterPropertyEditor(TypeInfo(TGLLibMaterialName), TGLMaterialMultiProxyMaster, '', TGLLibMaterialNameProperty);
  1398. RegisterPropertyEditor(TypeInfo(TGLLibMaterialName), TGLSLBumpShader, '', TGLLibMaterialNameProperty);
  1399. RegisterPropertyEditor(TypeInfo(TGLLibMaterialName), TGLSpriteAnimation, '', TGLLibMaterialNameProperty);
  1400. RegisterPropertyEditor(TypeInfo(TGLLibMaterialName), TGLMaterialProxy, '', TGLLibMaterialNameProperty);
  1401. RegisterPropertyEditor(TypeInfo(TGLLibMaterialName), TGLActorProxy, '', TGLLibMaterialNameProperty);
  1402. RegisterPropertyEditor(TypeInfo(TGLLibMaterialName), TGLFBORenderer, '', TGLLibMaterialNameProperty);
  1403. RegisterPropertyEditor(TypeInfo(TGLActorAnimationName), TGLAnimationControler, '', TGLAnimationNameProperty);
  1404. RegisterPropertyEditor(TypeInfo(TGLLibMaterialName), TGLTextureSharingShaderMaterial, 'LibMaterialName',
  1405. TGLLibMaterialNameProperty);
  1406. RegisterSelectionEditor(TGLBaseSceneObject, TGLBaseSceneObjectSelectionEditor);
  1407. RegisterSelectionEditor(TGLSoundLibrary, TGLSoundLibrarySelectionEditor);
  1408. RegisterPropertyEditor(TypeInfo(TGLLibMaterialName), TGLLibMaterialProperty,
  1409. 'NextPass', TGLLibMaterialNameProperty);
  1410. RegisterPropertyEditor(TypeInfo(TGLMaterialComponentName),
  1411. TGLTextureProperties, 'LibTextureName', TGLLibTextureNameProperty);
  1412. RegisterPropertyEditor(TypeInfo(TGLMaterialComponentName),
  1413. TGLTextureProperties, 'LibSamplerName', TGLLibSamplerNameProperty);
  1414. RegisterPropertyEditor(TypeInfo(TGLMaterialComponentName),
  1415. TGLMultitexturingProperties, 'LibCombinerName', TGLLibCombinerNameProperty);
  1416. RegisterPropertyEditor(TypeInfo(TGLMaterialComponentName),
  1417. TGLMultitexturingProperties, 'LibAsmProgName', TGLLibAsmProgNameProperty);
  1418. RegisterPropertyEditor(TypeInfo(TGLMaterialComponentName), TGLShaderModel3,
  1419. 'LibVertexShaderName', TGLLibShaderNameProperty);
  1420. RegisterPropertyEditor(TypeInfo(TGLMaterialComponentName), TGLShaderModel3,
  1421. 'LibFragmentShaderName', TGLLibShaderNameProperty);
  1422. RegisterPropertyEditor(TypeInfo(TGLMaterialComponentName), TGLShaderModel4,
  1423. 'LibVertexShaderName', TGLLibShaderNameProperty);
  1424. RegisterPropertyEditor(TypeInfo(TGLMaterialComponentName), TGLShaderModel4,
  1425. 'LibFragmentShaderName', TGLLibShaderNameProperty);
  1426. RegisterPropertyEditor(TypeInfo(TGLMaterialComponentName), TGLShaderModel4,
  1427. 'LibGeometryShaderName', TGLLibShaderNameProperty);
  1428. RegisterPropertyEditor(TypeInfo(TGLMaterialComponentName), TGLShaderModel5,
  1429. 'LibVertexShaderName', TGLLibShaderNameProperty);
  1430. RegisterPropertyEditor(TypeInfo(TGLMaterialComponentName), TGLShaderModel5,
  1431. 'LibFragmentShaderName', TGLLibShaderNameProperty);
  1432. RegisterPropertyEditor(TypeInfo(TGLMaterialComponentName), TGLShaderModel5,
  1433. 'LibGeometryShaderName', TGLLibShaderNameProperty);
  1434. RegisterPropertyEditor(TypeInfo(TGLMaterialComponentName), TGLShaderModel5,
  1435. 'LibTessControlShaderName', TGLLibShaderNameProperty);
  1436. RegisterPropertyEditor(TypeInfo(TGLMaterialComponentName), TGLShaderModel5,
  1437. 'LibTessEvalShaderName', TGLLibShaderNameProperty);
  1438. RegisterPropertyEditor(TypeInfo(string), TGLTextureImageEx, 'SourceFile', TPictureFileProperty);
  1439. RegisterPropertyEditor(TypeInfo(string), TGLShaderEx, 'SourceFile', TShaderFileProperty);
  1440. RegisterPropertyEditor(TypeInfo(string), TGLASMVertexProgram, 'SourceFile', TAsmProgFileProperty);
  1441. RegisterPropertyEditor(TypeInfo(Boolean), TGLBaseShaderModel, 'AutoFillOfUniforms', TUniformAutoSetProperty);
  1442. RegisterPropertyEditor(TypeInfo(TStringList), TGLShaderEx, 'Source', TGLShaderEditorProperty);
  1443. end;
  1444. //----------------------------------------------------------------------------
  1445. function GetGLSceneVersion: string;
  1446. var
  1447. LProject: IOTAProject;
  1448. LExePath, LProjectPath, LSVN, LRevision: string;
  1449. begin
  1450. LRevision := Copy(GLSCENE_REVISION, 20, 5);
  1451. // will be assigned after project compilation
  1452. // after each compilation get it from file \.svn\entries in 4-th line
  1453. // and write to file GLSceneRevision
  1454. // in both fail (no \.svn\entries or GLSceneRevision file) get a version value from GLScene.pas
  1455. LProject := GetActiveProject;
  1456. LExePath := ExtractFilePath(ParamStr(0));
  1457. if Assigned(LProject) then
  1458. begin
  1459. LProjectPath := ExtractFilePath(LProject.FileName);
  1460. LSVN := LProjectPath + '.svn\entries';
  1461. if FileExists(LSVN) then
  1462. with TStringList.Create do
  1463. try
  1464. // Load
  1465. LoadFromFile(LSVN);
  1466. if (Count >= 4) and (Trim(Strings[3]) <> '') and
  1467. IsDirectoryWriteable(LExePath) then
  1468. begin
  1469. LRevision := Trim(Strings[3]);
  1470. // Save
  1471. Clear;
  1472. Add(LRevision);
  1473. SaveToFile(LExePath + 'GLSceneRevision');
  1474. end;
  1475. finally
  1476. Free;
  1477. end;
  1478. end
  1479. else if FileExists(LExePath + 'GLSceneRevision') then
  1480. try
  1481. with TStringList.Create do
  1482. try
  1483. LoadFromFile(LExePath + 'GLSceneRevision');
  1484. if (Count >= 1) and (Trim(Strings[0]) <> '') then
  1485. LRevision := Trim(Strings[0]);
  1486. finally
  1487. Free;
  1488. end;
  1489. except
  1490. end;
  1491. // Finally
  1492. Result := Format(GLSCENE_VERSION, [LRevision]);
  1493. end;
  1494. function GetProjectTargetName: string;
  1495. var
  1496. Project: IOTAProject;
  1497. begin
  1498. Result := '';
  1499. Project := GetActiveProject;
  1500. if Assigned(Project) then
  1501. begin
  1502. Result := Project.ProjectOptions.TargetName;
  1503. if Length(Result) > 0 then
  1504. ForceDirectories(ExtractFilePath(Result));
  1505. end;
  1506. end;
  1507. initialization // ------------------------------------------------------------
  1508. SplashScreenServices.AddPluginBitmap(GetGLSceneVersion, LoadBitmap(HInstance, 'TGLScene'),
  1509. False, 'MPL 2.0 license', 'VCL version');
  1510. Stage.Utils.IsDesignTime := True;
  1511. Stage.Utils.vProjectTargetName := GetProjectTargetName;
  1512. GLS.Color.vUseDefaultColorSets := True;
  1513. GLS.Coordinates.vUseDefaultCoordinateSets := True;
  1514. ReadVideoModes;
  1515. with ObjectManager do
  1516. begin
  1517. CreateDefaultObjectIcons(HInstance);
  1518. RegisterSceneObject(TGLCamera, 'Camera', '', HInstance);
  1519. RegisterSceneObject(TGLLightSource, 'LightSource', '', HInstance);
  1520. RegisterSceneObject(TGLDummyCube, 'DummyCube', '', HInstance);
  1521. // Basic geometry
  1522. RegisterSceneObject(TGLSprite, 'Sprite', strOCBasicGeometry, HInstance);
  1523. RegisterSceneObject(TGLPoints, 'Points', strOCBasicGeometry, HInstance);
  1524. RegisterSceneObject(TGLLines, 'Lines', strOCBasicGeometry, HInstance);
  1525. RegisterSceneObject(TGLPlane, 'Plane', strOCBasicGeometry, HInstance);
  1526. RegisterSceneObject(TGLPolygon, 'Polygon', strOCBasicGeometry, HInstance);
  1527. RegisterSceneObject(TGLCube, 'Cube', strOCBasicGeometry, HInstance);
  1528. RegisterSceneObject(TGLFrustrum, 'Frustrum', strOCBasicGeometry, HInstance);
  1529. RegisterSceneObject(TGLSphere, 'Sphere', strOCBasicGeometry, HInstance);
  1530. RegisterSceneObject(TGLDisk, 'Disk', strOCBasicGeometry, HInstance);
  1531. RegisterSceneObject(TGLCone, 'Cone', strOCBasicGeometry, HInstance);
  1532. RegisterSceneObject(TGLCylinder, 'Cylinder', strOCBasicGeometry, HInstance);
  1533. RegisterSceneObject(TGLCapsule, 'Capsule', strOCBasicGeometry, HInstance);
  1534. RegisterSceneObject(TGLDodecahedron, 'Dodecahedron', strOCBasicGeometry, HInstance);
  1535. RegisterSceneObject(TGLIcosahedron, 'Icosahedron', strOCBasicGeometry, HInstance);
  1536. RegisterSceneObject(TGLHexahedron, 'Hexahedron', strOCBasicGeometry, HInstance);
  1537. RegisterSceneObject(TGLOctahedron, 'Octahedron', strOCBasicGeometry, HInstance);
  1538. RegisterSceneObject(TGLTetrahedron, 'Tetrahedron', strOCBasicGeometry, HInstance);
  1539. RegisterSceneObject(TGLSuperellipsoid, 'Superellipsoid', strOCBasicGeometry, HInstance);
  1540. // Advanced geometry
  1541. RegisterSceneObject(TGLAnimatedSprite, 'Animated Sprite', strOCAdvancedGeometry, HInstance);
  1542. RegisterSceneObject(TGLArrowLine, 'ArrowLine', strOCAdvancedGeometry, HInstance);
  1543. RegisterSceneObject(TGLArrowArc, 'ArrowArc', strOCAdvancedGeometry, HInstance);
  1544. RegisterSceneObject(TGLAnnulus, 'Annulus', strOCAdvancedGeometry, HInstance);
  1545. RegisterSceneObject(TGLExtrusionSolid, 'ExtrusionSolid', strOCAdvancedGeometry, HInstance);
  1546. RegisterSceneObject(TGLMultiPolygon, 'MultiPolygon', strOCAdvancedGeometry, HInstance);
  1547. RegisterSceneObject(TGLPipe, 'Pipe', strOCAdvancedGeometry, HInstance);
  1548. RegisterSceneObject(TGLRevolutionSolid, 'RevolutionSolid', strOCAdvancedGeometry, HInstance);
  1549. RegisterSceneObject(TGLTorus, 'Torus', strOCAdvancedGeometry, HInstance);
  1550. // Mesh objects
  1551. RegisterSceneObject(TGLActor, 'Actor', strOCMeshObjects, HInstance);
  1552. RegisterSceneObject(TGLFreeForm, 'FreeForm', strOCMeshObjects, HInstance);
  1553. RegisterSceneObject(TGLMesh, 'Mesh', strOCMeshObjects, HInstance);
  1554. RegisterSceneObject(TGLTilePlane, 'TilePlane', strOCMeshObjects, HInstance);
  1555. RegisterSceneObject(TGLPortal, 'Portal', strOCMeshObjects, HInstance);
  1556. RegisterSceneObject(TGLTerrainRenderer, 'TerrainRenderer', strOCMeshObjects, HInstance);
  1557. // Graph-plotting objects
  1558. RegisterSceneObject(TGLFlatText, 'FlatText', strOCGraphPlottingObjects, HInstance);
  1559. RegisterSceneObject(TGLHeightField, 'HeightField', strOCGraphPlottingObjects, HInstance);
  1560. RegisterSceneObject(TGLXYZGrid, 'XYZGrid', strOCGraphPlottingObjects, HInstance);
  1561. // Particle systems
  1562. RegisterSceneObject(TGLParticles, 'Particles', strOCParticleSystems, HInstance);
  1563. RegisterSceneObject(TGLParticleFXRenderer, 'PFX Renderer', strOCParticleSystems, HInstance);
  1564. // Environment objects
  1565. RegisterSceneObject(TGLEarthSkyDome, 'EarthSkyDome', strOCEnvironmentObjects, HInstance);
  1566. RegisterSceneObject(TGLSkyDome, 'SkyDome', strOCEnvironmentObjects, HInstance);
  1567. RegisterSceneObject(TGLSkyBox, 'SkyBox', strOCEnvironmentObjects, HInstance);
  1568. RegisterSceneObject(TGLAtmosphere, 'Atmosphere', strOCEnvironmentObjects, HInstance);
  1569. // HUD objects.
  1570. RegisterSceneObject(TGLHUDSprite, 'HUD Sprite', strOCHUDObjects, HInstance);
  1571. RegisterSceneObject(TGLHUDText, 'HUD Text', strOCHUDObjects, HInstance);
  1572. RegisterSceneObject(TGLResolutionIndependantHUDText,
  1573. 'Resolution Independant HUD Text', strOCHUDObjects, HInstance);
  1574. RegisterSceneObject(TGLAbsoluteHUDText, 'Absolute HUD Text', strOCHUDObjects, HInstance);
  1575. RegisterSceneObject(TGLGameMenu, 'GameMenu', strOCHUDObjects, HInstance);
  1576. RegisterSceneObject(TGLConsole, 'Console', strOCHUDObjects, HInstance);
  1577. // GUI objects.
  1578. RegisterSceneObject(TGLBaseControl, 'Root Control', strOCGuiObjects, HInstance);
  1579. RegisterSceneObject(TGLPopupMenu, 'GLPopupMenu', strOCGuiObjects, HInstance);
  1580. RegisterSceneObject(TGLForm, 'GLForm', strOCGuiObjects, HInstance);
  1581. RegisterSceneObject(TGLPanel, 'GLPanel', strOCGuiObjects, HInstance);
  1582. RegisterSceneObject(TGLButton, 'GLButton', strOCGuiObjects, HInstance);
  1583. RegisterSceneObject(TGLCheckBox, 'GLCheckBox', strOCGuiObjects, HInstance);
  1584. RegisterSceneObject(TGLEdit, 'GLEdit', strOCGuiObjects, HInstance);
  1585. RegisterSceneObject(TGLLabel, 'GLLabel', strOCGuiObjects, HInstance);
  1586. RegisterSceneObject(TGLAdvancedLabel, 'GLAdvancedLabel', strOCGuiObjects, HInstance);
  1587. RegisterSceneObject(TGLScrollbar, 'GLScrollbar', strOCGuiObjects, HInstance);
  1588. RegisterSceneObject(TGLStringGrid, 'GLStringGrid', strOCGuiObjects, HInstance);
  1589. RegisterSceneObject(TGLCustomControl, 'GLBitmapControl', strOCGuiObjects, HInstance);
  1590. // Special objects
  1591. RegisterSceneObject(TGLLensFlare, 'LensFlare', strOCSpecialObjects, HInstance);
  1592. RegisterSceneObject(TGLTextureLensFlare, 'TextureLensFlare', strOCSpecialObjects, HInstance);
  1593. RegisterSceneObject(TGLMirror, 'Mirror', strOCSpecialObjects, HInstance);
  1594. RegisterSceneObject(TGLShadowPlane, 'ShadowPlane', strOCSpecialObjects, HInstance);
  1595. RegisterSceneObject(TGLShadowVolume, 'ShadowVolume', strOCSpecialObjects, HInstance);
  1596. RegisterSceneObject(TGLZShadows, 'ZShadows', strOCSpecialObjects, HInstance);
  1597. // Texture objects
  1598. RegisterSceneObject(TGLSLTextureEmitter, 'GLSL Texture Emitter', strOCSpecialObjects, HInstance);
  1599. RegisterSceneObject(TGLSLProjectedTextures, 'GLSL Projected Textures', strOCSpecialObjects, HInstance);
  1600. RegisterSceneObject(TGLTextureEmitter, 'Texture Emitter', strOCSpecialObjects, HInstance);
  1601. RegisterSceneObject(TGLProjectedTextures, 'Projected Textures', strOCSpecialObjects, HInstance);
  1602. RegisterSceneObject(TGLBlur, 'Blur', strOCSpecialObjects, HInstance);
  1603. RegisterSceneObject(TGLMotionBlur, 'MotionBlur', strOCSpecialObjects, HInstance);
  1604. RegisterSceneObject(TGLSpaceText, 'SpaceText', strOCDoodad, HInstance);
  1605. RegisterSceneObject(TGLTrail, 'GLTrail', strOCSpecialObjects, HInstance);
  1606. RegisterSceneObject(TGLPostEffect, 'PostEffect', strOCSpecialObjects, HInstance);
  1607. RegisterSceneObject(TGLPostShaderHolder, 'PostShaderHolder', strOCSpecialObjects, HInstance);
  1608. // Doodad objects.
  1609. RegisterSceneObject(TGLTeapot, 'Teapot', strOCDoodad, HInstance);
  1610. RegisterSceneObject(TGLTree, 'Tree', strOCDoodad, HInstance);
  1611. RegisterSceneObject(TGLWaterPlane, 'WaterPlane', strOCDoodad, HInstance);
  1612. // Proxy objects.
  1613. RegisterSceneObject(TGLProxyObject, 'ProxyObject', strOCProxyObjects, HInstance);
  1614. RegisterSceneObject(TGLColorProxy, 'ColorProxy', strOCProxyObjects, HInstance);
  1615. RegisterSceneObject(TGLFreeFormProxy, 'FreeFormProxy', strOCProxyObjects, HInstance);
  1616. RegisterSceneObject(TGLMaterialProxy, 'MaterialProxy', strOCProxyObjects, HInstance);
  1617. RegisterSceneObject(TGLActorProxy, 'ActorProxy', strOCProxyObjects, HInstance);
  1618. RegisterSceneObject(TGLMultiProxy, 'MultiProxy', strOCProxyObjects, HInstance);
  1619. RegisterSceneObject(TGLMaterialMultiProxy, 'MaterialMultiProxy', strOCProxyObjects, HInstance);
  1620. // Other objects.
  1621. RegisterSceneObject(TGLDirectOpenGL, 'Direct OpenGL', '', HInstance);
  1622. RegisterSceneObject(TGLRenderPoint, 'Render Point', '', HInstance);
  1623. RegisterSceneObject(TGLImposter, 'Imposter Sprite', '', HInstance);
  1624. RegisterSceneObject(TGLFeedback, 'OpenGL Feedback', '', HInstance);
  1625. RegisterSceneObject(TGLFBORenderer, 'OpenGL FrameBuffer', '', HInstance);
  1626. end;
  1627. finalization // ------------------------------------------------------------------
  1628. ObjectManager.Free;
  1629. end.