PDA

View Full Version : medit-bitmap-rollout - scripted material


losbellos
03-14-2009, 03:40 PM
Hello There,

I got a scripted material plugin.
I would like to change a bitmap in it, when I press render preview.
Everything works fine, the preview image shows up in the rollout, except that when I select an other material in the material editor, the same image shows up, even know its filename property is the same.

Now is it a rollout/refresh problem, or for some reason the bitmap controller doesnt update individually even known its fileName property is different.

--the bitmap in the rollout:
bitmap matprevbmp fileName:"D:/redqueennew/scene/matprev/default.bmp" pos:[10,10]

--and then I change with:
meditmaterials[activeMeditSlot].pre_view.matprevbmp.FileName = ("D:/redqueennew/scene/matprev/" + (activeMeditSlot as string) + ".bmp")

--the filename result on 2 different material
--the previewed:
"D:/redqueennew/scene/matprev/15.bmp"
--and then on other one
"D:/redqueennew/scene/matprev/default.bmp"

however when selecting an other material the same image shows up.

Any ideas, how to fix this?
THanks a lot

ZeBoxx2
03-14-2009, 04:04 PM
try this..
Scripted Plug-in Clauseson <rollout> reload do ...

This event handler is defined for rollouts in scripted plug-ins. This handler is called in a scripted material or environment or render effect whenever an instance of the plug-in is open in the Material Editor or render effects dialog and another instance of the same plug-in class is selected. In this situation, the existing rollout is not closed and re-opened but rather left open and 'loaded' with the new instance. The 'reload' handler is called after the new instance is installed in the rollout and can be used in place of 'on <rollout> open do ...' handler to update the rollout. The open handler is not called in this case. The reload event handler is not called if the scripted object has custom attributes associated with it, rather the existing rollout is closed and a new rollout opened.



If that fails, just refresh the bitmap in the on <rollout> open

losbellos
03-14-2009, 05:09 PM
its doing the same differently.
The image updates on preview.
select an other slot, the original image shows there. - Fine.
going back to the updated slots, gest the original image reverts from the updated.
WHat is funny that the filenam is different. I think there is some confusion going on here.


clearlistener()
plugin material rrt2
name:"RedQueen2"

classID: #(655953908, 849023090)

extends:rayTraceMaterial replaceUI:true version:1

(

rollout pre_view "Material Preview" (

bitmap matprevbmp fileName:"D:/redqueennew/scene/matprev/default.bmp" pos:[10,10]
button rendpreview "PREVIEW" width:60 height:20 pos:[100,75]
label C1 "RedQeen Shader v0.7\r\n(c)Bela Bessenyei\r\nRedQueen - copyright Shinji Okagi" pos:[100,10] width:250 height:40

on rendpreview pressed do render_mat_preview()

/* on pre_view reload do ( -- Refreshing bitmap
xx = meditMaterials[activeMeditSlot].pre_view.matprevbmp.fileName
meditMaterials[activeMeditSlot].pre_view.matprevbmp.fileName = xx
)*/
on pre_view open do ( -- Refreshing bitmap
xx = meditMaterials[activeMeditSlot].pre_view.matprevbmp.fileName
meditMaterials[activeMeditSlot].pre_view.matprevbmp.fileName = xx
)

)
)


besides that I might try to use an external array containing the bitmaps, and try load from them the path. Maybe it helps. In this case the original image gets reverted even in the updated, while the fileName property holds the new path...
Then I will have to have 24 default bitmaps if the rollout accepts the string as a filename
("D:/redqueennew/scene/matprev/" + (activeMeditSlot as string) + ".bmp")

losbellos
03-14-2009, 05:24 PM
this works, but it would be good to have a simpler version, and understand a clear solution for the above.


on pre_view reload do (
meditMaterials[activeMeditSlot].pre_view.matprevbmp.fileName = prevbitmaparray[activeMeditSlot]
)

magicm
03-14-2009, 07:04 PM
Not sure if this is what you're after, but here's some quick changes:
plugin material rrt2
name:"RedQueen2"
classID: #(655953908, 849023090)
extends:rayTraceMaterial replaceUI:true version:1
(
parameters params rollout:pre_view
(
matprev type:#bitmap

on matprev set val do (
if this.pre_view.isDisplayed then (
this.pre_view.matprevbmp.bitmap = val
)
)
)

rollout pre_view "Material Preview"
(
bitmap matprevbmp pos:[10,10] width:50 height:50
button rendpreview "PREVIEW" width:60 height:20 pos:[100,75]
label C1 "RedQeen Shader v0.7\r\n(c)Bela Bessenyei\r\nRedQueen - copyright Shinji Okagi" pos:[100,10] width:250 height:40

-- dummy function which creates a bitmap with a random color
fn render_mat_preview =
(
local b = bitmap 50 50 filename:"c:\\temp.bmp" color:(random black white)
save b
-- assign the created bitmap to the 'matprev' property (see above)
matprev = b
)

on rendpreview pressed do render_mat_preview()

-- update the bitmap control with the bitmap stored in the 'matprev' property
on pre_view open do matprevbmp.bitmap = matprev
)
)
Hope this helps,
Martijn

losbellos
03-14-2009, 09:37 PM
Hej, Thanks a lot. This is cool. I have been thinking about this but I want able to solve this way. The array system is implemented now, but I will change into this asap.
Thanks a lot again!

flyingaway
03-16-2009, 03:29 AM
good I think it will useful

CGTalk Moderation
03-16-2009, 03:29 AM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.