Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /***********************************************************************
- * fACT
- * framework for Animation of virtual Characters in Three dimensions
- ***********************************************************************/
- /*!
- * \file sg_Console.cpp
- * \brief Definition of the class CsgConsole.
- * $Date: 2010/04/07$
- */
- #include "sg_Console.hpp"
- #include "OsInfo.hpp"
- #include "ChData.hpp"
- /*! \fn void CsgConsole::ConsoleLoop(CKonsola & konsola)
- * \brief Read from console and execute commands
- */
- void CsgConsole::ConsoleLoop(CKonsola & konsola)
- {
- //**************************************************
- // Inicjalizacja
- std::string linia;
- if (pOs->isDataSet())
- pOs->getdata()->setData("error_info", " ");
- OBJECT_3D_DEF obj(true, 0, "Avatar", 0); //obiekt sceny 3D
- konsola << "Avatar";
- konsola.getBuffer().push_back("Avatar");
- konsola.setcword(1);
- OnInfo(konsola);
- //**************************************************
- // Inicjalizacja Sceny
- obj.set_subobj_name("");
- pOs->Rotate(obj, -30, 0, 0, false);
- pOs->Move(obj, -30, 0, 0, 0, 0, false);
- obj.set_subobj_name("R UpperArm");
- pOs->Rotate(obj, -75, 0, 0, false);
- obj.set_subobj_name("L UpperArm");
- pOs->Rotate(obj, -75, 0, 0, false);
- //*************************************************************
- //***************************************************************
- //***************************************************************
- // Zadanie.
- //
- std::cin.get();
- //prawa z przodu*******************************************
- for (int i = 0; i < 10; ++i)
- {
- obj.set_subobj_name("");
- pOs->Move(obj, 1, 0, 0, 0, 0, false);
- obj.set_subobj_name("R UpperArm");
- pOs->Rotate(obj, -1.5, 2, 0, false); //-15
- obj.set_subobj_name("L UpperArm");
- pOs->Rotate(obj, -1.5, 2, 0, false); //15
- obj.set_subobj_name("R Thigh"); //20
- pOs->Rotate(obj, 2, 0, 0, false);
- obj.set_subobj_name("R Foot"); //-20
- pOs->Rotate(obj, -2, 0, 0, false);
- obj.set_subobj_name("L Thigh"); //-20
- pOs->Rotate(obj, -2, 0, 0, false);
- obj.set_subobj_name("L Calf"); //-10
- pOs->Rotate(obj, -1, 0, 0, true);
- }
- //while (true) {
- for (int i = 0; i < 15; ++i)
- {
- obj.set_subobj_name("");
- pOs->Move(obj, 1, 0, 0, 0, 0, false);
- obj.set_subobj_name("R UpperArm");
- pOs->Rotate(obj, 1, 2, 0, false); //0
- obj.set_subobj_name("L UpperArm");
- pOs->Rotate(obj, 1, 2, 0, false); //0
- obj.set_subobj_name("R Thigh"); //5
- pOs->Rotate(obj, -1, 0, 0, false);
- obj.set_subobj_name("R Foot"); //-5
- pOs->Rotate(obj, 1, 0, 0, false);
- obj.set_subobj_name("L Thigh"); //10
- pOs->Rotate(obj, 2, 0, 0, false);
- obj.set_subobj_name("L Calf"); //-70
- pOs->Rotate(obj, -4, 0, 0, true);
- }
- for (int i = 0; i < 15; ++i)
- {
- obj.set_subobj_name("");
- pOs->Move(obj, 1, 0, 0, 0, 0, false);
- obj.set_subobj_name("R UpperArm");
- pOs->Rotate(obj, 1, 2, 0, false); //15
- obj.set_subobj_name("L UpperArm");
- pOs->Rotate(obj, 1, 2, 0, false); //-15
- obj.set_subobj_name("R Thigh"); //-10
- pOs->Rotate(obj, -1, 0, 0, false);
- obj.set_subobj_name("R Foot"); //10
- pOs->Rotate(obj, 1, 0, 0, false);
- obj.set_subobj_name("L Thigh"); //40
- pOs->Rotate(obj, 2, 0, 0, false);
- obj.set_subobj_name("L Calf"); //-40
- pOs->Rotate(obj, 2, 0, 0, true);
- }
- for (int i = 0; i < 15; ++i)
- {
- obj.set_subobj_name("");
- pOs->Move(obj, 1, 0, 0, 0, 0, false);
- obj.set_subobj_name("R UpperArm");
- pOs->Rotate(obj, 1, 2, 0, false); //30
- obj.set_subobj_name("L UpperArm");
- pOs->Rotate(obj, 1, 2, 0, false); //-30
- obj.set_subobj_name("R Thigh"); //-25
- pOs->Rotate(obj, -1, 0, 0, false);
- obj.set_subobj_name("R Foot"); //10
- pOs->Rotate(obj, 0, 0, 0, false);
- obj.set_subobj_name("L Thigh"); //40
- pOs->Rotate(obj, 0, 0, 0, false);
- obj.set_subobj_name("L Calf"); //-10
- pOs->Rotate(obj, 2, 0, 0, true);
- }
- for (int i = 0; i < 10; ++i)
- {
- obj.set_subobj_name("");
- pOs->Move(obj, 1, 0, 0, 0, 0, false);
- obj.set_subobj_name("R UpperArm");
- pOs->Rotate(obj, -1.5, 2, 0, false); //15
- obj.set_subobj_name("L UpperArm");
- pOs->Rotate(obj, -1.5, 2, 0, false); //-15
- obj.set_subobj_name("R Thigh"); //-20
- pOs->Rotate(obj, 0.5, 0, 0, false);
- obj.set_subobj_name("R Calf");
- pOs->Rotate(obj, -1, 0, 0, false); //-10
- obj.set_subobj_name("L Thigh"); //20
- pOs->Rotate(obj, -2, 0, 0, false);
- obj.set_subobj_name("L Calf"); //0
- pOs->Rotate(obj, 1, 0, 0, false);
- obj.set_subobj_name("L Foot"); //-20
- pOs->Rotate(obj, -2, 0, 0, false);
- obj.set_subobj_name("R Foot"); //0
- pOs->Rotate(obj, -1, 0, 0, true);
- }
- //lewa z przodu************************************************
- for (int i = 0; i < 15; ++i)
- {
- obj.set_subobj_name("");
- pOs->Move(obj, 1, 0, 0, 0, 0, false);
- obj.set_subobj_name("L UpperArm");
- pOs->Rotate(obj, 1, 2, 0, false); //0
- obj.set_subobj_name("R UpperArm");
- pOs->Rotate(obj, 1, 2, 0, false); //0
- obj.set_subobj_name("L Thigh"); //5
- pOs->Rotate(obj, -1, 0, 0, false);
- obj.set_subobj_name("L Foot");
- pOs->Rotate(obj, 1, 0, 0, false);
- obj.set_subobj_name("R Thigh"); //10
- pOs->Rotate(obj, 2, 0, 0, false);
- obj.set_subobj_name("R Calf"); //-70
- pOs->Rotate(obj, -4, 0, 0, true);
- }
- for (int i = 0; i < 15; ++i)
- {
- obj.set_subobj_name("");
- pOs->Move(obj, 1, 0, 0, 0, 0, false);
- obj.set_subobj_name("L UpperArm");
- pOs->Rotate(obj, 1, 2, 0, false); //15
- obj.set_subobj_name("R UpperArm");
- pOs->Rotate(obj, 1, 2, 0, false); //-15
- obj.set_subobj_name("L Thigh"); //-10
- pOs->Rotate(obj, -1, 0, 0, false);
- obj.set_subobj_name("L Foot");
- pOs->Rotate(obj, 1, 0, 0, false);
- obj.set_subobj_name("R Thigh"); //40
- pOs->Rotate(obj, 2, 0, 0, false);
- obj.set_subobj_name("R Calf"); //-40
- pOs->Rotate(obj, 2, 0, 0, true);
- }
- for (int i = 0; i < 15; ++i)
- {
- obj.set_subobj_name("");
- pOs->Move(obj, 1, 0, 0, 0, 0, false);
- obj.set_subobj_name("L UpperArm");
- pOs->Rotate(obj, 1, 2, 0, false); //30
- obj.set_subobj_name("R UpperArm");
- pOs->Rotate(obj, 1, 2, 0, false); //-30
- obj.set_subobj_name("L Thigh"); //-25
- pOs->Rotate(obj, -1, 0, 0, false);
- obj.set_subobj_name("L Foot");
- pOs->Rotate(obj, 0, 0, 0, false);
- obj.set_subobj_name("R Thigh"); //40
- pOs->Rotate(obj, 0, 0, 0, false);
- obj.set_subobj_name("R Calf"); //-10
- pOs->Rotate(obj, 2, 0, 0, true);
- }
- for (int i = 0; i < 10; ++i)
- {
- obj.set_subobj_name("");
- pOs->Move(obj, 1, 0, 0, 0, 0, false);
- obj.set_subobj_name("L UpperArm");
- pOs->Rotate(obj, -1.5, 2, 0, false); //15
- obj.set_subobj_name("R UpperArm");
- pOs->Rotate(obj, -1.5, 2, 0, false); //-15
- obj.set_subobj_name("L Thigh"); //-20
- pOs->Rotate(obj, 0.5, 0, 0, false);
- obj.set_subobj_name("L Calf");
- pOs->Rotate(obj, -1, 0, 0, false); //-10
- obj.set_subobj_name("R Thigh"); //20
- pOs->Rotate(obj, -2, 0, 0, false);
- obj.set_subobj_name("R Calf"); //0
- pOs->Rotate(obj, 1, 0, 0, false);
- obj.set_subobj_name("R Foot"); //-20
- pOs->Rotate(obj, -2, 0, 0, false);
- obj.set_subobj_name("L Foot"); //0
- pOs->Rotate(obj, -1, 0, 0, true);
- }
- //}
- std::cin.get();
- }
- void CsgConsole::OnInitialize()
- {}
- void CsgConsole::Reload(CKonsola & konsola)
- {}
- /*!
- * \brief Executed after run() - starts new thread
- * /exception
- */
- void CsgConsole::main()
- {
- try
- {
- mainOnManually();
- pOs->setactiveObj3D(false);
- delete pOs;
- //pOs->UnregisterCharacter();
- }
- catch(fACT_exception& inException)
- {
- //pOs->UnregisterCharacter();
- delete pOs;
- std::cerr << "exception catched:" << std::endl;
- std::cerr << inException.what() << std::endl << std::flush;
- }
- catch(...)
- {
- delete pOs;
- //pOs->UnregisterCharacter();
- std::cerr << "Unknown exception catched!" << std::endl << std::flush;
- }
- }
- /*!
- * \brief main function of CsgConsole. Initialize scene. Runs pOs->OnBeginStrategy(). Read from console and execute user actions
- * /exception
- */
- void CsgConsole::mainOnManually()
- {
- try{
- pOs->OnBeginStrategy();
- }
- catch(...)
- {
- // pOs->done();
- return;
- }
- CKonsola konsola;
- ConsoleLoop(konsola);
- try{
- pOs->OnEndStrategy();
- }
- catch(...){}
- }
- /*! \fn void CsgConsole::OnInfo(CKonsola &konsola)
- * \brief Print Info about
- * \param konsola oistream with op parameters
- * \return info on konsola about operation execution
- */
- void CsgConsole::OnInfo(CKonsola &konsola)
- {
- int i= konsola.getcword();
- if(i<1)
- {
- //konsola.unlock();
- PrintP(konsola); konsola << "Too few parameters. Print: Help" << el << end;
- konsola.flush();
- return;
- }
- std::string group;
- konsola >> group;
- OBJECT_3D_DEF obj;
- if(group==" ")
- {
- //konsola.unlock();
- PrintP(konsola); konsola << "Wrong parameters. Print: Help" << el << end;
- konsola.flush();
- return;
- }
- else if(group=="Avatar")
- obj.isCharacter=true;
- else
- {
- obj.group=pOs->getossInfo()->getGroupByName(group.c_str());
- if(obj.group==NULL)
- obj.obj_name=group;
- }
- if(konsola.eof())
- {
- //konsola.unlock();
- _V_INFO_subobj vb;
- try{
- pOs->getSubObjsInfoVector(obj, vb);
- }
- catch(...)
- {
- PrintP(konsola); konsola << "Wrong parameters. Print: Help" << el << end;
- konsola.flush();
- return;
- }
- int vectorsize=vb.size();
- for(i=0;i<vectorsize;++i)
- {
- konsola << vb[i]->id << " - " << vb[i]->name.c_str() << " idParent- " << vb[i]->idParent << el;
- delete vb[i];
- }
- konsola << end;
- vb.clear();
- }
- konsola.flush();
- }
- //#endif // #ifndef _NO_EVOLUTION_RUN_
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement