Re: [osg-users] osgKeyboard

2010-02-05 Thread jago jagoc
Hi Nick,
this is the whole code :

#include 
#include 
#include 

#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 

#include 
#include 
#include 


class KeyboardModel : public osg::Referenced
{
public:

KeyboardModel() { createKeyboard(); }

osg::Group* getScene() { return _scene.get(); }

osg::Group* getHUDScene() { return _HUDscene.get(); }

void keyChange(int key,int value);

void CreateHUDKeyboard();

protected:

~KeyboardModel() {}

osg::Switch* addKey(osg::Vec3& pos, int key,const std::string&
text,float width, float height);
osg::Switch* addKey(int key,osg::Switch* sw);

void createKeyboard();

typedef std::map > KeyModelMap;

osg::ref_ptr_scene;
KeyModelMap _keyModelMap;
osg::ref_ptr _inputText;
osg::ref_ptr_HUDscene;


};

void KeyboardModel::keyChange(int key,int value)
{
osg::notify(osg::INFO) << "key value change, code="setCharacterSize(height);
textUp->setPosition(pos);
textUp->setDrawMode(osgText::Text::TEXT/*|osgText::Text::BOUNDINGBOX*/);
textUp->setAlignment(osgText::Text::LEFT_CENTER);
textUp->setAxisAlignment(osgText::Text::XZ_PLANE);
textUp->setText(text);

geodeUp->addDrawable(textUp);
}

osg::Geode* geodeDown = new osg::Geode;
{
osgText::Text* textDown = new osgText::Text;
textDown->setFont("fonts/arial.ttf");
textDown->setColor(osg::Vec4(1.0f,0.0f,1.0f,1.0f));
textDown->setCharacterSize(height);
textDown->setPosition(pos);

textDown->setDrawMode(osgText::Text::TEXT/*||osgText::Text::BOUNDINGBOX*/);
textDown->setAlignment(osgText::Text::LEFT_CENTER);
textDown->setAxisAlignment(osgText::Text::XZ_PLANE);
textDown->setText(text);

geodeDown->addDrawable(textDown);
}

osg::Switch* model = new osg::Switch;
model->addChild(geodeUp,true);
model->addChild(geodeDown,false);

_scene->addChild(model);

_keyModelMap[key] = model;

pos.x() += width;

return model;

}

osg::Switch* KeyboardModel::addKey(int key,osg::Switch* sw)
{
_keyModelMap[key] = sw;
return sw;
}

