diff --git a/indra/llplugin/llpluginclassmedia.cpp b/indra/llplugin/llpluginclassmedia.cpp index cc8fe53c3bfbefa58e087da6fe1db037e68a9029..8f161201f435af3c6aa880baaf707f82ff4e14a7 100644 --- a/indra/llplugin/llpluginclassmedia.cpp +++ b/indra/llplugin/llpluginclassmedia.cpp @@ -474,6 +474,33 @@ void LLPluginClassMedia::jsAgentLocationEvent( double x, double y, double z ) 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() ) diff --git a/indra/llplugin/llpluginclassmedia.h b/indra/llplugin/llpluginclassmedia.h index 015fb31252d87f973631c1c1409f0dbb73795872..c061390699d14c0e077f345fb6744c0bc69e65de 100644 --- a/indra/llplugin/llpluginclassmedia.h +++ b/indra/llplugin/llpluginclassmedia.h @@ -122,6 +122,8 @@ class LLPluginClassMedia : public LLPluginProcessParentOwner 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 ); diff --git a/indra/media_plugins/webkit/media_plugin_webkit.cpp b/indra/media_plugins/webkit/media_plugin_webkit.cpp index bdfbde84941524496adccb9b72aca44167568537..27f3c7260e318312980441b6753e6123d46c3d34 100644 --- a/indra/media_plugins/webkit/media_plugin_webkit.cpp +++ b/indra/media_plugins/webkit/media_plugin_webkit.cpp @@ -1194,11 +1194,21 @@ void MediaPluginWebKit::receiveMessage(const char *message_string) #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 diff --git a/indra/newview/llviewermedia.cpp b/indra/newview/llviewermedia.cpp index 2b9f32f6f547259c0a0aefd9df406f7cb5044dd5..c88c07942eeef544b663fe47aeaf01f6f1210835 100644 --- a/indra/newview/llviewermedia.cpp +++ b/indra/newview/llviewermedia.cpp @@ -2365,6 +2365,19 @@ void LLViewerMediaImpl::updateJavascriptObject() 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();