Game Development Community

Resource: Material Picker

by Ryan Mounts · in Torque 3D Professional · 05/23/2009 (9:01 pm) · 10 replies

Well, I didn't want to post this as an official resource because there are some modified source files included in the download. Even though the new Material Editor in Torque 3D is awesome, it seemed to me like the material selection mechanisms are a little cumbersome. The Material Mesh Selector added in Beta 2 is nice, but could still be a headache if you have a large number of objects in the scene. This resource, although not perfect, has the potential to be quite helpful. Through some source code and scripting changes, I've added a material eyedropper (like the color eyedropper in Photoshop) that allows you pick the material to edit right out of the viewport.

i291.photobucket.com/albums/ll284/rmounts/MatPicker.jpg
With these changes, you now have an eyedropper button that appears on the Material Mesh Selector pane. The eyedropper will not select terrain materials. There is also an issue with materials that contains spaces in their names, but I think this is a general Material Editor problem and not a problem with my changes. Some materials don't show up properly in Beta 2 (they work correctly in Beta 1), so that is also probably due to the new addtions to the Material Editor and not actual problems with my changes.

I haven't tested this just a whole lot, so there's surely plently of room for improvement. If anyone finds any mistakes or makes any improvements upon this resource, please repost it for others to use. Hopefully something like this will find its way into the Torque 3D release.

Download the file below, extract it into your "Torque 3D 2009 Beta 2" and overwrite the existing files. The Full demo in the Templates folder should be ready to play with (Full.dll is included). Included is a PDF listing all the files that were changed. All changes are commented with "// RDM" so they are easy to find in each file. Enjoy!

Material Picker for Torque 3D Beta 2

#1
05/23/2009 (9:15 pm)
Cool
I might try this out
#2
05/24/2009 (12:57 am)
Thanks Ryan. I strongly believe this should make it into Beta 3.
#3
05/24/2009 (1:53 am)
Man I hate mediafire all i got were popup ads the first few times I try to download.


Brilliant implementation! The mShape->materialList is clever I dont understand why it is not that way default.

Here is the bit I use for opcode:
//Load info->material //CGC
   if(materials)// Here we need to be sure it is an materials object 
   info->material = materials->getMaterialInst(TSShapeInstance::smRenderData.materialIndex );
   else
   info->material = NULL;//Be sure to place a NULL for anything that do not have materials

You will need to reimplemented an TSShapeInstance::RenderData TSShapeInstance::smRenderData; into tsShapeInstance.cpp I have no idea why its gone, without some type of replacement.

If that works for you, then you dont need gPolysoupOverride., and you get Material definition property like footfall sounds/footprints/dustFX from static mesh as a bonus benefit.



Thanks for your Material Picker that is what i originally thought the 'Mesh Selector' was going to be like when i first read about it.
#4
05/25/2009 (3:48 pm)
Sweet resource... we should just adopt this into the core if the tools team hasn't aready worked on it.
#5
07/09/2009 (9:18 pm)
Is this resource added in Beta4?
The current material selector is very cumbersome.
#6
07/10/2009 (3:39 am)
Actually, the material selector in Beta3 is pretty cool. You only select a your object, and you'll be able to edit any of its materials. I didn't find it cumbersome.
#7
07/10/2009 (6:41 am)
Yeah, the beta 3 editor is almost like this. The selection is raycast-based, and it seems to jump straight to the material under the cursor.
#8
07/10/2009 (7:01 am)
Don't forget in B3, that you select the object, and then there is a dropdown in the material editor to let you can choose any of the materials in the selected object.
#9
07/10/2009 (12:09 pm)
@Jaimi: I know, that is why I find it cumbersome. I have a big level made of 29 materials. It sucks to always look for the material I want to edit when I could just click on the material I want to edit.

@Manoel: When I click on my static mesh (anywhere), it always shows me the first material in the list. I can't select a specific one by clicking on it. So, if there's ray-cast based selection, it doesn't work.
#10
07/10/2009 (1:02 pm)
@Sorin: ah, that might be an issue if you have lots of materials in a single model. Anyway, it shouldn't be hard for GG to make it select the material you clicked at anyway, the info is there (as this resource proves).