Changeset 87 in flair-src for trunk/lib/FlairSimulator/src
- Timestamp:
- Sep 28, 2016, 8:41:02 AM (8 years ago)
- Location:
- trunk/lib/FlairSimulator/src
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/lib/FlairSimulator/src/FixedCamera.cpp
r70 r87 35 35 namespace simulator { 36 36 37 FixedCamera::FixedCamera(std::string name,core::Vector3D position,float inRotateSpeed,float inZoomSpeed):VisualizationCamera(name) { 38 RotY = -90; 39 RotZ = 0; 37 FixedCamera::FixedCamera(std::string name,core::Vector3D position,core::Vector3D lookat,float inRotateSpeed,float inZoomSpeed):VisualizationCamera(name) { 40 38 Rotating = false; 41 39 rotateSpeed=inRotateSpeed; 42 40 zoomSpeed=inZoomSpeed; 41 42 camera->bindTargetAndRotation(true); 43 43 camera->setPosition(vector3df(ToIrrlichtCoordinates(position))); 44 camera->setTarget(vector3df(ToIrrlichtCoordinates(lookat))); 45 init=false; 46 rotation=camera->getRotation(); 47 printf("%f %f %f\n",rotation.X,rotation.Y,rotation.Z); 44 48 fov=camera->getFOV(); 45 49 } … … 57 61 void FixedCamera::animateNode(ISceneNode *node, u32 timeMs) { 58 62 ICameraSceneNode *camera = static_cast<ICameraSceneNode *>(node); 63 vector3df newRotation=rotation; 59 64 60 float nRotY = RotY; 61 float nRotZ = RotZ; 65 if(init==false) { 66 rotation=camera->getRotation(); 67 printf("%f %f %f\n",rotation.X,rotation.Y,rotation.Z); 68 init=true; 69 } 70 float nRotY = 0;//rotation.Y; 71 float nRotZ = rotation.Z; 62 72 63 73 if (LMouseKey == true) { … … 65 75 RotateStart = MousePos; 66 76 Rotating = true; 67 nRotY = RotY;68 nRotZ = RotZ;77 //nRotY = rotation.Y; 78 nRotZ = rotation.Z; 69 79 } else { 70 nRotY += (RotateStart.Y - MousePos.Y) * rotateSpeed;80 nRotY = (RotateStart.Y - MousePos.Y) * rotateSpeed; 71 81 nRotZ += (RotateStart.X - MousePos.X) * rotateSpeed; 72 nRotY = sat(nRotY); 82 newRotation.rotateXZBy(-nRotY); 83 //nRotY = sat(nRotY); 73 84 } 74 85 } else if (Rotating) { 75 RotY += (RotateStart.Y - MousePos.Y) * rotateSpeed;76 RotZ += (RotateStart.X - MousePos.X) * rotateSpeed;77 RotY = sat(RotY);78 nRotY = RotY;79 nRotZ = RotZ;86 //rotation.Y += (RotateStart.Y - MousePos.Y) * rotateSpeed; 87 //rotation.Z += (RotateStart.X - MousePos.X) * rotateSpeed; 88 //rotation.Y = sat(rotation.Y); 89 //nRotY = rotation.Y; 90 nRotZ = rotation.Z; 80 91 Rotating = false; 81 92 } … … 91 102 } 92 103 93 camera->setRotation(vector3df(0,nRotY,nRotZ)); 94 camera->bindTargetAndRotation(true); 104 105 106 //camera->setRotation(vector3df(rotation.X,-180-nRotY,nRotZ)); 107 //camera->setRotation(vector3df(rotation.X,nRotY,0)); 108 //camera->bindTargetAndRotation(true); 109 camera->setRotation(rotation); 110 //camera->setTarget(vector3df(ToIrrlichtCoordinates(core::Vector3D(0,0,-2)))); 111 //rotation=camera->getRotation(); 112 //printf("%f %f %f\n",rotation.X,rotation.Y,rotation.Z); 113 95 114 camera->setFOV(newFov); 96 115 } -
trunk/lib/FlairSimulator/src/FixedCamera.h
r70 r87 26 26 class FixedCamera : public VisualizationCamera { 27 27 public: 28 FixedCamera(std::string name,core::Vector3D position, float rotateSpeed = -500.0f, float zoomSpeed = .1f);28 FixedCamera(std::string name,core::Vector3D position,core::Vector3D lookat=core::Vector3D(0,0,0),float rotateSpeed = -500.0f, float zoomSpeed = .05f); 29 29 ~FixedCamera(); 30 30 … … 34 34 float sat(float value); 35 35 irr::core::position2df RotateStart; 36 irr::core::vector3df rotation; 36 37 bool Rotating; 37 38 float rotateSpeed; 38 39 float zoomSpeed; 39 float RotY, RotZ;40 40 float fov; 41 bool init; 41 42 }; 42 43 -
trunk/lib/FlairSimulator/src/Parser.cpp
r69 r87 19 19 #include "Simulator.h" 20 20 #include "GenericObject.h" 21 #include "FixedCamera.h" 21 22 #include <vector3d.h> 23 #include <Vector3D.h> 22 24 #include <IrrlichtDevice.h> 23 25 #include <IFileSystem.h> … … 188 190 getSceneVect(cur_node->children, (xmlChar *)"rotation"), 189 191 getSceneVect(cur_node->children, (xmlChar *)"scale", true)); 192 } else if (xmlStrEqual(cur_node->name, (xmlChar *)"camera")) { 193 FixedCamera* fixedCamera=new FixedCamera(std::string((char *)xmlGetProp(cur_node, (xmlChar *)"name")), 194 getMeshVector3D(cur_node->children, (xmlChar *)"position"), 195 getMeshVector3D(cur_node->children, (xmlChar *)"lookat")); 190 196 } 191 197 } … … 204 210 } 205 211 return vector3df(0, 0, 0); 212 } 213 214 Vector3D Parser::getMeshVector3D(xmlNode *mesh_node, xmlChar *param) { 215 xmlNode *cur_node = NULL; 216 for (cur_node = mesh_node; cur_node; cur_node = cur_node->next) { 217 if (xmlStrEqual(cur_node->name, param)) { 218 return Vector3D(atof((char *)xmlGetProp(cur_node, (xmlChar *)"x")), 219 atof((char *)xmlGetProp(cur_node, (xmlChar *)"y")), 220 atof((char *)xmlGetProp(cur_node, (xmlChar *)"z"))); 221 } 222 } 223 return Vector3D(0, 0, 0); 206 224 } 207 225 -
trunk/lib/FlairSimulator/src/Parser.h
r15 r87 23 23 24 24 namespace flair { 25 namespace core { 26 class Vector3D; 27 } 28 } 29 30 namespace flair { 25 31 namespace simulator { 26 32 class Parser : public Gui { … … 28 34 /*can create: 29 35 - cylinders: in y axis 36 - fixed cameras 30 37 31 38 */ … … 45 52 irr::core::vector3df getSceneVect(xmlNode *mesh_node, xmlChar *param, 46 53 bool isScale = false); 54 core::Vector3D getMeshVector3D(xmlNode *mesh_node, xmlChar *param); 47 55 }; 48 56 }
Note:
See TracChangeset
for help on using the changeset viewer.