Mercurial > hg > Members > e075743
comparison src/PlayerEyePoint.cpp @ 10:5727d511a13a
add src in Martial Project Xcode.
author | tokumoritaichirou@nw0743.st.ie.u-ryukyu.ac.jp |
---|---|
date | Wed, 03 Feb 2010 03:39:04 +0900 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
9:143f7b9f867d | 10:5727d511a13a |
---|---|
1 /* | |
2 * PlayerEyePoint.cpp | |
3 * Martial | |
4 * | |
5 * Created by ryoma on 10/01/28. | |
6 * Copyright 2010 琉球大学. All rights reserved. | |
7 * | |
8 */ | |
9 | |
10 #include "PlayerEyePoint.h" | |
11 | |
12 PlayerEyePoint::PlayerEyePoint(MovableObject *owner): | |
13 EyePoint(owner->getName()), owner(owner){ | |
14 position = osg::Vec3(-10,0,2); | |
15 direction = osg::Vec3(0, 0, 0); | |
16 target = NULL; | |
17 relativeRotate = true; | |
18 } | |
19 | |
20 void PlayerEyePoint::setRelativeRotate(bool rr) { | |
21 relativeRotate = rr; | |
22 } | |
23 | |
24 void PlayerEyePoint::setTarget(MovableObject* _target) { | |
25 target = _target; | |
26 } | |
27 | |
28 void PlayerEyePoint::setOwner(MovableObject* _owner) { | |
29 owner = _owner; | |
30 } | |
31 | |
32 void PlayerEyePoint::frame() { | |
33 osg::Matrixd myCameraMatrix; | |
34 osg::Matrixd rotation; | |
35 osg::Matrixd cameraTrans; | |
36 osg::Matrixd ownerTrans; | |
37 | |
38 cameraTrans.makeTranslate(position); | |
39 ownerTrans.makeTranslate(owner->getPos()); | |
40 | |
41 /* if relativeRotate is false, relativeRoate * target->getDir().z() always equals 0 */ | |
42 rotation.makeRotate(relativeRotate*owner->getDir().z()+direction.z(), osg::Vec3(0,0,1)); | |
43 | |
44 myCameraMatrix = cameraTrans * rotation * ownerTrans; | |
45 | |
46 myCameraMatrix.makeLookAt(myCameraMatrix.getTrans(), owner->getPos(), osg::Vec3(0,0,1) * rotation); | |
47 Tman->setByInverseMatrix(myCameraMatrix); | |
48 } |