Оператор ЭВМ
Регистрация: 13.08.2009
Сообщений: 22
Написано 0 полезных сообщений (для 0 пользователей)
|
Ответ: Блокирование курсора
Сообщение от softcrasoft
Да. я не знаю как узнать на какой позиции y курсора он захватит объект. то есть на какойкоординате y курсора все объекты
|
Вот готовый пример(Наверное) теперь ты сможешь узнать на какой позиции Y "он" захватит объект.
Graphics3D 800,600
sphere=CreateSphere() EntityPickMode sphere,1
For k=1 To 100 model=CopyEntity( sphere ) EntityColor model,Rnd(255),Rnd(255),Rnd(255) EntityShininess model,Rnd(1) rad#=Rnd(1,2) EntityRadius model,rad ScaleEntity model,rad,rad,rad TurnEntity model,Rnd(360),Rnd(360),0 MoveEntity model,0,0,Rnd(20)+20 Next
FreeEntity sphere
light=CreateLight() TurnEntity light,45,45,0
camera=CreateCamera() CameraRange camera,.1,1000
entity=0
zoom#=1
While Not KeyHit(1) UpdateWorld RenderWorld
If KeyDown(30) zoom=zoom*1.1 If KeyDown(44) zoom=zoom/1.1 CameraZoom camera,zoom
x=MouseX() y=MouseY() If y<32 TurnEntity camera,-2,0,0 If y>480-32 TurnEntity camera,2,0,0 If x<32 TurnEntity camera,0,2,0 If x>640-32 TurnEntity camera,0,-2,0 e=CameraPick( camera,x,y ) If e<>entity If entity Then Draw_Wire_2D(entity,camera,0,0,0) entity=e EndIf If entity Draw_Wire_2D(entity,camera,250,250,250) EndIf Rect x,y-3,1,7 Rect x-3,y,7,1 Flip
Wend
Function Draw_Wire_2D(mesh,cam,red=0,grn=0,blu=0) Color red,grn,blu If EntityInView(mesh,cam)=False Then Return cnt=CountSurfaces(mesh) For a=1 To cnt surf=GetSurface(mesh,a) For tri=0 To CountTriangles(surf)-1 TFormPoint VertexX(surf,TriangleVertex(surf,tri,0)),VertexY(surf,TriangleVertex(surf,tri,0)),VertexZ(surf,TriangleVertex(surf,tri,0)),mesh,0 CameraProject(cam,TFormedX(),TFormedY(),TFormedZ()) sx1=ProjectedX() sy1=ProjectedY() TFormPoint VertexX(surf,TriangleVertex(surf,tri,1)),VertexY(surf,TriangleVertex(surf,tri,1)),VertexZ(surf,TriangleVertex(surf,tri,1)),mesh,0 CameraProject(cam,TFormedX(),TFormedY(),TFormedZ()) sx2=ProjectedX() sy2=ProjectedY() TFormPoint VertexX(surf,TriangleVertex(surf,tri,2)),VertexY(surf,TriangleVertex(surf,tri,2)),VertexZ(surf,TriangleVertex(surf,tri,2)),mesh,0 CameraProject(cam,TFormedX(),TFormedY(),TFormedZ()) sx3=ProjectedX() sy3=ProjectedY() If Check_Cull_2D(sx1,sy1,sx2,sy2,sx3,sy3)<0 Line sx1,sy1,sx2,sy2 Line sx2,sy2,sx3,sy3 Line sx3,sy3,sx1,sy1 End If Next Next End Function
Function Check_Cull_2D(x1,y1,x2,y2,x3,y3) Return (x1-x2)*(y3-y2)-(y1-y2)*(x3-x2) End Function
А если нет, начнём разговор сначала.
|