Thread: [Elvarg] Moving The Camera for Cutscenes

Results 1 to 5 of 5
  1. #1 [Elvarg] Moving The Camera for Cutscenes 
    Registered Member B E N's Avatar
    Join Date
    May 2012
    Posts
    142
    Thanks given
    14
    Thanks received
    3
    Rep Power
    36
    I have been playing around with the camera packets and cannot seem to figure out how they work exactly. I get the gist of it, but I get very confused when it comes to exact positioning. If someone could take the time to briefly explain how it all works I would greatly appreciate it.

    I'm trying to get the camera to face white wolf mountain, and the exact local coordinates for the spot I want the camera are X: 51 and Y: 51. When I use these the camera goes to the spot but then does a 180 and looks the complete opposite way like so:



    Also, it seems the end result is not the same every time even when using the same command with the same local coordinates:



    This wouldn't really be an issue if I could figure out how to make the camera face a certain direction. Whenever I try to rotate the camera after I move it, nothing really happens. It just stays in the same spot like so:



    But when trying to rotate from the normal camera view it just seems to do the same thing every single time no matter what coordinates I use:



    and



    I'm not sure if the methods are wrong, or if there's a different approach to this, or simply just using them wrong.
    These are the methods that I am using inside the packetsender class:

    Code:
    public PacketSender turnCameraTowardLocation(int x, int y, int level, int speed, int angle) {
    		PacketBuilder out = new PacketBuilder(177);
    		out.put(x / 64);
    		out.put(y / 64);
    		out.putShort(level);
    		out.put(speed);
    		out.put(angle);
    		player.getSession().write(out);
    		return this;
    	}
    
    	public PacketSender moveCameraToLocation(int x, int y, int z, int speed, int angle) {
    		PacketBuilder out = new PacketBuilder(166);
    		out.put(x);
    		out.put(y);
    		out.putShort(z);
    		out.put(speed);
    		out.put(angle);
    		player.getSession().write(out);
    		return this;
    	}
    And these are the commands I am using to access these:

    Code:
    if (parts[0].startsWith("movecam")) {
    			int x = Integer.parseInt(parts[1]);
    			int y = Integer.parseInt(parts[2]);
    			int z = Integer.parseInt(parts[3]);
    			int cs = Integer.parseInt(parts[4]);
    			int vs = Integer.parseInt(parts[5]);
    			player.getPacketSender().moveCameraToLocation(x, y, z, cs, vs);
    		}
    		
    		if (parts[0].startsWith("rotcam")) {
    			int x = Integer.parseInt(parts[1]);
    			int y = Integer.parseInt(parts[2]);
    			int z = Integer.parseInt(parts[3]);
    			int cs = Integer.parseInt(parts[4]);
    			int vs = Integer.parseInt(parts[5]);
    			player.getPacketSender().turnCameraTowardLocation(x, y, z, cs, vs);
    		}
    Ill also post the client side methods as well:

    Code:
    if (opcode == PacketConstants.ROTATE_CAMERA) {
    				oriented = true;
    				x = incoming.readUnsignedByte();
    				y = incoming.readUnsignedByte();
    				height = incoming.readUShort();
    				speed = incoming.readUnsignedByte();
    				angle = incoming.readUnsignedByte();
    				if (angle >= 100) {
    					xCameraPos = x * 128 + 64;
    					yCameraPos = y * 128 + 64;
    					zCameraPos = getCenterHeight(plane, yCameraPos, xCameraPos) - height;
    				}
    				opcode = -1;
    				return true;
    			}
    			
    			if (opcode == PacketConstants.MOVE_CAMERA) { //Gradually turn camera to spatial point.
    				oriented = true;
    				cinematicCamXViewpointLoc = incoming.readUnsignedByte();
    				cinematicCamYViewpointLoc = incoming.readUnsignedByte();
    				cinematicCamZViewpointLoc = incoming.readUShort();
    				constCinematicCamRotationSpeed = incoming.readUnsignedByte();
    				varCinematicCamRotationSpeedPromille = incoming.readUnsignedByte();
    				if (varCinematicCamRotationSpeedPromille >= 100) {
    					int cinCamXViewpointPos = cinematicCamXViewpointLoc * 128 + 64;
    					int cinCamYViewpointPos = cinematicCamYViewpointLoc * 128 + 64;
    					int cinCamZViewpointPos = getCenterHeight(plane, cinCamYViewpointPos, cinCamXViewpointPos) - cinematicCamZViewpointLoc;
    					int dXPos = cinCamXViewpointPos - xCameraPos;
    					int dYPos = cinCamYViewpointPos - yCameraPos;
    					int dZPos = cinCamZViewpointPos - zCameraPos;
    					int flatDistance = (int) Math.sqrt(dXPos * dXPos + dYPos * dYPos);
    					yCameraCurve = (int) (Math.atan2(dZPos, flatDistance) * 325.94900000000001D)
    							& 0x7ff;
    					xCameraCurve = (int) (Math.atan2(dXPos, dYPos) * -325.94900000000001D)
    							& 0x7ff;
    					if (yCameraCurve < 128)
    						yCameraCurve = 128;
    					if (yCameraCurve > 383)
    						yCameraCurve = 383;
    				}
    				opcode = -1;
    				return true;
    			}
    If someone could lend a hand and point me in the right direction, it would be very helpful since i've been stuck on this for awhile now.
    Reply With Quote  
     

  2. #2  
    Registered Member
    TheChosenOne's Avatar
    Join Date
    Jan 2013
    Posts
    975
    Thanks given
    47
    Thanks received
    160
    Rep Power
    366
    You can stop the "cinematic camera movement" with packet 107 (Stop cinematics).
    Also, what you call "Angle" is a parameter that controls the variable camera speed.
    The "speed" parameter is a constant speed. The "angle" which I call varCinCamMovementSpeedPromille control a variable speed component on top of the constant speed. A value above 100 should be instant.

    To get a real grasp on what's going on, it's easier to print out the relevant camera variables.
    As far as I know (could be wrong) sending packet 166 (move camera) shouldn't rotate it.
    My informative threads:
    [Only registered and activated users can see links. ]
    [Only registered and activated users can see links. ]
    Reply With Quote  
     

  3. #3  
    Registered Member B E N's Avatar
    Join Date
    May 2012
    Posts
    142
    Thanks given
    14
    Thanks received
    3
    Rep Power
    36
    Quote Originally Posted by TheChosenOne View Post
    You can stop the "cinematic camera movement" with packet 107 (Stop cinematics).
    Also, what you call "Angle" is a parameter that controls the variable camera speed.
    The "speed" parameter is a constant speed. The "angle" which I call varCinCamMovementSpeedPromille control a variable speed component on top of the constant speed. A value above 100 should be instant.

    To get a real grasp on what's going on, it's easier to print out the relevant camera variables.
    As far as I know (could be wrong) sending packet 166 (move camera) shouldn't rotate it.
    Sorry for being delayed with the response, I had a little vacation.

    Anyways, Packet 107 just stops the camera and resets it back to the original position (above the player's center), doesn't do me much good. I know the parameter names are odd, but I know what they all do.
    My issue is pretty much just the fact that the move camera packet (166) will also rotate after or while moving to the designated position, and I cannot get my rotate camera packet (177) to face the correct position.

    Which camera variables would help me determine why the camera is also rotating instead of just moving?
    Reply With Quote  
     

  4. #4  
    Registered Member
    TheChosenOne's Avatar
    Join Date
    Jan 2013
    Posts
    975
    Thanks given
    47
    Thanks received
    160
    Rep Power
    366
    Hmmm I've just done some testing and this is normal behaviour.
    It seems it remembers the last faceTo and camera position.
    So if you move your camera, it'll also try to keep facing the last position you've faced.

    I think it's best you try and use speed 100 to set the initial position (instant) and then work from there.
    My informative threads:
    [Only registered and activated users can see links. ]
    [Only registered and activated users can see links. ]
    Reply With Quote  
     

  5. Thankful user:


  6. #5  
    Registered Member B E N's Avatar
    Join Date
    May 2012
    Posts
    142
    Thanks given
    14
    Thanks received
    3
    Rep Power
    36
    Quote Originally Posted by TheChosenOne View Post
    Hmmm I've just done some testing and this is normal behaviour.
    It seems it remembers the last faceTo and camera position.
    So if you move your camera, it'll also try to keep facing the last position you've faced.

    I think it's best you try and use speed 100 to set the initial position (instant) and then work from there.
    Thank you for that information, it helps a lot.

    Now I need to figure out the rotation packet. It seems I can only get it to spin when the x and y values are huge, such as 5000-15000. It almost seems as if it is a value of how much to rotate instead of positional values.
    Reply With Quote  
     


Thread Information
Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Replies: 0
    Last Post: 11-08-2014, 07:07 PM
  2. Replies: 2
    Last Post: 02-26-2011, 08:28 PM
  3. Replies: 7
    Last Post: 03-11-2010, 03:44 PM
  4. Replies: 5
    Last Post: 09-17-2009, 08:33 PM
  5. [508]Camera Rotations for cutscenes
    By Virus X3 in forum Configuration
    Replies: 6
    Last Post: 01-24-2009, 03:31 AM
Tags for this Thread

View Tag Cloud

Posting Permissions
  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •