EntiyPick
Blitz3D Forums/Blitz3D Programming/EntiyPick
| ||
![]() Hi I have a problem, the cube as the vectors can be collected with the mouse, however if the vector is above the bucket, I can not selecionar, plays take from the tips that are outside the cube. The vectors are drawn with an order of EntityOrder, any suggestions? |
| ||
Try to be more precise in what you say, your 3d arrows are not vectors, they are 3d meshes. Vectors are 2d/3d lines in 2d/3d space with a direction and a length. You want to set the 3 arrows meshes as pickable meshes (entitypickmode(Mesh,2)) and not set the cube as pickable, else the cube will be picked first. |
| ||
I answered this problem on your last topic, when you have one cube selected, you need to hide it before the new pick and show it back just after. Or RemiD suggestion can be nice too, while a cube is selected, make it not pickable again until it is deselected. |
| ||
Hello, the translator of google not help much. You flanker, you mean this?For c.cube = Each cube HideEntity c\mesh Next CameraPick camera,MouseX(),MouseY() For c.cube = Each cube ShowEntity c\mesh Next Today I have work shift 24 hours when I get home I check this. |
| ||
Yes something like that, but you will have to check first if you have a cube selected :If cubeSelected For c.cube = Each cube HideEntity c\mesh Next EndIf CameraPick camera,MouseX(),MouseY() If cubeSelected For c.cube = Each cube ShowEntity c\mesh Next EndIf |
| ||
An alternative that i use in my codes :;before linepick For c.cube = each cube entitypickmode(c\mesh,2) Next ;linepick Linepick() If( PickedEntity() <> 0 ) ; endif ;after linepick For c.cube = each cube entitypickmode(c\mesh,0) Next |
| ||
Try to be more precise in what you say, your 3d arrows are not vectors, they are 3d meshes. Vectors are 2d/3d lines in 2d/3d space with a direction and a length. A vector is a mathematical construct and dos not exist in 2, 3 or any dimensionality. A vector is a quantitative description of both magnitude and direction that's all. They are not lines and vectors may have "no length" (i.e. zero magnitude). |
| ||
@_PJ_>>ok, but you get what i meant, arrow shapes and vectors are not the same thing. I should have said that vectors are math concepts which have a direction and a length. "magnitude" is an unknown word for a person without a math education. |
| ||
Ok, here no work. Cube not visible ; cubos.Tcubo = cube.Tcube For cubos.TCubo = Each TCubo For x% = 0 To 99 If cubos\cubo[x%] Then ; Selector on Cube If FindChild(cubos\cubo[x%],"Selector") Then HideEntity cubos\cubo[x%] End If CameraPick(camara\camara%,MouseX(),MouseY()) If FindChild(cubos\cubo[x%],"Selector") = False Then ShowEntity cubos\cubo[x%] End If End If Next Next |
| ||
Can you post a little more f your code? particularly tht which populate cubo[] field and assigns the NameEntity INSTANCE\cubo[ENTITY_HANDLE_AS_INDEX] This might help identify what's going wrong. |
| ||
Ok _PJ_ Problem, No select mesh selector for moven on cube, out cube yes. |
| ||
Parent mesh Selector. Create Cube. Move Cube. |
| ||
Well, there will need to be a NameEntity SelMovimiento\selector,"Selector" for each instance created Also, the PickedEntity() commandc ideally should follow the EntityPick/LinePick/CameraPick. Personally I would pass a variable containing the result of PickedEntity into the function itself: [code] CameraPick() Picked=PickedEntity() AsignarSelectorCubos(instance.TPEntes,Picked) Function AsignarSelectorCubos( propiedades.TPEntes, LastPicked) For cubos.TCubo = Each TCubo For x% = 0 To 99 If cubos\cubo[x%] Then If LastPicked = cubos\cubo[x%] Then |
| ||
Sorry you updated your post while I was writing my one. I'm going to sleep now but will help more tomorrow. |
| ||
If you parent the axis to your cube then hide the entity for picking the axis, you also hide the axis due to all the cube's hierarchy being hidden. But, your problem can be solved with another way : Do a linepick instead, then, if the pickedentity is the same as the previous pick, use the picked position to start another picking using another LinePick (loop until you don't pick anything or something different). Graphics3D 800,600,0,2 SetBuffer backBuffer() AmbientLight 0,0,0 Local light = CreateLight(2) MoveEntity light, 200,1000,-200 LightColor light, 255,180,120 Local cam = CreateCamera() MoveEntity cam, 5,5,-5 TurnEntity cam, 45,45,0 Local sphere = CreateSphere(32) : nameEntity sphere, "sphere" MoveEntity sphere, 0,1,0 EntityPickMode sphere, 2 Local plane = CreateCube() : nameEntity plane, "plane" ScaleEntity plane, 3,.5,3 PositionEntity plane, 0,-.5,0 EntityPickMode plane, 2 Local picked Repeat If MouseHit(1) If picked<>0 Then EntityColor picked, 255,255,255 picked = CamPick(cam, MouseX(),MouseY(), .1,10000, picked) If picked<>0 Then EntityColor picked, Rand(100,255),Rand(100,255),Rand(100,255) EndIf RenderWorld() Flip True Until KeyDown(1) End Function CamPick%(cam, x%,y%, RangeNear#=0.1, RangeFar#=10000.0, LastSelected%=0) ; transform 2D coords to 3D space Local l_Ratio# = Float(GraphicsHeight())/GraphicsWidth(); Local l_x# = -1 + 2.0 * Float(x)/GraphicsWidth(); Local l_y# = l_Ratio - 2.0 * Float(y) / GraphicsWidth(); ; start of picking TFormPoint l_x*RangeNear,l_y*RangeNear,RangeNear,cam, 0 Local l_X0# = TFormedX(), l_Y0# = TFormedY(), l_Z0# = TFormedZ() ; project far point TFormPoint l_x*RangeFar,l_y*RangeFar,RangeFar,cam, 0 Local l_X1# = TFormedX(), l_Y1# = TFormedY(), l_Z1# = TFormedZ() ; create a vector between the two points Local l_Vx# = l_X1-l_X0, l_Vy# = l_Y1-l_Y0, l_Vz# = l_Z1-l_Z0 ; launch first pick test LinePick l_X0,l_Y0,l_Z0, l_Vx,l_Vy,l_Vz ; if nothing then return 0 If PickedEntity()=0 Then LastSelected=0 : Return 0 If PickedEntity()<>LastSelected Then Return PickedEntity() ; normalize and scale very small Local l_Dv# = 0.005; Local l_DeltaX# = l_Vx; Local l_DeltaY# = l_Vy; Local l_DeltaZ# = l_Vz; Local l_DeltaN# = 1.0/Sqr(l_DeltaX*l_DeltaX+l_DeltaY*l_DeltaY+l_DeltaZ*l_DeltaZ); l_DeltaX = (l_DeltaX * l_DeltaN)*l_Dv; l_DeltaY = (l_DeltaY * l_DeltaN)*l_Dv; l_DeltaZ = (l_DeltaZ * l_DeltaN)*l_Dv; ; pick until something is hit and is not the last picked thing ; at each iteration use the last picking position and move along the vector with the Delta vector, so ; the next picking will start a bit farther Local Loop = 100 While Loop>0 l_X0 = PickedX()+l_DeltaX l_Y0 = PickedY()+l_DeltaY l_Z0 = PickedZ()+l_DeltaZ LinePick (l_X0,l_Y0,l_Z0, l_Vx,l_Vy,l_Vz) Select PickedEntity() Case 0 : Return 0 Case LastSelected Default Return PickedEntity() End Select Loop = Loop - 1 Wend Return 0 End Function |