Jump to content

guiDynamicTexture (GuiTextureCanvas) revisited


Azaezel

Recommended Posts

Repost for http://www.garagegames.com/community/forums/viewthread/140997 since that got burried in spam:


http://i.imgur.com/0lcIbaB.jpg


So. Full disclosure right off the bat, I'm an Awesomium Integration Kit owner ( you can get that here: www.gameinprogress.com/ ), and I highly recommend using that if you can, because it's both cleaner and more flexible. That being said, for quick prototyping, and testing that kind of thing vs development head to make sure changes don't break things, a variant on www.garagegames.com/community/resource/view/10899 can be found github.com/Azaezel/Torque3D/tree/guiOnObject. As I do clearly have a conflict of interest in further alterations, any suggested changes and/or calls for submission to development head will be based purely on this thread.

Link to comment
Share on other sites

am a awesomium guy too but i find the guionobject to be really helpfull in some areas, lets say you want to display a 3d model and combine that with a loadout or simply simulate computer screens ingame, or as a ingame menu, for that kind of stuff (as long as you don`t attempt to build a whole menu with it)

the guionobject is perfect.


Now as am using it in my current wip game,

some tips for ppl who plan to use this

  • 1 gui on 1 guionobject model



    only 1 GuiWindowCtrl can be run in a guionobject model (it might be possible to build a gui with multiple guiwindowctrl`s and executing those via setWindow(); but so far i have no clue how to get that working)



    - If you want to build a whole menu in one gui then take a look at the optionsDlg.gui located in game/art/gui, you can build a whole menu in one gui by using panes.

 


So far i havent found any issues related to the gui itself and it would be nice to see this in the upcoming T3D 3.7 release, it would serve as a promo for awesomium as well, since ppl who wish more functionality would want to get awesomium.

Link to comment
Share on other sites

  • 1 month later...

Speaking of Awesomium, is it still an active thing? I thought I heard it had dropped off the map or diminished in importance. I'm still using it, but would love to switch to something more mainstream and especially open source, which brings to mind, has anyone tried or know anyone who has tried WebKit?

Link to comment
Share on other sites

  • 1 month later...

I have this working in tandem with fxGuiSnooper, to show security camera feeds on an object.


Works flawlessly for that... However now that I am running 64-bit and can no longer use Awesomium, I am trying to move some of my GUIs onto objects to replace the Awesomium functionality.


I can get the GUIs to pop on there fine, just as they do with the fxGuiSnooper, but I do not have any mouse control on the GUIs. Is this normal? Anything I may be missing in the code that would enable that?


Thanks!

Link to comment
Share on other sites

You should indeed have mouse icon display...


Direct dump from the personal game using it at present:

new GuiTextureCanvas( MonitorCanvas )   
{  
  guiControl = "upgradeGUI";
  cursorBitmap = "art/gui/weaponHud/use.png";
};  

singleton Material(ScreensMaterial2)
{
mapTo = "monitorMat";
diffuseMap[0] = "art/gui/upgradeIcons/background.png";
diffuseMap[1] = "$guiMonitorCanvas";
emissive[0] = "0";
materialTag0 = "GUIs";
emissive[1] = "1";
diffuseColor[0] = "0.992157 0.992157 0.992157 1";
  glow[0] = "0";
  specular0 = "0.125 0.125 0.125 1";
  specularPower0 = "50";
  animFlags[0] = "0x0000000c";
  scrollDir[0] = "0 0";
  scrollSpeed[0] = "0";
  waveType[0] = "Triangle";
  waveFreq[0] = "1";
  waveAmp[0] = "1";
  metalness[0] = "1";
};

If you don't feed it one, it'll default to https://github.com/Azaezel/Torque3D/commit/a2429f516c6b6b9a897754b9e42823ecbd088afa#diff-a2e87f480b70f2395d66058eef8560d7R48


For clicking, there's:

function mouseFire(%val)
{
  if ($guiCanvas::Interact)
  {
     %guitarg = $guiCanvas::InteractingWith;
     if (%val)
        %guitarg.doMouseClick($guiCanvas::PosX,$guiCanvas::PosY);
     return;
  }
  $mvTriggerCount0++;
}

and you can follow the source-alts:

https://github.com/Azaezel/Torque3D/commit/a2429f516c6b6b9a897754b9e42823ecbd088afa#diff-a2e87f480b70f2395d66058eef8560d7R298 for tracking how those vars are handled.


That clarify things any?

Link to comment
Share on other sites

Sure, to get this working with fxGuiSnooper, you need a few things:


- A camera object (can be anything really, we use a transparent cube)

- A viewer object (set up with a mapped material to a GuiTextureCanvas)

- A GUI Control somewhere (we put one in the PlayGui) that will be mapped on to that viewer object... Within that Gui Control you should also have an fxGuiSnooper set up that points to the camera object


Then when the viewer object appears, it should be textured with that Gui Control, and the fxGuiSnooper nested inside that control should be active and should display the view from the camera object.


We got a bit more complicated than that, for example we have multiple cameras and our viewer cycles through them every 15 seconds, but with the basics above you should be able to get it working.


