Page 2 of 2

Posted: Thu May 12, 2011 2:22 pm
by TekniX
Hey Kazymjir , thanks a buch, did a quick search for it but didnt find anything usable :oops: . I think I have to recompile irrlicht for this, but I have to do this at home, so I wont really be able to tell you if it worked until tonight ( which is in aprox. 3.5 / 4 hours ) . Thanks for your help man :) until now I have this ( which fails because of the vector4d )

Code: Select all


					core::vector4df a = (nodePos.X,nodePos.Y,nodePos.Z,1);
					core::vector3df temp = intersectPlane.Normal;
					core::vector4df pRot = (temp.X,temp.Y,temp.Z,1);
					core::matrix4 mRot;
					mRot.setRotationDegrees(pRot);
					core::matrix4 iRot;
					if(!mRot.getInverse(iRot))
						cout << "\n smthing wrong cldnt get inverse rot matrix";
					core::vector4df t = (1,mOffY,mOffX,1);
					core::vector4df newPos = mRot * t * iRot * a;
					
@Lonesome Ducky : Ok, I didnt quite understand why we do this at a distance from 1, because the node is probably going to be a lot further away, but ill wait and see maybe I understand later :). Thank you !

Regards

TekniX

Posted: Thu May 12, 2011 8:56 pm
by Lonesome Ducky
The problem happened to be that I didn't divide by the screen dimensions like I should have:

Code: Select all

vector3df get3DCameraPlanePos(ICameraSceneNode* camera, position2di position, dimension2di screenSize) {
   vector2df offPos(((screenSize.Width-position.X)/(float)screenSize.Width)*2.0f-1.0f,-(((screenSize.Height-position.Y)/(float)screenSize.Height)*2.0f-1.0f));
   vector3df center = camera->getAbsolutePosition()+camera->getAbsoluteTransformation().getRotationDegrees().rotationToDirection();
   vector3df dirX = (camera->getViewFrustum()->getFarRightUp()-camera->getViewFrustum()->getFarLeftUp()).normalize();
   vector3df dirY = (camera->getViewFrustum()->getFarRightDown()-camera->getViewFrustum()->getFarRightUp()).normalize();
   return center+dirX*offPos.X-dirY*offPos.Y;
}
The distance of 1 is used so that the screen's edges are at -1 and 1. You can find the direction between the camera and the position returned, normalize it, and multiply by the distance away you want it to be.

Posted: Tue May 17, 2011 5:32 am
by agamemnus
Not sure if this is what you're looking for (probably not.. but worth a try), but try/look at this:

"RTS/simulation overhead camera function."
http://irrlicht.sourceforge.net/phpBB2/ ... hp?t=43470

Posted: Thu May 19, 2011 9:27 am
by TekniX
@Agamemnus : Not really but I had a look at it ;) .

Actually I solved this problem for now. Later on in development I will come back and solve it the right way ;) . Thank you all for now :)

Greetings TekniX

Posted: Sat May 21, 2011 6:34 pm
by gerdb
@author

stefbuet said all you need to know

Initial camera vectors, when there was no rotation and positioning

RIGHT ( 1,0,0 )
UP ( 0,1,0 )
LOOKAT ( 0,0,1 )

as you can see, its the identitymatrix

the basis vectors of your plane are RIGHT and UP

so if the camera is rotated or translated these vectors are the same way
transformed too.

View = Rotation*Translate*World

--> new basis vectors of plane, of course in world system coords
RIGHT' = View * RIGHT
UP' = View * UP

cya

ok

Posted: Mon May 30, 2011 11:17 am
by TekniX
I think I have it now ;)

thank you a lot guys :) !

Greetings

TekniX