Cannot CameraPick() with loadAnimMesh?

Blitz3D Forums/Blitz3D Programming/Cannot CameraPick() with loadAnimMesh?

Hi!

I tried to cameraPick animMeshes and meshes.
Meshes work fine, but animMeshes not.

I use:

Function targetbox(ent)
	If ent=0 Return 0
	If EntityInView(ent,camera)=0 Return 0
	CameraProject camera,EntityX(ent),EntityY(ent),EntityZ(ent)
	leftmost#=ProjectedX()
	rightmost#=ProjectedX()
	topmost#=ProjectedY()
	bottommost#=ProjectedY()
	;RuntimeError (leftmost#+" "+rightmost#+" "+topmost#+" "+bottommost#)
	For i=1 To CountSurfaces(ent)
		s=GetSurface(ent,1)
		For v=0 To CountVertices(s)-1
			TFormPoint VertexX(s,v),VertexY(s,v),VertexZ(s,v),ent,0
			CameraProject camera,TFormedX(),TFormedY(),TFormedZ()
			If ProjectedX()<leftmost leftmost=ProjectedX()
			If ProjectedX()>rightmost rightmost=ProjectedX()
			If ProjectedY()<topmost topmost=ProjectedY()
			If ProjectedY()>bottommost bottommost=ProjectedY()
		Next
	Next
	Rect leftmost,topmost,rightmost-leftmost,bottommost-topmost,0
End Function



...to draw a box around the objects, as feedforward.

Can't I pick animMeshes at all?

Jeroen,

Just a thought but you may have to make them pickable. There is a code archive for this I believe, I'd check the archives out.

[Sorry about this I always seem to suggest you start there, but the place is full of excellent little nuggets of information and examples.]

I think you may also have to find all the children and make them picakble too.

Have a route about, look for parent/children items and pickable items, you'll find it there somewhere I hope.


IPete2.

Hey iPete2,

Thanks for your suggestions so far.
I did made it pickable. I tried option 2 and 3 (cube and polygon).

Secondly I used countChildren/getChild to make them pickable as well, but it seems not to be working (unlike using this trick for entityAlpha and so on).

Hmm,

Then I'm out of suggestions for now, perhaps someone else can be of assistance?

Did you check out the bug forum to see its not a noted bug of some kind?

Keep asking, someone will know why. I seem to remember something about animmeshs having collision problems on frames other than the first frame too, I wonder if that's connected.

IPete2.

Is it a skinned or segmented mesh?

I works, somehow. You need to make the children pickable and it will return the handle of the picked child. Using getparent you can find the used entity. Using EntityClass$() can be used to test if the children are meshes or bones, and of course, only use it with meshes. Skinned ones (usually B3D) normaly have bones-children, segmeted eg. 3ds or .x have mesh children.

Take a look at your code is my advice - its likely the problem lies there. I created a mock 'lobby' scene using a 3DS mesh loaded in using LoadAnimMesh and set the destructable areas to be pickable. Worked fine.

Thanks!

I can't find anything on EntityClass in the docs or forum....what does it return?

EntityClass$() should return "Mesh" or "Bone" maybe some others ... "Camera". I haven't actually used it yet but just guessing.

What it returns is listed in the updates file in your Blitz3D directory.

[code]
For N = 1 To CountChildren(m\entity)
If Lower$(EntityClass$(GetChild(m\entity,N))) = "mesh"
EntityPickMode GetChild(m\entity,N),2
Next
[code]

I tried the above and it partially works:
the rectangle around the mesh is sized wrong, and on entities that actually animate, there is no rectangle at all :(