Let me know if I missed anything.


Cheers

P


My game-specific code below for reference:

 


********************************************
Playgui.gui:

  new GuiControl(FeedOneDlg) {
     position = "0 0";
     extent = "1024 768";
     minExtent = "8 8";
     horizSizing = "center";
     vertSizing = "center";
     profile = "GuiOverlayProfile";
     visible = "0";
     active = "0";
     tooltipProfile = "GuiToolTipProfile";
     hovertime = "1000";
     isContainer = "1";
     hidden = "1";
     canSave = "1";
     canSaveDynamicFields = "1";
        fixedAspectRatio = "0";

     new fxGuiSnooper(FeedOneDlgObj) {
        cameraZRot = "0";
        forceFOV = "0";
        reflectPriority = "1";
        renderStyle = "standard";
        margin = "0 0 0 0";
        padding = "0 0 0 0";
        anchorTop = "1";
        anchorBottom = "0";
        anchorLeft = "1";
        anchorRight = "0";
        position = "15 5";
        extent = "1000 760";
        minExtent = "8 2";
        horizSizing = "center";
        vertSizing = "center";
        profile = "GuiDefaultProfile";
        visible = "1";
        active = "1";
        tooltipProfile = "GuiToolTipProfile";
        hovertime = "1000";
        isContainer = "1";
        canSave = "1";
        canSaveDynamicFields = "0";
        ViewRotation = "0 0 0";
        ViewOffset = "0 0 0";
        FOV = "60";
        SweepAmplitude = "0 0 45";
        SweepTime = "25000 25000 25000";
        AttachedObject = "Cam1";
        OverlayBitmap = "0";
        OverlayTile = "0";
        OverlayColour = "0";
        ColorOverlay = "1 1 1 0.5";
        RedMask = "1";
        GreenMask = "1";
        BlueMask = "1";
     };
  }; 

********************************************

materials.cs file in the folder with my viewer object (object filename FeedOneGui.dae, material name within is FeedOneGui):

new GuiTextureCanvas( FeedOneCanvas )     
{    
  guiControl = "FeedOneDlg";    
};    

new Material(GuiFeedOneMat)     
{     
  diffuseMap[0] = "$guiFeedOneCanvas";     
  emissive[0] = true;    
  mapTo = "FeedOneGui";    
}; 


********************************************

Camera object to put in mission file:

        new StaticShape(cam1) {
           isAIControlled = "0";
           dataBlock = "SecurityCameraInvisibleData";
           position = "-240 63 120";
           rotation = "1 0 0 15";
           scale = "1 1 1";
           isSTControl = "0";
           canSave = "1";
           canSaveDynamicFields = "1";
        };


And the datablock for that camera (just an invisible object):

datablock StaticShapeData(SecurityCameraInvisibleData)
{
  // Basic Item properties
  shapeFile = "art/Camera/SpyCamNm.dts";
  scale = "2 0.5 1";
  mass = 2;
  friction = 1;
  elasticity = 0.3;
  emap = true;
};


Link to comment
Share on other sites

@Azaezel:


Perhaps I missed something in the engine code merge...


If I put a little echo comment in my default.bind, within the mousefire command, under the if statement for gui interact, and it never displays the echo in the console.


So... My gui interact stuff is not functioning or something.


I will look again at the merge, but I really feel I got it right. Is there something perhaps I should be looking at specifically in the engine code to make sure that clicking portion works?


Thanks

P

Link to comment
Share on other sites

Thanks, just double-checked the merge and I have all your code in there correctly.


I see the LOS mask, you added StaticShapeObjectType, I had done that so am not sure what I'm missing...


The object I'm placing is a StaticShape, has a datablock, it comes up properly showing the gui I want, I just have no mouse control and the cursor/reticle doesn't change or anything.


I'm running the latest 3.7 AFX Full build from GitHub as my base, all that stuff works great, anything that AFX could be doing that would be disabling this somehow perhaps? I can't think of anything else, as I have set it all up identically to how you had it in the guionobject github repo.


Thanks!

Link to comment
Share on other sites

nah, have afx rolled in this end as well... StaticShape, Not TSStatic like that dynamic_cast check? The UV detection end of things kind of falls apart if it's not wysywig/nonanimated. (Could cook up a custom class, but left that off for simplicity of tracking what was going on.). We got around that limitation this end by hotswapping an animated shape out via the following:


sometriggercallback

			%owner.screenAnimation.setHidden(false);
		%owner.screenAnimation.playThread( 0, "open" );

+

function monitorData::onOpen(%this,%obj)
{
%obj.owner.screen.setHidden(false);
%obj.schedule(300,"setHidden",true);
}
//see: https://github.com/GarageGames/Torque3D/pull/682

where .screenAnimation is a staticshape reference with an animation and .screen is a tsstatic with visible mesh flipped on for the collision end of things.

Link to comment
Share on other sites

Oh oops, you mean I should just straight TSStatic this sucker instead of going with the datablock StaticShape? That's no problem, they don't have to be StaticShapes, I can easily swap them out for TSStatics and see if that helps.


