EntityRadius

Blitz3D Forums/Blitz3D Beginners Area/EntityRadius

chi(Posted 2006) [#1]
hi community,

any chance to recenter the pivot of an object?

my problem: 1stperson-cam, height 1.5m, gravity=on

i use EntityRadius player,0.1,1.5 so that the camera is at eye level. but when i want to go through a door which is 2,1 m ill stuck. sure, cause the collision of player is 3m tall. player,0.1,1.0 - and i can pass the door but the cam is 1m above the floor (like a 1stchild-cam)
any clue to solve this? is there a way to point the camera to the top of the radius and not in the middle? i can do a lot in b3d but i stuck on a door - what a shame!!

thx 4 any help, chi


Sledge(Posted 2006) [#2]
Make the camera a child of the player entity and position it wherever you like relative to the latter.


chi(Posted 2006) [#3]
couldnt get it to work!

player=Createpivot()
camera=CreateCamera(player)
 PositionEntity player,0,1.5,0
 EntityRadius player,.2,1.5
 EntityType player,1
 CameraRange camera,.1,200
 cameraclscolor camera,250,250,245

;....loop
 MoveEntity player,0,-.05,0   ;fakegravity
...........


here is a picture so you can see what i mean: campos = red dot


1) EntityRadius player,0.2,1.0 = 2m -> cam 1m -> pass door + bad camheight
2) EntityRadius player,0.2,1.5 = 3m -> cam 1.5m ->no pass + good camheight
3) what im lookin for!


b32(Posted 2006) [#4]
Maybe you could move the camera up before RenderWorld and then down after it ? If the player is a mesh, you could try FitMesh to change the pivot's location, or scan through all the vertices and rearrange them yourself. I think the pivot is allways @0, 0, 0, in mesh coordinates. I think I remember seeing a '3Dmidhandle' function in the code archives.


Sledge(Posted 2006) [#5]

couldnt get it to work!


Because you haven't positioned the camera where you want it relative to the player.

camera=CreateCamera()
player=CreatePivot()
 PositionEntity player,0,1.5,0
 EntityRadius player,.2,1.5
 EntityType player,1
 CameraRange camera,.1,200
 cameraclscolor camera,250,250,245
 EntityParent camera,player
 PositionEntity camera,0,1,0,False

...the last line there moves the camera one unit up from its parent.

EDIT: EXAMPLE
Here's a camera, set high on a player entity, with markers so you can see what's going on... player's view top-right, and you will observe that it is set in the correct place as it sweeps under the doorframe.



chi(Posted 2006) [#6]
hi sledge,

thank you so much for your code! but its still not working in my code... i think its the fakegravity (or whatever)

so here is my full code: media: http://lunamedia.heim.at/playground.zip
global width=800
global height=600
Global mousespeed#=0.22
Global camerasmoothness#=5.0

Graphics3D width,height,0,2
SetBuffer BackBuffer()
hidepointer
MoveMouse width/2,height/2

camera=CreateCamera()

CameraViewport camera,0,0,width,height

player=CreatePivot()
PositionEntity player,0,1.5,-3
EntityRadius player,.2,1.5 ;a value of ,.2,1 and i can walk through the door - but im to short now ;-(
EntityType player,1
CameraRange camera,.1,200
CameraClsColor camera,245,245,255
EntityParent camera,player
PositionEntity camera,0,1.3,0,False


 
Global map=LoadMesh("playground.b3d")
 EntityType map,2
 Collisions 1,2,2,2

walksnd=loadsound("footstep.wav")
 SoundVolume walksnd,.2

head_bang_X#=0.016
head_bang_Y#=0.014

Collisions 1,2,2,2

While Not KeyHit(1)
 cls

 if mousedown(1) then shoe_size#=3.6:sp#=.018 else shoe_size#=2.5:sp#=.009
 

 mxs#=CurveValue(MouseXSpeed()*mousespeed,mxs,camerasmoothness)
 mys#=CurveValue(MouseYSpeed()*mousespeed,mys,camerasmoothness)
 MoveMouse width/2,height/2
 camxa#=camxa-mxs Mod 360
 camya#=camya+mys
 If camya<-89 Then camya=-89
 If camya>89 Then camya=89
 RotateEntity player,0,camxa,0
 RotateEntity camera,camya,0,0
 MoveEntity player,0,-.05,0

 walking=0
 If KeyDown(203) Then: MoveEntity player,-sp,0,0 : walking=1: EndIf
 If KeyDown(205) Then: MoveEntity player, sp,0,0 : walking=1: EndIf
 If KeyDown(208) Then: MoveEntity player,0,0,-sp : walking=1: EndIf
 If KeyDown(200) Then: MoveEntity player,0,0, sp : walking=1: EndIf


 If walking=1
  a1#=(a1#+shoe_size) Mod 360
 EndIf
 PositionEntity camera,Cos(a1#)*head_bang_X#,Sin(90+a1#*2)*head_bang_Y#,0,0

 UpdateWorld
 RenderWorld


 If Sin(90+a1*2)<-.85
  If  footstep_needed<>0
   Color 255,255,255
   playsound walksnd
   footstep_needed=0
  EndIf
 Else
  footstep_needed=1
 EndIf
 color 120,120,120
 text 10,10,"arrows = walk, lmouse = run, esc = exit"
 VWait
 Flip 0
 delay 1
Wend
clearworld()
End



Function CurveValue#(newvalue#,oldvalue#,increments )

If increments>1 oldvalue#=oldvalue#-(oldvalue#-newvalue#)/increments
If increments<=1 oldvalue=newvalue
Return oldvalue#

End Function


its not that im too lazy to do this on my own... im just too stupid. maybe someone can fix that?

thank you, chi


chi(Posted 2006) [#7]
omg its working ;-)

i changed to:

player=Createpivot()
 PositionEntity player,0,1.5,-3
 EntityRadius player,.2,1
 EntityType player,1

camera=CreateCamera(player)
 CameraRange camera,.1,200
 cameraclscolor camera,250,250,245

;.... loop.......
 TranslateEntity camera, 0, 0.5, 0
 updateworld
 renderworld
 ...

i didnt know that i have to put translateentity into the loop, but now its clear!

again, thx so much for your help...

chi


Sledge(Posted 2006) [#8]
Cool. Been away for a few days so I'm glad you got it sorted in the meantime.