示例#1
0
void Situated::load(const Aurora::GFF3Struct &instance, const Aurora::GFF3Struct *blueprint) {
	// General properties

	if (blueprint)
		loadProperties(*blueprint); // Blueprint
	loadProperties(instance);    // Instance


	// Specialized object properties

	if (blueprint)
		loadObject(*blueprint); // Blueprint
	loadObject(instance);    // Instance


	// Appearance

	if (_appearanceID == Aurora::kFieldIDInvalid)
		throw Common::Exception("Situated object without an appearance");

	loadAppearance();
	loadSounds();


	// Position

	float posX = instance.getDouble("X");
	float posY = instance.getDouble("Y");
	float posZ = instance.getDouble("Z");

	if (instance.hasField("Position")) {
		const Aurora::GFF3Struct &pos = instance.getStruct("Position");

		posX = pos.getDouble("x");
		posY = pos.getDouble("y");
		posZ = pos.getDouble("z");
	}

	setPosition(posX, posY, posZ);

	// Orientation

	float bearing = instance.getDouble("Bearing");

	float rotX = 0.0f;
	float rotY = 0.0f;
	float rotZ = 1.0f;
	float rotW = Common::rad2deg(bearing);

	if (instance.hasField("Orientation")) {
		const Aurora::GFF3Struct &o = instance.getStruct("Orientation");

		rotX = o.getDouble("x");
		rotY = o.getDouble("y");
		rotZ = o.getDouble("z");
		rotW = -Common::rad2deg(acos(o.getDouble("w")) * 2.0);
	}

	setOrientation(rotX, rotY, rotZ, rotW);
}
示例#2
0
void		GameEngine::loadGame()
{
  _menuTheme.stop();
  _menu.setGen(mode::gen::LOAD);
  _menu.setMode(mode::load::UNKNOWN);
  _menu.setSub(mode::load::SOLO);
  draw();

  std::ifstream file("saved/game");

  _map = new Map("saved/game", true);
  _map->loadFile(&file);
  loadObject(_map);
  _projection = glm::perspective(FOV,
  				 WIN_WIDTH / static_cast<float>(WIN_HEIGHT),
  				 MIN_RANGE,
  				 MAX_RANGE);
  _transformation = glm::lookAt(_camera, glm::vec3(_camera.x, 0, 0), glm::vec3(0, 1, 0));
  _shader.bind();
  _shader.setUniform("view", _transformation);
  _shader.setUniform("projection", _projection);

  loadObject((_player = new Marvin(_bombExplosion, _up, _bombz, _objs, _map, Marvin::PLAY1, glm::vec3(1, 0, 1))));
  // if (nbPlayer == 2)
  //   loadObject((_player2 = new Marvin(_bombExplosion, _up, _bombz, _objs, _map, Marvin::PLAY2, glm::vec3(_map->getWidth() - 2, 0, _map->getHeight() - 2))));
  for (int i = 0; i < _menu.getIA(); i++)
    loadObject(new Marvin(_bombExplosion, _up, _bombz, _objs, _map, Marvin::CPU, glm::vec3(_map->getWidth() - 2, 0, 1)));
  loadSounds();
  played = true;
  _menu.setPlay(true);
  _menu.setGen(mode::gen::UNKNOWN);
}
示例#3
0
CLevitate::CLevitate()
	: key(0)
	, def(16)
	, m_pos(Vec3f_ZERO)
	, m_baseRadius(50.f)
	, rhaut(100.f)
	, hauteur(80.f)
	, m_coneScale(0.f)
	, ang(0.f)
	, currdurationang(0)
	, currframetime(0)
	, tsouffle(NULL)
	, m_stoneDelay(0)
	, nbstone(0)
{
	int nb = 2;

	while(nb--) {
		this->cone[nb].coned3d = NULL;
		this->cone[nb].coneind = NULL;
		this->cone[nb].conevertex = NULL;
	}

	if(!stone0) {
		stone0 = loadObject("graph/obj3d/interactive/fix_inter/fx_raise_dead/stone01.teo");
	}

	stone0_count++;

	if(!stone1) {
		stone1 = loadObject("graph/obj3d/interactive/fix_inter/fx_raise_dead/stone02.teo");
	}

	stone1_count++;
}
示例#4
0
void Situated::load(const Aurora::GFF3Struct &instance, const Aurora::GFF3Struct *blueprint) {
	// General properties

	if (blueprint)
		loadProperties(*blueprint); // Blueprint
	loadProperties(instance);    // Instance


	// Specialized object properties

	if (blueprint)
		loadObject(*blueprint); // Blueprint
	loadObject(instance);    // Instance


	// Appearance

	if (_appearanceID == Aurora::kFieldIDInvalid)
		warning("Situated object \"%s\" without an appearance", _tag.c_str());

	loadAppearance();
	loadSounds();

	// Model

	if (!_modelName.empty()) {
		_model.reset(loadModelObject(_modelName));

		if (!_model)
			throw Common::Exception("Failed to load situated object model \"%s\"",
			                        _modelName.c_str());
	} else
		warning("Situated object \"%s\" (\"%s\") has no model", _name.c_str(), _tag.c_str());

	if (_model) {
		// Clickable
		_model->setTag(_tag);
		_model->setClickable(isClickable());

		// ID
		_ids.push_back(_model->getID());
	}

	// Position

	setPosition(instance.getDouble("X"),
	            instance.getDouble("Y"),
	            instance.getDouble("Z"));

	// Orientation

	float bearing = instance.getDouble("Bearing");

	setOrientation(0.0f, 0.0f, 1.0f, Common::rad2deg(bearing));
}
示例#5
0
CRiseDead::CRiseDead()
	: eSrc(Vec3f_ZERO)
	, fBetaRadCos(0.f)
	, fBetaRadSin(0.f)
	, tex_light(NULL)
	, end(40 - 1)
	, iSize(100)
	, bIntro(true)
	, sizeF(0)
	, fSizeIntro(0.f)
	, fRand(0.f)
	, fTexWrap(0)
	, ulDurationIntro(1000)
	, ulDurationRender(1000)
	, ulDurationOuttro(1000)
	, currframetime(0)
	, timestone(0)
	, nbstone(0)
{
	SetDuration(1000);
	ulCurrentTime = ulDurationIntro + ulDurationRender + ulDurationOuttro + 1;
	
	fOneOniSize = 1.0f / ((float) iSize);
	
	fColorBorder[0] = 1;
	fColorBorder[1] = 1;
	fColorBorder[2] = 1;
	
	fColorRays1[0] = 1;
	fColorRays1[1] = 1;
	fColorRays1[2] = 1;
	
	fColorRays2[0] = 0;
	fColorRays2[1] = 0;
	fColorRays2[2] = 0;
	
	stone[0] = NULL;
	stone[1] = NULL;
	
	if(!stone0) {
		stone0 = loadObject("graph/obj3d/interactive/fix_inter/fx_raise_dead/stone01.teo");
	}
	stone0_count++;
	
	if(!stone1) {
		stone1 = loadObject("graph/obj3d/interactive/fix_inter/fx_raise_dead/stone02.teo");
	}
	stone1_count++;
	
	tex_light = TextureContainer::Load("graph/obj3d/textures/(fx)_tsu4");
	

}
示例#6
0
bool ObjectManager::load(IDataSource* ids, uint32 version)
{
	if (!objIDs->load(ids, version)) return false;
	if (!actorIDs->load(ids, version)) return false;

	do {
		// peek ahead for terminator
		uint16 classlen = ids->read2();
		if (classlen == 0) break;
		char* buf = new char[classlen+1];
		ids->read(buf, classlen);
		buf[classlen] = 0;

		std::string classname = buf;
		delete[] buf;

		Object* obj = loadObject(ids, classname, version);
		if (!obj) return false;

		// top level gumps have to be added to the correct core gump
		Gump* gump = p_dynamic_cast<Gump*>(obj);
		if (gump) {
			GUIApp::get_instance()->addGump(gump);
		}

	} while(true);

	return true;
}
vector<KMFContainer*>* JSONModelLoader::deserialize(istream &inputStream){
	vector<ResolveCommand*> *resolverCommands = new vector<ResolveCommand*>;
	vector<KMFContainer*> *roots= new  vector<KMFContainer*>;
	Lexer *lexer =new Lexer(inputStream);
	Token currentToken = lexer->nextToken();
	if(currentToken.tokenType == LEFT_BRACE)
	{
		loadObject(lexer,"",NULL,roots,resolverCommands);
		for (std::vector<ResolveCommand*>::iterator it = resolverCommands->begin() ; it != resolverCommands->end(); ++it)
		{
			ResolveCommand *cmd = *it;
			cmd->run();
			delete cmd;

		}
	} else
	{
		delete roots;
		roots = NULL;
		Logger::Write(Logger::ERROR,"JSONModelLoader::deserializeBad Format / { expected");
	}


	delete resolverCommands;
	delete lexer;
	return roots;
}
示例#8
0
文件: game.cpp 项目: nelsonbss/rubiks
//----------------------------------------------------------------------
void game::extrudeObject(){
	//create and use circle
	SG_POINT   crCen = {0,0,0.0};  
	SG_VECTOR  crNor;  
	crNor.x = 0.0;  
	crNor.y = 3.0;  
	crNor.z = 0.0;
	sgSpaceMath::NormalVector(crNor); 
	SG_CIRCLE  crGeo;  
	crGeo.FromCenterRadiusNormal( crCen, 150, crNor);  
	sgCCircle* cr = sgCreateCircle(crGeo);   


	////extrude along vector
	SG_VECTOR extVec = {0,-300,0};  

	if (objectID == -1){
		extrudedObject = (sgC3DObject*)sgKinematic::Extrude((const sgC2DObject&)(*cr),NULL,0,extVec,true);
	}else{
		free(extrudedObject);
		extrudedObject = (sgC3DObject*)sgKinematic::Extrude((const sgC2DObject&)(*cr),NULL,0,extVec,true);
	}

	extrudedObject->SetAttribute(SG_OA_COLOR,30);
	extrudedB = true;
	sgDeleteObject(cr);

	//we  have the sg3DObjcect to load
	loadObject(200,slicingPos,posP);//using id=200

}
示例#9
0
void init (void) {
	// If Depth Test is not enabled, I would see my object infront of 
	// my polygon even if my object falls behind polygon. 
	glClearDepth(1);
	glEnable(GL_DEPTH_TEST);
	glEnable (GL_BLEND);
	//glBlendFunc (GL_SRC_ALPHA, GL_ONE);
	glClearColor (0.0, 0.0, 0.0, 0.0);

	
	windvelocity.x = 0.5;
	windvelocity.y = 0.5;
	windvelocity.z = 0.5;

	buildWalls(habcount, num_tri_hab, habitat, habvert);
	createPredator(1);
	addObject(20);
	//buildWalls(tricount, num_triangles, triangle, vert);
	//cube=loadObject("birds.obj"); 
	cube=loadObject("Fiat509_2.6.obj");
	glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
	glShadeModel (GL_SMOOTH);
    glEnable (GL_LIGHTING);
    glEnable (GL_LIGHT0);
	float col[]={1.0,1.0,1.0,1.0};  //light color is white
    glLightfv(GL_LIGHT0,GL_DIFFUSE,col);
	texture[0] = LoadTextureRAW( "wood.bmp",500,334);
	
 }
  Ref<SceneGraph::Node> CoronaLoader::loadGroupNode(const Ref<XML>& xml) 
  {
    if (xml->children.size() < 1) 
      THROW_RUNTIME_ERROR(xml->loc.str()+": invalid group node");

    /* load instances */
    auto p = loadInstances(xml->children[0]);
    Ref<SceneGraph::MaterialNode> material = p.first;
    avector<AffineSpace3fa>& xfms = p.second;
    
    /* load meshes */
    Ref<SceneGraph::GroupNode> objects = new SceneGraph::GroupNode;
    for (size_t i=1; i<xml->children.size(); i++)
      objects->add(loadObject(xml->children[i]));
    
    /* force material */
    objects->setMaterial(material);

    /* create instances */
    Ref<SceneGraph::GroupNode> instances = new SceneGraph::GroupNode;
    for (size_t i=0; i<xfms.size(); i++) 
      instances->add(new SceneGraph::TransformNode(xfms[i],objects.cast<SceneGraph::Node>()));

    return instances.cast<SceneGraph::Node>();
  }
UAVObjectBrowserWidget::UAVObjectBrowserWidget(QWidget *parent) : QWidget(parent)
{
    m_browser     = new Ui_UAVObjectBrowser();
    m_viewoptions = new Ui_viewoptions();
    m_viewoptionsDialog = new QDialog(this);
    m_viewoptions->setupUi(m_viewoptionsDialog);
    m_browser->setupUi(this);
    m_model = new UAVObjectTreeModel();
    m_browser->treeView->setModel(m_model);
    m_browser->treeView->setColumnWidth(0, 300);
    // m_browser->treeView->expandAll();
    BrowserItemDelegate *m_delegate = new BrowserItemDelegate();
    m_browser->treeView->setItemDelegate(m_delegate);
    m_browser->treeView->setEditTriggers(QAbstractItemView::AllEditTriggers);
    m_browser->treeView->setSelectionBehavior(QAbstractItemView::SelectItems);
    showMetaData(m_viewoptions->cbMetaData->isChecked());
    connect(m_browser->treeView->selectionModel(), SIGNAL(currentChanged(QModelIndex, QModelIndex)), this, SLOT(currentChanged(QModelIndex, QModelIndex)), Qt::UniqueConnection);
    connect(m_viewoptions->cbMetaData, SIGNAL(toggled(bool)), this, SLOT(showMetaData(bool)));
    connect(m_viewoptions->cbCategorized, SIGNAL(toggled(bool)), this, SLOT(categorize(bool)));
    connect(m_browser->saveSDButton, SIGNAL(clicked()), this, SLOT(saveObject()));
    connect(m_browser->readSDButton, SIGNAL(clicked()), this, SLOT(loadObject()));
    connect(m_browser->eraseSDButton, SIGNAL(clicked()), this, SLOT(eraseObject()));
    connect(m_browser->sendButton, SIGNAL(clicked()), this, SLOT(sendUpdate()));
    connect(m_browser->requestButton, SIGNAL(clicked()), this, SLOT(requestUpdate()));
    connect(m_browser->tbView, SIGNAL(clicked()), this, SLOT(viewSlot()));
    connect(m_viewoptions->cbScientific, SIGNAL(toggled(bool)), this, SLOT(useScientificNotation(bool)));
    connect(m_viewoptions->cbScientific, SIGNAL(toggled(bool)), this, SLOT(viewOptionsChangedSlot()));
    connect(m_viewoptions->cbMetaData, SIGNAL(toggled(bool)), this, SLOT(viewOptionsChangedSlot()));
    connect(m_viewoptions->cbCategorized, SIGNAL(toggled(bool)), this, SLOT(viewOptionsChangedSlot()));
    enableSendRequest(false);
}
示例#12
0
文件: area.cpp 项目: clone2727/xoreos
void Area::loadDoors(const Aurora::GFF3List &list) {
	for (Aurora::GFF3List::const_iterator d = list.begin(); d != list.end(); ++d) {
		Door *door = new Door(*_module, **d);

		loadObject(*door);
	}
}
示例#13
0
bool SceneLoader::loadObjects()
{
	int nObjects=0;
	objectElement=objectsElement->FirstChildElement("object");
	cout<<"Objects:";

	while(objectElement)
	{
		if(nObjects==global.maxobjects)
		{
			cout<<"Ja chegou limite de objectos\n";
			system("pause");
			return false;
		}
		else if(strcmp(objectElement->Value(), "object") == 0)
		{
			if(!loadObject())
				return false;
		}
		else
		{
			cout<<"Erro na tag objecto na "<<nObjects<<endl;
			system("pause");
			return false;
		}
		objectElement=objectElement->NextSiblingElement();
		nObjects++;
	}
	cout<<endl;
	return true;
}
示例#14
0
文件: area.cpp 项目: clone2727/xoreos
void Area::loadCreatures(const Aurora::GFF3List &list) {
	for (Aurora::GFF3List::const_iterator c = list.begin(); c != list.end(); ++c) {
		Creature *creature = new Creature(**c);

		loadObject(*creature);
	}
}
CObject::CObject(std::string path){
	nVertex = 0;
	nFaces = 0;
	nEdges = 0;
	nIndex = 0;
	current_shader = 0;
	mIndexes.clear();
	mVertex.clear();
	mFaceNormals.clear();
	mVertexNormals.clear();
	mColor.clear();
	xmin = ymin = zmin = xmax = ymax = zmax = NULL;
	transFX = transFY = transFZ = 0;
	scaleFX = scaleFY = scaleFZ = 1;
	ambientObject[0] = ambientObject[1] = ambientObject[2] = 0.5;
	diffuseObject[0] = diffuseObject[1] = diffuseObject[2] = 0.5;
	specularObject[0] = specularObject[1] = specularObject[2] = 1;
	roughnessValue = 1.0; 
	fresnelValue = 0.10; 
	gaussConstant = 100;
	quat[0] = quat[1] = quat[2] = quat[3] = 0;
	yaw = 0.f;
	loadObject(path);
	initBuffers();
}
示例#16
0
UAVObjectBrowserWidget::UAVObjectBrowserWidget(QWidget *parent) : QWidget(parent),
    updatePeriod(MAXIMUM_UPDATE_PERIOD)
{
    // Create browser and configuration GUIs
    m_browser = new Ui_UAVObjectBrowser();
    m_viewoptions = new Ui_viewoptions();
    m_viewoptionsDialog = new QDialog(this);
    m_viewoptions->setupUi(m_viewoptionsDialog);
    m_browser->setupUi(this);

    // Create data model
    m_model = new UAVObjectTreeModel(this);

    // Create tree view and add to layout
    treeView = new UAVOBrowserTreeView(MAXIMUM_UPDATE_PERIOD);
    treeView->setObjectName(QString::fromUtf8("treeView"));
    m_browser->verticalLayout->addWidget(treeView);

    connect(m_browser->saveSDButton, SIGNAL(clicked()), this, SLOT(saveObject()));
    connect(m_browser->readSDButton, SIGNAL(clicked()), this, SLOT(loadObject()));
    connect(m_browser->eraseSDButton, SIGNAL(clicked()), this, SLOT(eraseObject()));
    connect(m_browser->sendButton, SIGNAL(clicked()), this, SLOT(sendUpdate()));
    connect(m_browser->requestButton, SIGNAL(clicked()), this, SLOT(requestUpdate()));
    connect(m_browser->viewSettingsButton,SIGNAL(clicked()),this,SLOT(viewSlot()));


    connect((QTreeView*) treeView, SIGNAL(collapsed(QModelIndex)), this, SLOT(onTreeItemCollapsed(QModelIndex) ));
    connect((QTreeView*) treeView, SIGNAL(expanded(QModelIndex)), this, SLOT(onTreeItemExpanded(QModelIndex) ));

    connect(m_browser->le_searchField, SIGNAL(textChanged(QString)), this, SLOT(searchTextChanged(QString)));
    connect(m_browser->bn_clearSearchField, SIGNAL(clicked()), this, SLOT(searchTextCleared()));

    // Set browser buttons to disabled
    enableUAVOBrowserButtons(false);
}
示例#17
0
scene::scene(string filename){
	cout << "Reading scene from " << filename << " ..." << endl;
	cout << " " << endl;
	char* fname = (char*)filename.c_str();
	fp_in.open(fname);
	if(fp_in.is_open()){
		while(fp_in.good()){
			string line;
            utilityCore::safeGetline(fp_in,line);
			if(!line.empty()){
				vector<string> tokens = utilityCore::tokenizeString(line);
				if(strcmp(tokens[0].c_str(), "MATERIAL")==0){
				    loadMaterial(tokens[1]);
				    cout << " " << endl;
				}else if(strcmp(tokens[0].c_str(), "OBJECT")==0){
				    loadObject(tokens[1]);
				    cout << " " << endl;
				}else if(strcmp(tokens[0].c_str(), "CAMERA")==0){
				    loadCamera();
				    cout << " " << endl;
				}
			}
		}
	}
}
示例#18
0
文件: area.cpp 项目: clone2727/xoreos
void Area::loadPlaceables(const Aurora::GFF3List &list) {
	for (Aurora::GFF3List::const_iterator c = list.begin(); c != list.end(); ++c) {
		Placeable *placeable = new Placeable(**c);

		loadObject(*placeable);
	}
}
示例#19
0
文件: area.cpp 项目: clone2727/xoreos
void Area::loadWaypoints(const Aurora::GFF3List &list) {
	for (Aurora::GFF3List::const_iterator w = list.begin(); w != list.end(); ++w) {
		Waypoint *waypoint = new Waypoint(**w);

		loadObject(*waypoint);
	}
}
示例#20
0
文件: area.cpp 项目: clone2727/xoreos
void Area::loadTriggers(const Aurora::GFF3List &list) {
	for (Aurora::GFF3List::const_iterator c = list.begin(); c != list.end(); ++c) {
		Trigger *trigger = new Trigger(**c);

		loadObject(*trigger);
	}
}
示例#21
0
文件: map.cpp 项目: josegutab/scipion
/**
 * Construct a SOM from the code vectors in a stream
 * Parameter: _is  The stream
 * Parameter: _size Size of code vectors (number of data points)
 * @exception  runtime_error  If there are problems with the stream
 */
