aboutsummaryrefslogtreecommitdiff
path: root/cvs/cvsweb.cgi/code/client/Attic/move_listener.h?rev=1.2&content-type=text/x-cvsweb-markup&hideattic=0&sortby=date/index.html
blob: 5887d974752b00dc4df1023df5b56a0a1d74a076 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"><HTML>
<HEAD><style>		A { color:black }</style>
<!-- hennerik CVSweb $Revision: 1.93 $ -->
<TITLE>code/client/move_listener.h - view - 1.2</TITLE></HEAD>
<BODY BGCOLOR="#eeeeee">
<table width="100%" border=0 cellspacing=0 cellpadding=1 bgcolor="#aaaaaa"><tr valign=bottom><td><a href="move_listener.h?hideattic=0&amp;sortby=date"><IMG SRC="/inc/img/picto-up.gif" ALT="[BACK]" BORDER="0" WIDTH="14" HEIGHT="13"></a> <b>Return to <A HREF="move_listener.h?hideattic=0&amp;sortby=date">move_listener.h</A>
 CVS log</b> <IMG SRC="/inc/img/picto-news.gif" ALT="[TXT]" BORDER="0" WIDTH="13" HEIGHT="15"></td><td align=right><IMG SRC="/inc/img/picto-dir.gif" ALT="[DIR]" BORDER="0" WIDTH="15" HEIGHT="13"> <b>Up to  <a href="/cvs/cvsweb.cgi/?hideattic=0&amp;sortby=date">Nevrax</a> / <a href="/cvs/cvsweb.cgi/code/?hideattic=0&amp;sortby=date">code</a> / <a href="/cvs/cvsweb.cgi/code/client/?hideattic=0&amp;sortby=date">client</a></b></td></tr></table><HR noshade><table width="100%"><tr><td bgcolor="#ffffff">File:  <a href="/cvs/cvsweb.cgi/?hideattic=0&amp;sortby=date">Nevrax</a> / <a href="/cvs/cvsweb.cgi/code/?hideattic=0&amp;sortby=date">code</a> / <a href="/cvs/cvsweb.cgi/code/client/?hideattic=0&amp;sortby=date">client</a> / <a href="/cvs/cvsweb.cgi/code/client/Attic/?hideattic=0&amp;sortby=date">Attic</a> / <a href="/cvs/cvsweb.cgi/code/client/Attic/move_listener.h?hideattic=0&amp;sortby=date">move_listener.h</a>&nbsp;(<A HREF="/cvs/cvsweb.cgi/~checkout~/code/client/Attic/move_listener.h?rev=1.2&amp;hideattic=0&amp;sortby=date" target="cvs_checkout" onClick="window.open('/cvs/cvsweb.cgi/~checkout~/code/client/Attic/move_listener.h?rev=1.2','cvs_checkout','resizeable,scrollbars');"><b>download</b></A>)<BR>
Revision <B>1.2</B>, <i>Mon Dec  4 17:58:09 2000 UTC</i> (19 months, 3 weeks ago) by <i>coutelas</i>
<BR>Branch: <b>MAIN</b>
<BR>Changes since <b>1.1: +75 -65
 lines</b><PRE>
no message
</PRE>
</td></tr></table><HR noshade><PRE>/** \file move_listener.h
 * &lt;File description&gt;
 *
 * $Id: move_listener.h,v 1.2 2000/12/04 17:58:09 coutelas Exp $
 */

/* Copyright, 2000 Nevrax Ltd.
 *
 * This file is part of NEVRAX NEL.
 * NEVRAX NEL is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2, or (at your option)
 * any later version.

 * NEVRAX NEL is distributed in the hope that it will be useful, but
 * WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
 * General Public License for more details.

 * You should have received a copy of the GNU General Public License
 * along with NEVRAX NEL; see the file COPYING. If not, write to the
 * Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
 * MA 02111-1307, USA.
 */

#ifndef NL_MOVE_LISTENER_H
#define NL_MOVE_LISTENER_H

#include &quot;nel/misc/types_nl.h&quot;
#include &quot;nel/misc/event_listener.h&quot;
#include &quot;nel/misc/matrix.h&quot;
#include &quot;nel/3d/viewport.h&quot;
#include &quot;nel/3d/scene.h&quot;
#include &quot;nel/3d/camera.h&quot;



namespace NL3D 
{


/**
 * CMoveListener is a listener that handle a 3d matrix with mouse events.
 * \author Stephane Coutelas
 * \author Nevrax France
 * \date 2000
 */
class CMoveListener : public NLMISC::IEventListener
{
public:
 &nbsp; &nbsp; &nbsp; &nbsp;
 &nbsp; &nbsp; &nbsp; &nbsp;/** 
 &nbsp; &nbsp; &nbsp; &nbsp; * TMoveMode. 
 &nbsp; &nbsp; &nbsp; &nbsp; * moving modes
 &nbsp; &nbsp; &nbsp; &nbsp; */
 &nbsp; &nbsp; &nbsp; &nbsp;enum TMoveMode
 &nbsp; &nbsp; &nbsp; &nbsp;{
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;WALK,
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;FREE
 &nbsp; &nbsp; &nbsp; &nbsp;};
 &nbsp; &nbsp; &nbsp; &nbsp;
 &nbsp; &nbsp; &nbsp; &nbsp;/** 
 &nbsp; &nbsp; &nbsp; &nbsp; * Constructor. 
 &nbsp; &nbsp; &nbsp; &nbsp; * You should call init then.
 &nbsp; &nbsp; &nbsp; &nbsp; */
 &nbsp; &nbsp; &nbsp; &nbsp;CMoveListener();


