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 / Selecting objects one by one with certain textures

Author
Message
Rims Flames
11
Years of Service
User Offline
Joined: 5th Apr 2014
Location:
Posted: 15th Jul 2014 00:20
Hello community,

I want to select individual object and assign a texture to them when mouse on them and delete the texture when the mouse not on them, but i seem to have a problem like, when i select an object it will select it but when i select the second object, it doesn't selects, and then when reselecting the first object again, it selects both objects in the scene.

Here is the code:



Rims Flames
Derek Darkly
13
Years of Service
User Offline
Joined: 22nd Sep 2011
Location: Whats Our Vector, Victor?
Posted: 15th Jul 2014 04:30 Edited at: 15th Jul 2014 04:54
Personally, I would do something more like this:



This way each object has it own flag to signal whether it has already been textured or not.

(The coloring the object white part may not work for your purposes if you're actually loading and unloading different textures.)

666GO†O666
WickedX
16
Years of Service
User Offline
Joined: 8th Feb 2009
Location: A Mile High
Posted: 15th Jul 2014 06:22
Personally, I am going to shoot the next person I see using absolute paths and the next person responding to a thread and not pointing out it’s evils. Seriously, for you own sanity down the road, learn to use relative paths. For those who may not know, this is a absolute path.



By all rights your executable and project files should be in the selectiontest folder on your desktop. So the relative path should look like this.



Most of the time you with see someone put the media files in a sub-folder of the executable and projects root folder. For example say you have the media in the sub-folder; Media, therefore the relative path would be.



You may have noticed a few apps in you Program Files folder where the executable is in a sub-folder from the root. Usually it will be in a sub-folder named Bin. The media may be in a sub-folder from the root, named Media. In which case the relative path would be.



I realize this is off-topic. Just don’t want to see you pulling your hair out over this down the line.
WickedX
16
Years of Service
User Offline
Joined: 8th Feb 2009
Location: A Mile High
Posted: 15th Jul 2014 07:29 Edited at: 15th Jul 2014 07:34
Ok, back on topic. See if this works for you.

Derek Darkly
13
Years of Service
User Offline
Joined: 22nd Sep 2011
Location: Whats Our Vector, Victor?
Posted: 15th Jul 2014 08:11 Edited at: 15th Jul 2014 08:13
Quote: "I realize this is off-topic. Just don’t want to see you pulling your hair out over this down the line."


LoL... but what's the difference when you're pulling your own hair out over someone else's code?

Programming is a logical process, of course, but it's also an art form that ranges from finger-painting to masterpieces. We all get our feet wet in different ways.

For example, I hate indentations in code - I think it looks like trash, and no amount of 'other opinions' will ever change my mind.

Anyway, I think it's ok to use absolute paths in samples and snippets, because the other user may not have the same graphic anyway, and they can easily type in their own path. Obviously in final form, a program would use paths relative to the program's files, which all users would have at that point.

So, before you shoot us all... y'know, take a deep breath... count to 10, etc.

666GO†O666
WickedX
16
Years of Service
User Offline
Joined: 8th Feb 2009
Location: A Mile High
Posted: 15th Jul 2014 08:34 Edited at: 15th Jul 2014 08:47
To each, his own. No hair pulling going on here.

Quote: "For example, I hate indentations in code - I think it looks like trash, and no amount of 'other opinions' will ever change my mind."


If that works for you, that’s great. I can’t imagine having to edit thousands of lines of code that has no indentation and command after command separated on one line by a colon. It would be just as awful as editing spaghetti code. But, that’s just me.
Rims Flames
11
Years of Service
User Offline
Joined: 5th Apr 2014
Location:
Posted: 15th Jul 2014 11:19
Hey guys! Thank You all so very much for your help!

WickedX, i am using simple paths not like "C:\" etc, i was to lasy to delete the extra stuff from the path cuz i copyied from the folder on my desktop. .


I see that i can return to white color after selection, but is there a way to return to the object's default texture?

Thank You so much again!!!

Rims Flames
WickedX
16
Years of Service
User Offline
Joined: 8th Feb 2009
Location: A Mile High
Posted: 15th Jul 2014 21:01
The command Limb Texture can be used to get the objects image texture id. This should do the trick.



MateiSoft Romania
11
Years of Service
User Offline
Joined: 16th Oct 2013
Location:
Posted: 16th Jul 2014 00:54
I think this is like going back to a programed texture, i meant that every object has its own texture, and the idea was after deselecting, to automatically retrieve the object's unique texture and re apply to it. Is this possible? But hey, thank you for your patience with me!!!

Alex Matei CEO
www.alexmatei.com
WickedX
16
Years of Service
User Offline
Joined: 8th Feb 2009
Location: A Mile High
Posted: 16th Jul 2014 01:57 Edited at: 16th Jul 2014 03:04
Quote: "I think this is like going back to a programed texture, i meant that every object has its own texture, and the idea was after deselecting, to automatically retrieve the object's unique texture and re apply to it. Is this possible? But hey, thank you for your patience with me!!!"


If I’m understanding you correctly; Limb Texture is retrieving the objects image ID before changing the texture. You can use 100 objects all texture with a separate image texture and the above snippet will still work.

Edit: Yes, that code will work with object textures not assigned through code, but assigned by the x or dbo file formats. If that's what you want.

MateiSoft Romania
11
Years of Service
User Offline
Joined: 16th Oct 2013
Location:
Posted: 16th Jul 2014 11:14
i will try the code with an object that has already a texture and announce you Thank You very much again

Alex Matei CEO
www.alexmatei.com
MateiSoft Romania
11
Years of Service
User Offline
Joined: 16th Oct 2013
Location:
Posted: 16th Jul 2014 11:36
I tried, no work sadly



Alex Matei CEO
www.alexmatei.com
Chris Tate
DBPro Master
16
Years of Service
User Offline
Joined: 29th Aug 2008
Location: London, England
Posted: 16th Jul 2014 19:05
I am having interpreting the goal: how many objects are allowed to be selected at once? And why do you need your textures loaded at the point of mouse interaction and not during your program start?

WickedX
16
Years of Service
User Offline
Joined: 8th Feb 2009
Location: A Mile High
Posted: 16th Jul 2014 20:01
Looking at your code, you’re not loading a texture to select the object with. So, I’m guessing you are getting a; image does not exist at line... error. I can’t bring myself to use absolute paths, when I try my fingers cramp on me. But, I don’t see that as the problem. Here is the code I use to confirm that it works. Attached to this post is the complete project.



Attachments

Login to view attachments
MateiSoft Romania
11
Years of Service
User Offline
Joined: 16th Oct 2013
Location:
Posted: 16th Jul 2014 22:05
Well i am running the application not from making a new project just copy and paste the code your provided and load the objects with full paths because they are not near the exe is this the problem? cuz i don't see after texturing the object with a texture when hovered and then when leaving the object with mouse it stays white



Alex Matei CEO
www.alexmatei.com
MateiSoft Romania
11
Years of Service
User Offline
Joined: 16th Oct 2013
Location:
Posted: 16th Jul 2014 22:12
I copied the executable made from this code you provided and used relative paths and still no success

Alex Matei CEO
www.alexmatei.com
WickedX
16
Years of Service
User Offline
Joined: 8th Feb 2009
Location: A Mile High
Posted: 17th Jul 2014 00:25 Edited at: 17th Jul 2014 00:30
Does my project not work for you? After painful hand cramps, I change it to use absolute paths. The code still functions as designed. I even separated the models and textures into separate folders within the media folder and moved it to; C:\Program Files\The Game Creators\Dark Basic Professional Online\Projects. The project is on my desktop, still works! I did, change the objects relative texture path in a modeling program.



MateiSoft Romania
11
Years of Service
User Offline
Joined: 16th Oct 2013
Location:
Posted: 17th Jul 2014 00:37
Really!!! Look at this!

[img]null[/img]

Alex Matei CEO
www.alexmatei.com

Attachments

Login to view attachments
WickedX
16
Years of Service
User Offline
Joined: 8th Feb 2009
Location: A Mile High
Posted: 17th Jul 2014 00:44 Edited at: 17th Jul 2014 00:45
Does my project work? If it does then maybe its the texture path set up in the model. Without your media, I cannot test.

MateiSoft Romania
11
Years of Service
User Offline
Joined: 16th Oct 2013
Location:
Posted: 17th Jul 2014 01:03
No.Well i really think its not your code's fault, i will change the objects that i am importing and i will come back with a message! Big thank you!

Alex Matei CEO
www.alexmatei.com
MateiSoft Romania
11
Years of Service
User Offline
Joined: 16th Oct 2013
Location:
Posted: 17th Jul 2014 13:41
I tried with other objects, and still, when deselecting the object, in turns white, without it's texture....

Alex Matei CEO
www.alexmatei.com
WickedX
16
Years of Service
User Offline
Joined: 8th Feb 2009
Location: A Mile High
Posted: 17th Jul 2014 21:04
The download on the above post has the media I used. So, if that doesn’t work then the issue is somewhere else. I am using DBPro V7.4 on Windows7 SP1. 7.4 just seems less buggy. I have tried all updates since, it’s just not worth the few new functions.

MateiSoft Romania
11
Years of Service
User Offline
Joined: 16th Oct 2013
Location:
Posted: 17th Jul 2014 22:38
I have the latest upgrade from TGC's website. I am also using Windows 7 SP1. I downloaded the file from your post

Alex Matei CEO
www.alexmatei.com
WickedX
16
Years of Service
User Offline
Joined: 8th Feb 2009
Location: A Mile High
Posted: 17th Jul 2014 22:50 Edited at: 17th Jul 2014 22:57
And that download does not work?

Edit: If not, then that's something else the updates have broke.

MateiSoft Romania
11
Years of Service
User Offline
Joined: 16th Oct 2013
Location:
Posted: 17th Jul 2014 23:46
The files from the download didn't work... I feel very bad saying this but yeah, i think your right about the update...its strange

Alex Matei CEO
www.alexmatei.com
WickedX
16
Years of Service
User Offline
Joined: 8th Feb 2009
Location: A Mile High
Posted: 18th Jul 2014 00:06
You can have multiple version on your computer. I had 4 on my system at one time. Just rename the folder of your current copy. Then install DBPro again and update it to the version your what. You can then rename this folder and change the original back. Create a link to the alternate version and your good to go.

WickedX
16
Years of Service
User Offline
Joined: 8th Feb 2009
Location: A Mile High
Posted: 18th Jul 2014 02:57 Edited at: 18th Jul 2014 02:58
Just tested this on my Dark GDK update. Phew, it works

MateiSoft Romania
11
Years of Service
User Offline
Joined: 16th Oct 2013
Location:
Posted: 18th Jul 2014 10:26
I will try and retest it later this day(day in my country right now 10:26 AM)

Alex Matei CEO
www.alexmatei.com
MateiSoft Romania
11
Years of Service
User Offline
Joined: 16th Oct 2013
Location:
Posted: 18th Jul 2014 21:01
No luck...reinstalled dbpro and stuff... i don't know

Alex Matei CEO
www.alexmatei.com
WickedX
16
Years of Service
User Offline
Joined: 8th Feb 2009
Location: A Mile High
Posted: 18th Jul 2014 21:30
Sorry, I don't know either. All I do know, is it working for me.

WickedX
16
Years of Service
User Offline
Joined: 8th Feb 2009
Location: A Mile High
Posted: 18th Jul 2014 21:41
Attached is my executable with the media. See if this works for you. If not what if any error or message are you getting.

Attachments

Login to view attachments
WickedX
16
Years of Service
User Offline
Joined: 8th Feb 2009
Location: A Mile High
Posted: 19th Jul 2014 03:33
Well, I made a copy of my Dark Basic Professional Online folder and updated to the current official release -DBPro 7.62, and it works. So, it’s not a version issue. I am running this on a HP Netbook with a single core dual threaded processor and an Intel integrated graphics card. If this is not working for you, that is sad!

MateiSoft Romania
11
Years of Service
User Offline
Joined: 16th Oct 2013
Location:
Posted: 19th Jul 2014 11:00
Well, now, the executable withouth the project, that you gave to me, worked but when i compile the project with all the files, it doesn't work i will try again cuz thats really interesting whats happening

Alex Matei CEO
www.alexmatei.com
MateiSoft Romania
11
Years of Service
User Offline
Joined: 16th Oct 2013
Location:
Posted: 19th Jul 2014 11:05
Well, now it worked.... i don't why until today it didn't worked... Thank You very much for your time WickedX !!!

Alex Matei CEO
www.alexmatei.com
WickedX
16
Years of Service
User Offline
Joined: 8th Feb 2009
Location: A Mile High
Posted: 19th Jul 2014 22:27
Happy to hear you have it working. Yah, that is strange…

You’re welcome.

Login to post a reply

Server time is: 2025-05-14 10:31:56
Your offset time is: 2025-05-14 10:31:56