⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 camera.h

📁 Ray tracing on PS3, using the acceleration of PPU, No SPE acceleration is used. The code must be com
💻 H
字号:
/* Copyright (c) 2007 Massachusetts Institute of Technology * * Permission is hereby granted, free of charge, to any person obtaining a copy of * this software and associated documentation files (the "Software"), to deal in * the Software without restriction, including without limitation the rights to * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of * the Software, and to permit persons to whom the Software is furnished to do so, * subject to the following conditions: * * The above copyright notice and this permission notice shall be included in all * copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. *//** * camera.h - blue-steel Camera class * @author Brian Sweatt *  * Contains an implementation of a pin-hole perspective camera that shoots rays with  * a tmin value (near clipping plane) of 0.0f.  * * Users of this class should instantiate the Camera object on the SPU, providing the * vectors for the center of the camera (location of the pinhole), the direction the camera * is to face, the up direction, and the angle for the camera's field of view. * * This class is only instantiable on the SPU. blue-steel instantiates an object of this * type in the SPU ray tracer with a field of view angle of 45 degrees. Methods for changing * the position and direction of the camera from the PPU are provided in the blue-steel API */#ifndef _CAMERA_H_#define _CAMERA_H_#include <raypacket.h>extern "C" {#include <spu_intrinsics.h>#include <cross_product3.h>#include <normalize3.h>#include <normalize3_v.h>#include <simdmath.h>}class Camera { public:  Camera(const vector float &c, const vector float &d,	 const vector float &u, float a);  ~Camera() {}  inline RayPacket generateRayPacket(const vector float  &x, const vector float &y) {    RayPacket retVal;    vector float xCoords = spu_mul(x, size);    vector float yCoords = spu_mul(y, size);    vector float xTemp = spu_madd(yCoords, Ux, xLL);    vector float yTemp = spu_madd(yCoords, Uy, yLL);    vector float zTemp = spu_madd(yCoords, Uz, zLL);    xTemp = spu_madd(xCoords, Hx, xTemp);    yTemp = spu_madd(xCoords, Hy, yTemp);    zTemp = spu_madd(xCoords, Hz, zTemp);            retVal.x0 = Cx;    retVal.y0 = Cy;    retVal.z0 = Cz;    retVal.dx = spu_sub(xTemp, Cx);    retVal.dy = spu_sub(yTemp, Cy);    retVal.dz = spu_sub(zTemp, Cz);    _normalize3_v(&retVal.dx, &retVal.dy, &retVal.dz, retVal.dx, retVal.dy, retVal.dz);    return retVal;  }   void setCenter(const vector float &c);  vector float getCenter() {     return (vector float) {spu_extract(Cx,0), spu_extract(Cy, 0), spu_extract(Cz, 0), 0};  }  void setDirection(const vector float &d, const vector float &u);  vector float getDirection();  float getTMin() { return 0.0f; } private:  //vector float center, up, direction, horizontal;  vector float Hx, Hy, Hz, Ux, Uy, Uz, Cx, Cy, Cz;  // Store the lower-left coordinates of our virtual screen, splatted  vector float xLL, yLL, zLL;  vector float size;};#endif

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -