May 23, 2012, 04:30:46 PM *
Welcome, Guest. Please login or register.

Login with username, password and session length
News: Please report any bugs or issues that you might be encountering with the Beta in the Support System so that we can better keep track of any oustanding issues that may come up.

GameCore Support System
 
   Home   Help Search Login Register  
Pages: [1]
  Print  
Author Topic: Object Surface Scripting  (Read 720 times)
Squat
Hero Member
*****
Posts: 592


View Profile
« on: August 15, 2008, 05:46:06 PM »

1. Are there any samples of altering an object's surface properties on the fly? How is the scripting set up for accessing that?

2. Is there a way to set it up so you can create different looks that you name and have access to the code to fade them in and out during gameplay?

3. Is there also access to the additional layers through scripting to control things like the amount of blending?

I think it would be great for things like players going invisible or glowing during enhancements or blending in with the environment like MSG4. There's countless possibilities but my plans for it are to simply make vehicles flat grey that aren't being used and to bring the textures in while they're driven, making them grey again when you get out. Don't ask me why.

SideQuestion A: I see how to control lights placed in the world and within the objects, but how do you get control over the ambient light color, the skydome position...etc? World stuff?

SQ B: Is there a way to print a list of every object in the game to the console?
Logged
Ransom
Full Member
***
Posts: 132



View Profile
« Reply #1 on: August 16, 2008, 01:39:39 PM »

Questions 1, 2, and 3... Yes you can do all that.  See below a list of possible settings.

Quote
Surface@ GetSurface( const String&) @ ObjectMesh
void SetDetailMap( const String&, const String&) @ ObjectMesh
void SetDetailMap( const String&, Image@) @ ObjectMesh
void SetDiffuseMap( const String&, const String&) @ ObjectMesh
void SetDiffuseMap( const String&, Image@) @ ObjectMesh

void SetNormalMap( const String&, const String&) @ ObjectMesh
void SetNormalMap( const String&, Image@) @ ObjectMesh

void SetSpecularMap( const String&, const String&) @ ObjectMesh
void SetSpecularMap( const String&, Image@) @ ObjectMesh

void SetTexture( const String&, const String&) @ ObjectMesh

void SetBlendMode(int) @ Surface
void SetColor( float, float, float) @ Surface
void SetColour( float, float, float) @ Surface
void SetDetailAmount( float) @ Surface
void SetDiffuse( float) @ Surface
void SetFlag( int, bool) @ Surface
void SetFlags( int) @ Surface
void SetLuminosity( float) @ Surface
void SetShinyness( float) @ Surface
void SetSmoothingAngle( float) @ Surface
void SetSpecular( float) @ Surface
void SetTextureFlag( int, int, bool) @ Surface
void SetTextureFlags( int, int) @ Surface
void SetTextureOffset( float, float) @ Surface
void SetTranslucency( float) @ Surface
void SetTransparency( float) @ Surface

You would set it up like this...
Quote
//pseudo code

Object @ YOUR_OBJECT = GetGameManager().GetWorld().GetObject( "YourObjectsName");
ObjectMesh@ YOUR_MESH = YOUR_OBJECT.GetMesh("YourObjectsMeshName");
YOUR_MESH.SetDetailMap( "OldMap", "NewMap"); // will change the detail map
YOUR_MESH.SetDiffuseMap( "OldMap", "NewMap"); // will change the diffuse map
//... and so on

// to adjust the values of a particular surface would go something like...

Surface@ YOUR_SURFACE = YOUR_MESH.GetSurface( "YourSurfaceName");
YOUR_SURFACE.SetBlendMode("SomeInterger");
 

SQA... You can change the ambient light like this...
Quote
GetGameManager().GetWorld().SetAmbientColour( Red,Green,Blue);

And I THINK you have to set up a "custom object" for your sky in order to be able to manipulate it dynamically.  The sky object's OPR would reference a script that would control the sky.
Logged
Squat
Hero Member
*****
Posts: 592


View Profile
« Reply #2 on: August 16, 2008, 02:20:09 PM »

That is excellent, thank you sir.
Logged
hikmayan
Full Member
***
Posts: 231



View Profile
« Reply #3 on: August 23, 2008, 03:20:55 AM »

Yeah...thanks a lot man. Cool
Logged

You have to be in it.....to win it!
gekido
Guest
« Reply #4 on: August 25, 2008, 03:51:54 PM »

There is a function to get a handle to the sky object to manipulate it from script, it's a member of 'World':

Object@ GetSky()

so you can do:

Object@ skyObject = GetGameManager().GetWorld().GetSky();

and then manipulate the sky object like any normal object.
Logged
gekido
Guest
« Reply #5 on: September 08, 2008, 12:21:35 AM »

In my 'Character Creation' thread I posted a bit of sample code for changing / updating textures as well:

http://www2.gamecore.ca/forums/index.php?topic=80.0

Here's a sample function that I've been using (mind you it uses a specific config file):

Code:
void SwapMaterial( int index)
{
String charName = GetSaveGameVariableString("CurrentChar");

// load the character's info
        OptionsFile charRecord("CHAR");
        String charFile = "../characters/" + charName + ".char";
   
    // does this character have a record?
    if (DoesFileExist( charFile ))
    {
        charRecord.Load( charFile );
       
String newTexture = "Custom" + index;
String materialName = charRecord.GetVariableString("CustomizeMaterial");
String custom = charRecord.GetVariableString( newTexture);

        // get a handle to the in-game model so we can modify it
Object@ previewChar= GetGameManager().GetWorld().GetObject( charName);
if (previewChar != null)
{
previewChar.GetMesh( 0).SetDiffuseMap( materialName, custom);
}
    }
}
Logged
hikmayan
Full Member
***
Posts: 231



View Profile
« Reply #6 on: September 08, 2008, 01:39:06 AM »

Clear enough Mike,thanks.
Logged

You have to be in it.....to win it!
Pages: [1]
  Print  
 
Jump to:  

 
Powered by MySQL Powered by PHP bluBlur Skin © 2006, hbSkins
Powered by SMF 1.1.14 | SMF © 2006-2011, Simple Machines LLC
Valid XHTML 1.0! Valid CSS!