📄 ogre4jroot.h
字号:
/* Ogre4J
Copyright (C) 2002 macross
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or any later version.
This library 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
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#ifndef _OGRE4J_ROOT_H_
#define _OGRE4J_ROOT_H_
#include <jni.h>
#include <Ogre.h>
#include <OgreEventListeners.h>
#include <list>
using namespace Ogre;
class Ogre4JRoot:
public FrameListener,
public MouseListener,
public MouseMotionListener,
public KeyListener {
public:
static Ogre4JRoot& instance();
~Ogre4JRoot();
bool start(const char* pluginFile, const char* ressourceFile, bool showConfigDialog);
void exit();
jobject addViewport(JNIEnv *env, jobject camera);
void startRendering(JNIEnv *env, jobject frameListener);
public:
// listeners
bool frameStarted (const FrameEvent& evt);
bool frameEnded (const FrameEvent& evt);
void keyClicked (KeyEvent *e);
void keyPressed (KeyEvent *e);
void keyReleased (KeyEvent *e);
void mouseClicked (MouseEvent *e);
void mouseEntered (MouseEvent *e);
void mouseExited (MouseEvent *e);
void mousePressed (MouseEvent *e);
void mouseReleased (MouseEvent *e);
void mouseMoved (MouseEvent *e);
void mouseDragged (MouseEvent *e);
public:
// NativeObject
void* getCppRef(jobject jobj);
MovableObject* getCppMovableObjectRef(jobject jobj);
jobject newJRef(jclass clazz, void* cppRef, MovableObject* movableObjectRef = 0);
// JAVA -> OGRE
ColourValue newColourValue(jobject col);
Vector3 newVector3(jobject vec);
Quaternion newQuaternion(jobject q);
Plane newPlane(jobject pln);
// OGRE -> JAVA
jobject newVector3(const Vector3& vec);
jobject newColourValue(const ColourValue& col);
jobject newQuaternion(const Quaternion& q);
jobject newPlane(const Plane& pln);
private:
Ogre4JRoot();
private:
bool checkException();
jobject newFrameEvent(const FrameEvent& evt);
jobject newKeyEvent(KeyEvent* e);
jobject newMouseEvent(MouseEvent* e);
public:
bool quitRenderLoop;
Root* root;
RenderWindow* renderWindow;
EventProcessor* eventProcessor;
/*
* jni stuff
*/
JNIEnv*
jniEnv;
jobject
eventHub,
// global references, so we don't have to recreate event object
frameEventRef,
keyEventRef,
mouseEventRef;
jclass
nativeObjectClass,
viewportClass,
sceneManagerClass,
lightClass,
cameraClass,
boneClass,
sceneNodeClass,
entityClass,
overlayClass,
billboardClass,
billboardSetClass,
animationClass,
meshClass,
skeletonClass,
animationStateClass,
materialClass,
vectorClass,
quaternionClass,
colourValueClass,
logClass,
planeClass,
subEntityClass;
jfieldID
fidNativeObject_self,
fidNativeObject_movableObject,
fidVector3X,
fidVector3Y,
fidVector3Z,
fidColourValueR,
fidColourValueG,
fidColourValueB,
fidColourValueA,
fidQuaternionX,
fidQuaternionY,
fidQuaternionZ,
fidQuaternionW,
fidPlaneNormal,
fidPlaneD;
jmethodID
midVectorSet,
midQuaternionSet,
midColourValueSet,
midPlaneSet;
jmethodID
preRenderLoopMethodId,
postRenderLoopMethodId,
frameStartedMethodId,
frameEndedMethodId,
keyClickedMethodId,
keyPressedMethodId,
keyReleasedMethodId,
mouseClickedMethodId,
mouseEnteredMethodId,
mouseExitedMethodId,
mousePressedMethodId,
mouseReleasedMethodId,
mouseMovedMethodId,
mouseDraggedMethodId;
};
#define OGRE4J Ogre4JRoot::instance()
#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -