Jump to content
  • entries
    945
  • comments
    5,899
  • views
    930,065

Further down the rabbit::hole


Josh

7,418 views

 Share

Let's start with some code for making instances and unique copies of a material:

Material* mat1 = new Material;
mat1->SetColor(0,0,1,1);

Material* mat2 = mat1->Copy(true);
Material* mat3 = mat1->Copy(false);

mat1->SetColor(1,0,0,1);

mat1 and 2 will be red. mat3 will be blue. Shaders, textures, and entities work the same way.

 

Drawing commands are in. I like how OpenGL3 gets rid of all the built-in matrix stuff and just lets you deal with pure matrix multiplication. It would probably be pretty difficult for a beginner to get into, but it's much cleaner, and it forced me to learn a little more about matrices. I added a mat4 orthogonal projection class function, if you're interested in that sort of thing.

 

I don't have DrawImage(), SetBlend(), SetColor(), etc. commands in, because the material system can handle all of that, and it's much more powerful. Here's some sample code:

Material* mat = LoadMaterial("myimage.mat");
mat->SetColor(1,0,1,0.5);
mat->SetBlend(BLEND_ALPHA);
mat->Enable()
DrawRect(2,2,10,20);
mat->Disable()

You can also draw polygons onscreen if you want. Vertex positions will correspond to screen coordinates:

Material* mat = LoadMaterial("myimage.mat");
Surface* surf = CreateSurface();
surf->AddVertex(0,0,0);
surf->AddVertex(0,1,0);
surf->AddVertex(0,1,1);
surf->AddTriangle(0,1,2);
mat->Enable()
surf->Draw()
mat->Disable()

There are two types of multisampling in OpenGL. The older technique uses the graphics window pixel format. The newer technique involves an FBO with a multisample format. I am going to disable the first technique, because normally rendering is performed on an FBO (a Leadwerks "buffer") and you don't want multisampling to mess up your 2D drawing that is typically done after 3D rendering. It also prevents the user from having to recreate a graphics window to toggle antialiasing on and off. So to sum that all up, antialiasing should be as simple as just defining a multisample format when you create a buffer, which can be 1,2,4,8, or 16.

 

I also hired an outside developer to research fluid simulations for ocean water. Here is an early prototype. There's still some improvement to make, but the technique is promising:

 

On to the editor. Here's the prototype. You can see the asset tree on the right, which functions pretty much like Windows Explorer:

blogentry-1-028241400 1286080305_thumb.jpg

You can enter a word in the search box, press enter, and the results are instantly filtered. I was surprised at the speed, even with thousands of files:

blogentry-1-093826100 1286080368_thumb.jpg

You can right-click on a source art asset and convert it to a final game-ready file format. Here we have a png file you can convert to DDS:

blogentry-1-026904600 1286080421_thumb.jpg

And the familiar DDS convert dialog will appear:

blogentry-1-095367200 1286080429_thumb.jpg

If you choose the "Reconvert" option, the converter will be run with the last options used to convert that file, without pulling up the options dialog. These settings are stored in a file with the image file, and will be remembered across editor sessions.

 

One of the coolest features is that the editor automatically detects file changes and will ask you to reconvert a file. Or if you prefer, you can set the editor to always perform conversions automatically.

blogentry-1-054765300 1286080600_thumb.jpg

Overall, I myself am surprised at the speed with which Leadwerks Engine 3 is taking shape. It's still hard to say exactly when it will be ready, because little details can pop up and take more time, but it's going well.

 Share

28 Comments


Recommended Comments



Does the same work for models?

Model* mod1 = LoadModel("cube.gmf");
mod1->SetScale(1,2,1);

Model* mod2 = mod1->Copy(true);
Model* mod3 = mod1->Copy(false);

mod1->SetScale(2,1,1);

mod1 and mod2 would be double high, mod3 would be double wide?

Or can you make instanced models which each can have their own scale?

Link to comment

Entity matrices and colors are always unique for each copy or instance. The engine also doesn't attempt to instance entities the way you might in 3ds max or something, where changing the color of one might affect other instances. The copying/instancing just affects the loaded mesh data, so you can create a unique copy and apply different materials or alter the mesh without affecting others.