void KeyboardModel::createKeyboard()
{
_scene = new osg::Group;

osg::Vec3 origin(0.0f,0.0f,0.0f);
osg::Vec3 pos=origin;

addKey(pos,osgGA::GUIEventAdapter::KEY_Control_L,"Ctrl",2.0f,0.5f);
addKey(pos,osgGA::GUIEventAdapter::KEY_Super_L,"Super",2.0f,0.5f);
addKey(pos,osgGA::GUIEventAdapter::KEY_Alt_L,"Alt",2.0f,0.5f);
addKey(pos,osgGA::GUIEventAdapter::KEY_Space,"Space",3.0f,1.0f);
addKey(pos,osgGA::GUIEventAdapter::KEY_Mode_switch,"Switch",2.0f,0.5f);
addKey(pos,osgGA::GUIEventAdapter::KEY_Super_R,"Super",2.0f,0.5f);
addKey(pos,osgGA::GUIEventAdapter::KEY_Menu,"Menu",2.0f,0.5f);
addKey(pos,osgGA::GUIEventAdapter::KEY_Control_R,"Ctrl",2.0f,0.5f);

osg::Vec3 middle(pos.x()+1.0f,0.0f,0.0f);

pos.x() = 0.0f;
pos.z() += 1.0f;

addKey(pos,osgGA::GUIEventAdapter::KEY_Shift_L,"Shift",2.0f,0.5f);
addKey(pos,'\\',"\\",1.0f,1.0f);
addKey('Z',addKey(pos,'z',"Z",1.0f,1.0f));
addKey('X',addKey(pos,'x',"X",1.0f,1.0f));
addKey('C',addKey(pos,'c',"C",1.0f,1.0f));
addKey('V',addKey(pos,'v',"V",1.0f,1.0f));
addKey('B',addKey(pos,'b',"B",1.0f,1.0f));
addKey('N',addKey(pos,'n',"N",1.0f,1.0f));
addKey('M',addKey(pos,'m',"M",1.0f,1.0f));
addKey('<',addKey(pos,',',",",1.0f,1.0f));
addKey('>',addKey(pos,'.',".",1.0f,1.0f));
addKey('?',addKey(pos,'/',"/",1.0f,1.0f));
addKey(pos,osgGA::GUIEventAdapter::KEY_Shift_R,"Shift",2.0f,0.5f);

pos.x() = 0.0f;
pos.z() += 1.0f;

addKey(pos,osgGA::GUIEventAdapter::KEY_Caps_Lock,"Caps",2.0f,0.5f);
addKey('A',addKey(pos,'a',"A",1.0f,1.0f));
addKey('S',addKey(pos,'s',"S",1.0f,1.0f));
addKey('D',addKey(pos,'d',"D",1.0f,1.0f));
addKey('F',addKey(pos,'f',"F",1.0f,1.0f));
addKey('G',addKey(pos,'g',"G",1.0f,1.0f));
addKey('H',addKey(pos,'h',"H",1.0f,1.0f));
addKey('J',addKey(pos,'j',"J",1.0f,1.0f));
addKey('K',addKey(pos,'k',"K",1.0f,1.0f));
addKey('L',addKey(pos,'l',"L",1.0f,1.0f));
addKey(':',addKey(pos,';',";",1.0f,1.0f));
addKey('@',addKey(pos,'\'',"'",1.0f,1.0f));
addKey('~',addKey(pos,'#',"#",1.0f,1.0f));
addKey(pos,osgGA::GUIEventAdapter::KEY_Return,"Return",4.0f,0.5f);

pos.x() = 0.0f;
pos.z() += 1.0f;

addKey(pos,osgGA::GUIEventAdapter::KEY_Tab,"Tab",2.0f,0.5f);
addKey('Q',addKey(pos,'q',"Q",1.0f,1.0f));
addKey('W',addKey(pos,'w',"W",1.0f,1.0f));
addKey('E',addKey(pos,'e',"E",1.0f,1.0f));
addKey('R',addKey(pos,'r',"R",1.0f,1.0f));
addKey('T',addKey(pos,'t',"T",1.0f,1.0f));
addKey('Y',addKey(pos,'y',"Y",1.0f,1.0f));
addKey('U',addKey(pos,'u',"U",1.0f,1.0f))

Re: [osg-users] osgKeyboard

2010-02-05 Thread Trajce Nikolov
post your whole code . someone might help you
-Nick


On Fri, Feb 5, 2010 at 7:09 PM, jago jagoc  wrote:

> Hi alls,
> i would like to show a keybord 3d  as the text in  osgHud example. I
> am working on the osgkeyboard's project:
>  ...
>
> osg::Group* getHUDScene() { return _HUDscene.get(); }
>
> void KeyboardModel::CreateHUDKeyboard()
> {
>_HUDscene = new osg::Group;
>
>osg::Projection* HUDProjectionMatrix = new osg::Projection;
>
>HUDProjectionMatrix->setMatrix(osg::Matrix::ortho2D(0,1280,0,1024));
>
>osg::MatrixTransform* HUDModelViewMatrix = new osg::MatrixTransform;
>
>HUDModelViewMatrix->setMatrix(osg::Matrix::identity());
>
>HUDModelViewMatrix->setReferenceFrame(osg::Transform::ABSOLUTE_RF);
>
>_HUDscene->addChild(HUDProjectionMatrix);
>
>HUDProjectionMatrix->addChild(HUDModelViewMatrix);
>
>HUDModelViewMatrix->addChild(_scene);
>\\scene is a osgroup* to the keyboard
> }
> ...
> int main(int , char **)
> {
> 
>   viewer.setSceneData( keyboardModel->getHUDScene() );
>return viewer.run();
> }
>
> When i run the program  i don't see the keyboard in the scene.
> Any helps or pointer will be appreciate.
>
> Best regards,
> Jagovic
> ___
> osg-users mailing list
> osg-users@lists.openscenegraph.org
> http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
>
___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


[osg-users] osgKeyboard

2010-02-05 Thread jago jagoc
Hi alls,
i would like to show a keybord 3d  as the text in  osgHud example. I
am working on the osgkeyboard's project:
 ...

osg::Group* getHUDScene() { return _HUDscene.get(); }

void KeyboardModel::CreateHUDKeyboard()
{
_HUDscene = new osg::Group;

osg::Projection* HUDProjectionMatrix = new osg::Projection;

HUDProjectionMatrix->setMatrix(osg::Matrix::ortho2D(0,1280,0,1024));

osg::MatrixTransform* HUDModelViewMatrix = new osg::MatrixTransform;

HUDModelViewMatrix->setMatrix(osg::Matrix::identity());

HUDModelViewMatrix->setReferenceFrame(osg::Transform::ABSOLUTE_RF);

_HUDscene->addChild(HUDProjectionMatrix);

HUDProjectionMatrix->addChild(HUDModelViewMatrix);

HUDModelViewMatrix->addChild(_scene);
\\scene is a osgroup* to the keyboard
}
...
int main(int , char **)
{

   viewer.setSceneData( keyboardModel->getHUDScene() );
return viewer.run();
}

When i run the program  i don't see the keyboard in the scene.
Any helps or pointer will be appreciate.

Best regards,
Jagovic
___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


Re: [osg-users] osgkeyboard problem

2007-08-01 Thread Robert Osfield
Hi Roni,

On 8/1/07, ROSENZWEIG RONI <[EMAIL PROTECTED]> wrote:
> Is this solution (get/setRawKey) planned to be inserted in OSG, or do I have
> to

Not planned, but has been discussed.

This is an open source project, so its often a case of scratch an
itch.  I'm personally very stretched so can't engage with every little
avenue of development all the time...  I also don't have all the
answers, so sometimes one just has to roll ones sleeves up and learn
the code and the issues surrounding the feature you are after then
propose/code up a possible solution.

Robert.
___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


Re: [osg-users] osgkeyboard problem

2007-07-31 Thread ROSENZWEIG RONI


Hi Robert,

Is this solution (get/setRawKey) planned to be inserted in OSG, or do I
have to 
write it by myself? If so, can I get some pointers on how to write this 
function to get the raw key and not the converted one?

Roni


Robert Osfield <[EMAIL PROTECTED]> writes:

> 
> Hi Roni,
> 
> The character will that converted by your native windowing system into
ascii.
> 
> One possible solution would be to add a get/setRawKey into
> GUIEventAdatper to provide the modified keypress and the raw key
> press.
> 
> Robert.
> 
> On 7/31/07, ROSENZWEIG RONI <[EMAIL PROTECTED]> wrote:
> > Hello
> >
> > I have a problem which started in osg2.0 (worked fine in osg1.2).
> >
> > I want to read keyboard input with the ctrl key, such as ctrl+k,
ctrl+l etc.
> >
> > However when I use ea.getKey() I never get the "k" or "k" keys, but
some key
> > I can't understand.
> >
> > To demonstrate the problem, try running osgkeyboard, and press
ctrl+k  -
> > instead of typing "k" (like the demo did in osg1.2), an unknown
character is
> > shown (on my computer it looks like a square ...).
> >
> > I see that this problem (in a different form) was discovered a few
months
> > ago, was there a fix to the problem or a work-around?
> >
> > Roni
> > ___
> > osg-users mailing list
> > [EMAIL PROTECTED]
> >
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.or
g
> >
> >
> 


___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


Re: [osg-users] osgkeyboard problem

2007-07-31 Thread Robert Osfield
Hi Roni,

The character will that converted by your native windowing system into ascii.

One possible solution would be to add a get/setRawKey into
GUIEventAdatper to provide the modified keypress and the raw key
press.

Robert.

On 7/31/07, ROSENZWEIG RONI <[EMAIL PROTECTED]> wrote:
> Hello
>
> I have a problem which started in osg2.0 (worked fine in osg1.2).
>
> I want to read keyboard input with the ctrl key, such as ctrl+k, ctrl+l etc.
>
> However when I use ea.getKey() I never get the "k" or "k" keys, but some key
> I can't understand.
>
> To demonstrate the problem, try running osgkeyboard, and press ctrl+k  -
> instead of typing "k" (like the demo did in osg1.2), an unknown character is
> shown (on my computer it looks like a square …).
>
> I see that this problem (in a different form) was discovered a few months
> ago, was there a fix to the problem or a work-around?
>
> Roni
> ___
> osg-users mailing list
> osg-users@lists.openscenegraph.org
> http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
>
>
___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


[osg-users] osgkeyboard problem

2007-07-31 Thread ROSENZWEIG RONI
Hello

I have a problem which started in osg2.0 (worked fine in osg1.2).
I want to read keyboard input with the ctrl key, such as ctrl+k, ctrl+l
etc.
However when I use ea.getKey() I never get the "k" or "k" keys, but some
key I can't understand.

To demonstrate the problem, try running osgkeyboard, and press ctrl+k  -
instead of typing "k" (like the demo did in osg1.2), an unknown
character is shown (on my computer it looks like a square ...).

I see that this problem (in a different form) was discovered a few
months ago, was there a fix to the problem or a work-around?

Roni
___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org