BTW jakie polecacie narzedzie do tworzenia obiektow .x ???
Dzieki!
PS. wyslane na 3 grupy na raz :-)
--
gRiTs!!!
>>>>>>Pawel Halastra 'FRT'
>>>>>>fortar (at) o2 (dot) pl
>>>>>>http://3imagination.com
>>>>>>http://www.fortar.host.sk
>>>>>>ICQ: 35715927 GG: 5426327
pozdr.
st3tc
Po 100x dzieki! Zaraz zabieram sie wdrazanie tego w zycie :-)
bool CheckMouseHit(int xPos, int yPos)
{
IntersectInformation intInformation = new IntersectInformation();
float dist = float.MaxValue;
Object3D object3D = null;
Vector3 s, d, rPosition, rDirection;
foreach ( Object3D obj3D in renderObjects )
{
s = Vector3.Unproject(new Vector3( xPos, yPos, 0),
deviceD3D.Viewport,
deviceD3D.Transform.Projection,
deviceD3D.Transform.View,
deviceD3D.Transform.World );
d = Vector3.Unproject(new Vector3( xPos, yPos, 1),
deviceD3D.Viewport,
deviceD3D.Transform.Projection,
deviceD3D.Transform.View,
deviceD3D.Transform.World );
rPosition = s;
rDirection = Vector3.Normalize(d-s);
if ( obj3D.Mesh.Intersect( rPosition,
rDirection,
ref intInformation ) )
{
if ( intInformation.Dist < dist )
{
dist = intInformation.Dist;
object3D = obj3D;
}
}
}
if ( object3D != null )
{
// mamy obiekt i teraz "cos" trzeba z nim zrobic :)
return true;
}
return false;
}
Nie jest to trywialne. Szukajac zaczalem od tego:
http://www.tek-tips.com/viewthread.cfm?qid=882560&page=1
Zajrzyj troche na ta stronke.
Zajrzyj tez w sample do DXa: '...you can look in the Pick sample in the
DX SDK and see an example of how this is done...'
'...you determine a line from the
camera to the point where the mouse click is (transformed
to the 3d world) and check for every triangle of the
object if there is an intersection...'
Tez za bardzo przykladu nie rozumiem, bo algebre liniowa mialem 3 lata
temu, ale jesli dziala to dziala :)
Znalazlem cos jeszcze:
http://www.experts-exchange.com/Programming/Game_Development/3D_Programming/Q_20812666.html
Do poczytania. Sadze ze to rozwiaze Twoje problemy w calosci.
PS. Szukanie w internecie to bardzo przydatna umiejetnosc, ktorej
programisci zdaja sie nie dostrzegac.
Wpisalem w google: directX pick object 3d mouse
:D
Adam