📄 glserver.h
字号:
/*************************************************************************** * Copyright (C) 2004 - 2006 by ZJUBase *
* National Lab of Industrial Control Tech. * * Zhejiang University, China *
* * * Team members: *
* Currently the team leader is, * * Hao JIANG (jianghao@iipc.zju.edu.cn; riveria@gmail.com) *
* In the next season, the leader will be * * Yifeng ZHANG (yfzhang@iipc.zju.edu.cn) *
* ZJUBase 3D agent is created by * * Dijun LUO (djluo@iipc.zju.edu.cn) *
* All the members who has ever contributed: * * Jun JIANG *
* Xinfeng DU (xfdu@iipc.zju.edu.cn) *
* Yang ZHOU (yzhou@iipc.zju.edu.cn) *
* Zhipeng YANG *
* Xiang FAN *
* *
* Team Manager: *
* Ms. Rong XIONG (rxiong@iipc.zju.edu.cn) *
* *
* If you met any problems or you have something to discuss about * * ZJUBase. Please feel free to contact us through EMails given below. * * * * This program 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 of the License, or * * (at your option) any later version. * * * * This program 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 this program; if not, write to the * * Free Software Foundation, Inc., * * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * ***************************************************************************/
#ifndef _GLSERVER_H
#define _GLSERVER_H
#include "global.h"
#include "camera.h"
#include <string>
using namespace std;
#ifndef __glut_h__
void APIENTRY
glutSolidSphere(GLdouble radius, GLint slices, GLint stacks);
void APIENTRY
glutWireSphere(GLdouble radius, GLint slices, GLint stacks);
#endif
class GLServer
{
public:
enum ETextAlign { eNONE, eLEFT, eRIGHT, eCENTER };
GLServer(){};
GLServer(int width, int height,
Vector3 camPos,
Vector3 lookAtPos,
Vector3 up, bool wire);
~GLServer() {};
void InitGL();
void DrawGroundRectangle(Vector3 pos, double szX, double szY,
double angleDeg, double height = 0.0f);
void DrawCircle(const Vector3& pos, double radius,
double start_angle = 0.0, double end_angle = 360.0);
void ApplyCamera();
void DrawText(const char* text, Vector2 pos);
void DrawText3D(const char* text, const Vector3& pos);
void DrawText3D(const string& text, const Vector3& pos);
void DrawTextPix(const char* text, Vector2 pix, ETextAlign = eNONE);
int GetTextHeight() const;
int GetTextWidth(const char* text) const;
void DrawGoal(Vector3 goalPos, Vector3 sz, double barRadius = 0.06);
void DrawSphere(Vector3 spherePos, double radius, int res = 10);
void DrawShadowOfSphere(Vector3 spherePos,double radius);
void DrawWireBox(Vector3 boxPos, Vector3 sz);
void Reshape(int width, int height)
{
mWidth = width;
mHeight = height;
}
int GetWidth() { return mWidth; }
int GetHeight() { return mHeight; }
//inline functions
inline void SetViewByMouse(const Vector2& mousePos, const Vector2& refPos)
{
mCamera.SetViewByMouse(mousePos, refPos);
}
inline Vector3 GetCameraPos()
{
return mCamPos;
}
inline void SetCameraPos(const Vector3& newPos)
{
mCamPos = newPos;
mCamera.SetCameraPos(newPos);
}
inline void SetLookAtPos(const Vector3& newPos)
{
mLookAt = newPos;
mCamera.SetLookAtPos(newPos);
}
inline void MoveCamForward(double steps)
{
mCamera.MoveCamForward(steps);
mCamPos = mCamera.GetLookAtPos();
mLookAt = mCamera.GetCameraPos();
}
inline void MoveCamStrafeForward(double steps)
{
mCamera.MoveCamStrafeForward(steps);
mCamPos = mCamera.GetLookAtPos();
mLookAt = mCamera.GetCameraPos();
}
inline void MoveCamStrafe(double steps)
{
mCamera.MoveCamStrafe(steps);
mCamPos = mCamera.GetLookAtPos();
mLookAt = mCamera.GetCameraPos();
}
inline void MoveCamUp(double steps)
{
mCamera.MoveCamUp(steps);
mCamPos = mCamera.GetLookAtPos();
mLookAt = mCamera.GetCameraPos();
}
inline bool GetWireframe()
{
return mWireframe;
}
inline void SetWireframe(bool flag)
{
mWireframe = flag;
}
protected:
Vector3 mCamPos;
Vector3 mLookAt;
Vector3 mUp;
Camera mCamera;
bool mWireframe;
int mWidth;
int mHeight;
};
#endif // _GLSERVER_H
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -