Notifications
Clear all

[Closed] Drag and Drop Material/Texture from dotnet listview to Materialeditor

Hello everybody,
I found here in the forum some examples how to drag and drop Materials to Object; scene file to viewport, texture string to material editor. But with all this examples I don’t get it to work that I can drag and drop a material from a listview to the material editor, or a texture map to a let say diffuse slot from a material.
From 2006 I read a post and in that someone has say that this only works inside the material editor it self. Is there no change since this time?

MarcoBrunetta has post here a code that come in the direction to that what I need, but his code only works for drag and drop material to a object.

I have modify them for this example:


 fn hitTest = (
 	  local theRay=mapScreenToWorldRay mouse.pos
 	  local dist=undefined
 	  local theHit=undefined
 	  local hitObject=undefined
 	  for x in objects do (
 		  hitRay=intersectRay x theRay
 		  if hitRay!=undefined then (
 			  tempDist=distance hitRay.pos theRay.pos
 			  if dist==undefined or tempDist<dist then (
 				  dist=tempDist
 				  theHit=hitRay
 				  hitObject = X
 				)
 			)
 		)
 	  hitObject 
   )
   
 try ( destroyDialog matList ) catch ( )	
 rollout matList "matList" width:200 height:300 (
 	local list = #()
 	local theMat
 	  local theObject
 	  local dragFlag = false
 	dotNetControl lv "system.windows.forms.listView" pos:[5,5] width:190 height:290
 	
 fn doMaterialList mats = (
 	for i = 1 to mats.count do (
 		li = dotNetObject "System.Windows.Forms.ListViewItem" mats[i].name
 		li.tag = dotnetMXSValue mats[i]
 		append list li
 		)
 		lv.items.addRange list
 	)
 
 on matList open do (	
 	--Setup the forms view
 	lv.HeaderStyle = none
 	lv.columns.add "" 180
 	lv.view = ( dotNetClass "system.windows.forms.view" ).details
 	lv.allowDrop = true
 	doMaterialList meditMaterials
 	)
 	
 ON lv ItemDrag arg DO (
 	dragFlag = true
 	theMat = lv.items.item[arg.item.index].tag.value
 	)
 
 ON lv mouseUp arg DO (
 	dragFlag = false
 	)
 	  
 ON lv lostFocus arg DO (
 	theObject = hitTest()
 	IF theObject != undefined AND dragFlag == true DO (
 		theObject.material = theMat
 		)
 	theObject = undefined
 	)
 )
 createDialog matList
 

Maybe you have a idea?

5 Replies

I’m not sure that this is even posible.
Why don’t you create a button that can send selected list item (in this case material) to ME sample slot?

1 Reply
(@denist)
Joined: 11 months ago

Posts: 0

possible… with very small… one pixel size rollout control materialbutton

In my original script I have a right click menu, with that I can send the list item to a material editor slot. It works great, but you know that when you start a script you want to make a very good one with all possible features :).

1 Reply
(@gazybara)
Joined: 11 months ago

Posts: 0

Yup. I understand you. I love to use every possible hack but only if is necessary and not have impact on performance

You always have the answer.