PDA

View Full Version : Next3D



User137
11-04-2010, 11:20 AM
Edit: Name "Next3D" is trademark of LearningSoft company, this library has nothing to do with them.
Project name changed to nxPascal. This lib is not commercial and never will be.

This is a set of pascal units to ease programming, especially game programming. I started the project perhaps 2007 after i realized where my GLEngine had gone to wrong direction. Everything is categorized and contain abstract classes and strictly separated OpenGL specific implementations of them. If you want to use specific feature of the library you can do just that and it should just click to everything... This was first done for Delphi, then fully converted to Lazarus (freepascal) and is now changed to compile with them both.

Full source (26.6.2010): (Files unavailable for now)
Demos (26.6.2010):
UI Editor (6.5.2010):
For nxNetwork you also need Synapse lib from http://synapse.ararat.cz/doku.php

Units

nxGL - OpenGL graphics engine.
Classes: TGLTextureSet, TGLModel, TGLFont, TNXGL (Engine itself), TVertexArray, TGLUI (User interface with panels, buttons etc. is work in progress)
TNXGL has some functions to control OpenGL rendering. For DelphiX-like ease of use 2D there is DrawRotate() which can use any size patterned textures and draw it rotated around given point in image.
nxNetwork - High level wrapper for Synapse network library. Simple classes for TCP and UDP server and client.
nxMath - Math functions for basic and 2D.
nxMath3D - Math functions for 3D. Vector, matrix, (quaternion).
nxTypes - Basic datatypes used throughout most units.
nxGraph - Contains basic 2D graphics and texture loading from files. Used heavily by nxGL. Contains abstracts of user interface and graphics engine.
nxModel - 3D model formats (W3D, (MS3D not much tested), (OBJ some point)). Bones not yet supported. Some level of vertex animation is done.
nxStrings - Few advanced string functions.
nxDX - DirectX possibility. I don't know DirectX well enough to do this yet.
nxPath - Path finding unit for grid based maps, not yet tested with Lazarus though it compiles from older code. Doesn't look for optimal path but tries to find 1 rough and quick.

Tools:

Edit3D - Delphi made 3D-modelling tool. Is able to import OBJ, MS3D and save W3D.
UIEditor - Lazarus work in progress for User interface. When it's done you would be able to design the whole game interface, save it and use in game. Later may support simple events like opening panel with button but programmer has full control of them for now. Object-tree makes the layout very similar to drawing a form in Delphi/Lazarus, but this one allows full OpenGL's graphical advances.

I'll keep updating this post and only make new replies if something notable comes up.

michalis
11-04-2010, 03:31 PM
Sounds interesting, but we would have to see the code to play with it :) I understand there's no www page where we can see the code or screenshots yet? If this is open-source, I would advice creating a project hosted on https://sourceforge.net/ or http://code.google.com/hosting/ or such.

User137
11-04-2010, 04:18 PM
Some screenshots in other project thread using this:
http://www.pascalgamedevelopment.com/forum/index.php?topic=5597.0
And this video is still valid as the game works exactly as good or maybe better in Lazarus:
http://www.youtube.com/watch?v=kzDrqhHbwKw

Uploaded full source at: (see first post)

And i also understand that it would need to come with some demo-programs... i will see what i can do if you have interest ;)

Simple texture demo:
First you need to set library path for new project's compiler options. This is directory where i placed the lib:
$(LazarusDir)\fpc\2.4.1\units\i386-win32\next3d
Next add LazOpenGLContext in project's required packages. (This step i'd like to eliminate)

uses ... , dglOpenGL, nxGL;
...
procedure TForm1.FormCreate(Sender: TObject);
begin
nx.CreateGlWindow(self);
// OpenGLContext will take in mouse events from the form
tex.AddTexture('new','test.png');
// First texture in the list will have index 0
end;

procedure TForm1.Timer1Timer(Sender: TObject);
begin
if not nx.Initialized then exit;
nx.Clear(true,false); // color,depth buffers
nx.Enable2D;
//tex.SetTex(0); // We don't now need to set it again
nx.Draw(20,10,0);
nx.Disable2D;
nx.Flip;
end;

