PointEntity and Quad Roll

Blitz3D Forums/Blitz3D Programming/PointEntity and Quad Roll

Hi :)

It was a long time that i have post a blitz3d problem :)

But i become crazy with quad roll. Trye this code and press
key UP, you will see the sprite made a unwanted roll

And want only a camera facing, but without roll !! it is
possible ? I have search many solutions and informations
on the forum or code archive but i find nothing to help me ?
or i'm idiot and i have not very well search ? (possible)

I think that the POINTENTITY command is the problem, but
i don't understand how make some quad => camera/facing
without this function ?

Cheers

Graphics3D 640,480,32,0
SetBuffer BackBuffer()

Type character
	Field sprite
	Field rot#
End Type

pivot=CreatePivot()
camera=CreateCamera(pivot)

PositionEntity camera,0,3,-5 : RotateEntity camera,30,0,0

ground=CreatePoly(-5,5,10,10) : RotateEntity ground,90,0,0 : EntityAlpha ground,0.5 : EntityOrder ground,1

; Create 5 characters
For i=-4 To 4 Step 2
	c.character=New character
	c\sprite=CreatePoly(-0.5,0.5,1,1) : PositionEntity c\sprite,i,0,0
	EntityFX c\sprite,1
	c\rot#=0
Next



;-------------------
;Main Game Loop     --------------
;-------------------

While Not KeyDown(1)

For a.character=Each character
	PointEntity a\sprite,camera
Next

;Keyboard Control
If KeyDown( 208 )=True Then pitch#=pitch#-1 
If KeyDown( 200 )=True Then pitch#=pitch#+1
If KeyDown( 203 )=True Then yaw#=yaw#-2
If KeyDown( 205 )=True Then yaw#=yaw#+2

RotateEntity pivot,pitch#,yaw#,0

RenderWorld

Flip

Wend

End

;Functions
;------------

Function CreatePoly(xpos#,zpos#,x#,z#) ;Create a backless Square (sprite)
	sprite=CreateMesh()
	he=CreateBrush(255,255,255)
	v=CreateSurface(sprite,he)
	FreeBrush he
	AddVertex (v,xpos#,zpos#,0,      1,0)
	AddVertex (v,xpos#+x#,zpos#,0,   0,0)
	AddVertex (v,xpos#+x#,zpos#-z#,0,0,1)
	AddVertex (v,xpos#,zpos#-z#,0,   1,1)
	AddTriangle(v,2,1,0)
	AddTriangle(v,0,3,2)
	AddTriangle(v,0,1,2)
	AddTriangle(v,2,3,0)
	Return sprite
End Function


why not use the sprite command set ?

I often use the vector commands or atan2() to point things at objects but i'm thrown by your use of a pivot for the camera ... how is the pivot entity going to be used to relate to the camera ?

You can use the vector commands or atan2() to calculate the bearing between two positions and modify the angle based upon the rotation of your camera or pivot - depening upon which of those two entities is holding your rotational information.

"why not use the sprite command set ?"
The problem is the same with sprite

But for a mathematical solution, do you have an example ?

I swapped your createPoly function for a basic sprite creation function and it didnt roll like your example

Function createPoly(xpos#,zpos#,x#,z#)
	sprite=CreateSprite()
	ScaleSprite sprite,x,z
	PositionEntity sprite,xpos,0,zpos
	Return sprite
End Function


When working in psuedo 2D you might also want to get into the habbit of using x and z as your primary plain with y as your depth, this will make entityRoll() your tertiary rotation field thus resolve many Eular issues without having to think about them.,

I'll retry to work with sprite, thanks becky.

Filax,

I see no purpose for the pivot but it seems to be causing the issues. If you remove all references to it and rotate the camera itself this all works fine.

Stevie