drag and drop meshes
drag and drop meshes
Has anyone already posted some code for dragging and dropping meshes?
I couldn't find any coding for that. If not, does anyone has programmed that yet and could post his dragging routine for that? That would be great!
I couldn't find any coding for that. If not, does anyone has programmed that yet and could post his dragging routine for that? That would be great!
I haven't done it yet but I don't see it being a problem. You would have check when the cursor is over a mesh ( you can do that with the collision detection ), then mark that mesh as selected somehow, make that mesh follow the cursor while it is selected and stop moving when the button is released or pressed again. All is possible, I suggest you get aquainted with the API as all the answers to that bit of theory are in there.
oh, I that about this way to solve the problem too, but the problem was not the theory but the coding. for example I would use getSceneNodeFromCameraBB() for the collision detection. But how to make the mesh follow the cursor I have no idea. I could find something like that in the API so if someone has an idea or still has already coded that kind of routine, it would be great!
still need help
Ok. I tried to write some code. but there are still bugs I can't figure out. Please help!
First of all I wrote in the function OnEvent() the code to get the dragging:
if ((event.EventType == irr::EET_MOUSE_INPUT_EVENT) &&
(event.MouseInput.Event == irr::EMIE_MOUSE_MOVED))
{
if (Dragging)
{
MoveOb(irr::core::position2d<irr::s32>(event.MouseInput.X -
MousPos.X, event.MouseInput.Y - MousPos.Y));
MousPos.X = event.MouseInput.X;
MousPos.Y = event.MouseInput.Y;
ret = true;
}
//Dragging = false;
}
the Dragging = true and the mouse coordinates are stored when left mouse button is pressed down and the mesh is hit. (that works fine!)
The function MoveOb does this :
void CSelfGUI::MoveOb(irr::core::position2d<irr::s32> PosM)
{
irr::core::vector3df pos = ((irr::scene::IAnimatedMeshSceneNode*)
EdEl.getLast().pElType)->getPosition();
irr::core::vector3df PosOb;
PosOb.X = (irr::f32) PosM.X;
PosOb.Y = (irr::f32) PosM.Y;
pos += PosOb;
((irr::scene::IAnimatedMeshSceneNode*)EdEl.getLast().pElType)-
>setPosition(pos);
}
Right now I take the last inserted mesh and try to get and set the Position.
What it is basicly doing right now is to move the mesh just downwards. When I set the Dragging = flase in the onEvent it just stops the moving downwards step by step . When I don't set the dragging then it moves downwards till it is not in the viewport anymore. It does not follow the mouse cursor!.
Please help!
First of all I wrote in the function OnEvent() the code to get the dragging:
if ((event.EventType == irr::EET_MOUSE_INPUT_EVENT) &&
(event.MouseInput.Event == irr::EMIE_MOUSE_MOVED))
{
if (Dragging)
{
MoveOb(irr::core::position2d<irr::s32>(event.MouseInput.X -
MousPos.X, event.MouseInput.Y - MousPos.Y));
MousPos.X = event.MouseInput.X;
MousPos.Y = event.MouseInput.Y;
ret = true;
}
//Dragging = false;
}
the Dragging = true and the mouse coordinates are stored when left mouse button is pressed down and the mesh is hit. (that works fine!)
The function MoveOb does this :
void CSelfGUI::MoveOb(irr::core::position2d<irr::s32> PosM)
{
irr::core::vector3df pos = ((irr::scene::IAnimatedMeshSceneNode*)
EdEl.getLast().pElType)->getPosition();
irr::core::vector3df PosOb;
PosOb.X = (irr::f32) PosM.X;
PosOb.Y = (irr::f32) PosM.Y;
pos += PosOb;
((irr::scene::IAnimatedMeshSceneNode*)EdEl.getLast().pElType)-
>setPosition(pos);
}
Right now I take the last inserted mesh and try to get and set the Position.
What it is basicly doing right now is to move the mesh just downwards. When I set the Dragging = flase in the onEvent it just stops the moving downwards step by step . When I don't set the dragging then it moves downwards till it is not in the viewport anymore. It does not follow the mouse cursor!.
Please help!
Even when I change the code so that I get the position of the mesh once (when I press the left mouse button down).And just store the position of the mouse once when I press the left mouse button down and try to caculate with these digits it still has the same problems.
if ((event.EventType == irr::EET_MOUSE_INPUT_EVENT) &&
(event.MouseInput.Event == irr::EMIE_MOUSE_MOVED))
{
if (Dragging)
{
MoveOb(irr::core::position2d<irr::s32>(event.MouseInput.X -
MousPos.X, event.MouseInput.Y - MousPos.Y));
ret = true;
}
// Dragging = false;
}
void CScreen::MoveOb(irr::core::position2d<irr::s32> PosM)
{
irr::core::vector3df PosOb;
PosOb.X = (irr::f32) PosM.X;
PosOb.Y = (irr::f32) PosM.Y;
posBuf = pos;
posBuf += PosOb;
((irr::scene::IAnimatedMeshSceneNode*)EdEl.getLast().pElType)-
>setPosition(posBuf);
}
if ((event.EventType == irr::EET_MOUSE_INPUT_EVENT) &&
(event.MouseInput.Event == irr::EMIE_MOUSE_MOVED))
{
if (Dragging)
{
MoveOb(irr::core::position2d<irr::s32>(event.MouseInput.X -
MousPos.X, event.MouseInput.Y - MousPos.Y));
ret = true;
}
// Dragging = false;
}
void CScreen::MoveOb(irr::core::position2d<irr::s32> PosM)
{
irr::core::vector3df PosOb;
PosOb.X = (irr::f32) PosM.X;
PosOb.Y = (irr::f32) PosM.Y;
posBuf = pos;
posBuf += PosOb;
((irr::scene::IAnimatedMeshSceneNode*)EdEl.getLast().pElType)-
>setPosition(posBuf);
}
Allright!!
I found out what the problem was! If anyone is interessted in the solution, here it is:
-----------------------------------------------------------------
in the OnEvent function
-----------------------------------------------------------------
if ((event.EventType == irr::EET_MOUSE_INPUT_EVENT) &&
(event.MouseInput.Event == irr::EMIE_LMOUSE_PRESSED_DOWN))
{
if (event.MouseInput.X >= viewportRect.UpperLeftCorner.X &&
event.MouseInput.X <= viewportRect.LowerRightCorner.X &&
event.MouseInput.Y >= viewportRect.UpperLeftCorner.Y &&
event.MouseInput.Y <= viewportRect.LowerRightCorner.Y)
{
irr::core::position2d<irr::s32> ConvertedMousePos;
irr::f32 ratio = 1024 / (irr::f32)viewportRect.getWidth();
ConvertedMousePos.X = (irr::s32)((event.MouseInput.X -
viewportRect.UpperLeftCorner.X) * ratio);
ConvertedMousePos.Y = (irr::s32)((event.MouseInput.Y -
viewportRect.UpperLeftCorner.Y) * ratio);
irr::scene::ISceneCollisionManager* pSCollMan = m_pDevice-
>getSceneManager()->getSceneCollisionManager();
irr::scene::ISceneNode* selectedNode = pSCollMan-
>getSceneNodeFromScreenCoordinatesBB(ConvertedMousePos);
if (selectedNode)
{
irr::core::position2d<irr::s32> MouseBuf (event.MouseInput.X,
event.MouseInput.Y);
MousPos = MouseBuf;
pos = ((irr::scene::IAnimatedMeshSceneNode*)EdEl.getLast
().pElType)->getPosition();
Dragging = true;
ret = true;
}
}
}
if ((event.EventType == irr::EET_MOUSE_INPUT_EVENT) &&
(event.MouseInput.Event == irr::EMIE_MOUSE_MOVED))
{
if (Dragging)
{
MoveOb(irr::core::position2d<irr::s32>(event.MouseInput.X -
MousPos.X, event.MouseInput.Y - MousPos.Y));
ret = true;
}
}
if ((event.EventType == irr::EET_MOUSE_INPUT_EVENT) &&
(event.MouseInput.Event == irr::EMIE_LMOUSE_LEFT_UP))
{
if (event.MouseInput.X >= viewportRect.UpperLeftCorner.X &&
event.MouseInput.X <= viewportRect.LowerRightCorner.X &&
event.MouseInput.Y >= viewportRect.UpperLeftCorner.Y &&
event.MouseInput.Y <= viewportRect.LowerRightCorner.Y)
{
Dragging = false;
ret = true;
}
}
---------------------------------------------------------------
the MoveOb function
---------------------------------------------------------------
void CSelfGUI::MoveOb(irr::core::position2d<irr::s32> PosM)
{
irr::f32 RatioX = ((irr::f32) 29)/640; //29and 21 stay for the number of
vectors of the same rect as 640x480
irr::f32 RatioY = ((irr::f32) 21)/480;
irr::core::vector3df PosOb;
PosOb.X = ((RatioX) * ((irr::f32) PosM.X));
PosOb.Y = ((-RatioY) * ((irr::f32) PosM.Y));
posBuf = pos;
posBuf += PosOb;
((irr::scene::IAnimatedMeshSceneNode*)EdEl.getLast().pElType)-
>setPosition(posBuf);
}
Hope that helps other programmers too
-----------------------------------------------------------------
in the OnEvent function
-----------------------------------------------------------------
if ((event.EventType == irr::EET_MOUSE_INPUT_EVENT) &&
(event.MouseInput.Event == irr::EMIE_LMOUSE_PRESSED_DOWN))
{
if (event.MouseInput.X >= viewportRect.UpperLeftCorner.X &&
event.MouseInput.X <= viewportRect.LowerRightCorner.X &&
event.MouseInput.Y >= viewportRect.UpperLeftCorner.Y &&
event.MouseInput.Y <= viewportRect.LowerRightCorner.Y)
{
irr::core::position2d<irr::s32> ConvertedMousePos;
irr::f32 ratio = 1024 / (irr::f32)viewportRect.getWidth();
ConvertedMousePos.X = (irr::s32)((event.MouseInput.X -
viewportRect.UpperLeftCorner.X) * ratio);
ConvertedMousePos.Y = (irr::s32)((event.MouseInput.Y -
viewportRect.UpperLeftCorner.Y) * ratio);
irr::scene::ISceneCollisionManager* pSCollMan = m_pDevice-
>getSceneManager()->getSceneCollisionManager();
irr::scene::ISceneNode* selectedNode = pSCollMan-
>getSceneNodeFromScreenCoordinatesBB(ConvertedMousePos);
if (selectedNode)
{
irr::core::position2d<irr::s32> MouseBuf (event.MouseInput.X,
event.MouseInput.Y);
MousPos = MouseBuf;
pos = ((irr::scene::IAnimatedMeshSceneNode*)EdEl.getLast
().pElType)->getPosition();
Dragging = true;
ret = true;
}
}
}
if ((event.EventType == irr::EET_MOUSE_INPUT_EVENT) &&
(event.MouseInput.Event == irr::EMIE_MOUSE_MOVED))
{
if (Dragging)
{
MoveOb(irr::core::position2d<irr::s32>(event.MouseInput.X -
MousPos.X, event.MouseInput.Y - MousPos.Y));
ret = true;
}
}
if ((event.EventType == irr::EET_MOUSE_INPUT_EVENT) &&
(event.MouseInput.Event == irr::EMIE_LMOUSE_LEFT_UP))
{
if (event.MouseInput.X >= viewportRect.UpperLeftCorner.X &&
event.MouseInput.X <= viewportRect.LowerRightCorner.X &&
event.MouseInput.Y >= viewportRect.UpperLeftCorner.Y &&
event.MouseInput.Y <= viewportRect.LowerRightCorner.Y)
{
Dragging = false;
ret = true;
}
}
---------------------------------------------------------------
the MoveOb function
---------------------------------------------------------------
void CSelfGUI::MoveOb(irr::core::position2d<irr::s32> PosM)
{
irr::f32 RatioX = ((irr::f32) 29)/640; //29and 21 stay for the number of
vectors of the same rect as 640x480
irr::f32 RatioY = ((irr::f32) 21)/480;
irr::core::vector3df PosOb;
PosOb.X = ((RatioX) * ((irr::f32) PosM.X));
PosOb.Y = ((-RatioY) * ((irr::f32) PosM.Y));
posBuf = pos;
posBuf += PosOb;
((irr::scene::IAnimatedMeshSceneNode*)EdEl.getLast().pElType)-
>setPosition(posBuf);
}
Hope that helps other programmers too
how do newbies use this?
Copying and pasting all of that into the Quake map example gives me errors.
What else do I need to get it to work?
What else do I need to get it to work?
event is undeclared indentifier, etc. etc.
When you say in the OnEvent function[/] where is that at? There are several functions that have OnEvent in them when I searched for it.
Can you post your working example somewhere please?
When you say in the OnEvent function[/] where is that at? There are several functions that have OnEvent in them when I searched for it.
Can you post your working example somewhere please?
h:\irrlicht-0.6\examples\2.Quake3Map\main.cpp(186) : error C2065: 'event' : undeclared identifier
h:\irrlicht-0.6\examples\2.Quake3Map\main.cpp(186) : error C2228: left of '.EventType' must have class/struct/union type
type is ''unknown-type''
h:\irrlicht-0.6\examples\2.Quake3Map\main.cpp(187) : error C2228: left of '.MouseInput' must have class/struct/union type
type is ''unknown-type''
h:\irrlicht-0.6\examples\2.Quake3Map\main.cpp(187) : error C2228: left of '.Event' must have class/struct/union type
h:\irrlicht-0.6\examples\2.Quake3Map\main.cpp(187) : error C3861: 'event': identifier not found, even with argument-dependent lookup
h:\irrlicht-0.6\examples\2.Quake3Map\main.cpp(190) : error C2228: left of '.MouseInput' must have class/struct/union type
type is ''unknown-type''
h:\irrlicht-0.6\examples\2.Quake3Map\main.cpp(190) : error C2228: left of '.X' must have class/struct/union type
h:\irrlicht-0.6\examples\2.Quake3Map\main.cpp(190) : error C2065: 'viewportRect' : undeclared identifier
h:\irrlicht-0.6\examples\2.Quake3Map\main.cpp(190) : error C2228: left of '.UpperLeftCorner' must have class/struct/union type
type is ''unknown-type''
h:\irrlicht-0.6\examples\2.Quake3Map\main.cpp(190) : error C2228: left of '.X' must have class/struct/union type
h:\irrlicht-0.6\examples\2.Quake3Map\main.cpp(191) : error C2228: left of '.MouseInput' must have class/struct/union type
type is ''unknown-type''
h:\irrlicht-0.6\examples\2.Quake3Map\main.cpp(191) : error C2228: left of '.X' must have class/struct/union type
h:\irrlicht-0.6\examples\2.Quake3Map\main.cpp(191) : error C2228: left of '.LowerRightCorner' must have class/struct/union type
type is ''unknown-type''
h:\irrlicht-0.6\examples\2.Quake3Map\main.cpp(191) : error C2228: left of '.X' must have class/struct/union type
h:\irrlicht-0.6\examples\2.Quake3Map\main.cpp(192) : error C2228: left of '.MouseInput' must have class/struct/union type
type is ''unknown-type''
h:\irrlicht-0.6\examples\2.Quake3Map\main.cpp(192) : error C2228: left of '.Y' must have class/struct/union type
h:\irrlicht-0.6\examples\2.Quake3Map\main.cpp(192) : error C2228: left of '.UpperLeftCorner' must have class/struct/union type
type is ''unknown-type''
h:\irrlicht-0.6\examples\2.Quake3Map\main.cpp(192) : error C2228: left of '.Y' must have class/struct/union type
h:\irrlicht-0.6\examples\2.Quake3Map\main.cpp(193) : error C2228: left of '.MouseInput' must have class/struct/union type
type is ''unknown-type''
h:\irrlicht-0.6\examples\2.Quake3Map\main.cpp(193) : error C2228: left of '.Y' must have class/struct/union type
h:\irrlicht-0.6\examples\2.Quake3Map\main.cpp(193) : error C2228: left of '.LowerRightCorner' must have class/struct/union type
type is ''unknown-type''
h:\irrlicht-0.6\examples\2.Quake3Map\main.cpp(193) : error C2228: left of '.Y' must have class/struct/union type
h:\irrlicht-0.6\examples\2.Quake3Map\main.cpp(190) : error C3861: 'event': identifier not found, even with argument-dependent lookup
h:\irrlicht-0.6\examples\2.Quake3Map\main.cpp(191) : error C3861: 'event': identifier not found, even with argument-dependent lookup
h:\irrlicht-0.6\examples\2.Quake3Map\main.cpp(191) : error C3861: 'viewportRect': identifier not found, even with argument-dependent lookup
h:\irrlicht-0.6\examples\2.Quake3Map\main.cpp(192) : error C3861: 'event': identifier not found, even with argument-dependent lookup
h:\irrlicht-0.6\examples\2.Quake3Map\main.cpp(192) : error C3861: 'viewportRect': identifier not found, even with argument-dependent lookup
h:\irrlicht-0.6\examples\2.Quake3Map\main.cpp(193) : error C3861: 'event': identifier not found, even with argument-dependent lookup
h:\irrlicht-0.6\examples\2.Quake3Map\main.cpp(193) : error C3861: 'viewportRect': identifier not found, even with argument-dependent lookup
h:\irrlicht-0.6\examples\2.Quake3Map\main.cpp(196) : error C2228: left of '.getWidth' must have class/struct/union type
type is ''unknown-type''
h:\irrlicht-0.6\examples\2.Quake3Map\main.cpp(196) : error C3861: 'viewportRect': identifier not found, even with argument-dependent lookup
h:\irrlicht-0.6\examples\2.Quake3Map\main.cpp(197) : error C2228: left of '.MouseInput' must have class/struct/union type
type is ''unknown-type''
h:\irrlicht-0.6\examples\2.Quake3Map\main.cpp(197) : error C2228: left of '.X' must have class/struct/union type
h:\irrlicht-0.6\examples\2.Quake3Map\main.cpp(198) : error C2228: left of '.UpperLeftCorner' must have class/struct/union type
type is ''unknown-type''
h:\irrlicht-0.6\examples\2.Quake3Map\main.cpp(198) : error C2228: left of '.X' must have class/struct/union type
h:\irrlicht-0.6\examples\2.Quake3Map\main.cpp(197) : error C3861: 'event': identifier not found, even with argument-dependent lookup
h:\irrlicht-0.6\examples\2.Quake3Map\main.cpp(198) : error C3861: 'viewportRect': identifier not found, even with argument-dependent lookup
h:\irrlicht-0.6\examples\2.Quake3Map\main.cpp(199) : error C2228: left of '.MouseInput' must have class/struct/union type
type is ''unknown-type''
h:\irrlicht-0.6\examples\2.Quake3Map\main.cpp(199) : error C2228: left of '.Y' must have class/struct/union type
h:\irrlicht-0.6\examples\2.Quake3Map\main.cpp(200) : error C2228: left of '.UpperLeftCorner' must have class/struct/union type
type is ''unknown-type''
h:\irrlicht-0.6\examples\2.Quake3Map\main.cpp(200) : error C2228: left of '.Y' must have class/struct/union type
h:\irrlicht-0.6\examples\2.Quake3Map\main.cpp(199) : error C3861: 'event': identifier not found, even with argument-dependent lookup
h:\irrlicht-0.6\examples\2.Quake3Map\main.cpp(200) : error C3861: 'viewportRect': identifier not found, even with argument-dependent lookup
h:\irrlicht-0.6\examples\2.Quake3Map\main.cpp(202) : error C2065: 'm_pDevice' : undeclared identifier
h:\irrlicht-0.6\examples\2.Quake3Map\main.cpp(203) : error C2059: syntax error : '>'
h:\irrlicht-0.6\examples\2.Quake3Map\main.cpp(205) : error C2059: syntax error : '>'
h:\irrlicht-0.6\examples\2.Quake3Map\main.cpp(209) : error C2228: left of '.MouseInput' must have class/struct/union type
type is ''unknown-type''
h:\irrlicht-0.6\examples\2.Quake3Map\main.cpp(209) : error C2228: left of '.X' must have class/struct/union type
h:\irrlicht-0.6\examples\2.Quake3Map\main.cpp(209) : error C3861: 'event': identifier not found, even with argument-dependent lookup
h:\irrlicht-0.6\examples\2.Quake3Map\main.cpp(210) : error C2228: left of '.MouseInput' must have class/struct/union type
type is ''unknown-type''
h:\irrlicht-0.6\examples\2.Quake3Map\main.cpp(210) : error C2228: left of '.Y' must have class/struct/union type
h:\irrlicht-0.6\examples\2.Quake3Map\main.cpp(210) : error C3861: 'event': identifier not found, even with argument-dependent lookup
h:\irrlicht-0.6\examples\2.Quake3Map\main.cpp(211) : error C2065: 'MousPos' : undeclared identifier
h:\irrlicht-0.6\examples\2.Quake3Map\main.cpp(212) : error C2065: 'pos' : undeclared identifier
h:\irrlicht-0.6\examples\2.Quake3Map\main.cpp(212) : error C2065: 'EdEl' : undeclared identifier
h:\irrlicht-0.6\examples\2.Quake3Map\main.cpp(213) : error C2228: left of '.getLast' must have class/struct/union type
type is ''unknown-type''
h:\irrlicht-0.6\examples\2.Quake3Map\main.cpp(213) : error C2228: left of '.pElType' must have class/struct/union type
h:\irrlicht-0.6\examples\2.Quake3Map\main.cpp(213) : error C2227: left of '->getPosition' must point to class/struct/union
h:\irrlicht-0.6\examples\2.Quake3Map\main.cpp(214) : error C2065: 'Dragging' : undeclared identifier
h:\irrlicht-0.6\examples\2.Quake3Map\main.cpp(215) : error C2065: 'ret' : undeclared identifier
h:\irrlicht-0.6\examples\2.Quake3Map\main.cpp(220) : error C2228: left of '.EventType' must have class/struct/union type
type is ''unknown-type''
h:\irrlicht-0.6\examples\2.Quake3Map\main.cpp(221) : error C2228: left of '.MouseInput' must have class/struct/union type
type is ''unknown-type''
h:\irrlicht-0.6\examples\2.Quake3Map\main.cpp(221) : error C2228: left of '.Event' must have class/struct/union type
h:\irrlicht-0.6\examples\2.Quake3Map\main.cpp(220) : error C3861: 'event': identifier not found, even with argument-dependent lookup
h:\irrlicht-0.6\examples\2.Quake3Map\main.cpp(221) : error C3861: 'event': identifier not found, even with argument-dependent lookup
h:\irrlicht-0.6\examples\2.Quake3Map\main.cpp(223) : error C3861: 'Dragging': identifier not found, even with argument-dependent lookup
h:\irrlicht-0.6\examples\2.Quake3Map\main.cpp(225) : error C2228: left of '.MouseInput' must have class/struct/union type
type is ''unknown-type''
h:\irrlicht-0.6\examples\2.Quake3Map\main.cpp(225) : error C2228: left of '.X' must have class/struct/union type
h:\irrlicht-0.6\examples\2.Quake3Map\main.cpp(226) : error C2228: left of '.X' must have class/struct/union type
type is ''unknown-type''
h:\irrlicht-0.6\examples\2.Quake3Map\main.cpp(226) : error C2228: left of '.MouseInput' must have class/struct/union type
type is ''unknown-type''
h:\irrlicht-0.6\examples\2.Quake3Map\main.cpp(226) : error C2228: left of '.Y' must have class/struct/union type
h:\irrlicht-0.6\examples\2.Quake3Map\main.cpp(226) : error C2228: left of '.Y' must have class/struct/union type
type is ''unknown-type''
h:\irrlicht-0.6\examples\2.Quake3Map\main.cpp(225) : error C3861: 'MoveOb': identifier not found, even with argument-dependent lookup
h:\irrlicht-0.6\examples\2.Quake3Map\main.cpp(225) : error C3861: 'event': identifier not found, even with argument-dependent lookup
h:\irrlicht-0.6\examples\2.Quake3Map\main.cpp(226) : error C3861: 'MousPos': identifier not found, even with argument-dependent lookup
h:\irrlicht-0.6\examples\2.Quake3Map\main.cpp(226) : error C3861: 'event': identifier not found, even with argument-dependent lookup
h:\irrlicht-0.6\examples\2.Quake3Map\main.cpp(226) : error C3861: 'MousPos': identifier not found, even with argument-dependent lookup
h:\irrlicht-0.6\examples\2.Quake3Map\main.cpp(227) : error C3861: 'ret': identifier not found, even with argument-dependent lookup
h:\irrlicht-0.6\examples\2.Quake3Map\main.cpp(231) : error C2228: left of '.EventType' must have class/struct/union type
type is ''unknown-type''
h:\irrlicht-0.6\examples\2.Quake3Map\main.cpp(232) : error C2228: left of '.MouseInput' must have class/struct/union type
type is ''unknown-type''
h:\irrlicht-0.6\examples\2.Quake3Map\main.cpp(232) : error C2228: left of '.Event' must have class/struct/union type
h:\irrlicht-0.6\examples\2.Quake3Map\main.cpp(231) : error C3861: 'event': identifier not found, even with argument-dependent lookup
h:\irrlicht-0.6\examples\2.Quake3Map\main.cpp(232) : error C3861: 'event': identifier not found, even with argument-dependent lookup
h:\irrlicht-0.6\examples\2.Quake3Map\main.cpp(234) : error C2228: left of '.MouseInput' must have class/struct/union type
type is ''unknown-type''
h:\irrlicht-0.6\examples\2.Quake3Map\main.cpp(234) : error C2228: left of '.X' must have class/struct/union type
h:\irrlicht-0.6\examples\2.Quake3Map\main.cpp(234) : error C2228: left of '.UpperLeftCorner' must have class/struct/union type
type is ''unknown-type''
h:\irrlicht-0.6\examples\2.Quake3Map\main.cpp(234) : error C2228: left of '.X' must have class/struct/union type
h:\irrlicht-0.6\examples\2.Quake3Map\main.cpp(235) : error C2228: left of '.MouseInput' must have class/struct/union type
type is ''unknown-type''
h:\irrlicht-0.6\examples\2.Quake3Map\main.cpp(235) : error C2228: left of '.X' must have class/struct/union type
h:\irrlicht-0.6\examples\2.Quake3Map\main.cpp(235) : error C2228: left of '.LowerRightCorner' must have class/struct/union type
type is ''unknown-type''
h:\irrlicht-0.6\examples\2.Quake3Map\main.cpp(235) : error C2228: left of '.X' must have class/struct/union type
h:\irrlicht-0.6\examples\2.Quake3Map\main.cpp(236) : error C2228: left of '.MouseInput' must have class/struct/union type
type is ''unknown-type''
h:\irrlicht-0.6\examples\2.Quake3Map\main.cpp(236) : error C2228: left of '.Y' must have class/struct/union type
h:\irrlicht-0.6\examples\2.Quake3Map\main.cpp(236) : error C2228: left of '.UpperLeftCorner' must have class/struct/union type
type is ''unknown-type''
h:\irrlicht-0.6\examples\2.Quake3Map\main.cpp(236) : error C2228: left of '.Y' must have class/struct/union type
h:\irrlicht-0.6\examples\2.Quake3Map\main.cpp(237) : error C2228: left of '.MouseInput' must have class/struct/union type
type is ''unknown-type''
h:\irrlicht-0.6\examples\2.Quake3Map\main.cpp(237) : error C2228: left of '.Y' must have class/struct/union type
h:\irrlicht-0.6\examples\2.Quake3Map\main.cpp(237) : error C2228: left of '.LowerRightCorner' must have class/struct/union type
type is ''unknown-type''
h:\irrlicht-0.6\examples\2.Quake3Map\main.cpp(237) : error C2228: left of '.Y' must have class/struct/union type
h:\irrlicht-0.6\examples\2.Quake3Map\main.cpp(234) : error C3861: 'event': identifier not found, even with argument-dependent lookup
h:\irrlicht-0.6\examples\2.Quake3Map\main.cpp(234) : error C3861: 'viewportRect': identifier not found, even with argument-dependent lookup
h:\irrlicht-0.6\examples\2.Quake3Map\main.cpp(237) : fatal error C1003: error count exceeds 100; stopping compilation
Quake3Map - 102 error(s)
Hi, first of all you need to get comfortable with the onEvent functions in the demos, because my OnEvent is probably a little complex for a newbie.
Thats why it makes no sense to put all my classes into this forum.But I try to give you a hint how to start. In every program where you have interaction with it you need an EventReciever. This EventReciever has to be set for example in the main function like I did:
CMyEventReceiver MyEventReceiver(s_pDevice, GuiEnv, pMyScreen);
// this line creates MyEventReciever which I show you further down with the arguments Irrlichtdevice, Irrlichtenvironment and the Screen where my Events will be. There could be more screen and than you have to change the current Screen, but we leave it at one screen. It is important to include the CMyEventReceiver class in the main function: #include "CMyEventReceiver.h"
s_pDevice->setEventReceiver( &MyEventReceiverEd );
// this line sets the EventReciever.
This is my EventReciever:
#include "EventReceiverEd.h"
#include "Global.h"
#include "Screen.h"
CMyEventReceiver::CMyEventReceiver(irr::IrrlichtDevice* device, irr::gui::IGUIEnvironment* GuiEnv, CScreen* pMyScreen)
{
m_pDevice = device;
m_pGuiEnv = GuiEnv;
listbox = 0;
cnt = 0;
m_pScreen= pMyScreen;
}
CMyEventReceiver::~CMyEventReceiver()
{
}
bool CMyEventReceiver::OnEvent(irr::SEvent event)
{
bool ret = false;
m_EventReceived = true;
if ( (event.EventType == irr::EET_GUI_EVENT) ||
(event.EventType == irr::EET_MOUSE_INPUT_EVENT) )
{
ret = m_pScreen->OnEvent(event);
}
else
{
// we did not handle the event, so leave it to the Irrlicht engine
ret = false;
}
return ret;
}
What actually happens here is that I give the event to that screen where the event happens. In this case: class CScreen. The MyEventReciever has to inherit from the Irrlicht eventreciever what you have to set in the header:
class CEventReceiverEd : public irr::IEventReceiver
Now most of the work is done (but you still have to fit it to your program, it probably won't work at the first time, because it is to indiviuall) But if you get comfortable with it you will learn to specify it.
Event the OnEventfunction I wrote there are lots of line you need to adjust to your programm:
((irr::scene::IAnimatedMeshSceneNode*)EdEl.getLast
().pElType)->
There I get the last insert Mesh from the class CEdEl. you need to change these kind of things.
Hope I could give you a start hint.
Thats why it makes no sense to put all my classes into this forum.But I try to give you a hint how to start. In every program where you have interaction with it you need an EventReciever. This EventReciever has to be set for example in the main function like I did:
CMyEventReceiver MyEventReceiver(s_pDevice, GuiEnv, pMyScreen);
// this line creates MyEventReciever which I show you further down with the arguments Irrlichtdevice, Irrlichtenvironment and the Screen where my Events will be. There could be more screen and than you have to change the current Screen, but we leave it at one screen. It is important to include the CMyEventReceiver class in the main function: #include "CMyEventReceiver.h"
s_pDevice->setEventReceiver( &MyEventReceiverEd );
// this line sets the EventReciever.
This is my EventReciever:
#include "EventReceiverEd.h"
#include "Global.h"
#include "Screen.h"
CMyEventReceiver::CMyEventReceiver(irr::IrrlichtDevice* device, irr::gui::IGUIEnvironment* GuiEnv, CScreen* pMyScreen)
{
m_pDevice = device;
m_pGuiEnv = GuiEnv;
listbox = 0;
cnt = 0;
m_pScreen= pMyScreen;
}
CMyEventReceiver::~CMyEventReceiver()
{
}
bool CMyEventReceiver::OnEvent(irr::SEvent event)
{
bool ret = false;
m_EventReceived = true;
if ( (event.EventType == irr::EET_GUI_EVENT) ||
(event.EventType == irr::EET_MOUSE_INPUT_EVENT) )
{
ret = m_pScreen->OnEvent(event);
}
else
{
// we did not handle the event, so leave it to the Irrlicht engine
ret = false;
}
return ret;
}
What actually happens here is that I give the event to that screen where the event happens. In this case: class CScreen. The MyEventReciever has to inherit from the Irrlicht eventreciever what you have to set in the header:
class CEventReceiverEd : public irr::IEventReceiver
Now most of the work is done (but you still have to fit it to your program, it probably won't work at the first time, because it is to indiviuall) But if you get comfortable with it you will learn to specify it.
Event the OnEventfunction I wrote there are lots of line you need to adjust to your programm:
((irr::scene::IAnimatedMeshSceneNode*)EdEl.getLast
().pElType)->
There I get the last insert Mesh from the class CEdEl. you need to change these kind of things.
Hope I could give you a start hint.