Initial import!
Initial import!

file:b/CMakeLists.txt (new)
--- /dev/null
+++ b/CMakeLists.txt
@@ -1,1 +1,36 @@
+CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
+PROJECT(3dtictactoe)
 
+SET(CMAKE_MODULE_PATH "/usr/lib64/OGRE/cmake/;~/dev/kkengine-git/share/kkengine/cmake;${CMAKE_MODULE_PATH}")
+
+FIND_PACKAGE(KKEngine REQUIRED)
+FIND_PACKAGE(OGRE REQUIRED)
+FIND_PACKAGE(OIS REQUIRED)
+
+SET(SRCS
+  main.cpp
+  TTT.cpp
+  Cursor.cpp
+  Marker.cpp
+  )
+
+SET(DATAS
+  media/models/lemon.mesh
+  media/materials/lemon.material
+  media/models/beer.mesh
+  media/materials/beer.material
+)
+
+
+INCLUDE_DIRECTORIES(${KKENGINE_INCLUDE_DIRS} ${OGRE_INCLUDE_DIRS} ${OIS_INCLUDE_DIRS})
+
+ADD_EXECUTABLE(3dtictactoe ${SRCS})
+TARGET_LINK_LIBRARIES(3dtictactoe ${KKENGINE_LIBRARIES} ${OGRE_LIBRARIES} ${OIS_LIBRARIES})
+
+CONFIGURE_FILE(plugins.cfg ${CMAKE_CURRENT_BINARY_DIR}/plugins.cfg)
+CONFIGURE_FILE(resources.cfg ${CMAKE_CURRENT_BINARY_DIR}/resources.cfg)
+
+FOREACH(DATA ${DATAS})
+  CONFIGURE_FILE(${DATA} ${CMAKE_CURRENT_BINARY_DIR}/${DATA} COPYONLY)
+ENDFOREACH(DATA)
+

file:b/Cursor.cpp (new)
--- /dev/null
+++ b/Cursor.cpp
@@ -1,1 +1,61 @@
+#include "Cursor.h"
 
+#include <OgreEntity.h>
+
+Cursor::Cursor(Ogre::SceneManager *sceneMngr)
+  : _sceneMngr(sceneMngr)
+{ 
+  _cursorNode=_sceneMngr->getRootSceneNode()->createChildSceneNode();
+  _cursorNode->setPosition(Ogre::Vector3(0,0,0));
+  _cursorNode->setScale(Ogre::Vector3(40,40,40));
+  _cursorNode->pitch(Ogre::Degree(30));
+  _cursorNode->roll(Ogre::Degree(30));
+  _position=Ogre::Vector3(0,0,0);
+
+  setType("lemon");
+}
+
+Ogre::Vector3 Cursor::position()
+{
+  return _position;
+}
+
+Ogre::String Cursor::type()
+{
+  return _type;
+}
+
+void Cursor::setType(Ogre::String type)
+{
+  _type=type;
+  
+  _cursorNode->detachAllObjects();
+  if(_sceneMngr->hasEntity(_type+"cursor"))
+    _cursorEntity=_sceneMngr->getEntity(_type+"cursor");
+  else
+    {
+      _cursorEntity=_sceneMngr->createEntity(_type+"cursor",_type+".mesh");
+      _cursorEntity->setRenderQueueGroup(10);
+    }
+  _cursorNode->attachObject(_cursorEntity);
+
+  
+}
+
+void Cursor::move(Ogre::Vector3 dir)
+{
+  _position+=dir;
+
+  if(Ogre::Math::Abs(_position.x)>1)
+    _position.x=_position.x/Ogre::Math::Abs(_position.x);
+  if(Ogre::Math::Abs(_position.y)>1)
+    _position.y=_position.y/Ogre::Math::Abs(_position.y);
+  if(Ogre::Math::Abs(_position.z)>1)
+    _position.z=_position.z/Ogre::Math::Abs(_position.z);
+
+  //printf("%f %f %f\n",_position.x,_position.y,_position.z);
+  _cursorNode->setPosition(_position*100);
+}
+
+
+

