A Couple of Material Questions & Blender

HI all, couple of quick questions…



I have my models/materials initially all created in blender, and they import just fine, however Now I would like to apply a new material on some of the objects, but then I would like to toggle back to the original material, this leads me to the following 2 questions.


  1. Is there no way to obtain a reference to an existing objects material? i.e. I see Spatial defines setMaterial, but there is no getMaterial function?
  2. Given my materials are initially created in blender, is there any way to generate the .j3m files from those? or is this a manual process where I have to build out the j3m file piece by piece?



    Thanx
  1. The Geometry has getMaterial() as only Geometry can have materials. Cast the Spatial to Geometry.
  2. You can do that in the SDK. Open a model file and select a Geometry inside in the SceneExplorer, then select “create j3m” in the properties window under “Material”.

sweet thanx for the quick reply :slight_smile:

Hi again, so I opened up the object model (scene), scrolled down to the node of interest, and expanded it.



It shows:

NodeName

  • Circle.007:Spatial
  • Mesh





    So I opened up the properties for the Spatial (Circle.007)

    and I see the option (text box) for create j3m file

    but it appears to be grayed out, and I cannot interact with it? (perhaps I have a older version of the sdk?)

    Note: i can click the box […] which shows me existing (j3m files) associated with the project, but no option to create a new one.



    note: it looks all the ‘options’ in the properties window are grayed out and non-functional.



    any pointers?

Convert the model to j3o, native formats are not editable.

Using the j3o version appeared to enable the editing as you said :slight_smile:



but…some observations:


  1. When I did selected create new j3m file, it created a new j3m file in the model directly (I was expecting it to pop into the material directory).
  2. The j3m file also appeared…to be template and did not actually have the material data from blender.

    i.e. this is what it created:



    Material MyMaterial : Common/MatDefs/Light/Lighting.j3md {

    MaterialParameters {

    }

    }



    The color/texture information was not generated.



    Not a big deal…I don’t actualy need a j3m file, for the default materials, since I can just grab that from the geomerty itself once they are loaded up.


  3. I did actually try a sdk update today, when it restarted, and fired up my game, it complained about not being able load assets of type: ‘blend’

    I just ended up rolling back to my previous version of the sdk, and its working again.


  4. I built a new unshaded j3m file…In the editor the color does not appear to show up correctly…my j3m file:

    Material rollovermat : Common/MatDefs/Misc/Unshaded.j3md {

    MaterialParameters {

    Color : 0 0.71 0 0

    ColorMap : Textures/rollover_light2.png

    }

    AdditionalRenderState {

    }

    }

    (note: the rollover_light2 png is just a 2 tone png (1 is alpha, the other is not)

    in the game it shows up green, in the editor it just shows up white…not a big deal…I’m probably missing something, but anyhow thanx for the pointers…back to coding :slight_smile: