I am building a java3d GUI, using which users can create custom scene graphs, without needing to know the code, i want to pick specific boxes using mouse, and i want to be able to move them around.. so for that i need picking..
There are say, 2 boxes and 2 spheres in my scenegraph. I just want to pick one of them and know which one was picked. I can find out what type of object was clicked, like if i click on specific sphere, or box, i can find that out, but i dont know how can i find out which object was it, so i can process it.
Could anyone suggest me a solution to the problem? All I want is to know
which object was picked. That's all.
Ok, for now the problem has been solved.
Whenever u add a box or a sphere into scene graph, you need to add custom userData to these object.
e.g. if u are adding a Box object, then
boxOb.setUserData("box1"); //this can be any datatype
when you retrieve data from picking, you just call getUserData() method on getNode() method.
BAMM!! you will get the custom datatype which u set, you can process this further as per your application.
Cheers :)
Related
I am trying to implement a dialogue system for a game that I am making. I have the actual system for handling the text and input all set up. My question is asking about how you actually show the text and have it formatted properly in a certain sprite.
The "best way" is a broad and subjective term, and it may be different for each person, but I can give you some tips regarding the question in your second sentence, to put you in the right direction:
How to actually show the text and have it formatted properly in a certain sprite?
Considering a dialogue box is a User Interface, you should put the code, that draws the dialog box, in the Draw_Gui of the object. Because that will draw stuff in front of the camera, and doesn't need to keep positions of the map in mind. Since Draw_Gui is in an object, you can put the dialogue box in a parent NPC, or let a seperate persistent object handle it (called an object manager)
To format it properly within a sprite, you can use draw_text_ext(x,y,string,sep,w), especially the w parameter will be helpful, as that allows you to let the text start on a new line if it exceeds past that width, and the sep parameter let you deside the space between the lines of text, to ensure the amount or lines in your dialog box will look clean.
I have a property on my user control called 'DataGridViewColumnType' and wondered if it was possible to make it a drop down and a list of column types to choose from? Even if it was just a list of strings would be good enough.
I have been playing with the attribute
<Editor("System.Windows.Forms.Design.DataGridColumnCollectionEditor, System.Design", GetType(UITypeEditor))>
But not having much luck and not sure it'd actually do what I want even if if I could get it to work. It just opens a column collection editor but the add button doesn't work and i haven't been able to get it to work so couldn't get any further.
So i thought if I can just create the list myself then somehow turn my property into a drop down that displays my list that would be fine. I just haven't done this before and can't seem to find much on how to achieve it.
To illustrate what I'm asking, let's say I have a custom TextBox that has 2 modes. Mode 1 only allows numbers, and mode 2 only allows dates in a particular format.
Using a class module I can create this custom TextBox, and I can use a loop when the userform initialises to set which TextBoxes are custom.
What I'd like to happen is have the custom TextBox, or what ever custom control I want, show up in the toolbox. And I also want its custom properties, if they exist, to show up in the property window.
So far, I've been unable to find a way to do this. In fact, I've been unable to find out if it's even possible. It seems, to me anyway, that it's something that should be possible, but maybe I'm barking up the wrong tree. If it's possible I'd really appreciate being pointed to a resource.
I have 20 or so grids in my application suite. I'd like to create a global copy/paste context menu which I can bind to every single grid rather than code in each form.
I am unsure what is the best way to achieve this, I have started to create a class with my menu in it, but get stuck at the point of adding the actual menu options. For example I know I'll need to call a "copy" event, but I also know I'll need to tell it what I am copying, and I cannot see how that is done in vb.net when you can only add the address of a method minus parameters.
e.g.
.MenuItems.Add("Copy Cell", New System.EventHandler(AddressOf CopyCell))
Obviously I want "CopyCell" to only be coded in one place as well, rather than repeated in each form. I will always be copying the same object (SelectedCellCollection).
I am not sure how to make the menu have an event with parameters, or how to make it "know" that I want to always copy the selected items. I'm aware that I'd have to do some coding in the form but just trying to work out the way to minimize it.
I have created my own context menu class (via inheritance) with specific copy and paste functionality / options tailored to the grid I am using. It works fine and only needs one line of code per form/grid to activate.
Take software for a fish merchant.
To sell a certain kind of fish, the UI shows a picture of the fish. The user can click it, then a window pops up in which he can select a different fish.
In a naive implementation, the component needs
access to the FishImageLibrary, to retrieve the image
access to the FishSelectionPopup, to ask the user for a new fish
Solution 1: Pass both classes along.
The problem is that our component can be inside another component. So these two classes would have to be passed along to our component, creating dependencies all over the place.
Solution 2: Callbacks.
Implementation using callbacks wouldn't be very clean either because the component can be inside another component, and the event would have to propagate through the whole hierarchy. This requires changes to several classes.
Any suggestions for a really clean solution?
So, that would be a kind of picturebox displaying whatever fish is selected and opening a selection pop-up when clicked.
I guess that box would be part of a bigger structure whose job is presenting the selected fish. Maybe there's a label with the fish's name, another one that presents the size.. I'd have their parent component set their values when a fish is selected. It would know FishImageLibrary and be able to retrieve the image address based on the fish.
For the pop-up I think the command pattern is pretty standard for this kind of problems. It lets you pass a standardized object to your picture box that won't have to know implementation specifics of OpenSelectionPopup, which itself knows about FishSelectionPopup and how to open it.