Camera Rotation Help PLZ
Blitz3D Forums/Blitz3D Beginners Area/Camera Rotation Help PLZ
| ||
Hi All, I really need help, I can't seem to get my head around it. I want to have a cam system like in DnD Heroes for the XBOX...allow me to explain. It has a full 360 rotation cam in 3rd person perspective that is independant of character direction. And it allows you to zoom in closer to character for viewing. So if the character is walking forward, it allows you to have the cam in front of the character, looking at him/her as he/she walks. It's great for tight areas like dungeons See what I mean? Completely Independant 360 rotation around and above the charcter. It is parented in some way also to the character. Are there any pro's that can help? And yes, I have already looked in the archives, and did forum searches...found a couple things but only half way there, and all with static placement and movement. Thanx for any help that can be provided. |
| ||
if you want to be able to orbit around the payer, I take it you want to do that with the mouseXSpeed, right? you may use sin/cos to position your camera, somethng like: dis#=15 while keydown(1)=0 ; main loop ; do things... ; orbit code x#=entityx(player) y#=entityy(player) z#=entityz(player) positionentity camera,x+(sin(a)*dis),y+5,z+(cos(a)*dis) pointentity camera,player rotateentity camera, entitypitch(camera),entityyaw(camera),0 renderworld() flip ; handle mouse orbit movemouse graphicswidth()/2,graphicsheight()/2 a=a+ mousexspeed() if a<0 then a=a+360 if a>360 then a=a-360 dis=dis+mousezspeed() ; mousewheel to zoom if dis<5 then dis=5 if dis >25 then dis=25 wend This is of course only a very basic skeleton. For a good camera handling you should smooth things, using rubberband alignement, and probably AlignToVector for smooth rotation. Additionally you may need an obstacles handler, this is going to make your zoom routine more complex. |
| ||
Thank you... EDIT> the orbit cam works only when i shake my mouse...lol, but only orbits like 2 pixels. My IDE is 1.90 and Linker is 1.64...if thats helps. But, it can't seem to get it ro "Orbit" around...it does the zoom just fine, just no Orbit. How do i input "code" into the forum? I will post my code if you are wiling to take a look at it? |
| ||
Try this simple example, use cursors and A/S to rotate camera. Should be easy for you to implement the mouse control.Graphics3D 640,480,16,1 Global LIGHT = CreateLight() Global PLANE = CreatePlane() EntityColor PLANE, 200,100,100 texture = CreateTexture( 32, 32 ) SetBuffer TextureBuffer( texture ) For y = 0 To 1 For x = 0 To 1 Color 100, 150+25*( ( x+y) Mod 2 ) , 100 Rect x*16,y*16,16,16,1 Next Next SetBuffer BackBuffer() ScaleTexture texture, 50,50 EntityTexture PLANE, texture FreeTexture texture Global CUBE = CreateCube() : FitMesh CUBE, -2,0,-2,4,10,4 Tmp = CreateCube() : FitMesh Tmp, -1,7,2,2,2,2 : AddMesh Tmp, CUBE : FreeEntity Tmp Global TARGET = CreatePivot() Global CAMERApivot = CreatePivot() Global CAMERA = CreateCamera( CAMERApivot ) PositionEntity CAMERA, 0,50,-50 PointEntity CAMERA , CAMERApivot While Not KeyDown(1) PositionEntity CAMERApivot , EntityX( CUBE ) , 0, EntityZ( CUBE ) TurnEntity CAMERApivot, 0 , KeyDown(31) - KeyDown(30) , 0 ;move relative to camera Mx# = KeyDown(205) - KeyDown(203) Mz# = KeyDown(200) - KeyDown(208 ) If Mx <> 0 Or Mz <> 0 ;move relative to camera TFormVector Mx, 0, Mz , CAMERApivot , 0 TranslateEntity CUBE, TFormedX(), 0, TFormedZ() ;turn relative to movement PositionEntity TARGET, EntityX( CUBE ) + TFormedX() , 0, EntityZ( CUBE ) + TFormedZ() TurnEntity CUBE, 0 , DeltaYaw( CUBE, TARGET ) * .25, 0 EndIf RenderWorld() Flip Wend |
| ||
Very sweet...thank you to both of you guys. @JFK- I got the orbit mouse cam to "orbit" but I had to rem out the movemouse line. Now it rotates if the mouse is slighty moved. @Stevie- Looks great, I will see if I can port to mouse. I will continue to plug away at both examples given and I greatly appreciate the code you guys posted. |