Link to comment

>Or if you prefer, you can set the editor to always perform conversions automatically.

 

Does that do a batch convert, or does it remember the individual conversion settings for each asset?

Link to comment

So this means that (in that sample )

Material* mat1 = new Material;
mat1->SetColor(0,0,1,1);

Material* mat2 = mat1->Copy(true);
Material* mat3 = mat1->Copy(false);

mat1->SetColor(1,0,0,1)

mat2 is a new Material with same attributes as mat1

mat3 is essential a pointer to mat1.

 

what happens with mat1 if mat3 is deleted, or with mat3 if mat1 is deleted?

 

Also. What is the meaning of having a Copy( true ). That can be handled by a copy operator.

Copy(false) is the better called something like CreateInstance or CreateReference

 

Then it would be

Material* mat1 = new Material;
mat1->SetColor(0,0,1,1);

Material* mat2 = new( *mat1  ) ; /
Material* mat3 = mat1->CreateReference();

mat1->SetColor(1,0,0,1)

 

or

Material mat1;
mat1.SetColor(0,0,1,1);

Material mat2( mat1  ) ; 
Material* mat3 = mat1->CreateReference();

mat1.SetColor(1,0,0,1);

 

or

Material mat1;
mat1.SetColor(0,0,1,1);

Material mat2;
mat2 = mat1  ; 
Material* mat3 = mat1->CreateReference();

mat1.SetColor(1,0,0,1);

Link to comment

Good question, I think it should say:

Material* mat3 = new mat1->Copy(false);

because else mat3 is indeed only pointer to something which mat1->Copy(false); gave it.

Link to comment

I agree with Roland! Looks much nicer that way, and will make it easier to read the code. Isn't as much fun to read code with a bunch of anonymous parameters that are just true, false, 0, 1 etc.

 

Good question, I think it should say:

Material* mat3 = new mat1->Copy(false);

because else mat3 is indeed only pointer to something which mat1->Copy(false); gave it.

 

That is not correct. Copy will create a new object and return it.

Link to comment

It will probably be possible to add your own converters, as well, and have them integrate into the editor like that.

Link to comment

Yeah, Editor should be the central tool when making games. Even if you don't use Editor scenes much, it provides a nice portal to access all assets and avoid unnecessary coding in the main program.

 

That's why it's important to have a custom menu option, so you can put there all kind of exe files to launch, and even give them some command line parameters like $selectionname for the asset name which is currently selected, $selectionfilename, $sbxfilename, $projectname, etc...

 

I would first put "Save Backup"="git push" and "Sync with Team"="git pull" there as menu commands, so I can make backups and sync my game files with other team members directly from Editor. Next, I would also add "Code Game"="start $projectname.sln", to start Visual Studio, and then also "Manage Teamspace Files"="git gui", and many more things :D

Link to comment

All I could say is please make the editor very flexible and dynamic. Give us the ability to add our own stuff like menu's and such. Let us launch our own UI panels for our own functionality. A good example for that would be pathfinding stuff. Being able to add our own UI panel to control pathfinding settings to an object would be ideal. The more flexible the better.

Link to comment

I like the editor's functionality, although I must say, you're still failing to convey an explorer-like experience. Already 2 icon sets and only 4 icons.

Link to comment

If there is one shader I hope you make very versatile and easy to alter in realtime within the editor, I hope it's the SSDO shader. Bloom and others would be nice too though.

Link to comment

I was hoping for a more visual appealing editor and not just another windows style one...there are reasons for thousends of different windows themes out there. :D

Link to comment

I was hoping for a more visual appealing editor and not just another windows style one...there are reasons for thousends of different windows themes out there. ;)

 

Michael Betke +1

Link to comment

I thought about this, but I actually don't want there to be a new interface to learn. I want people to know how to use the interface immediately. The features are the point, not the interface.

 

If you just think the Windows interface is ugly, perhaps you should consider Leadwerks for Mac. ;)

Link to comment

I want people to know how to use the interface immediately.

 

so youre not going the blender route? ah thats too bad... was looking forward to having to watch a video tutorial just to learn how to move the camera or to do anything else that's inherently simple in any other interface... ;)

Link to comment

Guest
Add a comment...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...