Notifications
Clear all

[Closed] Shading selected objects in a colour

Greetings!

I’m working as Junior Animator on a next-gen videogame using Unreal Engine 3. I’ve noticed that Unreal Ed has an interesting behaviour on how it displays selected objects in viewports; it shades them in a transparent purple hue.
No selection brackets, no wireframe overlay, just a colourful semi-transparent shading. I kind of like this way of displaying selected objects and I was wondering if anyone knew of a script that could be used to achieve this effect or if anyone could point me in the proper direction as to how to get this working in Max.

Cheers!

13 Replies

I don’t think you can easily get rid of the selection brackets by script – I know you can disable them in the viewports themselves through the viewport display options.

As for the visual change… you could use a selectionSetChanged callback to keep track of selection changes and either…
A. Toggle the “see-through” node property. This is a transparent grey, rather than a transparent magenta.
B. Store the object’s original material, replace with the transparent magenta material; when de-selected, restore the object’s original material.

Thanks for the tips. Selection brackets really aren’t bothering me right now. More specifically, what UnrealEd does is colour the selected object’s texture in a purple hue, meaning to say it retains it’s original texture and/or mapping and shades it; you can still see the texture, it’s as if you added a coloured layer on top with 50% opacity.

I really have no idea about MAXscripting at all but I’ll check out the callback function and see what I can find out…

Cheers!

Sry for ruining your learning effect but I have had some time, so I put something together. This adds a transparent, purple material to the selected objects…if you want to keep the texture you’d rather edit the current material than assining a new one. Maybe not the best approach, but it works somehow


    (
    	callbacks.removeScripts id:#U3Selection [color=Lime]--// unregister the callback[/color]
    [b]	local [/b]aPrevSelection = #() --// array containing previous selection
    [b]	local [/b]aPrevMaterials = #() --// array containing previous selection's materials
    
    [b]	local [/b]mSelMaterial = standard() --// create a new standard material
    	mSelMaterial.opacity = 40 --// opacity value
    	mSelMaterial.diffuse = (color 90 10 120) --// diffuse & ambient color
    	
    	[b]global [/b]fnU3Selection  = [b]function [/b]fnU3Selection =
    	(
    		  [b]if [/b]aPrevSelection != undefined  [b]and [/b]aPrevMaterials != undefined [b]do[/b]
    		  (
    			  [b]for [/b]i = 1 [b]to [/b]aPrevSelection.count [b]do [/b]
    			 (
    				[b]if[/b] aPrevMaterials[i] == undefined [b]then [/b](
    					aPrevSelection[i].material = noMaterial()
    				)
    				[b]else [/b](
    					aPrevSelection[i].material = aPrevMaterials[i] --// reassign old materials
    				)
    			 )
    		  )
    		
    		aPrevSelection = selection [b]as [/b]array --// create a copy of the current selection
    
    		[b]for [/b]i = 1 [b]to [/b]aPrevSelection.count [b]do [/b]
    		(
    			aPrevMaterials[i] = aPrevSelection[i].material --// store the old material
    			aPrevSelection[i].material = mSelMaterial --// assign the transparent material
    		)
    	)
    	callbacks.addScript #selectionSetChanged "fnU3Selection()" id:#U3Selection
)
    

Thanks zortech! I’m getting a message when running the script:

“Call needs funciont or class, got: undefined”

Take into account that I’m using MAXscript>New Script then pasting the code and evaluating. What is is that I’m doing wrong?

Cheers!

Ah shit, my bad.

I have edited the code so it should work now. The function is now in a global scope. xD

Edit: if you’re assining a new material to the selected object, when deselecting it, the material will be overwritten with the previous material…kinda stupid.

Wow! That’s pretty impressive indeed! Are you sure there’s no possible way to preserve the object’s current texture and shade it in purple? What I mean is that the texture stays visible, only tinted like I mentioned in my first post.

Cheers for real!

I’ve tried to find a way to edit the material in a way that it appears purple, but the only thing I got was an ugly selfillumination material and memory leaks caused by to many material copies xD So here’s a different approach, probably not very fast, as it clones the actual mesh…but the closest thing to the u3 selection type. (I guess)


       (
       	callbacks.removeScripts id:#U3Selection --// unregister the callback
       	[b]local [/b]aPrevSelection = #() --// array containing previous selection
       	[b]local [/b]objShadeMesh = #() --// array containing cloned objects
       	[b]local [/b]mSelMaterial = standard()
       	mSelMaterial.opacity = 50
       	mSelMaterial.diffuse = (color 150 10 200)
       	mSelMaterial.selfIllumColor = (color 150 10 200)
       	mSelMaterial.useSelfIllumColor = true
       	
       	[b]global [/b]fnU3Selection = [b]function [/b]fnU3Selection =
       	(
       		  [b]if [/b]objShadeMesh != undefined [b]and [/b]objShadeMesh.count > 0 [b]do[/b]
       		  (
       			[b]for [/b]o[b] in [/b]objShadeMesh [b]do try [/b](delete [b]o[/b])[b] catch[/b]()
       			objShadeMesh = #()
       		  )
       		
       		aPrevSelection = [b]for [/b]o [b]in [/b]selection [b]where [/b]superClassOf o == GeometryClass [b]collect [/b]o
       
       		[b]for [/b]i = 1 [b]to [/b]aPrevSelection.count [b]do [/b]
       		(
       			objShadeMesh[i] = reference aPrevSelection[i]
       			addModifier objShadeMesh[i] (push Push_Value:1.5) --// increase the push value if necessary
       			objShadeMesh[i].material = mSelMaterial
		)
       	)
       	callbacks.addScript #selectionSetChanged "fnU3Selection()" id:#U3Selection
       )
       

Works great with push set to 0.001

The only shame is that it doesn’t work once you throw in some animation (or move the object around for that matter). Ah well, it will come in handy somehow though. Thank-you VERY much for your efforts!

Cheers!

Hehe well whatever works for you! I have edited the code so the new mesh is linked to the base mesh, this should do the trick for animated objects.

Yay you are welcome, it was fun to do something different.

Page 1 / 2