Notifications
Clear all

[Closed] replacing mat preview in Mat editor ?

Hello all ,

  once again i couldn't find anything abotu this topic here or in the reference  maybe it's
  not possible   but i first want to  ask you 

This is a screenshot of the material i’m working on right now
I’m implementing material preview rendered with indigo

  is there any way to replace the material preview with the bitmap you can see below.?

u3dreal

1 Reply

Also i have some problems when loading the rendered bitmaps as you see it works
quite good but when i do the preview on an other material in another slot
then i will write out a new bitmap containing the preview of the new material

     unfortunatelly now when loading the bitmap into the bitmap in the material the
     old bitmap gets exchanged as well  is there any way to make this only change for the
     new material
     
     here is the code i came up with.

      on dopre pressed do (
         		
         		pre_file = createfile "C:\indigo\matpreview\previewmat.xml"
         			
         			format "<scenedata>

" to:Pre_file
 				format "		<material>
" to:Pre_file
 			 	 format "			<name>material</name>
" to:Pre_file
 				format "			<diffuse>
" to:Pre_file
 			 	format "				<colour>% % %</colour>
" ((diffuse.r / 255)*gain) ((diffuse.g / 255)*gain) ((diffuse.b / 255)*gain) to:Pre_file
 				format "			</diffuse>

" to:Pre_file
 			 	format "		</material>

" to:Pre_file
         			format "</scenedata>

" to:Pre_file
         		close pre_file
         		matname = activeMeditSlot
         		prebat = createfile "C:\Indigo\matpreview\preview.bat"
      				format "@ECHO OFF
" to:prebat
 			 format "START /B /min C:\Indigo\indigo.exe C:\indigo\matpreview\preview.xml -o c:\indigo\matpreview/%preview.png
" matname to:prebat
         				format "EXIT
" to:prebat
         		close prebat
         		ShellLaunch "C:\Indigo\matpreview\preview.bat" ""
         		clock.active = true
         

This generates the apropriate material information for the renderer and the batchfile to start the renderer this works OK


      on clock tick do
         	(
         	valUp = (test.text as integer)-1
         	test.text = valUp as string
         	
         	if clock.ticks == 20 then (
         
         	prename = "c:\indigo\matpreview/"+(matname as string)+"preview.png"
         	prebit = openBitMap prename
         	precop = copy prebit
         	prepic.bitmap = precop
         	test.text = "20"
         	clock.active = false
         	clock.ticks = 0
         	)
         	)
         

This updates the prepic bitmap in the GUI ,after waiting for 20sec for indigo to finish the preview ,with the rendered filename as you see i have been messing around with the copy bitmap fuction but it does not seem to work the way i use it… when i do the update on the second matslot the previewimage (prepic) of the first slot will get updated as well
why that as the filename has changed…?

     1preview for first slot
     2preview for second slot
     
     Does anyone have an idea ? help will be greatly apprechiated !
     
     
     u3dreal ;)