procedure TForm1.FormClose(Sender: TObject; var CloseAction: TCloseAction);
begin
nx.KillGLWindow;
end;

michalis
11-04-2010, 06:30 PM
Cool, video and screenshots in that thread look really impressive.

I tested compilation under Linux: You need to remove Windows from nxPath uses (to have TPoint type defined, you better use cross-platform Types unit instead). Then everything compiles fine under Linux (including nxNetwork based on synapse). (Well, besides nxDX, but that's obviously expected :) ).

Note about your nxGL.pas LazOpenGLContext notes: if you need to use OpenGLContext unit (for TOpenGLControl), then you *should* have to add LazOpenGLContext into required packages. There's no "workaround" for this (not a clean one at least), this is by design :) In practice, you may distribute Lazarus package (.lpk file) for your engine, and make your engine package require the LazOpenGLContext package. Then developers will be able to easily use your engine as Lazarus package, and the required LazOpenGLContext will be automatically pulled by dependencies.

This is what I use for my engine, and it works without problems :)

Yes, let us know when a demo will be available :)

chronozphere
11-04-2010, 10:19 PM
Wow... so this is the engine you are using for your RTS project. I'll have a closer look at the source soon as I am about to start working on my own engine soon. :)

User137
12-04-2010, 09:52 PM
I tested compilation under Linux: You need to remove Windows from nxPath uses (to have TPoint type defined, you better use cross-platform Types unit instead). Then everything compiles fine under Linux (including nxNetwork based on synapse). (Well, besides nxDX, but that's obviously expected :) ).
Demos are now available, and thx, i also updated nxPath - source zip is also updated :)

4 new demos contain:
- texture: Basic window and texture drawing in normal and rotated way. Alpha blending.
- networkTest: Simple decrypted connection with TCP and UDP. 2 buttons for test packets, you can also open multiple instances of it to test server's client handling.
- pathfind: Simple 2D drawing combined with pathfinding class. Included maze.bmp contain the maze and start points for paths which find way to cursor. Also shows how to change texture loading options such as forced color to alpha.
- model: Loading and rendering a rotating 3D model. Surfacing another rotating model in cursor pointed position and click drag flamey particles.

For now i don't have much built-in support for particles because they much depend on program you want to use them to. Some use vertex arrays etc, there are tens of ways and purposes...

Edit: Updated demos file again.. little speed optimization for path finder app :p

chronozphere
13-04-2010, 01:34 PM
Did you remove the source again?

I would like to download it, but It says the file is deleted. :(

User137
13-04-2010, 02:35 PM
Works just fine for me (from first post), edited the second post's old link out. Also sorry about 60 sec wait and ads, but that was 1 easy place to make a persistent upload account to.

Edit: Pathfinding demo should look like this:
http://i39.tinypic.com/2z8qg6t.png

chronozphere
13-04-2010, 05:52 PM
Thanks. :) That link seems to work.

User137
14-04-2010, 01:47 PM
Just giving heads-up on the UI Editor. You maybe noticed how unfinished the UI classes are in the release version, now i have however got to point where i was able to draw panels and buttons. Onwards UI Editor may take quite bit longer to finish but this was the critical step.
http://i40.tinypic.com/nq6849.png
Objects scale with window unless they use "absolute position" or "absolute size", i haven't seen that kind of feature used much before. On the downside it makes object width and height have 2 scaling levels depending on the mode. By default objects position and size are 0..1 and not absolute.

In engine level also tiny change in font texture loading; instead of color-key (black) i now use AlphaColor option for smoother but pixel-perfect "antialiased" fonts. Also added nx.LastError property for handling errors on loading etc.

Also, plan is to add list of textures and fonts in UI editor so you could define and save all graphics used in game, instead of adding them in program manually. UI needs this feature anyway if want to have at least 2 different looking buttons etc.

azrael11
25-04-2010, 05:29 AM
This is very interesting...