 &nbsp; &nbsp; &nbsp; &nbsp;/** 
 &nbsp; &nbsp; &nbsp; &nbsp; * Constructor. 
 &nbsp; &nbsp; &nbsp; &nbsp; * You should call init then.
 &nbsp; &nbsp; &nbsp; &nbsp; * \param scene the scene
 &nbsp; &nbsp; &nbsp; &nbsp; * \param w screen width in pixels
 &nbsp; &nbsp; &nbsp; &nbsp; * \param h screen height in pixels
 &nbsp; &nbsp; &nbsp; &nbsp; * \param camera the camera
 &nbsp; &nbsp; &nbsp; &nbsp; */
 &nbsp; &nbsp; &nbsp; &nbsp;void init(CScene * scene, uint w, uint h, const class CCamera&amp; camera)
 &nbsp; &nbsp; &nbsp; &nbsp;{
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;_Scene = scene;
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;_Width = w;
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;_Height = h;
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;_Viewport = scene-&gt;getViewport();

 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;float dummy;
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;_ViewMatrix = camera.getMatrix ();
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;camera.getFrustum (_Left, _Right, _Bottom, _Top, _Depth, dummy);
 &nbsp; &nbsp; &nbsp; &nbsp;}

 &nbsp; &nbsp; &nbsp; &nbsp;/**
 &nbsp; &nbsp; &nbsp; &nbsp; * Set the moving mode
 &nbsp; &nbsp; &nbsp; &nbsp; * \param m the moving mode
 &nbsp; &nbsp; &nbsp; &nbsp; */
 &nbsp; &nbsp; &nbsp; &nbsp;void setMode(TMoveMode m)
 &nbsp; &nbsp; &nbsp; &nbsp;{
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;_Mode = m;
 &nbsp; &nbsp; &nbsp; &nbsp;}

 &nbsp; &nbsp; &nbsp; &nbsp;/** 
 &nbsp; &nbsp; * Register the listener to the server.
 &nbsp; &nbsp; &nbsp; &nbsp; */
 &nbsp; &nbsp; &nbsp; &nbsp;void addToServer (NLMISC::CEventServer&amp; server);

 &nbsp; &nbsp; &nbsp; &nbsp;/** 
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;* Unregister the listener to the server.
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;*/
 &nbsp; &nbsp; &nbsp; &nbsp;void removeFromServer (NLMISC::CEventServer&amp; server);
 &nbsp; &nbsp; &nbsp; &nbsp;

private:

 &nbsp; &nbsp; &nbsp; &nbsp;/// Internal use
 &nbsp; &nbsp; &nbsp; &nbsp;virtual void operator()(const NLMISC::CEvent&amp; event);

 &nbsp; &nbsp; &nbsp; &nbsp;/// moving mode
 &nbsp; &nbsp; &nbsp; &nbsp;TMoveMode _Mode;
 &nbsp; &nbsp; &nbsp; &nbsp;
 &nbsp; &nbsp; &nbsp; &nbsp;/// view matrix
 &nbsp; &nbsp; &nbsp; &nbsp;NLMISC::CMatrix _ViewMatrix;

 &nbsp; &nbsp; &nbsp; &nbsp;/// viewport
 &nbsp; &nbsp; &nbsp; &nbsp;NL3D::CViewport &nbsp; &nbsp; &nbsp; &nbsp;_Viewport;
 &nbsp; &nbsp; &nbsp; &nbsp;
 &nbsp; &nbsp; &nbsp; &nbsp;/// true if previous mouse move event was re-centering cursor
 &nbsp; &nbsp; &nbsp; &nbsp;bool _CursorReset;

 &nbsp; &nbsp; &nbsp; &nbsp;CScene * _Scene;
 &nbsp; &nbsp; &nbsp; &nbsp;
 &nbsp; &nbsp; &nbsp; &nbsp;/// screen width
 &nbsp; &nbsp; &nbsp; &nbsp;uint _Width;

 &nbsp; &nbsp; &nbsp; &nbsp;/// screen height
 &nbsp; &nbsp; &nbsp; &nbsp;uint _Height;

 &nbsp; &nbsp; &nbsp; &nbsp;///frustum parameters
 &nbsp; &nbsp; &nbsp; &nbsp;float _Top;
 &nbsp; &nbsp; &nbsp; &nbsp;float _Bottom;
 &nbsp; &nbsp; &nbsp; &nbsp;float _Left;
 &nbsp; &nbsp; &nbsp; &nbsp;float _Right;
 &nbsp; &nbsp; &nbsp; &nbsp;float _Depth;
 &nbsp; &nbsp; &nbsp; &nbsp;
 &nbsp; &nbsp; &nbsp; &nbsp;/// current position
 &nbsp; &nbsp; &nbsp; &nbsp;CVector _Pos;

 &nbsp; &nbsp; &nbsp; &nbsp;///current rotation z angle
 &nbsp; &nbsp; &nbsp; &nbsp;float _RotZ;

 &nbsp; &nbsp; &nbsp; &nbsp;///current rotation x angle
 &nbsp; &nbsp; &nbsp; &nbsp;float _RotX;
 &nbsp; &nbsp; &nbsp; &nbsp;
 &nbsp; &nbsp; &nbsp; &nbsp;/// step for translation
 &nbsp; &nbsp; &nbsp; &nbsp;static const float _StepTrans;

 &nbsp; &nbsp; &nbsp; &nbsp;/// step for rotation
 &nbsp; &nbsp; &nbsp; &nbsp;static const float _StepRot;

}; // NL3D

}

#endif // NL_MOVE_LISTENER_H

/* End of move_listener.h */
</PRE>