file:b/Cursor.h (new)
--- /dev/null
+++ b/Cursor.h
@@ -1,1 +1,28 @@
+#ifndef CURSOR_H_
+#define CURSOR_H_
 
+#include <OgreSceneManager.h>
+
+class Cursor 
+{
+public:
+  Cursor(Ogre::SceneManager *sceneMngr);
+
+  void move(Ogre::Vector3 dir);
+
+  Ogre::Vector3 position();
+
+  Ogre::String type();
+  void setType(Ogre::String type);
+private:
+  Ogre::SceneManager *_sceneMngr;
+
+  Ogre::Entity *_cursorEntity;
+  Ogre::SceneNode *_cursorNode;
+
+  Ogre::Vector3 _position;
+  Ogre::String _type;
+};
+
+#endif // CURSOR_H_
+

file:b/Marker.cpp (new)
--- /dev/null
+++ b/Marker.cpp
@@ -1,1 +1,20 @@
+#include "Marker.h"
 
+#include <OgreEntity.h>
+
+int Marker::_count=0;
+
+Marker::Marker(Ogre::SceneManager *sceneMngr,Ogre::Vector3 position,Ogre::String type)
+  : _sceneMngr(sceneMngr)
+{   
+  _count++;
+  _markerEntity=sceneMngr->createEntity(type+Ogre::StringConverter::toString(_count),type+".mesh");
+  _markerNode=_sceneMngr->getRootSceneNode()->createChildSceneNode();
+  _markerNode->attachObject(_markerEntity);
+  _markerNode->setPosition(position*100);
+  _markerNode->setScale(Ogre::Vector3(40,40,40));
+  _markerNode->pitch(Ogre::Degree(30));
+  _markerNode->roll(Ogre::Degree(30));
+}
+
+

file:b/Marker.h (new)
--- /dev/null
+++ b/Marker.h
@@ -1,1 +1,21 @@
+#ifndef MARKER_H_
+#define MARKER_H_
 
+#include <OgreSceneManager.h>
+
+class Marker 
+{
+public:
+  Marker(Ogre::SceneManager *sceneMngr,Ogre::Vector3 position,Ogre::String type);
+
+private:
+  static int _count;
+
+  Ogre::SceneManager *_sceneMngr;
+
+  Ogre::Entity *_markerEntity;
+  Ogre::SceneNode *_markerNode;
+};
+
+#endif // MARKER_H_
+

file:b/TTT.cpp (new)
--- /dev/null
+++ b/TTT.cpp
@@ -1,1 +1,188 @@
+#include "TTT.h"
 