I hope you have a stable version soon with gui components and others.
Do you plan to target in three platforms win,linux,macosx ?
Do you plan to make vcl for this engine like glscene... ?

User137
25-04-2010, 09:40 AM
This is very interesting...

I hope you have a stable version soon with gui components and others.
It is stable but much work to be done. I did buttons and panels first to test the tree-structure and that is all working perfectly even in editor. Changing properties, moving, resizing, deleting objects and sub-objects and rendering is all finished. What remains is saving/loading from files, rest of the UI components, font and texture tools.


Do you plan to target in three platforms win,linux,macosx ?
I code this in Win32 but none of my units uses Windows, so it should not be dependant on platform.


Do you plan to make vcl for this engine like glscene... ?
No. I don't actually know all what GLScene can do, when i tried it last it tended to crash my Delphi and i got rid of it. But this is a Lazarus project now which is not going to be compatible with Delphi without additional coding. Things like TRawImage only exist in freepascal.

wodzu
04-05-2010, 08:29 AM
Looks like you put onto it a large amount of work User137. I have some questions if you don't mind about the TGLFont class.

How do you handle fonts? I mean do you use specific OS function to convert a given font into the texture \ bitmap and put it onto the display list?

Or do the user must manually prepare a texture font?

User137
04-05-2010, 08:41 AM
I create a TBitmap and use canvas font function to draw it, that should work on different platforms. There is another function that converts TBitmap into OpenGL readable data format and then loads it in.
Edit: simply put i create a font-map, a single big texture containing alot of characters. No displaylists are involved.
I posted the function earlier at:

http://www.pascalgamedevelopment.com/forum/index.php?topic=6196.msg50120#msg50120

But you can also see it in the full source. Programmer just has to decide what font size and texture size to use. They are stored in font specific class and renderer will adapt to the values. Canvas font system has the nice feature TextWidth() which lets you also save size of each character.

wodzu
04-05-2010, 09:40 AM
Thanks, that is an ellegant solution :)

So you are relaying on the Lazarus crosplatform font functions.

User137
06-05-2010, 04:33 PM
News from UIEditor again: http://i42.tinypic.com/11bnjvc.png
- Figured out file format and done saving and loading.
- Added Label and Edit components.
- Editor has now snapping option which was needed for more professional looks.
- Absolute and relative coordinates now working. By default components are created relative, which means that they scale with window size. Can be changed on_the_fly in editor.
Note: Even though loading and rendering will already work in game there are no mouse events yet.

Some minor changes in the engine itself which made me update demos slightly. I wanted to support DelphiX-like simplicity so i added SetColor function, making it now not necessary to include OpenGL header in simple 2D games at all. Pathfind unit has GetBetterPath function which looks path from "start to end" and "end to start" and returns path that was shorter. There is now a class TDisplayList, much code was changed due to this.

Updating first post with new links today...

WILL
06-05-2010, 07:41 PM
Very nice. Would you be able to include the UI as a separate library later on? A full-blown RTS is out of my capabilities for game dev, but I have an other game which I'd love to have a nice GUI to handle my window/menu functions. Custom self-made menus being a must for it as it would have heavy use of menus and status screens.

Oh and what effect would Delphi Mode set in Lazarus have on compiling these units with my existing projects?

User137
06-05-2010, 10:06 PM
The UI is sort of standalone. Only thing that atm ties it to nxGL is automatic resizing (this happens only in TUIPanel.Draw()). It is possible to make a function do that manually by values, but it's very fast to check window sizes from nxGL itself.
And another thing is textures and fonts. Neither of these propably need the engine, but depend on the base units.

All i'm saying, OpenGL is almost same no matter how you create window, with minor changes you would be able to integrate whole Next3D in your current engine. It is overall light package. If i was to detach UI separately aswell they wouldn't necessarily stay updated same way and it would conflict with the structure of Next3D...

Menus did cross my mind and they are possible to make. So far i have skipped them though, being not so much needed feature and a bit complex thing to do. After making dropdown-list it may become more clear how to do it, they are similar.

