Ejemplo n.º 1
0
bool PhysicsDirect::submitClientCommand(const struct SharedMemoryCommand& command)
{
	if (command.m_type==CMD_REQUEST_DEBUG_LINES)
	{			
		return processDebugLines(command);
	}

	if (command.m_type==CMD_REQUEST_CAMERA_IMAGE_DATA)
	{
		return processCamera(command);
	}
    if (command.m_type == CMD_REQUEST_CONTACT_POINT_INFORMATION)
    {
        return processContactPointData(command);
    }

	if (command.m_type == CMD_REQUEST_VISUAL_SHAPE_INFO)
	{
		return processVisualShapeData(command);
	}
	if (command.m_type == CMD_REQUEST_AABB_OVERLAP)
	{
		return processOverlappingObjects(command);
	}

	bool hasStatus = m_data->m_commandProcessor->processCommand(command,m_data->m_serverStatus,&m_data->m_bulletStreamDataServerToClient[0],SHARED_MEMORY_MAX_STREAM_CHUNK_SIZE);
	m_data->m_hasStatus = hasStatus;
	/*if (hasStatus)
	{
		postProcessStatus(m_data->m_serverStatus);
		m_data->m_hasStatus = false;
	}
	*/
	return hasStatus;
}
void ConfigFile::processXML(const xmlpp::Node* node){
	if(node->get_name()!="UWSimScene") {
		OSG_WARN <<"ConfigFile::processXML: XML file is not an UWSimScene file."<< std::endl;
	} else{
		xmlpp::Node::NodeList list = node->get_children();
		for(xmlpp::Node::NodeList::iterator iter = list.begin(); iter != list.end(); ++iter)
		{
			xmlpp::Node* child=dynamic_cast<const xmlpp::Node*>(*iter);
			if(child->get_name()=="oceanState")
				processOceanState(child);
			else if(child->get_name()=="simParams")
				processSimParams(child);
			else if(child->get_name()=="camera")
				processCamera(child);
			else if(child->get_name()=="vehicle"){
				Vehicle vehicle;
				processVehicle(child,vehicle);
				postprocessVehicle(vehicle);
				vehicles.push_back(vehicle);
			}
			else if(child->get_name()=="object"){
				Object  object;
				memset(object.offsetp,0,3*sizeof(double));
				memset(object.offsetr,0,3*sizeof(double));
				object.physicProperties.reset();
				processObject(child,object);
				objects.push_back(object);
			}
			else if(child->get_name()=="rosInterfaces")
				processROSInterfaces(child);
		}
	}

}
Ejemplo n.º 3
0
void DotSceneLoader::processScene(rapidxml::xml_node<>* XMLRoot)
{
	// Process the scene parameters
	Ogre::String version = getAttrib(XMLRoot, "formatVersion", "unknown");

	Ogre::String message = "[DotSceneLoader] Parsing dotScene file with version " + version;
	if (XMLRoot->first_attribute("ID"))
		message += ", id " + Ogre::String(XMLRoot->first_attribute("ID")->value());
	if (XMLRoot->first_attribute("sceneManager"))
		message += ", scene manager " + Ogre::String(XMLRoot->first_attribute("sceneManager")->value());
	if (XMLRoot->first_attribute("minOgreVersion"))
		message += ", min. Ogre version " + Ogre::String(XMLRoot->first_attribute("minOgreVersion")->value());
	if (XMLRoot->first_attribute("author"))
		message += ", author " + Ogre::String(XMLRoot->first_attribute("author")->value());

	Ogre::LogManager::getSingleton().logMessage(message);

	rapidxml::xml_node<>* pElement;

	// Process environment (?)
	pElement = XMLRoot->first_node("environment");
	if (pElement)
		processEnvironment(pElement);

	// Process nodes (?)
	pElement = XMLRoot->first_node("nodes");
	if (pElement)
		processNodes(pElement);

	// Process externals (?)
	pElement = XMLRoot->first_node("externals");
	if (pElement)
		processExternals(pElement);

	// Process userDataReference (?)
	pElement = XMLRoot->first_node("userDataReference");
	if (pElement)
		processUserDataReference(pElement);

	// Process octree (?)
	pElement = XMLRoot->first_node("octree");
	if (pElement)
		processOctree(pElement);

	// Process light (?)
	//pElement = XMLRoot->first_node("light");
	//if(pElement)
	//    processLight(pElement);

	// Process camera (?)
	pElement = XMLRoot->first_node("camera");
	if (pElement)
		processCamera(pElement);

	// Process terrain (?)
	pElement = XMLRoot->first_node("terrain");
	if (pElement)
		processTerrain(pElement);
}
Ejemplo n.º 4
0
//! [10]
void Base3DView::mouseMoveEvent(QMouseEvent *event)
{
    if(event->modifiers() == Qt::AltModifier)
        processCamera(event);
    else 
        processMouseInput(event);

    m_lastPos = event->pos();
}
Ejemplo n.º 5
0
void DotSceneLoader::processScene(TiXmlElement* xmlRoot) {
	std::string version = getAttrib(xmlRoot, "formatVersion", "unknown");

	std::string message = "[DotSceneLoader] Parsing dotScene file with version " + version;

	if(xmlRoot->Attribute("ID"))
		message += ", id " + std::string(xmlRoot->Attribute("ID"));
	if(xmlRoot->Attribute("sceneManager"))
		message += ", scene manager " + std::string(xmlRoot->Attribute("sceneManager"));
	if(xmlRoot->Attribute("minOgreVersion"))
		message += ", min. Ogre version " + std::string(xmlRoot->Attribute("minOgreVersion"));
	if(xmlRoot->Attribute("author"))
		message += ", author " + std::string(xmlRoot->Attribute("author"));

	TiXmlElement *element;

	// Process nodes (?)
	element = xmlRoot->FirstChildElement("nodes");
	if(element)
		processNodes(element);

	// Process externals (?)
	element = xmlRoot->FirstChildElement("externals");
	if(element)
		processExternals(element);

	// Process environment (?)
	element = xmlRoot->FirstChildElement("environment");
	if(element)
		processEnvironment(element);

	// Process terrain (?)
	element = xmlRoot->FirstChildElement("terrain");
	if(element)
		processTerrain(element);

	// Process userDataReference (?)
	element = xmlRoot->FirstChildElement("userDataReference");
	if(element)
		processUserDataReference(element);

	// Process octree (?)
	element = xmlRoot->FirstChildElement("octree");
	if(element)
		processOctree(element);

	// Process light (?)
	element = xmlRoot->FirstChildElement("light");
	if(element)
		processLight(element);

	// Process camera (?)
	element = xmlRoot->FirstChildElement("camera");
	if(element)
		processCamera(element);
}
Ejemplo n.º 6
0
void DotSceneLoader::processEnvironment(rapidxml::xml_node<>* XMLNode)
{
	rapidxml::xml_node<>* pElement;

	// Process camera (?)
	pElement = XMLNode->first_node("camera");
	if (pElement)
		processCamera(pElement);

	// Process fog (?)
	pElement = XMLNode->first_node("fog");
	if (pElement)
		processFog(pElement);

	// Process skyBox (?)
	pElement = XMLNode->first_node("skyBox");
	if (pElement)
		processSkyBox(pElement);

	// Process skyDome (?)
	pElement = XMLNode->first_node("skyDome");
	if (pElement)
		processSkyDome(pElement);

	// Process skyPlane (?)
	pElement = XMLNode->first_node("skyPlane");
	if (pElement)
		processSkyPlane(pElement);

	// Process clipping (?)
	pElement = XMLNode->first_node("clipping");
	if (pElement)
		processClipping(pElement);

	// Process colourAmbient (?)
	pElement = XMLNode->first_node("colourAmbient");
	if (pElement)
		mSceneMgr->setAmbientLight(parseColour(pElement));

	// Process colourBackground (?)
	//! @todo Set the background colour of all viewports (RenderWindow has to be provided then)
	pElement = XMLNode->first_node("colourBackground");
	if (pElement)
		;//mSceneMgr->set(parseColour(pElement));

	// Process userDataReference (?)
	pElement = XMLNode->first_node("userDataReference");
	if (pElement)
		processUserDataReference(pElement);
}
Ejemplo n.º 7
0
void DotSceneLoader::processEnvironment(rapidxml::xml_node<>* XMLNode) {
	rapidxml::xml_node<>* pElement;

	// Process camera (?)
	pElement = XMLNode->first_node("camera");
	if (pElement)
		processCamera(pElement);

	// Process fog (?)
	pElement = XMLNode->first_node("fog");
	if (pElement)
		processFog(pElement);

	// Process skyBox (?)
	pElement = XMLNode->first_node("skyBox");
	if (pElement)
		processSkyBox(pElement);

	// Process skyDome (?)
	pElement = XMLNode->first_node("skyDome");
	if (pElement)
		processSkyDome(pElement);

	// Process skyPlane (?)
	pElement = XMLNode->first_node("skyPlane");
	if (pElement)
		processSkyPlane(pElement);

	// Process clipping (?)
	pElement = XMLNode->first_node("clipping");

	// Process colourAmbient (?)
	pElement = XMLNode->first_node("colourAmbient");
	if (pElement)
		mSceneMgr->setAmbientLight(parseColour(pElement));

	// Process colourBackground (?)
	pElement = XMLNode->first_node("colourBackground");
	/*
	if (pElement)
		;// mSceneMgr->set(parseColour(pElement));
	 */
	// Process userDataReference (?)
	pElement = XMLNode->first_node("userDataReference");
}
Ejemplo n.º 8
0
	//---------------------------------------------------------------------
	void SceneResource::processScene( const Util::XmlNode * sceneNode) const
	{
		Util::String worldSizeStr(mXmlReader->getAttribute(sceneNode, "world_size"));
		IF_FALSE_EXCEPTION(!worldSizeStr.empty(), "Current scene donnot have world_size attribute!");

		Util::real worldSize = boost::lexical_cast<Util::real>(worldSizeStr);
		EngineManager::getSingleton().getSceneManager()->setWorldSize(worldSize);

		const Util::XmlNode * cameraNode = mXmlReader->getFirstNode(sceneNode, "camera");
		IF_NULL_EXCEPTION(cameraNode, "Current scene donnot have camera node!");

		processCamera(cameraNode);

		const Util::XmlNode * snNode = mXmlReader->getFirstNode(sceneNode, "node");
		while (snNode)
		{
			processSceneNode(snNode);

			snNode = mXmlReader->getNextSiblingNode(snNode);
		}
	}
Ejemplo n.º 9
0
bool Parser::processConfig()
{
	std::string strEtiqueta;
    bool 		bFinBloque = false;

    while(!bFinBloque) {
		// Buscamos etiqueta.
		if(!ignorarChars())
			return false;
        
        if(!readToken(strEtiqueta))
            return false;

        if(strEtiqueta == "/config")
			bFinBloque = true;
        else
        {
            if(strEtiqueta == "renderer") {
				if(!processRenderer())
					return false;
            }
            else if(strEtiqueta == "camera") {
				if(!processCamera())
					return false;
            }
            else if(strEtiqueta == "image") {
				if(!processImage())
					return false;
            }
            else {
				// Etiqueta desconocida, no perteneciente a la seccion config.
                return false;
            }
        }
    }
    
    return true;
}
Ejemplo n.º 10
0
void DotSceneLoader::processNode(rapidxml::xml_node<>* XMLNode, Ogre::SceneNode *pParent)
{
	// Construct the node's name
	Ogre::String name = m_sPrependNode + getAttrib(XMLNode, "name");

	// Create the scene node
	Ogre::SceneNode *pNode;
	if (name.empty())
	{
		// Let Ogre choose the name
		if (pParent)
			pNode = pParent->createChildSceneNode();
		else
			pNode = mAttachNode->createChildSceneNode();
	}
	else
	{
		// Provide the name
		if (pParent)
			pNode = pParent->createChildSceneNode(name);
		else
			pNode = mAttachNode->createChildSceneNode(name);
	}

	// Process other attributes
	Ogre::String id = getAttrib(XMLNode, "id");
	bool isTarget = getAttribBool(XMLNode, "isTarget");

	rapidxml::xml_node<>* pElement;

	// Process position (?)
	pElement = XMLNode->first_node("position");
	if (pElement)
	{
		pNode->setPosition(parseVector3(pElement));
		pNode->setInitialState();
	}

	// Process rotation (?)
	pElement = XMLNode->first_node("rotation");
	if (pElement)
	{
		pNode->setOrientation(parseQuaternion(pElement));
		pNode->setInitialState();
	}

	// Process scale (?)
	pElement = XMLNode->first_node("scale");
	if (pElement)
	{
		pNode->setScale(parseVector3(pElement));
		pNode->setInitialState();
	}

	// Process lookTarget (?)
	pElement = XMLNode->first_node("lookTarget");
	if (pElement)
		processLookTarget(pElement, pNode);

	// Process trackTarget (?)
	pElement = XMLNode->first_node("trackTarget");
	if (pElement)
		processTrackTarget(pElement, pNode);

	// Process node (*)
	pElement = XMLNode->first_node("node");
	while (pElement)
	{
		processNode(pElement, pNode);
		pElement = pElement->next_sibling("node");
	}

	// Process entity (*)
	pElement = XMLNode->first_node("entity");
	while (pElement)
	{
		processEntity(pElement, pNode);
		pElement = pElement->next_sibling("entity");
	}

	// Process light (*)
	//pElement = XMLNode->first_node("light");
	//while(pElement)
	//{
	//    processLight(pElement, pNode);
	//    pElement = pElement->next_sibling("light");
	//}

	// Process camera (*)
	pElement = XMLNode->first_node("camera");
	while (pElement)
	{
		processCamera(pElement, pNode);
		pElement = pElement->next_sibling("camera");
	}

	// Process particleSystem (*)
	pElement = XMLNode->first_node("particleSystem");
	while (pElement)
	{
		processParticleSystem(pElement, pNode);
		pElement = pElement->next_sibling("particleSystem");
	}

	// Process billboardSet (*)
	pElement = XMLNode->first_node("billboardSet");
	while (pElement)
	{
		processBillboardSet(pElement, pNode);
		pElement = pElement->next_sibling("billboardSet");
	}

	// Process plane (*)
	pElement = XMLNode->first_node("plane");
	while (pElement)
	{
		processPlane(pElement, pNode);
		pElement = pElement->next_sibling("plane");
	}

	// Process userDataReference (?)
	pElement = XMLNode->first_node("userDataReference");
	if (pElement)
		processUserDataReference(pElement, pNode);
}
Ejemplo n.º 11
0
static void processObject( Obj *obj, Scene *scene, mmap& materials )
{
	// Assume the object is named.
	string name;
	Obj *child; 

	if( obj->getTypeName() == "id" ) {
		name = obj->getID();
		child = NULL;
	} else if( obj->getTypeName() == "named" ) {
		name = obj->getName();
		child = obj->getChild();
	} else {
		ostrstream oss;
		oss << "Unknown input object ";
		obj->printOn( oss );

		throw ParseError( string( oss.str() ) );
	}

	if( name == "directional_light" ) {
		if( child == NULL ) {
			throw ParseError( "No info for directional_light" );
		}

		scene->add( new DirectionalLight( scene, 
			tupleToVec( getField( child, "direction" ) ).normalize(),
			tupleToVec( getColorField( child ) ) ) );
	} else if( name == "point_light" ) {
		if( child == NULL ) {
			throw ParseError( "No info for point_light" );
		}
		PointLight* pointLight = new PointLight(scene,
			tupleToVec(getField(child, "position")),
			tupleToVec(getColorField(child)));
		scene->add(pointLight);

		if (hasField(child, "constant_attenuation_coeff") && 
			hasField(child, "linear_attenuation_coeff")	&& 
			hasField(child, "quadratic_attenuation_coeff"))
		{
			pointLight->setAttenuationCoefficients(
				getField(child, "constant_attenuation_coeff")->getScalar(),
				getField(child, "linear_attenuation_coeff")->getScalar(),
				getField(child, "quadratic_attenuation_coeff")->getScalar());
		}
	}
	else if (name == "ambient_light") {
		if (child == NULL) {
			throw ParseError("No info for ambient_light");
		}
		AmbientLight* ambientLight = new AmbientLight(scene,
			tupleToVec(getColorField(child)));
		scene->add(ambientLight);
	} else if( 	name == "sphere" ||
				name == "box" ||
				name == "cylinder" ||
				name == "cone" ||
				name == "square" ||
				name == "translate" ||
				name == "rotate" ||
				name == "scale" ||
				name == "transform" ||
                name == "trimesh" ||
                name == "polymesh") { // polymesh is for backwards compatibility.
		processGeometry( name, child, scene, materials, &scene->transformRoot);
		//scene->add( geo );
	} else if( name == "material" ) {
		processMaterial( child, &materials );
	} else if( name == "camera" ) {
		processCamera( child, scene );
	} else {
		throw ParseError( string( "Unrecognized object: " ) + name );
	}
}
Ejemplo n.º 12
0
void DotSceneLoader::processNode(TiXmlElement *xmlNode, Node *pParent) {
	// Construct the node's name
	std::string name = getAttrib(xmlNode, "name");

	// Create the scene node
	Node *node;
	if(name.empty()) {
		// Let Ogre choose the name
		if(pParent) {
			node = scene->createNode();
			pParent->addChild(node);
		} else {
			node = scene->createNode();
			rootNode->addChild(node);
		}
	} else {
		// Provide the name
		if(pParent) {
			node = scene->createNode(/*name*/);
			pParent->addChild(node);
		} else {
			node = scene->createNode(/*name*/);
			rootNode->addChild(node);
		}
	}

	// Process other attributes
	std::string id = getAttrib(xmlNode, "id");
	bool isTarget = getAttribBool(xmlNode, "isTarget");

	TiXmlElement *element;

	// Process position (?)
	element = xmlNode->FirstChildElement("position");
	if(element) {
		node->setPosition(parseVector3(element));
	}

	// Process rotation (?)
	element = xmlNode->FirstChildElement("rotation");
	if(element) {
		node->setOrientation(parseQuaternion(element));
	}

	// Process scale (?)
	element = xmlNode->FirstChildElement("scale");
	if(element) {
		node->setScale(parseVector3(element));
	}

	// Process lookTarget (?)
	element = xmlNode->FirstChildElement("lookTarget");
	if(element)
		processLookTarget(element, node);

	// Process trackTarget (?)
	element = xmlNode->FirstChildElement("trackTarget");
	if(element)
		processTrackTarget(element, node);

	// Process node (*)
	element = xmlNode->FirstChildElement("node");
	while(element) {
		processNode(element, node);
		element = element->NextSiblingElement("node");
	}

	// Process entity (*)
	element = xmlNode->FirstChildElement("entity");
	while(element) {
		processEntity(element, node);
		element = element->NextSiblingElement("entity");
	}

	// Process light (*)
	element = xmlNode->FirstChildElement("light");
	while(element) {
		processLight(element, node);
		element = element->NextSiblingElement("light");
	}

	// Process camera (*)
	element = xmlNode->FirstChildElement("camera");
	while(element) {
		processCamera(element, node);
		element = element->NextSiblingElement("camera");
	}

	// Process particleSystem (*)
	element = xmlNode->FirstChildElement("particleSystem");
	while(element) {
		processParticleSystem(element, node);
		element = element->NextSiblingElement("particleSystem");
	}

	// Process billboardSet (*)
	element = xmlNode->FirstChildElement("billboardSet");
	while(element) {
		processBillboardSet(element, node);
		element = element->NextSiblingElement("billboardSet");
	}

	// Process plane (*)
	element = xmlNode->FirstChildElement("plane");
	while(element) {
		processPlane(element, node);
		element = element->NextSiblingElement("plane");
	}

	// Process userDataReference (?)
	element = xmlNode->FirstChildElement("userDataReference");
	if(element)
		processUserDataReference(element, node);
}
Ejemplo n.º 13
0
void JsonApiHandlerHttp::processApi(const string &data, const Params &paramsGET)
{
    jsonParam.clear();

    //parse the json data
    json_error_t jerr;
    json_t *jroot = json_loads(data.c_str(), 0, &jerr);

    if (!jroot || !json_is_object(jroot))
    {
        cDebugDom("network") << "Error loading json : " << jerr.text << ". No JSON, trying with GET parameters.";

        jsonParam = paramsGET;

        if (jroot)
        {
            json_decref(jroot);
            jroot = nullptr;
        }
    }
    else
    {
        char *d = json_dumps(jroot, JSON_INDENT(4));
        if (d)
        {
            cDebugDom("network") << d;
            free(d);
        }

        //decode the json root object into jsonParam
        jansson_decode_object(jroot, jsonParam);
    }


    //check for if username/password matches
    string user = Utils::get_config_option("calaos_user");
    string pass = Utils::get_config_option("calaos_password");

    if (Utils::get_config_option("cn_user") != "" &&
            Utils::get_config_option("cn_pass") != "")
    {
        user = Utils::get_config_option("cn_user");
        pass = Utils::get_config_option("cn_pass");
    }

    if (user != jsonParam["cn_user"] || pass != jsonParam["cn_pass"])
    {
        cDebugDom("network") << "Login failed!";

        Params headers;
        headers.Add("Connection", "close");
        headers.Add("Content-Type", "text/html");
        string res = httpClient->buildHttpResponse(HTTP_400, headers, HTTP_400_BODY);
        sendData.emit(res);
        closeConnection.emit(0, string());

        if (jroot)
        {
            json_decref(jroot);
            jroot = nullptr;
        }

        return;
    }

    //check action now
    if (jsonParam["action"] == "get_home")
        processGetHome();
    else if (jsonParam["action"] == "get_state")
        processGetState(jroot);
    else if (jsonParam["action"] == "get_states")
        processGetStates();
    else if (jsonParam["action"] == "query")
        processQuery();
    else if (jsonParam["action"] == "get_param")
        processGetParam();
    else if (jsonParam["action"] == "set_param")
        processSetParam();
    else if (jsonParam["action"] == "del_param")
        processDelParam();
    else if (jsonParam["action"] == "set_state")
        processSetState();
    else if (jsonParam["action"] == "get_playlist")
        processGetPlaylist();
    else if (jsonParam["action"] == "poll_listen")
        processPolling();
    else if (jsonParam["action"] == "get_cover")
        processGetCover();
    else if (jsonParam["action"] == "get_camera_pic")
        processGetCameraPic();
    else if (jsonParam["action"] == "get_timerange")
        processGetTimerange();
    else if (jsonParam["action"] == "camera")
        processCamera();
    else
    {
        if (!jroot)
        {
            Params headers;
            headers.Add("Connection", "close");
            headers.Add("Content-Type", "text/html");
            string res = httpClient->buildHttpResponse(HTTP_400, headers, HTTP_400_BODY);
            sendData.emit(res);
            closeConnection.emit(0, string());

            if (jroot)
                json_decref(jroot);

            return;
        }

        if (jsonParam["action"] == "config")
            processConfig(jroot);
        else if (jsonParam["action"] == "get_io")
            processGetIO(jroot);
        else if (jsonParam["action"] == "audio")
            processAudio(jroot);
        else if (jsonParam["action"] == "audio_db")
            processAudioDb(jroot);
        else if (jsonParam["action"] == "set_timerange")
            processSetTimerange(jroot);
        else if (jsonParam["action"] == "autoscenario")
            processAutoscenario(jroot);
    }

    if (jroot)
        json_decref(jroot);
}
void StatePlaying::process(float dt)
{ 
  PlaneObject *planeObject = m_objects->getPlaneObject();

  // this should never happen but if it does leave
  if (planeObject == NULL) 
    return; 
    
  gConsole.process();
  
  // call process and move on all objects in the object manager
  m_objects->update(dt); 
    
  // process escape key and space bar
  processInput();

  // update location of camera
  processCamera(dt);
    
  // allow water to process per frame movements
  water->process(dt);
 
  // as soon as the plane crashes, start the timer
  if (planeObject->isPlaneAlive() == false && m_planeCrashed == false)
  {
    m_planeCrashed = true; // set that the plane has crashed
    m_timeSinceCrashed = 0.0f;
    m_crowID = -1;   
  }

  // once the timer hits 3 seconds, make the camera follow a crow
  if (m_planeCrashed)
  {
    m_timeSinceCrashed += dt;
    if (m_timeSinceCrashed >= 3.0f && m_crowID == -1)
    {
      // make the camera follow a crow around
      m_crowID = m_objects->getCrow();
      if (m_crowID != -1)
        m_tetherCamera->setTargetObject(m_crowID);

      // play the failed sound
      m_failedSound = gSoundManager.requestSoundHandle("Failed.wav");
      m_failedInstance = gSoundManager.requestInstance(m_failedSound);
      if(m_failedInstance != SoundManager::NOINSTANCE)
      {
        gSoundManager.setToListener(m_failedSound,m_failedInstance);
        gSoundManager.play(m_failedSound,m_failedInstance);
      }
    }
    else if(m_failedInstance != SoundManager::NOINSTANCE)
      gSoundManager.setToListener(m_failedSound,m_failedInstance);
  }

  // render reflection
  if (Water::m_bReflection)
  {
    // render water reflection    
    Plane plane( 0, 1, 0, -water->getWaterHeight());
    //get water texture ready  
    water->m_reflection.beginReflectedScene(plane);
    renderScene(true);
    water->m_reflection.endReflectedScene();    
  }

}
Ejemplo n.º 15
0
bool PhysicsDirect::submitClientCommand(const struct SharedMemoryCommand& command)
{
	if (command.m_type==CMD_REQUEST_DEBUG_LINES)
	{			
		return processDebugLines(command);
	}

	if (command.m_type==CMD_REQUEST_CAMERA_IMAGE_DATA)
	{
		return processCamera(command);
	}

	bool hasStatus = m_data->m_commandProcessor->processCommand(command,m_data->m_serverStatus,&m_data->m_bulletStreamDataServerToClient[0],SHARED_MEMORY_MAX_STREAM_CHUNK_SIZE);
	m_data->m_hasStatus = hasStatus;
	if (hasStatus)
	{
		const SharedMemoryStatus& serverCmd = m_data->m_serverStatus;

		switch (m_data->m_serverStatus.m_type)
		{
			case CMD_RESET_SIMULATION_COMPLETED:
			{
				m_data->m_debugLinesFrom.clear();
				m_data->m_debugLinesTo.clear();
				m_data->m_debugLinesColor.clear();
				for (int i=0;i<m_data->m_bodyJointMap.size();i++)
				{
					BodyJointInfoCache2** bodyJointsPtr = m_data->m_bodyJointMap.getAtIndex(i);
					if (bodyJointsPtr && *bodyJointsPtr)
					{
						BodyJointInfoCache2* bodyJoints = *bodyJointsPtr;
						for (int j=0;j<bodyJoints->m_jointInfo.size();j++) {
							if (bodyJoints->m_jointInfo[j].m_jointName)
							{
								free(bodyJoints->m_jointInfo[j].m_jointName);
							}
							if (bodyJoints->m_jointInfo[j].m_linkName)
							{
								free(bodyJoints->m_jointInfo[j].m_linkName);
							}
						}
						delete (*bodyJointsPtr);
					}
				}
				m_data->m_bodyJointMap.clear();
                
				break;
			}
			case CMD_URDF_LOADING_COMPLETED:
			{
				if (serverCmd.m_dataStreamArguments.m_streamChunkLength > 0) 
				{
					bParse::btBulletFile bf(
						&m_data->m_bulletStreamDataServerToClient[0],
						serverCmd.m_dataStreamArguments.m_streamChunkLength);
					bf.setFileDNAisMemoryDNA();
					bf.parse(false);
					int bodyIndex = serverCmd.m_dataStreamArguments.m_bodyUniqueId;

					BodyJointInfoCache2* bodyJoints = new BodyJointInfoCache2;
					m_data->m_bodyJointMap.insert(bodyIndex,bodyJoints);

					for (int i = 0; i < bf.m_multiBodies.size(); i++) 
					{
						int flag = bf.getFlags();
						if ((flag & bParse::FD_DOUBLE_PRECISION) != 0) 
						{
							Bullet::btMultiBodyDoubleData* mb =
								(Bullet::btMultiBodyDoubleData*)bf.m_multiBodies[i];

							addJointInfoFromMultiBodyData(mb,bodyJoints, m_data->m_verboseOutput);
						} else 
						{
							Bullet::btMultiBodyFloatData* mb =
								(Bullet::btMultiBodyFloatData*)bf.m_multiBodies[i];

							addJointInfoFromMultiBodyData(mb,bodyJoints, m_data->m_verboseOutput);
						}
					}
					if (bf.ok()) {
						if (m_data->m_verboseOutput) 
						{
							b3Printf("Received robot description ok!\n");
						}
					} else 
					{
						b3Warning("Robot description not received");
					}
				}
                break;
            }
			
		 default:
			 {
				// b3Error("Unknown server status type");
			 }
		};
										  
		
	}
	return hasStatus;
}