Jump to content

Torque2D on Patreon


Recommended Posts

  • Replies 62
  • Created
  • Last Reply

Top Posters In This Topic

So far i have found i will need to create separate render functions for different stencil options from the batchrender.


Using the example code here https://github.com/jacobbrunson/BasicLighting/blob/master/src/Main.java


So far i have found that in winGLSpecial.cc we have this

static void APIENTRY logglBlendFunc(GLenum sfactor, GLenum dfactor)
{
  char sf[128], df[128];

  BlendToName( sf, sfactor );
  BlendToName( df, dfactor );

  fprintf( winState.log_fp, "glBlendFunc( %s, %s )\n", sf, df );
  fflush(winState.log_fp);
  dllglBlendFunc( sfactor, dfactor );
}

 

Which is then referenced in the batch renderer here

inline void setBlendMode( GLenum srcFactor, GLenum dstFactor, const ColorF& blendColor = ColorF(1.0f, 1.0f, 1.0f, 1.0f))
   {
       // Ignore no change.
       if (    mBlendMode &&
               mSrcBlendFactor == srcFactor &&
               mDstBlendFactor == dstFactor &&
               mBlendColor == blendColor )
               return;

       // Flush.
       flush( mpDebugStats->batchBlendStateFlush );

       mBlendMode = true;
       mSrcBlendFactor = srcFactor;
       mDstBlendFactor = dstFactor;
       mBlendColor = blendColor;
   }

 

Im going to create separate functions for stencilop and stencilfunc for rendering lights and light occluders but only if the scene contains a light. this way if your scene does not create a light there should be no difference in the render order at all, but if your scene does have lights, they need to be rendered first and past to frag shader

Link to post
Share on other sites

Im still working on this to get it working but have tailed off a bit, using some of simon loves work on creating a particle editor, i have begun work on an animation editor. I may make simon loves particle editor look a bit nicer to fit with design that i am going for with the animtion editor, it works perfectly with torque 3.4 with some minor tweaks, im thinking of consolidating all assets into a main assets folder with different sections for different types of items particles, sprites, gui etc for use with different editors. I see you have started work on implementing editors as well are there any code changes needed for the editors you are going to add? or is the editor going to load like a module ?

Link to post
Share on other sites

Sounds like you were busy over the weekend :)


I have started work on the editors, but I was quickly side-swiped by how run-down the GUI has become. So I started refurbishing the GUI and writing documentation as I went. You can find it in the wiki and try it out in the dev branch.


I did manage to put in some scaffolding for the editors. They open with the console - separated by tabs. The editors will load everything they do as a module into a separate module manager (to keep the actual game stuff away from the editors stuff). I did the same thing with the assets. The editor assets are loaded by a different asset manager instance. This should make it much easier to build an asset editor.


So there are lots of code changes to the GUI and many of the controls are still broken or I removed them (there were 9 buttons). You can read about my changes so far here:


https://github.com/GarageGames/Torque2D/wiki/GUI-Guide


I also did several Patreon post about my changes that you could read.


https://www.patreon.com/Torque2D


I took a break from the editors to do an update to my game, but the update is almost done and I'll return to the editors soon.

Link to post
Share on other sites

ah yes i downloaded that it looks brilliant with them being in the console!! i really like that, i have them at the moment as a dropdown menu.


One thing though with the latest dev branch its not registering touch events in the sandbox controls but is that because the gui elements are coded different?


It will be pretty cool when the editors are done i will keep trying to make my editors in the background with the 3.4 build, they should just drop into your editor folders without many changes being needed, are you going to be rolling the likes of animation editor, particle editor etc all into one main scene editor? or do u want to keep them separate?

Link to post
Share on other sites

I wanted to have an "Asset Manager" that handles particles and animations along with static images. The scene editor is probably separate but I could see there being button to jump to an asset in the Asset Manager.


I changed the event names from "Mouse" events to "Touch" events on the GUI controls which broke everything. I've been slowly fixing them and I haven't gotten to some to the controls used by the sandbox yet. There's other breaking changes still in the works as well, but that's the main one.

