Jump to content

Two issues with GuiObjectView [Solved]


irei1as

Recommended Posts

-Using basic lightning-

First I start a new mission and open the gui editor so I can change playGui.gui

Then I add a GuiObjectView (child to playgui), choose a model and it displays correctly. I save the gui and close the game (end the application, not just end the mission). No problem this first time.


But after starting the program again, the model then shows no texture. And if you use the model elsewhere (like a TSStatic) it keeps not showing textures. It seems the object.cs is not loaded correctly or something.

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


Is there any way to fix that? Or should I just add dinamically the GuiObjectView -with script and not save it in playGui.gui-?



My other question is if there is any way to avoid that "fog" inside the GuiObjectView so it's fully transparent.


-------------------------------------------------------------------------

-Edit-

The issues were fixed. Let me post them here as reference for anybody looking for this in the future.


A) The lack of texture comes because the exec("...gui") is loaded before the material.cs of the shape.

Two way to fix it:

1- Manually call exec("art/shapes/...(whatever)/material.cs") before exec("playgui.gui") in the init file.

2- (Better but slower)Save the guiObjectView without the shapes loaded and use the callback

function GuiObjectView_name::onWake(%this)

to load them with setmodel(...). -Note: you may want to use an if statement so it's only loaded once(when %this.shapefile $= "").-


B) The fog it's actually a PostFX enabled in the rendering pass. You could change the PostFX or to totally disable it for the gui:

Change in void GuiObjectView::renderWorld( const RectI& updateRect ) of the c++ code of guiObjectView.cpp


SceneRenderState state

(

gClientSceneGraph,

SPT_Diffuse,

SceneCameraState( GFX->getViewport(), frust, MatrixF::Identity, GFX->getProjectionMatrix() ),

renderPass,

true

);


to


SceneRenderState state

(

gClientSceneGraph,

SPT_Diffuse,

SceneCameraState( GFX->getViewport(), frust, MatrixF::Identity, GFX->getProjectionMatrix() ),

renderPass,

false

);

Link to comment
Share on other sites

  • 10 months later...

Thanks for this @irei1as


Setting the sceneRenderThingy to false stopped the horrible fogging and alpha issues and the material loss was fixed by having the gui element reload itself in playGui.onWake().

 

function PlayGui::onWake(%this)
{
//...
 
   //yorks make guiObjectView reload it's object to prevent material loss
   //easier if we have the gui element named
   %viewer = "meshViewer";
   if(%viewer.isActive())
   {
      %mesh = %viewer.getModel();
      echo("\c4guiObjectViewer is " @ %viewer SPC %mesh);
      if(isFile(%mesh))
         %viewer.setModel(%mesh);
      else
         echo("\c2no model");
   }
   else
      echo("\c2nope - no mesh viewer");
}
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...