I am wondering if Irrlicht engine can handle the case in which the user clicks the left-mouse button and drags and drops to create a rectangular selection.
For example,
My question is how I can draw this rectangular selection? I think it should be drawn in another scene manager, shouldn't it?
How to build walls?
You can use ISceneCollisionManager ::getRayFromScreenCoordinates to create a ray which you can then collide against a plane to get a point in 3D. The plane basically sets the height at which you want that ray to collide so in your case it will probably have normal vector pointing upwards and a d value of your height (usually the y of your floor-height).
Some example code here how to use getRayFromScreenCoordinates: http://irrlicht.sourceforge.net/phpBB2/ ... oordinates
Some example code here how to use getRayFromScreenCoordinates: http://irrlicht.sourceforge.net/phpBB2/ ... oordinates
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
here is my not finished game constructor http://kolosov.ath.cx/pyge.zip
walls drawing with mouse as plane mesh on grid
source is python script, but it is similar c++
walls drawing with mouse as plane mesh on grid
source is python script, but it is similar c++
Thanks for your advice.CuteAlien wrote:You can use ISceneCollisionManager ::getRayFromScreenCoordinates to create a ray which you can then collide against a plane to get a point in 3D. The plane basically sets the height at which you want that ray to collide so in your case it will probably have normal vector pointing upwards and a d value of your height (usually the y of your floor-height).
Some example code here how to use getRayFromScreenCoordinates: http://irrlicht.sourceforge.net/phpBB2/ ... oordinates
But how are the lines drawn? How to represent the rectangle? Which API should be used?
Now, I can get the starting and ending 3D points of the selection. I would like to represent the wall by a cube with a certain texture.
So, you can imagine that I have already selected a plane in planeXZ after dragging& dropping the left mouse button, how can I set the wall which has its bottom y-value = that planeXZ.y value? And how to set the wall height based on the bottom?
Last edited by wsw1231 on Sat Mar 05, 2011 8:43 am, edited 1 time in total.
Would draw3DBox() be better?_maxim_ wrote:IVideoDriver->draw3DLine(vector3d<f32> start, vector3d<f32> end) see my link abovewsw1231 wrote:But how are the lines drawn? How to represent the rectangle? Which API should be used?
IVideoDriver->draw2DRectangle(SColor, rect<s32>(X1, Y1, X2, Y2))
from 2DGraphics example 6
Because in my case, the selection is on the planeXZ, so it is reasonable to make the selection rectangle to be 3D but with y-value = 0.
But I am not sure how to use that API
Edit:
OK, I think draw3DBox can do if I set the box minEdge and maxEdge y values to 0.
But can I fill alpha color to the 3D Box?
Yes, better choice.
This code draw rectangle, sorry for python
alpha change has no effect for me, perhaps must be first change line width
This code draw rectangle, sorry for python
Code: Select all
device = createDevice(EDT_OPENGL, dimension2du(640, 480))
driver = device.getVideoDriver()
smgr = device.getSceneManager()
camera = smgr.addCameraSceneNodeFPS()
camera.setPosition(vector3df(50,200,50))
m = SMaterial()
m.Lighting = False
matrix = matrix4()
while device.run():
driver.beginScene(True, True, SColor(255,0,0,255))
driver.setMaterial(m)# for valid color
driver.setTransform(ETS_WORLD, matrix)# for valid detection 3d coords
driver.draw3DBox(aabbox3df(0,0,0,100,0,100), SColor(128,255,0,0))
smgr.drawAll()
driver.endScene()
device.drop()
Thanks for your code. I will try it later._maxim_ wrote:Yes, better choice.
This code draw rectangle, sorry for python
alpha change has no effect for me, perhaps must be first change line widthCode: Select all
device = createDevice(EDT_OPENGL, dimension2du(640, 480)) driver = device.getVideoDriver() smgr = device.getSceneManager() camera = smgr.addCameraSceneNodeFPS() camera.setPosition(vector3df(50,200,50)) m = SMaterial() m.Lighting = False matrix = matrix4() while device.run(): driver.beginScene(True, True, SColor(255,0,0,255)) driver.setMaterial(m)# for valid color driver.setTransform(ETS_WORLD, matrix)# for valid detection 3d coords driver.draw3DBox(aabbox3df(0,0,0,100,0,100), SColor(128,255,0,0)) smgr.drawAll() driver.endScene() device.drop()
For the alpha color, I think you misunderstood my meaning. I would like to apply alpha color to the selection region instead of the border of the selection region. That means what I am asking is how to fill alpha color to that aabbox3d