Link to post
Share on other sites

For the Asset Manager I imagine a list of assets on one side and a list of controls on the other with the selected asset displayed in the center. So if you pick a particle effect, it's displayed in the center with the various settings for the particle effect on to the right of it.

Link to post
Share on other sites
I think we are thinking along the same lines, would each asset be attributed to a different project? So for example load a project and all scenes and assets attributed to that project load up in the manager or would it be all assets are just readily available without having to add them to a projects asset manager first?
Link to post
Share on other sites

It would be all the assets in the default asset manager in the engine (so readily available). The assets for the editors will be loaded in a separate asset manager so they will not appear in the editor. This is actually happening already in the dev branch.


Also, the idea of loading a project was one that I struggled with for a long time. I finally settled on having the editors as more of an add-on for the game (which would not be added for the release of course) similar to the way the console is. Or another way of thinking of it is that we are just taking the console and extending it. It's a little bit of a paradigm shift from the old TGB but it saves a lot of effort that we don't have the man-power for. So the game loads as normal and somewhere in main it loads the editors which do everything they can to stay out of the global namespace and base asset manager. Of course, the editor is loaded as modules and if the game had modules with the same name that would be a problem. With that exception it should work great. I currently treat the Sandbox like the "game".


Also, I've set up a library fold that I want to have reusable modules in. I hope to create a "Module Manager" that can add modules from the library into your game folder. There's already code to copy modules so this actually might be easier than it sounds. In the future I hope to have a lot default functionality built as modules so that people can quickly prototype ideas. For example, a dialog box module for an RPG type game. I image after copying it the user will need to make changes but it will give them a quick starting point. For now the library just has the AppCore module in there.

Link to post
Share on other sites

browsing the code i did see functions exposed to script for merging scenes and modules its pretty cool. After browsing through for most of the day it is remarkable what functions are exposed to script with a lot of options that aren't being utilized. Must be left over code from the editors.


Some of the example toys don't even make use of those functions such as multiple scenes on one canvas. dynamic guis quite a few actually. Would be pretty cool to have a base module that is a main menu that when play is pressed it loads a simple game or something.

Link to post
Share on other sites
  • 3 months later...

oh just a heads up about developing in android studio, a lot of the errors that were coming up android studio fixed itself but one error in particular was linked to aapt2 and android studio couldnt fix it because it couldnt find the right files, they have been moved to googles maven repository so in the build.gradle file under all projects you have to add


google()


like this

allprojects {

repositories {

google()

jcenter()

   }
}

 

and then it will build without errors Torque 2d 3.4

Link to post
Share on other sites

other things that may have contributed to it working


in the android studio directory, make a gradle.properties file and have this line in it:

org.gradle.jvmargs=-Xmx2g -XX:MaxPermSize=256m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8

 

then in build.gradle in android studio add

dexOptions {
        javaMaxHeapSize = "4G"
 
        } 

 

just after android{



the only thing i cant seem to get working in the emulator is the audio, i havent tested it on a device yet but i think it may just be the emulator will have to wait until i can get my hands on a phone to see.

Edited by marauder2k9
Link to post
Share on other sites

Also on the audio front, the error 2019-09-01 20:10:13.417 17891-17912/com.garagegames.torque2d E/libOpenSLES: Cannot create audio player: unsupported byte order 1


seems it only happens on API 27 devices (ive tested 2 so far) API 28 devices seem to not show up this problem, even though both devices seem to be x86

Link to post
Share on other sites

Got it figured out for anyone in future this is how i did it:

 

function MyModule::createLives()
 
{
 
	%livesText = new TextSprite()
 
	{
		Scene = MyScene;
		Font = "myModule:TifaxFont";
		Position = "0 -1.8";
		FontSize = 15;
		OverflowModeY = "Visible";
		OverflowModeX = "Visible";
		BlendColor = "1 1 1 1";
		TextAlignment = "center";
		TextVAlignment = "Middle";
		Class = "LivesText";
		UpdateCallback = true;
	};
}
function LivesText::onUpdate(%this)
{
	%this.Text = $lives;
}
Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   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...