- Home
- Products
- Integration
- Tutorial
- Barcode FAQ
- Purchase
- Company
SE TTIN G UP DIFFER ENT CA MERA MODE S IN YOUR 3 D WORLD in Word
CHAPTER 2 SE TTIN G UP DIFFER ENT CA MERA MODE S IN YOUR 3 D WORLD Data Matrix 2d Barcode Printer In None Using Barcode creation for Office Word Control to generate, create DataMatrix image in Word applications. www.OnBarcode.comPrinting Code-39 In None Using Barcode generation for Word Control to generate, create Code39 image in Word applications. www.OnBarcode.comRecipe 4-17 in 4 explains in detail how to find the rotation angle corresponding to a direction. In this case, you have to find two angles because the direction is in 3D. Start by finding the leftrightRot angle. Figure 2-5 shows the XZ plane containing the camera and the target. The diagonal line is the direction the camera is facing, and the X and Z lines are simply the X and Z components of that vector. In a triangle with a 90-degree angle, if you want to find the angle of a corner, all you need to do is take the arctangent of the side opposite the corner, divided by the shortest side next to the corner. In this case, this comes down to X divided by Z. The Atan2 function allows you to specify both values instead of their division, because this removes an ambiguity. This is how you find the leftrightRot angle. Code 128A Drawer In None Using Barcode drawer for Word Control to generate, create Code 128A image in Word applications. www.OnBarcode.comPrinting PDF-417 2d Barcode In None Using Barcode encoder for Word Control to generate, create PDF 417 image in Word applications. www.OnBarcode.comTarget
UPC - 13 Encoder In None Using Barcode creator for Office Word Control to generate, create EAN-13 image in Word applications. www.OnBarcode.comUPC Symbol Drawer In None Using Barcode drawer for Microsoft Word Control to generate, create UPCA image in Microsoft Word applications. www.OnBarcode.comAngle Z
Creating ECC200 In None Using Barcode printer for Microsoft Word Control to generate, create ECC200 image in Microsoft Word applications. www.OnBarcode.comLeitcode Maker In None Using Barcode generation for Word Control to generate, create Leitcode image in Office Word applications. www.OnBarcode.comFigure 2-5. Finding the leftrightRot angle To find the updownAngle, you can use Figure 2-6. Here, the dashed line shows the direction the camera is looking. You want to find the angle between the Up Y component and the projection of the direction on the XZ floor plane. So, you pass these to the Atan2 method, and you receive the updownAngle. Encoding DataMatrix In None Using Barcode printer for Word Control to generate, create DataMatrix image in Microsoft Word applications. www.OnBarcode.comDataMatrix Generation In .NET Framework Using Barcode printer for Visual Studio .NET Control to generate, create Data Matrix ECC200 image in VS .NET applications. www.OnBarcode.comTarget
Matrix Barcode Printer In Java Using Barcode generation for Java Control to generate, create Matrix 2D Barcode image in Java applications. www.OnBarcode.comUPC-A Supplement 2 Creator In Visual C# Using Barcode encoder for VS .NET Control to generate, create UPC Symbol image in VS .NET applications. www.OnBarcode.comAngle
2D Creator In Visual Studio .NET Using Barcode encoder for ASP.NET Control to generate, create Matrix 2D Barcode image in ASP.NET applications. www.OnBarcode.comBarcode Maker In .NET Using Barcode generation for .NET Control to generate, create Barcode image in VS .NET applications. www.OnBarcode.comCamera Z
Printing Linear Barcode In Visual C#.NET Using Barcode maker for VS .NET Control to generate, create 1D image in .NET applications. www.OnBarcode.comDataMatrix Drawer In .NET Framework Using Barcode encoder for Reporting Service Control to generate, create Data Matrix 2d barcode image in Reporting Service applications. www.OnBarcode.comFigure 2-6. Finding the updownAngle
Paint EAN 13 In Visual Basic .NET Using Barcode encoder for .NET framework Control to generate, create UPC - 13 image in Visual Studio .NET applications. www.OnBarcode.comUPC Code Recognizer In Visual Studio .NET Using Barcode scanner for VS .NET Control to read, scan read, scan image in Visual Studio .NET applications. www.OnBarcode.comCHAPTER 2 SE TTIN G UP DIFFE RENT CA MERA MODE S IN YOUR 3 D WORLD
UCC-128 Creator In Objective-C Using Barcode printer for iPad Control to generate, create UCC.EAN - 128 image in iPad applications. www.OnBarcode.comRecognize EAN13 In .NET Framework Using Barcode scanner for .NET Control to read, scan read, scan image in Visual Studio .NET applications. www.OnBarcode.comUsage
Make sure you call your UpdateBezier method from your Update method: UpdateBezier(); Now all you have to do to start a fly-by is call the InitBezier method! if (bezTime > 1.0f) InitBezier(new Vector3(0,10,0), new Vector3(0,0,0), new Vector3(0, 0, -20), new Vector3(0, 0, -10)); When you want to integrate your fly-by with your user camera, you can start from your camera s position and target easily: if (bezTime > 1.0f) InitBezier(fpsCam.Position, fpsCam.Position + fpsCam.Forward * 10.0f, new Vector3(0, 0, -20), new Vector3(0, 0, -10)); You can see I have placed the starting target 10 units in front of the starting position. This will often give a smoother result, because otherwise the camera would have to make a sharp turn when tracking the target. Smooth Start and Acceleration
By constantly increasing the bezTime from 0 to 1 by a fixed amount, the speed at which the camera moves over the Bezier curve is a constant. This will result in a rather uncomfortable starting and ending. What you really want is to have the bezTime first rise slowly from 0 to 0.2 and then rise pretty fast to 0.8, while slowing down again during the last part between 0.8 and 1. This is exactly what MathHelper.SmoothStep does: you give it a constantly increasing value between 0 and 1, and it will return a value between 0 and 1 that has a smooth starting and ending! The only place where you need this is in the UpdateBezier method, so replace the middle two lines with this code: float smoothValue = MathHelper.SmoothStep(0, 1, bezTime); Vector3 newCamPos = Bezier(bezStartPosition, bezMidPosition, bezEndPosition, smoothValue); Vector3 newCamTarget = Vector3.Lerp(bezStartTarget, bezEndTarget, smoothValue); The smoothValue variable will hold this smoothed value between 0 and 1, which will be passed to the methods, instead of the constantly increasing bezTime variable. Solving Incorrect/Fast Camera Rotation at the End of the Fly-By
This part of the recipe addresses a problem that can occur in some cases. One of such cases is shown in the left part of Figure 2-7, where the path of the camera position and the curve of the target is shown from above. In the beginning, the camera will be looking to the left, until both curves cross. At this point, the camera will suddenly be switched, so it is looking to the right! You can correct this situation by simply shifting the midpoint of the curve to the left, instead of to the right. This way, you get a curve as shown in the right part, where the starting camera will start by looking to the right and doesn t have to be switched to the left.
|
|