The units seem to have their own modes set at beginning so your project wouldn't effect them. nxGL uses objfpc at the moment, which if changed to delphi seems to (at least) enrage about procedure pointers done differently ^^ (i have later become to like delphi mode more though, old relics these things...)

Edit: About menus i might add that, as seen in the screenshot the normal Lazarus menus work well with it. Popup menus won't have issues either. Still i may add them later for they can be more graphical.

Vinzvega
07-05-2010, 08:22 PM
User137 : This is very impressive ! The rts shown on youtube was made with this lib ?
Very speed !

User137
26-06-2010, 07:22 PM
I'm spending way too much time playing games :D

Anyway, UI Editor had its file format still rewritten cause i wanted it to be more dynamic. More properties can be added later with old files still be readable without any changes to the engine.

But important change to Next3D today when i was updating my Ubuntu linux system; all demos compiled and run perfectly! Exception to Networktest which throws access violation and crash on Server.Connect. Pre-compiled .exe runs fine with wine though but OpenGL is slower like that.

nr.2 on important changes is Delphi support. I added alot of IFDEF's here and there so same units now run in Delphi, Lazarus both in Windows and Linux. I made Delphi versions of all 4 demos and they are working, including synapse network (well minor glitch with 1 server thread staying open...).

At this point there are some plans for multipurpose particle engine. Challenge is to make it use only as much memory as particle type needs, i think the solution needs multiple records or sub-classes. Still little bit unsure if class object would be fast enough.

Files updated cause it's first version that supports Delphi too.

WILL
27-06-2010, 03:57 AM
I'm spending way too much time playing games :D

Famous last developer's post. :p (PS: 'The Force Unleashed Sith Edition' is super fun on the Mac!)

Hey your Next3D engine is starting to sound really neat. Since you are planning on releasing your engine, I'm assuming, for public usage, what do you think about doing a small article on how it's made up and how developers can use it in their games? The engine doesn't have to be done to do an article on it at this stage, just maybe a small description of what you're doing with some cool diagrams and figures illustrating the basic concept of the engine. I think this would do well to promote it's usage amoung other fellow developers. And would be a great article. Write me back at contact@pascalgamer.com if you are interested or just want to tell me to bugger off. ;)

Either way this project looks great and I hope it get's to 1.0 eventually. UI is such a tricky aspect of game development.

User137
09-07-2010, 12:25 PM
Opened a website for this project:
http://next3d.webs.com/

So far been unable to upload .zip there but at least i can share photos, news and have dedicated forums for questions/suggestions.

djcityscapes
13-07-2010, 07:50 PM
This is interesting. Is this compatible with Delphi 2007?

User137
13-07-2010, 09:25 PM
Works with Delphi 7, i have no other versions.

User137
22-08-2010, 08:38 AM
Some news again about UI Editor and Next3D:
- Added new draw functions to Font class supporting wrapping and bounded text area.
- Added new draw functions to draw in "repeat" and "sections" mode. Sections are new and default way to draw UI components to retain sharp details. Pattern of a texture is divided in 9 custom sized parts where edges are not scaled when drawn, middle sections are. Button for example only has 1 texture shared for up and down state.
Screenshot: http://i35.tinypic.com/23vf2gy.png
- Saving and loading is finished with the dynamic format.
- List and DropDownList added. Supports text centering.
- Added Memo component. Supports wrapping and 2 ways scrolling.

I've been thinking how to manage multiple layouts and windows in 1 file. First i thought to make a separate layout list but now came up with idea of Visibility. User can simply add everything in the main panel and toggle the Visible state of its children with a CheckListBox.

chronozphere
23-08-2010, 08:32 AM
Hey, that's a fine looking UI editor. ;)

Are you using XML to store the UI layout or something else?

User137
23-08-2010, 12:20 PM
No its own format. XML and similar has too much bloat such as <> tag characters, indentations etc. I just wanted to make it barely understandable when reading with Notepad in purpose of debugging or maybe even editing some value if needed.
http://pastebin.com/8F5HWtpR