FuzzyMap::FuzzyMap(std::istream& _is, const unsigned _size, bool _cv) : FuzzyCodeBook(false)
{
    somLayout = NULL;
    if (_cv)
        readSelf(_is, _size);
    else
        loadObject(_is);
}
示例#22
0
文件: map.cpp 项目: josegutab/scipion
/**
 * Construct a SOM from the code vectors in a stream
 * Parameter: _is  The stream
 * @exception  runtime_error  If there are problems with the stream
 */
ClassificationMap::ClassificationMap(std::istream& _is, bool _cv) : CodeBook(false)
{
    somLayout = NULL;
    if (_cv)
        readSelf(_is);
    else
        loadObject(_is);
}
示例#23
0
Model::Model(string name)
{
    objectLoaded = false;

    if(name != "")
        loadObject(name);

    displayList = 0;
}
void CompliantGraspCopyTask::start()
{
  //get the details of the planning task itself
  if (!mDBMgr->GetPlanningTaskRecord(mPlanningTask.taskId, &mPlanningTask)) {
    DBGA("Failed to get planning record for task");
    mStatus = FAILED;
    return;
  }

  loadHand();
  if (mStatus == FAILED) { return; }

  if (!mHand->isA("Pr2Gripper2010")) {
    DBGA("Compliant copy task only works on the PR2 gripper");
    mStatus = FAILED;
    return;
  }
  Pr2Gripper2010 *gripper = static_cast<Pr2Gripper2010 *>(mHand);

  loadObject();
  if (mStatus == FAILED) { return; }

  //load all the grasps
  std::vector<db_planner::Grasp *> graspList;
  if (!mDBMgr->GetGrasps(*(mPlanningTask.model), mPlanningTask.handName, &graspList)) {
    DBGA("Load grasps failed");
    mStatus = FAILED;
    emptyGraspList(graspList);
    return;
  }

  bool success = true;
  std::vector<db_planner::Grasp *>::iterator it;
  for (it = graspList.begin(); it != graspList.end(); it++) {
    GraspPlanningState *graspState = static_cast<GraspitDBGrasp *>(*it)->getFinalGraspPlanningState();
    gripper->setCompliance(Pr2Gripper2010::NONE);
    graspState->execute();
    DBGA("Compliant copy around finger 0");
    if (!compliantCopy(*it, Pr2Gripper2010::FINGER0)) {
      success = false;
      break;
    }
    gripper->setCompliance(Pr2Gripper2010::NONE);
    graspState->execute();
    DBGA("Compliant copy around finger 1");
    if (!compliantCopy(*it, Pr2Gripper2010::FINGER1)) {
      success = false;
      break;
    }
  }
  gripper->setCompliance(Pr2Gripper2010::NONE);

  emptyGraspList(graspList);
  if (success) { mStatus = DONE; }
  else { mStatus = FAILED; }
}
示例#25
0
文件: situated.cpp 项目: Glyth/xoreos
void Situated::load(const Aurora::GFF3Struct &instance, const Aurora::GFF3Struct *blueprint) {
    // General properties

    if (blueprint)
        loadProperties(*blueprint); // Blueprint
    loadProperties(instance);    // Instance


    // Specialized object properties

    if (blueprint)
        loadObject(*blueprint); // Blueprint
    loadObject(instance);    // Instance


    // Sounds

    loadSounds();

    // Position

    setPosition(instance.getDouble("X"),
                instance.getDouble("Y"),
                instance.getDouble("Z"));

    // Orientation

    float bearing = instance.getDouble("Bearing");

    float rotX = 0.0f;
    float rotY = 0.0f;
    float rotZ = 1.0f;
    float rotW = Common::rad2deg(bearing);

    if (instance.hasField("OrientationW")) {
        rotX = instance.getDouble("OrientationX");
        rotY = instance.getDouble("OrientationY");
        rotZ = instance.getDouble("OrientationZ");
        rotW = Common::rad2deg(acos(instance.getDouble("OrientationW")) * 2.0);
    }

    setOrientation(rotX, rotY, rotZ, rotW);
}
示例#26
0
boost::shared_ptr< ResourceObject > ResourceObjectManager::getResourceObject(const std::string& id)
{
    if (id.empty())
        return boost::shared_ptr< ResourceObject >();

    // Check that object already loaded.
    auto oi = m_objects.find(id);
    if (oi != m_objects.end())
        return oi->second;

    // Check that object wasn't loaded, but there is JSON file for it
    auto fi = m_objectFiles.find(id);
    if (fi != m_objectFiles.end())
    {
        boost::shared_ptr<std::istream> f = ResourceManager::instance().getFileStream(fi->second);
        if (!f)
            return boost::shared_ptr< ResourceObject >();
        Json::Reader reader;
        Json::Value root;
        if (!reader.parse(*f, root))
        {
            Log::error() << L"[ROM] Error parsing JSON file " << fi->second << ": " << reader.getFormatedErrorMessages();
            return boost::shared_ptr< ResourceObject >();
        }
        m_objectFiles.erase(fi->first);
        return loadObject(id, root);
    }

    // OK, no object, no file, so check that directory that may contains object was loaded.

    std::string dir = directory(id);
    //Remove trailing slash
    if (!dir.empty())
        dir = dir.substr(0, dir.length() - 1);

    if (dir.empty())
    {
        Log::error() << "[ROM] Cannot find object " << id;
        return boost::shared_ptr< ResourceObject >();
    }

    auto di = std::find(m_directories.begin(), m_directories.end(), dir);
    if (di != m_directories.end())
    {
        // Directory loaded, but there is no object
        Log::error() << "[ROM] Cannot find object " << id;
        return boost::shared_ptr< ResourceObject >();
    }

    // Load dir recursively
    if (!getResourceObject(dir))
        return boost::shared_ptr< ResourceObject >();

    return getResourceObject(id);
}
void ARX_EQUIPMENT_RecreatePlayerMesh() {
	
	if(EXITING)
		return;
	
	arx_assert(entities.player());
	
	Entity * io = entities.player();
	
	if(io->obj != hero)
		delete io->obj;

	io->obj = loadObject("graph/obj3d/interactive/npc/human_base/human_base.teo", false);
	
	applyTweak(EQUIP_SLOT_HELMET, TWEAK_HEAD, "head");
	applyTweak(EQUIP_SLOT_ARMOR, TWEAK_TORSO, "chest");
	applyTweak(EQUIP_SLOT_LEGGINGS, TWEAK_LEGS, "leggings");
	
	Entity * target = entities.player();
	
	for(size_t i = 0; i < MAX_EQUIPED; i++) {
		if(ValidIONum(player.equiped[i])) {
			Entity *toequip = entities[player.equiped[i]];

			if(toequip) {
				if(toequip->type_flags & (OBJECT_TYPE_DAGGER | OBJECT_TYPE_1H | OBJECT_TYPE_2H | OBJECT_TYPE_BOW)) {
					if(player.Interface & INTER_COMBATMODE) {
						ARX_EQUIPMENT_AttachPlayerWeaponToHand();
					} else {
						EERIE_LINKEDOBJ_LinkObjectToObject(target->obj, toequip->obj, "weapon_attach", "primary_attach", toequip);
					}
				} else if(toequip->type_flags & OBJECT_TYPE_SHIELD) {
					if(ValidIONum(player.equiped[EQUIP_SLOT_SHIELD])) {
						EERIE_LINKEDOBJ_LinkObjectToObject(target->obj, toequip->obj, "shield_attach", "shield_attach", toequip);
					}
				}
			}
		}
	}

	ARX_PLAYER_Restore_Skin();
	HERO_SHOW_1ST = -1;

	if(EXTERNALVIEW) {
		ARX_INTERACTIVE_Show_Hide_1st(entities.player(), 0);
	} else {
		ARX_INTERACTIVE_Show_Hide_1st(entities.player(), 1);
	}

	ARX_INTERACTIVE_HideGore(entities.player(), 1);
	EERIE_Object_Precompute_Fast_Access(hero);
	EERIE_Object_Precompute_Fast_Access(entities.player()->obj);

	ARX_INTERACTIVE_RemoveGoreOnIO(entities.player()); 
}
示例#28
0
//=============================================================================
// METHOD    : SPELLwsStorage::loadLong
//=============================================================================
long SPELLwsStorage::loadLong()
{
	if (!m_file.is_open()) return -1;
    if (m_mode == MODE_WRITE)
    {
        THROW_EXCEPTION("Unable to load long value", "Initialized in write mode", SPELL_ERROR_WSTART);
    }
    PyObject* longObject = loadObject();
    long value = PyLong_AsLong(longObject);
    Py_XDECREF(longObject);
    return value;
}
示例#29
0
Object* ObjectManager::loadObject(IDataSource* ids, uint32 version)
{
	uint16 classlen = ids->read2();
	char* buf = new char[classlen+1];
	ids->read(buf, classlen);
	buf[classlen] = 0;

	std::string classname = buf;
	delete[] buf;

	return loadObject(ids, classname, version);
}
void ofxFeatureFinder::loadObjectsInFolder(string folder) {

    ofDirectory dir(folder);
    dir.allowExt("yml");
    dir.listDir();

    for(int i = 0; i < dir.numFiles(); i++){
        string fullPath = dir.getAbsolutePath() + "/" + dir.getName(i);
        cout << "loading object description " << fullPath << endl;
        loadObject(fullPath);
    }

}