Bounding Box not working on LoadAnimMesh ( ) ?

Blitz3D Forums/Blitz3D Programming/Bounding Box not working on LoadAnimMesh ( ) ?

Guy Fawkes(Posted 2016) [#1]
Hi all. For some reason, this code only works for entities created inside of Blitz3D. Not anything with LoadAnimMesh ( ). How can I fix this?

EntityBox_Lib.bb:





Thank You for the help! =)

~GF


RemiD(Posted 2016) [#2]
Your weird indentation disturbs me. (Sorry)


We have already discussed about skinned animated mesh and the tpose in another post, don't you remember ? Here : http://www.blitzbasic.com/Community/posts.php?topic=105302

You can get the position of skinned animated vertices in any pose by using the ugrade vB.001 and vB.002 by Bobysait, here : http://www.blitzbasic.com/Community/posts.php?topic=105408

What do you want to accomplish exactly ?


Guy Fawkes(Posted 2016) [#3]
I basically want to put a Bounding box no matter what size or position the animated mesh is around the animated mesh. That is all.

~GF


RemiD(Posted 2016) [#4]
You could define manually the width,height,depth of the bounding box depending on the approximate width,height,depth used by the animated mesh when in a specific pose.

Or you could parent pivots to the extremities of each bodypart (hips, head, lefthand, righthand, leftfoot, rightfoot) and use their positions to determine the width,height, depth of the space used by the animated mesh when in a specific pose (between minx,miny,minz and maxx,maxy,maxz)

Or you could use the upgrade vB.001/vB.002 to be able to get the global position of each skinned vertex while the mesh is animating in order to dertermine the space used by the animated mesh when in a specific pose...


Guy Fawkes(Posted 2016) [#5]
I decided to use vB.003. But still the same problem. I can't get LoadAnimMesh ( ) to work with the Bounding Box and now with the Plot Points on Vertices functions... :(

EntityBox_Lib.bb:





Thank You, Remi.

~GF


RemiD(Posted 2016) [#6]
Did you managed to get the skinned vertices positions while the mesh is animating ?
If no, i can provide an example.

For your other problem, you will have to learn to debug your code (i use debuglog and 3dmarkers to understand what is going on)

For example, for each vertex, get the vertex position, then create a marker (cube scaled 0.01,0.01,0.01), then position the marker at the vertex position, then position the camera near enough the mesh, then oriente the camera towards the vertex, then renderword flip waitkey, then check visually if the marker seems to be positionned at the correct position. This should help you to see if you can get the correct position of each vertex... Then debug your procedure to find the error and fix it...

Keep in mind that with rigged skinned animated meshes you have to use scaleentity, never scalemesh !


Guy Fawkes(Posted 2016) [#7]
Remi. You don't get it. My code works fine. What I'm saying is the functions won't activate on LoadAnimMesh ( ) like they do on LoadMesh ( ). Which is the whole point of this post in the 1st place.

~GF


RemiD(Posted 2016) [#8]
edit... You haven't answered this :

Did you managed to get the skinned vertices positions while the mesh is animating ?


and debug visually with markers to make sure the positions you get are correct...


Guy Fawkes(Posted 2016) [#9]
No, I did not. Why are you being so difficult to be around? You're sapping energy from me... Why is it SO hard for you to break your lame-stream programming & come to help those in need? I broke mine 3 years ago! And I've NEVER felt better! But you.. YOU will NEVER help people. All that you will do is give them the same indoctrination BULL CRAP that you give me. So you know what? Unless you have come to actually help leave this thread. Otherwise, I'm glad to have you.

~GF


RemiD(Posted 2016) [#10]
Not sure why you are angry, i have asked a question to make sure that you did this step properly...

In the code that you posted, there is the function PlotMeshVertices() which shows how to use the new functions created by Bobysait to get the skinned vertices positions (the names of his functions are incorrect, it should be SkinnedVertexX(), SkinnedVertexY(), SkinnedVertexZ(), but whatever...)
So, to get the position of a skinned vertex (a vertex which is influenced by a joint/bone), you need to use these new functions :
VertexRiggedX(MeshRef%,SurfaceRef%,VertexIndex%)
VertexRiggedY(MeshRef%,SurfaceRef%,VertexIndex%)
VertexRiggedZ(MeshRef%,SurfaceRef%,VertexIndex%)
instead of the usual functions :
VertexX(MeshRef%,SurfaceRef%,VertexIndex%)
VertexY(MeshRef%,SurfaceRef%,VertexIndex%)
VertexZ(MeshRef%,SurfaceRef%,VertexIndex%)

(notice how i have no problem with most members on these forums but you have problems with several members, and then reread your last post...)

So you will probably need 2 functions, one for meshes with notskinned vertices and one for meshes with skinned vertices. Or maybe add a flag in your function to know when to use VertexXYZ or VertexRiggedXYZ (depending on if the mesh is notrigged notskinned or rigged skinned)


Guy Fawkes(Posted 2016) [#11]

Not sure why you are angry, i have asked a question to make sure that you did this step properly...

In the code that you posted, there is the function PlotMeshVertices() which shows how to use the new functions created by Bobysait to get the skinned vertices positions (the names of his functions are incorrect, it should be SkinnedVertexX(), SkinnedVertexY(), SkinnedVertexZ(), but whatever...)
So, to get the position of a skinned vertex (a vertex which is influenced by a joint/bone), you need to use these new functions :
VertexRiggedX(MeshRef%,SurfaceRef%,VertexIndex%)
VertexRiggedY(MeshRef%,SurfaceRef%,VertexIndex%)
VertexRiggedZ(MeshRef%,SurfaceRef%,VertexIndex%)
instead of the usual functions :
VertexX(MeshRef%,SurfaceRef%,VertexIndex%)
VertexY(MeshRef%,SurfaceRef%,VertexIndex%)
VertexZ(MeshRef%,SurfaceRef%,VertexIndex%)

(notice how i have no problem with most members on these forums but you have problems with several members, and then reread your last post...)

So you will probably need 2 functions, one for meshes with notskinned vertices and one for meshes with skinned vertices. Or maybe add a flag in your function to know when to use VertexXYZ or VertexRiggedXYZ (depending on if the mesh is notrigged notskinned or rigged skinned)



Where's the question?

~GF


RemiD(Posted 2016) [#12]
I just gave you the solution in my previous post...
The error is (i think) in the function GetMeshExtents(), now use your brain and make it happen.


Guy Fawkes(Posted 2016) [#13]
Nope. Try again.




RemiD(Posted 2016) [#14]
I won't debug your code for you, i have explained what i would do and how, now it's your problem. Good luck anyway.


Guy Fawkes(Posted 2016) [#15]
Don't put words in my mouth. I didn't ask you to. -.- You do NOTHING but pick on me & I do NOT appreciate it. PERIOD.


BlitzMan(Posted 2016) [#16]
Guy Fawkes why do you get so irate,RemiD was just trying to help.

Damn it the ball fell out me mouse.


RustyKristi(Posted 2016) [#17]
RemiD and the guys here have always been helpful to us GF. If you feel that you're not satisfied with the answer, just wait for someone or make it more clear what you are trying to do.

Let's not forget that they're doing this for free with their own spare time. We are all lucky enough that they have chosen to respond to some questions that "might" have been asked before and at least appreciate the gesture that they're answering it again.

In short, calm down man and drop the attitude. You're not paying them for support and they don't deserve to be treated like this, they're just trying to help.

I have rated this forum to be the most helpful or at least most active compared to previous discussion boards that I have participated before. So let's not abuse their generosity that they are extending to us noobs or novice blitz coders.

my 2¢


RemiD(Posted 2016) [#18]
Your indentation is senseless and make the code more difficult to read.
Local s, surf, surfs, v, verts, x#, y#, z#

		Local minx# = Infinity
	
			Local miny# = Infinity
		
				Local minz# = Infinity
		
			Local maxx# = -Infinity
	
		Local maxy# = -Infinity

	Local maxz# = -Infinity

Mesh_MinX = minx

		Mesh_MinY = miny
	
			Mesh_MinZ = minz
		
				Mesh_MaxX = maxx
			
					Mesh_MaxY = maxy
			
				Mesh_MaxZ = maxz
		
			Mesh_MagX = maxx - minx
	
		Mesh_MagY = maxy - miny

	Mesh_MagZ = maxz - minz

Global type_cam      =     1
	
		Global type_obj      =     2
		
			Global type_land     =     3
			
				Graphics3D 800, 600, 0, 2
				
					SetBuffer BackBuffer ( )
					
						SeedRnd MilliSecs ( )
						
;							PreCache ( )
							
								Include "EntityBox_Lib.bb"
							
							Global cam
						
						Global sky
					
					Global plane
				
				Global dummy_column
			
			Global dummy_mesh
		
		Global pbox
	
	Global walk_anim

Really ?

What's your problem man ?


Also, i have spotted an error on this line :
If y < minx Then miny = y Else If y > maxy Then maxy = y

but you need to learn to debug your code by yourself (debuglog() is really helpful for this)


RemiD(Posted 2016) [#19]
here is a code example + a rigged skinned animated mesh :
http://rd-stuff.fr/SkinnedVertexX()-SkinnedVertexY()-SkinnedVertexZ()-PlotSkinnedVertices()-20160411.7z

4 functions useful for what you are trying to do :
SkinnedVertexX() ;get the skinned vertex X position
SkinnedVertexY() ;get the skinned vertex Y position
SkinnedVertexZ() ;get the skinned vertex Z position
PlotSkinnedVertices() ;display the skinned vertices positions with rect() (with a specific rect radius (like a bigger plot))


Guy Fawkes(Posted 2016) [#20]
Remi. I've told you countless times & I'll tell you one more time. I am NOT here to argue with you & I do NOT criticize the way YOU code. So stop criticizing the way "I" code.


RemiD(Posted 2016) [#21]
The way i code has a logic behind it, indentation is not done arbitrarily and not for art. But yes you are free to do what you want, just don't be surprised if we (or at least i) consider you like a weirdo...

Anyway i hope that my code example will help you to make some progress.


wmaass(Posted 2016) [#22]
Hey there guys. My youngest son is an Aspy. Very bright and lovable kid, proud to be his pop. I can tell you that he processes info and approaches problems in odd ways. And at times it makes it hard for me to help him with things. I have to try and think like he does and it ain't easy. But we manage. This year he will be graduating with all A grades!

I guess what I am saying is perhaps there is a little of this going on here, maybe. RemiD, I do admire how you continue to help.


Guy Fawkes(Posted 2016) [#23]
I understand your thoughts on my coding style, however, I've had enough of that topic. Any help would be appreciated.

~GF


wmaass(Posted 2016) [#24]
GF, clearly you have a love for coding, you can go a long way with that kind of passion my friend.

Honestly, I don't have the answer to your original question. RemiD is pointing you in the right direction. He is a good, patient dude.

Consider that just as we all have a way learning, others have a way of teaching. We all have to give a little one way or the other.


RemiD(Posted 2016) [#25]
Ok i will consider in the future that GF may have a different way to think and view things. And maybe weird indentation can be an art if you want to obfuscate your code. :P


@GF>>please confirm : you want the bounding box to have a width,height,depth which corresponds to the space between minx,miny,minz and maxx,maxy,maxz of the animated mesh considering all poseframes of all animations (and the minx,miny,minz and the maxx,maxy,maxz must be found by considering the skinned vertices positions in all poseframes of all animations) ?


Guy Fawkes(Posted 2016) [#26]
Correct, RemiD.

~GF


RemiD(Posted 2016) [#27]
Wouldn't it be easier and quicker to manually define the minx,miny,minz maxx,maxy,maxz ?

Why do you absolutely need such a function for a rigged skinned animated mesh ?

If you really need it, you will need to check, for each poseframe, if each skinned vertex is inside or outside the minx,miny,minz maxx,maxy,maxz, so you will probably need this : http://www.blitzbasic.com/b3ddocs/command.php?name=SetAnimTime&ref=3d_a-z


Guy Fawkes(Posted 2016) [#28]
Remi. The whole point of this thread is to simply get the box to show up around an animated, skinned mesh. When you do a LoadAnimMesh ( ), the box DOESN'T show up. When you do a LoadMesh ( ), the box DOES show up. That's the only problem this code has is the ability for it not to show up on Anim Meshes. Plain & simple.

~GF


RemiD(Posted 2016) [#29]
And i have explained several times why your function will not work "plain & simple" with rigged skinned animated meshes with several poseframes... But since you don't want to consider what i have explained, i give up.


Guy Fawkes(Posted 2016) [#30]
Did it ever occur to you that I already TRIED changed it to the Rigged functions & it STILL didn't work?


Stevie G(Posted 2016) [#31]
@ RemiD, I think you've been incredibly patient and it's disappointing that you have not been thanked a single time after all the time and effort.

@ GF,
The function works for loadmesh as it's a single mesh and your function only checks the extents for a single mesh. Using loadanimmesh I would assume that you have a root mesh and multiple child meshes, which could also have child meshes. You're extents function needs to check the root mesh and all it's children.

Something along these lines ...



Where you call GetEntityExtents, using recursive = false if using loadmesh and recursive = true if using loadanimmesh.

Now obviousyly this doesn't take into account the scale or rotation of each mesh and or the animation pose but I think RemiD has given you plenty to go on.

Stevie


Matty(Posted 2016) [#32]
Can you not work out the maximum bounding box in your modeling software and work from that?


Guy Fawkes(Posted 2016) [#33]
Thanks, Stevie G, I'll try it! =) Matty, no. It must work for every mesh. Animated & Skinned, scaled, rotated, etc.

~GF


RemiD(Posted 2016) [#34]
@Stevie G>>Good point , there may be child meshes when using loadanimmesh(), i always forget about that because i never use it...