NecroDOME
27-08-2010, 10:24 PM
GUI editor looks nice and useful!!

How much work would it be to make it compatible with my "DataFile" format? url: http://www.necrosoft.nl/?p=790 It has nested elements, more like simplified readable XML. It only needs to place image, text, edit, panels and button elements with some small configurations like text and image.

just a question... I'm looking for a simple UI editor. And I don't want to make one myself :P.

Nice work!

User137
28-08-2010, 09:12 AM
Well, yeah it can be little tricky saving object tree to another format. The current saving/loading is written in the container objects themselves, called recursively.

But your data format doesn't look complicated. How do you store normal and multiline strings?

NecroDOME
28-08-2010, 09:14 AM
multiline strings would be saved either with escape characters or per-line. I also use it to define materials and models

User137
14-09-2010, 07:39 PM
Something new again... Along with a simple test app, UI is now made interactive with mouse events. Not all components have full functionality yet but buttons and scrollbars do. I can already predict alot of issues with memo component needing a flexible select area and insert-typing... but what is already done is enough to make a full game user-interface. Even though main program can use even a slow timer to render it all, the response speed is lightning fast because of form events.

UIEditor had a little cleaning done by using PageControl for extra dialogs. MainPanel child objects have a visibility toggler so it is possible to design multiple fullscreen views, or bits and parts here and there.

Edit and list components have next highest priority. Texture- and font-selector should also be done some point.

One word about customizability, UIEditor can't and propably will not be able to change settings of subobjects such as scrollbar belonging to List object. They however can be easily customized runtime in code; changing colors, texture, fonts etc. UI uses default textures (reserved png filenames) which all components will use unless changed in texture-selector.

User137
26-09-2010, 05:46 PM
New versions and new test program added, also first public release of UIEditor:
http://next3d.webs.com

With the test program you should be able to scroll memo, list, dropdown-list ect with mousewheel, arrow keys and mouse. I cannot express how much you can do with that stuff already but i hope the tester gives out some hint :) I also made a built-in system for frame fading which are used at start and end of test program. It can be used to easily but smoothly hide/show different frames in given milliseconds.

Delphi compatibility is remaining in the demos, and the engine core has had a lot of fixes here and there. For example nx.FrameTick variable is faster and preferred alternative to using GetTickCount function in the main program.

edit: OH! And that is the way i'd want every scrollbar to work :D Not having to search for the handle to drag but instead be able to click and drag anywhere in the bar to move it there.

User137
22-02-2011, 08:42 PM
Time to update on status again.

Just almost done (edit: Done and all Delphi compatible again) with a huge change within UI files. There is now nxUI.pas and nxGLUI.pas because i like to make universally working code. nxUI can be somewhat easily adapted to be drawn with any engine, even with standard Canvas. I just now need to finish drawing functions in the GL unit.

With 2D drawing in good shape already with easy to use functions, i feel like i need to start working on 3D. This means i'll try to create 2 applications: 3D modelling program and animator. Modelling program will use save format OBJ and import as many formats as i can. Both programs will use this GL based UI.

The 3D animator is new project what i have been experimented a bit years ago. But only recently i've been starting to have more vision of what i want of it.
- Bones (joints) are created and attached in this editor.
- 1 project open at the time. Saved in 1 file of custom format (maybe N3D).
- Vertically scrollable small bar left side of screen containing all 3D models in project.
- Vertex and bone animation in same file.
- Each model has N amount of keyframes.
- Multiple animations can be created and shown same time in purpose of making synchronized animation between many objects. (For example 2 humans handshaking would be rather frustrating task without sync)

And still, purpose of Next3D is to be useful to many, maybe fill the gaps. It can be used as standalone for games, but it can also be used alongside other engines. It is highly modular etc. For instance you may have a OpenGL based graphics engine of your own but you will still be able to use drawing, math, font functions and UI with it. The beauty is in that there are no components or anything needed to install at all. Just add units to the Lazarus\FPC\Delphi search path.