Should have noticed that in the dynamic cast that it was looking for TSStatic when I have StaticShapes I'm trying to do this with. Duh!


Thanks, will try and see if that does it.

Link to comment
Share on other sites

Yep that did it :)


Have interaction being detected now! Although it does not seem to be actioning when I click... That doMouseClick function i see in the default bind, is that something that is in the engine or that I have to add in script somewhere?


Close!

Link to comment
Share on other sites

I got this working finally after just a bit more tinkering...


Works great, thanks much for the help!


One thing I am curious about though - when I pop into Oculus Rift mode it does not detect the interaction, I get no mouse cursor or any control, clicking just fires my weapon. My crosshair just stays normal as I pan across the Gui, like it doesn't recognize it.


Anything you can think of that I have to tweak to make this work? I know it is possible to have dual-cursor for the Rift, as we see it in the Awesomium kit we have :)

Link to comment
Share on other sites

I'm using the code from your GuiOnObject GitHub repo...


Cool that it's still being tweaked in development - what has changed between that version and the one I have?


I will keep looking at the Oculus issue - it looks like it just has something to do with when the raycast is firing, like it is not firing when in Oculus mode. Perhaps by looking at how Stefan did it in the Awesomium kit will point me in the right direction.


Thanks!

Link to comment
Share on other sites

  • 1 year later...

I have this working completely in my game, the only problem is mouse actions don't do anything.


I used the gui from the documentation as an example just to try with creating my own model for the gui object and all that the text is supposed to change to hello world u know that one?


Well when the mouse interacts with the object the button changes states to being pressed but the text doesnt change furthermore when i load up the options dialog i cant interact with anything the crosshair shows up as designed but no drop down menu or anything like that shows

Link to comment
Share on other sites

An example of what i mean


Here u can see the gui in its default state

http://i.imgur.com/Jf8gnCN.png


then whenever u click the button

http://i.imgur.com/0WyvKhO.png


it clearly changes but the text does not update.


Also do u think there is a way to get this to interact with key strokes? for typing in passwords and the like?

Link to comment
Share on other sites

yea this is the full implementation in one material file for it:

 

//--- OBJECT WRITE BEGIN ---
%guiContent = new GuiControl(TestGui) {
  position = "0 0";
  extent = "640 480";
  minExtent = "8 2";
  horizSizing = "right";
  vertSizing = "bottom";
  profile = "GuiDefaultProfile";
  visible = "1";
  active = "1";
  tooltipProfile = "GuiToolTipProfile";
  hovertime = "1000";
  isContainer = "1";
  canSave = "1";
  canSaveDynamicFields = "1";

  new GuiWindowCtrl() {
     text = "Hello World";
     resizeWidth = "1";
     resizeHeight = "1";
     canMove = "1";
     canClose = "1";
     canMinimize = "1";
     canMaximize = "1";
     canCollapse = "0";
     edgeSnap = "1";
     margin = "0 0 0 0";
     padding = "0 0 0 0";
     anchorTop = "1";
     anchorBottom = "0";
     anchorLeft = "1";
     anchorRight = "0";
     position = "0 0";
     extent = "630 463";
     minExtent = "8 2";
     horizSizing = "right";
     vertSizing = "bottom";
     profile = "GuiWindowProfile";
     visible = "1";
     active = "1";
     tooltipProfile = "GuiToolTipProfile";
     hovertime = "1000";
     isContainer = "1";
     canSave = "1";
     canSaveDynamicFields = "0";

     new GuiButtonCtrl() {
        text = "Click Me";
        groupNum = "-1";
        buttonType = "PushButton";
        useMouseEvents = "0";
        position = "139 207";
        extent = "140 30";
        minExtent = "8 2";
        horizSizing = "right";
        vertSizing = "bottom";
        profile = "GuiButtonProfile";
        visible = "1";
        active = "1";
        command = "lblHWDisplay.setValue(\"Hello World\");";
        tooltipProfile = "GuiToolTipProfile";
        hovertime = "1000";
        isContainer = "0";
        canSave = "1";
        canSaveDynamicFields = "0";
     };
     new GuiTextCtrl(lblHWDisplay) {
        text = " Waiting...";
        maxLength = "1024";
        margin = "0 0 0 0";
        padding = "0 0 0 0";
        anchorTop = "1";
        anchorBottom = "0";
        anchorLeft = "1";
        anchorRight = "0";
        position = "68 127";
        extent = "313 64";
        minExtent = "8 2";
        horizSizing = "right";
        vertSizing = "bottom";
        profile = "GuiBigTextProfile";
        visible = "1";
        active = "1";
        tooltipProfile = "GuiToolTipProfile";
        hovertime = "1000";
        isContainer = "1";
        canSave = "1";
        canSaveDynamicFields = "0";
     };
  };
};
//--- OBJECT WRITE END ---


%guiContent = new GuiTextureCanvas(TestOffCanvas)
{
   guiControl = "TestGui";

};

singleton Material(ScreenTest_ScreenMaterial)
{
  mapTo = "ScreenMaterial";
  diffuseMap[0] = "$guiTestOffCanvas";
  materialTag0 = "GUIs";
};

Link to comment
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...