+#include <OgreManualObject.h>
+
+TTT::TTT()
+  : App()
+{ }
+
+void TTT::setupScene()
+{
+  createGrid();
+
+  createCamera();
+
+  _cursor=new Cursor(sceneMngr());
+}
+
+void TTT::createGrid()
+{
+  Ogre::ManualObject *manual=sceneMngr()->createManualObject("manual");
+ 
+  // Y axis
+  manual->begin("BaseWhiteNoLighting", Ogre::RenderOperation::OT_LINE_LIST);
+  manual->position(50,-150,50);
+  manual->position(50,150,50);
+  manual->end();
+
+  manual->begin("BaseWhiteNoLighting", Ogre::RenderOperation::OT_LINE_LIST);
+  manual->position(-50,-150,50);
+  manual->position(-50,150,50);
+  manual->end();
+
+  manual->begin("BaseWhiteNoLighting", Ogre::RenderOperation::OT_LINE_LIST);
+  manual->position(50,-150,-50);
+  manual->position(50,150,-50);
+  manual->end();
+
+  manual->begin("BaseWhiteNoLighting", Ogre::RenderOperation::OT_LINE_LIST);
+  manual->position(-50,-150,-50);
+  manual->position(-50,150,-50);
+  manual->end();
+
+  // X axis
+  manual->begin("BaseWhiteNoLighting", Ogre::RenderOperation::OT_LINE_LIST);
+  manual->position(-150,50,50);
+  manual->position(150,50,50);
+  manual->end();
+
+  manual->begin("BaseWhiteNoLighting", Ogre::RenderOperation::OT_LINE_LIST);
+  manual->position(-150,50,-50);
+  manual->position(150,50,-50);
+  manual->end();
+
+  manual->begin("BaseWhiteNoLighting", Ogre::RenderOperation::OT_LINE_LIST);
+  manual->position(-150,-50,50);
+  manual->position(150,-50,50);
+  manual->end();
+
+  manual->begin("BaseWhiteNoLighting", Ogre::RenderOperation::OT_LINE_LIST);
+  manual->position(-150,-50,-50);
+  manual->position(150,-50,-50);
+  manual->end();
+
+  // Z axis
+  manual->begin("BaseWhiteNoLighting", Ogre::RenderOperation::OT_LINE_LIST);
+  manual->position(50,50,-150);
+  manual->position(50,50,150);
+  manual->end();
+
+  manual->begin("BaseWhiteNoLighting", Ogre::RenderOperation::OT_LINE_LIST);
+  manual->position(50,-50,-150);
+  manual->position(50,-50,150);
+  manual->end();
+
+  manual->begin("BaseWhiteNoLighting", Ogre::RenderOperation::OT_LINE_LIST);
+  manual->position(-50,50,-150);
+  manual->position(-50,50,150);
+  manual->end();
+
+  manual->begin("BaseWhiteNoLighting", Ogre::RenderOperation::OT_LINE_LIST);
+  manual->position(-50,-50,-150);
+  manual->position(-50,-50,150);
+  manual->end();
+
+  
+  // add ManualObject to the RootSceneNode (so it will be visible)
+  sceneMngr()->getRootSceneNode()->attachObject(manual);
+}
+
+void TTT::createCamera()
+{
+  Ogre::Camera *camera=sceneMngr()->createCamera("Camera");
+  camera->setAspectRatio(Ogre::Real(viewport()->getActualWidth())/Ogre::Real(viewport()->getActualHeight()));  
+  viewport()->setCamera(camera);
+
+  _cameraMan=new OgreBites::SdkCameraMan(camera);
+  _cameraMan->setStyle(OgreBites::CS_ORBIT);
+  _cameraMan->setTarget(sceneMngr()->getRootSceneNode());
+  _cameraMan->setYawPitchDist(Ogre::Degree(-40),Ogre::Degree(45),Ogre::Real(500));
+}
+
+bool TTT::mousePressed(const OIS::MouseEvent& evt, OIS::MouseButtonID id)
+{
+  _cameraMan->injectMouseDown(evt,id);
+  return App::mousePressed(evt,id);
+}
+ 
+bool TTT::mouseReleased(const OIS::MouseEvent& evt, OIS::MouseButtonID id)
+{
+  _cameraMan->injectMouseUp(evt,id);
+  return App::mouseReleased(evt,id);
+}
+ 
+bool TTT::mouseMoved(const OIS::MouseEvent& evt)
+{
+    _cameraMan->injectMouseMove(evt);
+    return App::mouseMoved(evt);
+}
+ 
+bool TTT::keyPressed(const OIS::KeyEvent& evt)
+{
+  switch(evt.key)
+    {
+    case OIS::KC_UP:
+      _cursor->move(Ogre::Vector3(1,0,0));
+      break;
+    case OIS::KC_DOWN:
+      _cursor->move(Ogre::Vector3(-1,0,0));
+      break;
+    case OIS::KC_LEFT:
+      _cursor->move(Ogre::Vector3(0,0,-1));
+      break;
+    case OIS::KC_RIGHT:
+      _cursor->move(Ogre::Vector3(0,0,1));
+      break;
+    case OIS::KC_PGUP:
+      _cursor->move(Ogre::Vector3(0,1,0));
+      break;
+    case OIS::KC_PGDOWN:
+      _cursor->move(Ogre::Vector3(0,-1,0));
+      break;
+    case OIS::KC_RETURN:
+      place();
+    default:
+      _cameraMan->injectKeyDown(evt);
+    }
+  return App::keyPressed(evt);
+}
+ 
+bool TTT::keyReleased(const OIS::KeyEvent& evt)
+{
+  _cameraMan->injectKeyUp(evt);
+  return App::keyReleased(evt);
+}
+
+void TTT::place()
+{
+  Ogre::Vector3 pos=_cursor->position();
+  unsigned int code=0;
+  code|=(codeforpos(pos.x)<<0);
+  code|=(codeforpos(pos.y)<<3);
+  code|=(codeforpos(pos.z)<<6);
+  printf("%d: %f %f %f\n",code,pos.x,pos.y,pos.z);
+  printf("count %d\n",_markers.count(code));
+
+  if(_markers.count(code)>0) 
+    {
+      printf("%p\n",_markers[code]);
+      return;}
+
+  Ogre::String type=_cursor->type();
+  Marker *marker=new Marker(sceneMngr(),pos,type);
+  _markers[code]=marker;
+
+  if(type=="lemon")
+    _cursor->setType("beer");
+  else
+    _cursor->setType("lemon");
+}
+
+unsigned int TTT::codeforpos(int x)
+{
+  if(x==-1) return 1;
+  if(x==0) return 2;
+  if(x==1) return 4;
+  return 0;
+}
+

