Odd Pivot Behavior

Blitz3D Forums/Blitz3D Programming/Odd Pivot Behavior

-Rick-(Posted 2004) [#1]
If you read my post on Plotting Inclination then you'll recall I was having trouble getting a planet's Y position. One sollution I'm currently trying now is to throw out the formulas and just tilt the pivot of the planet.

I have my planet, its parent is a pivot. Tilting the pivot of course just rotates the sphere. I tied the planet's pivot to another pivot which I called "Cpivot" for centerpivot and placed that at the Solar System Center. When I tilted this pivot to the Inclination angle then suddenly all my planets aligned perfectly on their orbit lines. Problem solved ... until ..

I have labels of the planets. My labels locate themselves to where the planet would be if it didnt have the Cpivot. Here is the relevant code :

If Labels Then
	CameraProject(camera,EntityX(b\pivot),EntityY(b\pivot),EntityZ(b\pivot))
	If EntityInView (b\pivot,camera) Then
		Text ProjectedX(),ProjectedY(),Upper(b\name),True,True
	EndIf
EndIf

camera is obviously my camera entity, b/pivot is my "body" pivot (body refering to planet/moon/sun/asteroid/comet/etc), and b\name is the name of the body.

This codes falls in a For b.body = each body statement so that I can check all my astonomical bodies. Basically all its suppose to do is see if something is "on screen" and then if it is put a label overtop it.

Its like the CameraProject command is working only with the b\pivot LOCAL values and not taking into account that b\pivot has been further tilted by b\Cpivot

I PositionEntity b\pivot just before this query and it places the planet in the right place .. why wouldnt it read the correct pivot values back? The order of "parenthood" is thus :

b\CPivot(Centered at 0,0,0)<---b\pivot(Planet Position)<---b\item(image of planet)


Jeppe Nielsen(Posted 2004) [#2]
wouldn't the use of the global parameter solve your problem?:
If Labels Then
	;Notice the true flag, at the EntityX/Y/Z() commands:
	CameraProject(camera,EntityX(b\pivot,true),EntityY(b\pivot,true),EntityZ(b\pivot,true))
	If EntityInView (b\pivot,camera) Then
		Text ProjectedX(),ProjectedY(),Upper(b\name),True,True
	EndIf
EndIf



-Rick-(Posted 2004) [#3]
Jeppe!!!!!!

Sweet, you nailed it on try ONE. I've been pounding my head to figure out if i just missed some global somewhere and had started to think maybe CameraProject went back only 1 parent entity lol.

Everything is good in the Rick Universe now :) Back to programming and finding the next bug to bust my head over hehe.

Thanks a million!


Jeppe Nielsen(Posted 2004) [#4]
You're welcome :)