Commits

Anonymous committed b50f4fe

Added support for pushing agent global location on grid and agent orientation out to LLQtWebKit

  • Participants
  • Parent commits f15479a

Comments (0)

Files changed (4)

indra/llplugin/llpluginclassmedia.cpp

 	sendMessage( message );
 }
 
+void LLPluginClassMedia::jsAgentGlobalLocationEvent( double x, double y, double z )
+{
+	if( ! mPlugin || !mPlugin->isRunning() || mPlugin->isBlocked() )
+	{
+		return;
+	}
+
+	LLPluginMessage message(LLPLUGIN_MESSAGE_CLASS_MEDIA, "js_agent_global_location");
+	message.setValueReal( "x", x );
+	message.setValueReal( "y", y );
+	message.setValueReal( "z", z );
+	sendMessage( message );
+}
+
+void LLPluginClassMedia::jsAgentOrientationEvent( double angle )
+{
+	if( ! mPlugin || !mPlugin->isRunning() || mPlugin->isBlocked() )
+	{
+		return;
+	}
+
+	LLPluginMessage message(LLPLUGIN_MESSAGE_CLASS_MEDIA, "js_agent_orientation");
+	message.setValueReal( "angle", angle );
+
+	sendMessage( message );
+}
+
 void LLPluginClassMedia::jsAgentLanguageEvent( const std::string& language )
 {
 	if( ! mPlugin || !mPlugin->isRunning() || mPlugin->isBlocked() )

indra/llplugin/llpluginclassmedia.h

 	void jsExposeObjectEvent( bool expose );
 	void jsValuesValidEvent( bool valid );
 	void jsAgentLocationEvent( double x, double y, double z );
+	void jsAgentGlobalLocationEvent( double x, double y, double z );
+	void jsAgentOrientationEvent( double angle );
 	void jsAgentLanguageEvent( const std::string& language );
 	void jsAgentRegionEvent( const std::string& region_name );
 	void jsAgentMaturityEvent( const std::string& maturity );

indra/media_plugins/webkit/media_plugin_webkit.cpp

 #endif
 			}
 			else
-			if(message_name == "js_agent_language")
+			if(message_name == "js_agent_global_location")
 			{
 #if LLQTWEBKIT_API_VERSION >= 9
-				const std::string& language = message_in.getValue("language");
-				LLQtWebKit::getInstance()->setAgentLanguage( language );
+				F32 x = message_in.getValueReal("x");
+				F32 y = message_in.getValueReal("y");
+				F32 z = message_in.getValueReal("z");
+				LLQtWebKit::getInstance()->setAgentGlobalLocation( x, y, z );
+#endif
+			}
+			else			
+			if(message_name == "js_agent_orientation")
+			{
+#if LLQTWEBKIT_API_VERSION >= 9
+				F32 angle = message_in.getValueReal("angle");
+				LLQtWebKit::getInstance()->setAgentOrientation( angle );
 #endif
 			}
 			else

indra/newview/llviewermedia.cpp

 		double z = agent_pos.mV[ VZ ];
 		mMediaSource->jsAgentLocationEvent( x, y, z );
 
+		// current location within the grid
+		LLVector3d agent_pos_global = gAgent.getLastPositionGlobal();
+		double global_x = agent_pos_global.mdV[ VX ];
+		double global_y = agent_pos_global.mdV[ VY ];
+		double global_z = agent_pos_global.mdV[ VZ ];
+		mMediaSource->jsAgentGlobalLocationEvent( global_x, global_y, global_z );
+
+		// current agent orientation
+		double rotation = atan2( gAgent.getAtAxis().mV[VX], gAgent.getAtAxis().mV[VY] );
+		double angle = rotation * RAD_TO_DEG;
+		if ( angle < 0.0f ) angle = 360.0f + angle;	// TODO: has to be a better way to get orientation!
+		mMediaSource->jsAgentOrientationEvent( angle );
+
 		// current region agent is in
 		std::string region_name("");
 		LLViewerRegion* region = gAgent.getRegion();