Page 1 of 1
Imagegadget3D New Issues... Frustrated!
Posted: Sat Feb 05, 2011 10:56 pm
by Rook Zimbabwe
I am having troubles making a already loaded image work with Imagegadget 3D() the text from the online manual is slightly confusing... do I need to make it a texture???
Creates an Image gadget in the current GadgetList. If #PB_Any is used as '#Gadget3D' parameter, the new gadget number will be returned as 'Result'. The TextureID represents an image and can be obtained with TextureID() from the Texture library. If the TextureID is 0, then no image will be displayed. The gadget dimensions autofit to the image size.
I had alreadyloaded the images to the program with the
Code: Select all
#J= "Data\"
DataSection
Image1:
IncludeBinary #J + "BACK0.jpg"
Image2:
IncludeBinary #J + "2.jpg"
; etc
EndDataSection
but either I get a grey box in the 3D GUI or I get a program error...
Anyone got a working example of the DUI 3D Imagegadget working?

Re: Imagegadget3D issues
Posted: Sat Feb 05, 2011 11:21 pm
by Comtois
Rook Zimbabwe wrote:I am having troubles making a already loaded image work with Imagegadget 3D() the text from the online manual is slightly confusing... do I need to make it a texture???
Yes.
Anyone got a working example of the DUI 3D Imagegadget working?
added 3 lines in the Gadget3D.pb example.
Code: Select all
;
; ------------------------------------------------------------
;
; PureBasic - Gadget 3D
;
; (c) Fantaisie Software
;
; ------------------------------------------------------------
;
#CameraSpeed = 10
#MainWindow = 0
#CloseButton = 0
#Image3D = 1 ; <<< NEW
IncludeFile "Screen3DRequester.pb"
Define.f KeyX, KeyY, MouseX, MouseY
If InitEngine3D()
Add3DArchive("Data/", #PB_3DArchive_FileSystem)
Add3DArchive("GUI/", #PB_3DArchive_FileSystem)
Add3DArchive("Data/skybox.zip", #PB_3DArchive_Zip)
InitSprite()
InitKeyboard()
InitMouse()
If Screen3DRequester()
SkyBox("desert07.jpg")
CreateCamera(0, 0, 0, 100, 100) ; Front camera
CameraLocate(0,0,100,100)
LoadTexture(0, "Geebee2.bmp") ; <<< NEW
OpenWindow3D(#MainWindow, 100, 100, 300, 300, "Hello in 3D !")
ButtonGadget3D(#CloseButton, 10, 260, 120, 25, "Close")
ImageGadget3D(#Image3D, 10, 60, 200, 200, TextureID(0)) ; <<< NEW
ShowGUI(128, 1) ; Display the GUI, semi-transparent and display the mouse cursor
Repeat
Screen3DEvents()
If ExamineKeyboard()
Input$ = KeyboardInkey()
EndIf
If ExamineMouse()
MouseX = -(MouseDeltaX()/10)*#CameraSpeed
MouseY = -(MouseDeltaY()/10)*#CameraSpeed
InputEvent3D(MouseX(), MouseY(), MouseButton(#PB_MouseButton_Left), Input$)
EndIf
; Handle the GUI 3D events, it's similar to regular GUI events
;
Repeat
Event = WindowEvent3D()
Select Event
Case #PB_Event3D_Gadget
If EventGadget3D() = #CloseButton
CloseWindow3D(#MainWindow)
EndIf
EndSelect
Until Event = 0
RenderWorld()
FlipBuffers()
Until KeyboardPushed(#PB_Key_Escape) Or Quit = 1
EndIf
Else
MessageRequester("Error", "The 3D Engine can't be initialized",0)
EndIf
Re: Imagegadget3D issues
Posted: Mon Feb 07, 2011 5:34 pm
by Rook Zimbabwe
Thank you Comtois... that is great!

Re: Imagegadget3D issues
Posted: Wed Feb 09, 2011 8:50 pm
by Rook Zimbabwe
Small issue now... have 2 textures and want to change form 1 to the other when spacebar is pressed... according to the CHM this is supposed to work... it isn't.
what did I do wrong?
Code: Select all
; ------------------------------------------------------------
;
; PureBasic - Gadget 3D
;
; (c) Fantaisie Software
;
; ------------------------------------------------------------
;
#CameraSpeed = 10
#MainWindow = 0
#CloseButton = 0
#Image3D = 1 ; <<< NEW
IncludeFile "Screen3DRequester.pb"
Define.f KeyX, KeyY, MouseX, MouseY
If InitEngine3D()
Add3DArchive("Data/", #PB_3DArchive_FileSystem)
Add3DArchive("GUI/", #PB_3DArchive_FileSystem)
Add3DArchive("Data/skybox.zip", #PB_3DArchive_Zip)
InitSprite()
InitKeyboard()
InitMouse()
If Screen3DRequester()
SkyBox("14.jpg")
CreateCamera(0, 0, 0, 100, 100) ; Front camera
CameraLocate(0,0,100,100)
LoadTexture(0, "26.bmp")
LoadTexture(1,"25.bmp") ; ******** NEW
OpenWindow3D(#MainWindow, 100, 100, 300, 300, "Hello in 3D !")
ButtonGadget3D(#CloseButton, 10, 260, 120, 25, "Close")
ImageGadget3D(#Image3D, 10, 60, 200, 200, TextureID(0)) ; <<< NEW
ShowGUI(128, 1) ; Display the GUI, semi-transparent and display the mouse cursor
Repeat
Screen3DEvents()
If ExamineKeyboard()
Input$ = KeyboardInkey()
EndIf
If KeyboardReleased(#PB_Key_Space)
SetGadgetState3D(#Image3D, TextureID(1)) ; ************* This does NOT work!!!
EndIf
If ExamineMouse()
MouseX = -(MouseDeltaX()/10)*#CameraSpeed
MouseY = -(MouseDeltaY()/10)*#CameraSpeed
InputEvent3D(MouseX(), MouseY(), MouseButton(#PB_MouseButton_Left), Input$)
EndIf
; Handle the GUI 3D events, it's similar to regular GUI events
;
Repeat
Event = WindowEvent3D()
Select Event
Case #PB_Event3D_Gadget
If EventGadget3D() = #CloseButton
CloseWindow3D(#MainWindow)
EndIf
EndSelect
Until Event = 0
RenderWorld()
FlipBuffers()
Until KeyboardPushed(#PB_Key_Escape) Or Quit = 1
EndIf
Else
MessageRequester("Error", "The 3D Engine can't be initialized",0)
EndIf

Re: Imagegadget3D New Issues... Frustrated!
Posted: Thu Feb 10, 2011 12:15 am
by Nituvious
You're right, according to the help file it's supposed to work exactly like this. I couldn't get it to work no matter what I tried. Debugging says that the change was successful. Could there possibly be some sort of redraw for the Gadget3D library?
Re: Imagegadget3D New Issues... Frustrated!
Posted: Thu Feb 10, 2011 5:50 am
by PMV
Re: Imagegadget3D New Issues... Frustrated!
Posted: Thu Feb 10, 2011 6:08 pm
by Rook Zimbabwe
yep I found that later in the day after my post...
my solution? Draw a new gadget with the same #ID in the same location with the new texture...
Lame code idea but it works!
considering that this is not really a gadget anyway but a billboard... seems to be OK and since OGRE is OOPish should not cause a memory issue.
Re: Imagegadget3D New Issues... Frustrated!
Posted: Thu Feb 10, 2011 9:01 pm
by PMV
Rook Zimbabwe wrote:and since OGRE is OOPish should not cause a memory issue.
oop and memory issues are two separate things