Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

DarkBASIC Professional Discussion / Texture retrievement with menu

Author
Message
MateiSoft Romania
12
Years of Service
User Offline
Joined: 16th Oct 2013
Location:
Posted: 22nd Jan 2014 12:28
Hello awesome community!

Please if someone can help me on retrieving the textures from a folder and creating a menu where i can choose the texture and then apply it on an object from that menu?

I really appreciate all your support!

Thank You!

Alex Matei CEO
www.alexmatei.com
Van B
Moderator
23
Years of Service
User Offline
Joined: 8th Oct 2002
Location: Sunnyvale
Posted: 22nd Jan 2014 12:55
I'm sure there's an example if you check 'Find first' - it looks through a specified folder and prints the results to the screen. I tend to just use a temporary array, like list$(256), then add to that for dropdown menus and file selectors - means you need just 1 bubble sort for any type of list.

Anyway, I do have a snippet but it's not pretty, just a screen where you can click on a file name to select it, I'll post it up today, then you'd just have to make it pretty.

Also, I would suggest having an instant list function rather than making something too fancy. Like, press a button then it makes a droplist, basically your list of files with a dozen items, scrollable. If you've ever used standard Windows controls, it would be like a combo list box, shows the value with a button beside to show all options... would be pretty quick and efficient that way I think.

I am the one who knocks...
chafari
Valued Member
20
Years of Service
User Offline
Joined: 2nd May 2006
Location: Canary Islands
Posted: 22nd Jan 2014 13:47
Hi there.
You can use the same example code I shoq you some days ago, and just change .x or .3ds for the file tipe that you need(bmp, jpg, tga...).once you select, you would be able to texture your object.

I'm not a grumpy grandpa
MateiSoft Romania
12
Years of Service
User Offline
Joined: 16th Oct 2013
Location:
Posted: 22nd Jan 2014 14:22
Thanks for the responses and chafari yes i used your code i am now trying to adapt it to my code i wanted to see if there is another alternative,another example just for me to learn something new and i wanted to compare the codes to see the fittings.Please don't judge me wrong, i really appreciate your help! Your code has been applied in my engine for some time

Thank You!

Alex Matei CEO
www.alexmatei.com
chafari
Valued Member
20
Years of Service
User Offline
Joined: 2nd May 2006
Location: Canary Islands
Posted: 22nd Jan 2014 15:31
Not complaining mate, just pointing you how to achieve it

I'm not a grumpy grandpa
MateiSoft Romania
12
Years of Service
User Offline
Joined: 16th Oct 2013
Location:
Posted: 24th Jan 2014 13:20
Chafari i don't really understand how can i make the texturing possible between the this code which lets me add multiple objects into a scene

perform checklist for files
cq = checklist quantity()
numFiles = 0
dim files(-1) as string
for n = 1 to cq
s$ = checklist string$(n)
if right$(s$, 2) = ".x"
array insert at bottom files()
files(numFiles) = s$
inc numFiles
endif
next n

if numFiles = 0
print "put some .x files in the .exe's folder first. Press key..."
end
endif

`position camera 0,50,700,55
`rotate camera 90,0,0

ground = 1
if object exist (ground) = 0
make object plane ground, 10000, 10000 : xrotate object ground, 90
endif

fileDrag = -1
impobrot# = 0
kinarr = 0

do


update terrain

if object exist(65538) = 1
position object 65538,camera position x(0),0,camera position z(0)
endif

if object exist(8000) = 1
a# = get terrain ground height( 8000, object position x(65538), object position z(65538) )
position object 65538,camera position x(0),a#,camera position z(0)
endif

if keystate(1) = 1
if object exist(65538) = 1
delete object 65538
endif
endif



camstat()
camerasetup()
console()

if keystate(1) = 1
exit
ENDIF

oMc = mc
mx = mousex()
my = mousey()
mc = mouseclick()


ink 0xffffffff, 0 : box 0, 0, 160, scrH
line 161, 0, 161, scrH
y = 0
mouseOver = -1
nMax = numFiles-1
for n = 0 to nMax
if mx < 160 and my => y and my < y+15
if fileDrag = -1
ink 0, 0 : box 0, y, 160, y+14
ink 0xffffffff, 0 : text 0, y, files(n)
mouseOver = n
else
ink 0xff808080, 0 : box 0, y, 160, y+14
ink 0xffffffff, 0 : text 0, y, files(n)
endif
else
ink 0xffffffff, 0 : text 0, y, files(n)
endif
inc y, 15
next n

select mc
case 1
if oMc = 0
if mouseOver <> -1
fileDrag = mouseOver
`CUSTOM!

obj = newObjId()
load object files(fileDrag), obj

if object exist(8000) = 1
hide object ground
pick screen mousex(),mousey(), 30
x# = get pick vector x()+camera position x()
z# = get pick vector z()+camera position z()
a# = get terrain ground height( 8000, object position x(obj), object position z(obj) )
position object obj,x#,a#,z#
else
show object ground
pick screen mousex(),mousey(), 30
x# = get pick vector x()+camera position x()
z# = get pick vector z()+camera position z()
position object obj,x#,0,z#
endif


`pick screen mousex(),mousey(), 30
`x# = get pick vector x()+camera position x()
`z# = get pick vector z()+camera position z()
`position object obj,x#,0,z#

`END CUSTOM!
endif
endif
endcase
case 2
if oMc = 0
if mx > 160
pickedObj = pick object(mx, my, 2, 65535)
if pickedObj <> 0
delete object pickedObj
endif
endif
endif

endcase
case 0
if oMc = 1
if fileDrag <> -1
if mx > 160
pickedObj = pick object(mx, my, ground, ground)