file:b/TTT.h (new)
--- /dev/null
+++ b/TTT.h
@@ -1,1 +1,42 @@
+#ifndef TTT_H_
+#define TTT_H_
 
+#include <kkengine/App.h>
+
+#include <SdkCameraMan.h>
+
+#include <map>
+
+#include "Cursor.h"
+#include "Marker.h"
+
+
+class TTT : public App
+{
+public:
+  TTT();
+
+protected:
+  void setupScene();
+
+  bool mousePressed(const OIS::MouseEvent& evt, OIS::MouseButtonID id);
+  bool mouseReleased(const OIS::MouseEvent& evt, OIS::MouseButtonID id);
+  bool mouseMoved(const OIS::MouseEvent& evt);
+  bool keyPressed(const OIS::KeyEvent& evt);
+  bool keyReleased(const OIS::KeyEvent& evt);
+
+private:
+  OgreBites::SdkCameraMan *_cameraMan;
+  Cursor *_cursor;
+  std::map<unsigned int,Marker * > _markers;
+
+  void createGrid();
+  void createCamera();
+
+  void place();
+
+  unsigned int codeforpos(int x);
+};
+
+#endif // TTT_H_
+

file:b/main.cpp (new)
--- /dev/null
+++ b/main.cpp
@@ -1,1 +1,19 @@
+#include "TTT.h"
 
+#include <OgreException.h>
+
+int main(int argc,char* argv[])
+{
+  TTT app;
+
+  try 
+    {
+      app.run();
+    }
+  catch(Ogre::Exception &e)
+    {
+      std::cerr << "An exception has occured: " << e.getFullDescription().c_str() << std::endl;
+    }
+  return 0;
+}
+

Binary files /dev/null and b/media/blender/beer.blend differ

Binary files /dev/null and b/media/blender/lemon.blend differ

--- /dev/null
+++ b/media/materials/beer.material
@@ -1,1 +1,13 @@
+material BeerMaterial
+{
+	receive_shadows on
+	technique
+	{
+		pass
+		{
+			ambient 0.25 0.17 0.12
+			diffuse 0.25 0.17 0.12
+		}
+	}
+}
 

--- /dev/null
+++ b/media/materials/lemon.material
@@ -1,1 +1,13 @@
+material LemonMaterial
+{
+	receive_shadows on
+	technique
+	{
+		pass
+		{
+			ambient 0.8 0.63 0.14
+			diffuse 0.8 0.63 0.14
+		}
+	}
+}
 

Binary files /dev/null and b/media/models/beer.mesh differ

Binary files /dev/null and b/media/models/lemon.mesh differ

file:b/plugins.cfg (new)
--- /dev/null
+++ b/plugins.cfg
@@ -1,1 +1,2 @@
-
+PluginFolder=/usr/lib/OGRE
+Plugin=RenderSystem_GL

file:b/resources.cfg (new)
--- /dev/null
+++ b/resources.cfg
@@ -1,1 +1,7 @@
+[KKEngine]
+FileSystem=@KKENGINE_DATA@/media/overlays
+FileSystem=@KKENGINE_DATA@/media/fonts
 
+[TTT]
+FileSystem=media/models
+FileSystem=media/materials