Author Topic: need help with selection, and commands.  (Read 986 times)

Xalune

  • Guest
need help with selection, and commands.
« on: 5 August 2009, 22:17:31 »
Hey mates,

I am a newbie as you realise, and working on a project about pen centric computing...
If more certainty is needed , I am trying to modify commands and some actions in GAE's codes to get benefits of pen cent. comp.

For this, I simply use mouse input, no graphic tablet integration is needed.
I've began to process on my own source and header file, and was able to draw mouse path.

In order to do that, I copied the way that is followed in Renderer::renderSelectionQuad() with a little difference as, up.x and up.y coordinates have been copied to an Vec2i array, and then rendered this array.

Code: [Select]
void DrawPath::renderDrawingPath(const Game *game){

    const Gui *gui_pen=game->getGui();;
    const SelectionQuad *sq_pen= gui_pen->getSelectionQuad();

    Vec2i down= sq_pen->getPosDown();
    Vec2i up= sq_pen->getPosUp();

drawpath_Init(down.x,down.y);

insert_Location(up.x-5,up.y-5);

if(gui_pen->isSelecting()){
        glPushAttrib(GL_CURRENT_BIT | GL_POINT_BIT);       
glColor3f(0.1f,0.1f,0.9f);
glBegin(GL_POINTS);
int i=0;
while(i<size){
renderLocation(paths[i].x,paths[i].y);
i++;
}
glEnd();
        glPopAttrib();

   }
}

I called this function in Game::render2d() like renderSelectionQuad().
drawPath_Init() and insert_Location() copies coordinates to my array. So use of it can be seen in the while loop.
renderLocation() draws 8x8 square starting from given coordinates.

I know codes isn't that much modular, but will be in soon. I am designing a queue structure right now that will contain gestures, and it will enable analysing and merging of gestures. I haven't got so much problem with identifying of these.

And, for the god's sake, I am troubled with manipulating game commands...

After all of this intro, let me to ask my humble questions:

1.For my first gesture, I thought group selection would be perfect. However I have found little clues , I was desperate to understand work of functions did.
I was able to see calculateNearest() and updateSelection() which were possibly what I need.
Code: [Select]
void Gui::mouseDownLeft(int x, int y) {

...

//begin drag-drop selection & update selection for single-click
} else {
selectionQuad.setPosDown(Vec2i(x, y));
calculateNearest(units, gameCamera->getPos());
updateSelection(false, units);
}
I can't resolve how to use these functions. Could you tell me how groupSelection can be done in a manner of codes?
As I thought, it calculates the area of a rectangle which is bounded by mousedown and mouseup coordinates and assigns all of the units to a UnitContainer. I haven't seen any code parts like that, and I can't resolve how this work is done.
In my project, I will draw a circle, rectangle or any closed path, and I want group selection can be done in the area which is inside of my closed path.
If you can help me to resolve how this is done, then I will define my first working Gesture!

2. For second step of gesturing, I am also able to identify drawings as letters or symbols,  and I want to use them as particular commands like:
Quote
d) Hotkeys (only in game camera more)

a => activate attack command for selection
m => activate move command for selection
s => issue stop command to selection
i => select next idle harvester
b => select next building
d => select next damaged unit
t => select next storage unit
r => select next producer unit

 Can you tell at which part of codes these are mentioned, like if (key==keyA) do something(); if I could find these parts, I think, I can successfuly adapt these parts to my gestures.

3. This isn't a hard question actually, I want to begin my drawing process after a certain key is down(like Shift). Can I do this job by controlling  if(input->isShiftDown) ?

Thank you for your answers, regards!!!!