if pickedObj <> 0
x# = camera position x() + get pick vector x()
y# = camera position y() + get pick vector y()
z# = camera position z() + get pick vector z()
obj = newObjId()
`load object files(fileDrag), obj
`position object obj, x#, y#, z#
endif
else
i = my / 15
if i > numFiles-1 then i = numFiles-1
if i <> fileDrag
item$ = files(fileDrag)
if fileDrag < numFiles-1
for n = fileDrag to numFiles-2
files(n) = files(n+1)
next n
endif
minN = i : if minN < 1 then minN = 1
for n = numFiles-1 to minN step -1
files(n) = files(n-1)
next n
files(i) = item$
endif
endif

fileDrag = -1
endif
endif
endcase
endselect


if mx > 160
pickedObj = pick object(mx,my,2,65535)
if keystate(19) = 1
inc impobrot#
yrotate object pickedObj,impobrot#
ENDIF
ENDIF


if mx > 160
pickedObj = pick object(mx,my,2,65535)
if upkey() = 1
move object pickedObj,2
ENDIF
ENDIF

if mx > 160
pickedObj = pick object(mx,my,2,65535)
if downkey() = 1
move object pickedObj,-2
ENDIF
ENDIF


if mx > 160
pickedObj = pick object(mx,my,2,65535)
if leftkey() = 1
dec kinarr
position object pickedObj,object position z(pickedObj) + kinarr,0,0
ENDIF
ENDIF

if mx > 160
pickedObj = pick object(mx,my,2,65535)
if rightkey() = 1
inc kinarr
position object pickedObj,object position z(pickedObj) + kinarr,0,0
ENDIF
ENDIF

sync
loop
endfunction

function newObjId()
for n = 1 to 65535
if object exist(n) = 0 then exitfunction n
next n
endfunction 0

And your code for textures


rem mask to clear screen
get image 100,0,0,640,480

rem looking for image files....YOU CAN CHANGE EXTENCION FOR .3DS .X .DBO or whatever you need
set cursor 0,20
find first
dim arch$(100) rem maximum quantity of files in array
arch=1

repeat

if get file type()=0
arch$(arch)=get file name$()
extension$=right$(arch$(arch),4)
if extension$=".bmp" or extension$=".jpg" or extension$=".tga" or extension$=".png" or extension$=".dds"
arch=arch+1
if arch>100 then arch=100
endif
endif

find next
until get file type()=-1

for t=1 to arch-1
inc file
ink rgb(0,100,0),0
print arch$(t)," ",file rem show us the number of image files we found in folder
next t


do

ink rgb(140,140,140),0
box 200,0,400,30
ink rgb(255,255,255),0
set cursor 205,5

if mousey()>items
print arch$(mousey()/15)
endif

if mousey()>20 and mousey()<arch*15

if mouseclick()=1
load image arch$(mousey()/15),1
paste image 100,200,50 rem mask to clear screen that we capture above
paste image 1,200,50
endif
endif
sync
loop


Alex Matei CEO
www.alexmatei.com
chafari
Valued Member
20
Years of Service
User Offline
Joined: 2nd May 2006
Location: Canary Islands
Posted: 24th Jan 2014 13:46 Edited at: 24th Jan 2014 13:53
This code from Monocoder, open 3D objects, and sure that if we modify some code, we'll probably open images also.

I had an old code here, that will open all images(maximum 100) that find in a folder. Try this , make a new folder for this example, and create a new forder "media", and put there an amount of images(maximum 100) it doesn't matter the size. Then copy this snippet and save it into project folder and execute. You will be able to select image in a browser, and sexture the Dumy object. You can move up or donwn the browser with upkey/downkey. I hope you can find it usefull.







Edited. this code is a new update, but has not help comments sorry.




Cheers.

I'm not a grumpy grandpa
MateiSoft Romania
12
Years of Service
User Offline
Joined: 16th Oct 2013
Location:
Posted: 28th Jan 2014 18:25
Hey chafari! Sorry for the delay!
Yes in works very well indeed thank you very much for this code! You are always helpful!

Alex Matei CEO
www.alexmatei.com
chafari
Valued Member
20
Years of Service
User Offline
Joined: 2nd May 2006
Location: Canary Islands
Posted: 28th Jan 2014 19:03
@MateiSoft Romania Enjoy it ..

I'm not a grumpy grandpa
MateiSoft Romania
12
Years of Service
User Offline
Joined: 16th Oct 2013
Location:
Posted: 28th Jan 2014 19:32
Thank you! But i do want to bother you with one important question that still hasn't been responded. You know in FPSC there the GUI buttons for save load and interracts with the main EDITOR which is made in dark basic pro. Even the other controls/buttons from the GUI are linked to communicate with the DBPRO-made EDITOR. I have a GUI made in Visual Basic and i even linked my editor there. But the only thing is that i can't make let'say a button from the GUI work with DBPRO when clicked to do something in DBPRO application.

I really appreciate your time to explain and to help me!
Thank You very much again

Alex Matei CEO
www.alexmatei.com
GreenDixy
17
Years of Service
User Offline
Joined: 24th Jul 2008
Location: Toronto
Posted: 29th Jan 2014 10:02
search for bluegui on the forums it is one I use and like for a plugin

.:: Http://DeanWorks.Ca ::.
My software never has bugs. It just develops random features.
MateiSoft Romania
12
Years of Service
User Offline
Joined: 16th Oct 2013
Location:
Posted: 29th Jan 2014 10:15
I know about Blue GUI but i know that in C++ or VB its much more convenient and i wanted to see if there is someone who knows about doin' this.

Alex Matei CEO
www.alexmatei.com

Login to post a reply

Server time is: 2026-07-06 07:52:24
Your offset time is: 2026-07-06 07:52:24