void ImportTracker::plywood_above_head() { LLMessageSystem* msg = gMessageSystem; msg->newMessageFast(_PREHASH_ObjectAdd); msg->nextBlockFast(_PREHASH_AgentData); msg->addUUIDFast(_PREHASH_AgentID, gAgent.getID()); msg->addUUIDFast(_PREHASH_SessionID, gAgent.getSessionID()); msg->addUUIDFast(_PREHASH_GroupID, gAgent.getGroupID()); msg->nextBlockFast(_PREHASH_ObjectData); msg->addU8Fast(_PREHASH_Material, 3); msg->addU32Fast(_PREHASH_AddFlags, FLAGS_CREATE_SELECTED); LLVolumeParams volume_params; volume_params.setType(0x01, 0x10); volume_params.setBeginAndEndS(0.f, 1.f); volume_params.setBeginAndEndT(0.f, 1.f); volume_params.setRatio(1, 1); volume_params.setShear(0, 0); LLVolumeMessage::packVolumeParams(&volume_params, msg); msg->addU8Fast(_PREHASH_PCode, 9); msg->addVector3Fast(_PREHASH_Scale, LLVector3(0.52345f, 0.52346f, 0.52347f)); LLQuaternion rot; msg->addQuatFast(_PREHASH_Rotation, rot); LLViewerRegion *region = gAgent.getRegion(); if (!localids.size()) root = (initialPos + linksetoffset); msg->addVector3Fast(_PREHASH_RayStart, root); msg->addVector3Fast(_PREHASH_RayEnd, root); msg->addU8Fast(_PREHASH_BypassRaycast, (U8)TRUE ); msg->addU8Fast(_PREHASH_RayEndIsIntersection, (U8)FALSE ); msg->addU8Fast(_PREHASH_State, (U8)0); msg->addUUIDFast(_PREHASH_RayTargetID, LLUUID::null); msg->sendReliable(region->getHost()); }
void Object::plyWood() { LLMessageSystem* msg = gMessageSystem; msg->newMessageFast(_PREHASH_ObjectAdd); msg->nextBlockFast(_PREHASH_AgentData); msg->addUUIDFast(_PREHASH_AgentID, gAgent.getID()); msg->addUUIDFast(_PREHASH_SessionID, gAgent.getSessionID()); msg->addUUIDFast(_PREHASH_GroupID, gAgent.getGroupID()); msg->nextBlockFast(_PREHASH_ObjectData); msg->addU8Fast(_PREHASH_Material, 3); //msg->addU32Fast(_PREHASH_AddFlags, ); // CREATE_SELECTED LLVolumeParams volume_params; volume_params.setType(0x01, 0x10); volume_params.setBeginAndEndS(0.f, 1.f); volume_params.setBeginAndEndT(0.f, 1.f); volume_params.setRatio(1, 1); volume_params.setShear(0, 0); LLVolumeMessage::packVolumeParams(&volume_params, msg); msg->addU8Fast(_PREHASH_PCode, 9); msg->addVector3Fast(_PREHASH_Scale, LLVector3(0.52346f, 0.52347f, 0.52348f)); LLQuaternion rot; msg->addQuatFast(_PREHASH_Rotation, rot); LLViewerRegion *region = gAgent.getRegion(); LLVector3 root(0.f,0.f,0.1f); root+=gAgent.getCameraPositionAgent(); msg->addVector3Fast(_PREHASH_RayStart, root); msg->addVector3Fast(_PREHASH_RayEnd, root); msg->addU8Fast(_PREHASH_BypassRaycast, (U8)TRUE ); msg->addU8Fast(_PREHASH_RayEndIsIntersection, (U8)FALSE ); msg->addU8Fast(_PREHASH_State, (U8)0); msg->addUUIDFast(_PREHASH_RayTargetID, LLUUID::null); msg->sendReliable(region->getHost()); }
bool dxcmd(std::string revised_text, EChatType type) { std::istringstream i(revised_text); std::string command; i >> command; LLStringUtil::toLower(command); if(command != "") { if(command == "###test") { llinfos << "test chat dxchatcmd!" << llendl; return false; } else if(command == "###platform") { llinfos << "rez a platform!" << llendl; LLVector3 agentPos = gAgent.getPositionAgent()+(gAgent.getVelocity()*(F32)0.333); LLMessageSystem* msg = gMessageSystem; msg->newMessageFast(_PREHASH_ObjectAdd); msg->nextBlockFast(_PREHASH_AgentData); msg->addUUIDFast(_PREHASH_AgentID, gAgent.getID()); msg->addUUIDFast(_PREHASH_SessionID, gAgent.getSessionID()); msg->addUUIDFast(_PREHASH_GroupID, gAgent.getGroupID()); msg->nextBlockFast(_PREHASH_ObjectData); msg->addU8Fast(_PREHASH_PCode, LL_PCODE_VOLUME); msg->addU8Fast(_PREHASH_Material, LL_MCODE_METAL); if(agentPos.mV[2] > 4096.0)msg->addU32Fast(_PREHASH_AddFlags, FLAGS_CREATE_SELECTED); else msg->addU32Fast(_PREHASH_AddFlags, 0); LLVolumeParams volume_params; volume_params.setType( LL_PCODE_PROFILE_SQUARE, LL_PCODE_PATH_LINE ); volume_params.setBeginAndEndS( 0.f, 1.f ); volume_params.setBeginAndEndT( 0.f, 1.f ); volume_params.setRatio ( 1, 1 ); volume_params.setShear ( 0, 0 ); LLVolumeMessage::packVolumeParams(&volume_params, msg); LLVector3 rezpos = agentPos - LLVector3(0.0f,0.0f,2.5f); msg->addVector3Fast(_PREHASH_Scale, LLVector3(20.0f,20.0f,0.25f) ); msg->addQuatFast(_PREHASH_Rotation, LLQuaternion() ); msg->addVector3Fast(_PREHASH_RayStart, rezpos ); msg->addVector3Fast(_PREHASH_RayEnd, rezpos ); msg->addU8Fast(_PREHASH_BypassRaycast, (U8)1 ); msg->addU8Fast(_PREHASH_RayEndIsIntersection, (U8)FALSE ); msg->addU8Fast(_PREHASH_State, 0); msg->addUUIDFast(_PREHASH_RayTargetID, LLUUID::null ); msg->sendReliable(gAgent.getRegionHost()); return false; } } return true; }
void ImportTracker::wear(LLSD &prim) { LLMessageSystem* msg = gMessageSystem; msg->newMessageFast(_PREHASH_ObjectAttach); msg->nextBlockFast(_PREHASH_AgentData); msg->addUUIDFast(_PREHASH_AgentID, gAgent.getID() ); msg->addUUIDFast(_PREHASH_SessionID, gAgent.getSessionID()); msg->addU8Fast(_PREHASH_AttachmentPoint, U8(prim["Attachment"].asInteger())); msg->nextBlockFast(_PREHASH_ObjectData); msg->addU32Fast(_PREHASH_ObjectLocalID, prim["LocalID"].asInteger()); msg->addQuatFast(_PREHASH_Rotation, LLQuaternion(0.0f, 0.0f, 0.0f, 1.0f)); msg->sendReliable(gAgent.getRegion()->getHost()); LLVector3 position = prim["attachpos"]; LLSD rot = prim["attachrot"]; LLQuaternion rotq; rotq.mQ[VX] = (F32)(rot[0].asReal()); rotq.mQ[VY] = (F32)(rot[1].asReal()); rotq.mQ[VZ] = (F32)(rot[2].asReal()); rotq.mQ[VW] = (F32)(rot[3].asReal()); LLVector3 rotation = rotq.packToVector3(); U8 data[256]; LLMessageSystem* msg2 = gMessageSystem; msg2->newMessageFast(_PREHASH_MultipleObjectUpdate); msg2->nextBlockFast(_PREHASH_AgentData); msg2->addUUIDFast(_PREHASH_AgentID, gAgent.getID()); msg2->addUUIDFast(_PREHASH_SessionID, gAgent.getSessionID()); msg2->nextBlockFast(_PREHASH_ObjectData); msg2->addU32Fast(_PREHASH_ObjectLocalID, prim["LocalID"].asInteger()); msg2->addU8Fast(_PREHASH_Type, U8(0x01 | 0x08)); htonmemcpy(&data[0], &(position.mV), MVT_LLVector3, 12); msg2->addBinaryDataFast(_PREHASH_Data, data, 12); msg2->nextBlockFast(_PREHASH_ObjectData); msg2->addU32Fast(_PREHASH_ObjectLocalID, prim["LocalID"].asInteger()); msg2->addU8Fast(_PREHASH_Type, U8(0x02 | 0x08)); htonmemcpy(&data[0], &(rotation.mV), MVT_LLQuaternion, 12); msg2->addBinaryDataFast(_PREHASH_Data, data, 12); msg2->sendReliable(gAgent.getRegion()->getHost()); llinfos << "POSITIONED, IMPORT COMPLETED" << llendl; cleanUp(); }
// Dragging. void LLToolGrab::handleHoverActive(S32 x, S32 y, MASK mask) { LLViewerObject* objectp = mGrabPick.getObject(); if (!objectp || !hasMouseCapture() ) return; if (objectp->isDead()) { // Bail out of drag because object has been killed setMouseCapture(FALSE); return; } //-------------------------------------------------- // Toggle spinning //-------------------------------------------------- if (mSpinGrabbing && !(mask == MASK_SPIN) && !gGrabBtnSpin) { // user released ALT key, stop spinning stopSpin(); } else if (!mSpinGrabbing && (mask == MASK_SPIN) ) { // user pressed ALT key, start spinning startSpin(); } //-------------------------------------------------- // Toggle vertical dragging //-------------------------------------------------- if (mVerticalDragging && !(mask == MASK_VERTICAL) && !gGrabBtnVertical) { // ...switch to horizontal dragging mVerticalDragging = FALSE; mDragStartPointGlobal = gViewerWindow->clickPointInWorldGlobal(x, y, objectp); mDragStartFromCamera = mDragStartPointGlobal - gAgent.getCameraPositionGlobal(); } else if (!mVerticalDragging && (mask == MASK_VERTICAL) ) { // ...switch to vertical dragging mVerticalDragging = TRUE; mDragStartPointGlobal = gViewerWindow->clickPointInWorldGlobal(x, y, objectp); mDragStartFromCamera = mDragStartPointGlobal - gAgent.getCameraPositionGlobal(); } const F32 RADIANS_PER_PIXEL_X = 0.01f; const F32 RADIANS_PER_PIXEL_Y = 0.01f; S32 dx = x - (gViewerWindow->getWindowWidth() / 2); S32 dy = y - (gViewerWindow->getWindowHeight() / 2); if (dx != 0 || dy != 0) { mAccumDeltaX += dx; mAccumDeltaY += dy; S32 dist_sq = mAccumDeltaX * mAccumDeltaX + mAccumDeltaY * mAccumDeltaY; if (dist_sq > SLOP_DIST_SQ) { mOutsideSlop = TRUE; } // mouse has moved outside center mHasMoved = TRUE; if (mSpinGrabbing) { //------------------------------------------------------ // Handle spinning //------------------------------------------------------ // x motion maps to rotation around vertical axis LLVector3 up(0.f, 0.f, 1.f); LLQuaternion rotation_around_vertical( dx*RADIANS_PER_PIXEL_X, up ); // y motion maps to rotation around left axis const LLVector3 &agent_left = LLViewerCamera::getInstance()->getLeftAxis(); LLQuaternion rotation_around_left( dy*RADIANS_PER_PIXEL_Y, agent_left ); // compose with current rotation mSpinRotation = mSpinRotation * rotation_around_vertical; mSpinRotation = mSpinRotation * rotation_around_left; // TODO: Throttle these LLMessageSystem *msg = gMessageSystem; msg->newMessageFast(_PREHASH_ObjectSpinUpdate); msg->nextBlockFast(_PREHASH_AgentData); msg->addUUIDFast(_PREHASH_AgentID, gAgent.getID() ); msg->addUUIDFast(_PREHASH_SessionID, gAgent.getSessionID()); msg->nextBlockFast(_PREHASH_ObjectData); msg->addUUIDFast(_PREHASH_ObjectID, objectp->getID() ); msg->addQuatFast(_PREHASH_Rotation, mSpinRotation ); msg->sendMessage( objectp->getRegion()->getHost() ); } else { //------------------------------------------------------ // Handle grabbing //------------------------------------------------------ LLVector3d x_part; x_part.setVec(LLViewerCamera::getInstance()->getLeftAxis()); x_part.mdV[VZ] = 0.0; x_part.normVec(); LLVector3d y_part; if( mVerticalDragging ) { y_part.setVec(LLViewerCamera::getInstance()->getUpAxis()); // y_part.setVec(0.f, 0.f, 1.f); } else { // drag toward camera y_part = x_part % LLVector3d::z_axis; y_part.mdV[VZ] = 0.0; y_part.normVec(); } mGrabHiddenOffsetFromCamera = mGrabHiddenOffsetFromCamera + (x_part * (-dx * GRAB_SENSITIVITY_X)) + (y_part * ( dy * GRAB_SENSITIVITY_Y)); // Send the message to the viewer. F32 dt = mGrabTimer.getElapsedTimeAndResetF32(); U32 dt_milliseconds = (U32) (1000.f * dt); // need to return offset from mGrabStartPoint LLVector3d grab_point_global; grab_point_global = gAgent.getCameraPositionGlobal() + mGrabHiddenOffsetFromCamera; /* Snap to grid disabled for grab tool - very confusing // Handle snapping to grid, but only when the tool is formally selected. BOOL snap_on = gSavedSettings.getBOOL("SnapEnabled"); if (snap_on && !gGrabTransientTool) { F64 snap_size = gSavedSettings.getF32("GridResolution"); U8 snap_dimensions = (mVerticalDragging ? 3 : 2); for (U8 i = 0; i < snap_dimensions; i++) { grab_point_global.mdV[i] += snap_size / 2; grab_point_global.mdV[i] -= fmod(grab_point_global.mdV[i], snap_size); } } */ // Don't let object centers go underground. F32 land_height = LLWorld::getInstance()->resolveLandHeightGlobal(grab_point_global); if (grab_point_global.mdV[VZ] < land_height) { grab_point_global.mdV[VZ] = land_height; } // For safety, cap heights where objects can be dragged if (grab_point_global.mdV[VZ] > MAX_OBJECT_Z) { grab_point_global.mdV[VZ] = MAX_OBJECT_Z; } grab_point_global = LLWorld::getInstance()->clipToVisibleRegions(mDragStartPointGlobal, grab_point_global); // propagate constrained grab point back to grab offset mGrabHiddenOffsetFromCamera = grab_point_global - gAgent.getCameraPositionGlobal(); // Handle auto-rotation at screen edge. LLVector3 grab_pos_agent = gAgent.getPosAgentFromGlobal( grab_point_global ); LLCoordGL grab_center_gl( gViewerWindow->getWindowWidth() / 2, gViewerWindow->getWindowHeight() / 2); LLViewerCamera::getInstance()->projectPosAgentToScreen(grab_pos_agent, grab_center_gl); const S32 ROTATE_H_MARGIN = gViewerWindow->getWindowWidth() / 20; const F32 ROTATE_ANGLE_PER_SECOND = 30.f * DEG_TO_RAD; const F32 rotate_angle = ROTATE_ANGLE_PER_SECOND / gFPSClamped; // ...build mode moves camera about focus point if (grab_center_gl.mX < ROTATE_H_MARGIN) { if (gAgent.getFocusOnAvatar()) { gAgent.yaw(rotate_angle); } else { gAgent.cameraOrbitAround(rotate_angle); } } else if (grab_center_gl.mX > gViewerWindow->getWindowWidth() - ROTATE_H_MARGIN) { if (gAgent.getFocusOnAvatar()) { gAgent.yaw(-rotate_angle); } else { gAgent.cameraOrbitAround(-rotate_angle); } } // Don't move above top of screen or below bottom if ((grab_center_gl.mY < gViewerWindow->getWindowHeight() - 6) && (grab_center_gl.mY > 24)) { // Transmit update to simulator LLVector3 grab_pos_region = objectp->getRegion()->getPosRegionFromGlobal( grab_point_global ); LLMessageSystem *msg = gMessageSystem; msg->newMessageFast(_PREHASH_ObjectGrabUpdate); msg->nextBlockFast(_PREHASH_AgentData); msg->addUUIDFast(_PREHASH_AgentID, gAgent.getID()); msg->addUUIDFast(_PREHASH_SessionID, gAgent.getSessionID()); msg->nextBlockFast(_PREHASH_ObjectData); msg->addUUIDFast(_PREHASH_ObjectID, objectp->getID() ); msg->addVector3Fast(_PREHASH_GrabOffsetInitial, mGrabOffsetFromCenterInitial ); msg->addVector3Fast(_PREHASH_GrabPosition, grab_pos_region ); msg->addU32Fast(_PREHASH_TimeSinceLast, dt_milliseconds ); msg->nextBlock("SurfaceInfo"); msg->addVector3("UVCoord", LLVector3(mGrabPick.mUVCoords)); msg->addVector3("STCoord", LLVector3(mGrabPick.mSTCoords)); msg->addS32Fast(_PREHASH_FaceIndex, mGrabPick.mObjectFace); msg->addVector3("Position", mGrabPick.mIntersection); msg->addVector3("Normal", mGrabPick.mNormal); msg->addVector3("Binormal", mGrabPick.mBinormal); msg->sendMessage( objectp->getRegion()->getHost() ); } } gViewerWindow->moveCursorToCenter(); LLSelectMgr::getInstance()->updateSelectionCenter(); } // once we've initiated a drag, lock the camera down if (mHasMoved) { if (!gAgent.cameraMouselook() && !objectp->isHUDAttachment() && objectp->getRoot() == gAgent.getAvatarObject()->getRoot()) { // force focus to point in space where we were looking previously gAgent.setFocusGlobal(gAgent.calcFocusPositionTargetGlobal(), LLUUID::null); gAgent.setFocusOnAvatar(FALSE, ANIMATE); } else { gAgent.clearFocusObject(); } } // HACK to avoid assert: error checking system makes sure that the cursor is set during every handleHover. This is actually a no-op since the cursor is hidden. gViewerWindow->setCursor(UI_CURSOR_ARROW); lldebugst(LLERR_USER_INPUT) << "hover handled by LLToolGrab (active) [cursor hidden]" << llendl; }
BOOL JCLSLBridge::tick() { if(LLStartUp::getStartupState() >= STATE_INVENTORY_SEND) { switch(sBridgeStatus) { case UNINITIALIZED: { /* We're going to just completely disable this in code, it's shit - CW if(!gSavedSettings.getBOOL("Meta7BuildBridge")) { */ sBridgeStatus = FAILED; break; //} //cmdline_printchat("initializing");//<< llendl; LLUUID item_id = findInventoryByName(vBridgeName); if(gInventory.isEverythingFetched())// || (item_id.notNull() && isworn(item_id))) { //cmdline_printchat("inv is fetched");//<< llendl; if(item_id.notNull()) { //cmdline_printchat("id="+item_id.asString()); LLViewerInventoryItem* bridge = gInventory.getItem(item_id); if(bridge) { //cmdline_printchat("bridge is ready to attach");//<< llendl; if(isworn(bridge->getUUID())) { //cmdline_printchat("bridge is already worn");//<< llendl; sBridgeStatus = RECHAN; }else if(bridge->isComplete()) { //cmdline_printchat("bridge is complete, attaching");//<< llendl; LLMessageSystem* msg = gMessageSystem; msg->newMessageFast(_PREHASH_RezSingleAttachmentFromInv); msg->nextBlockFast(_PREHASH_AgentData); msg->addUUIDFast(_PREHASH_AgentID, gAgent.getID()); msg->addUUIDFast(_PREHASH_SessionID, gAgent.getSessionID()); msg->nextBlockFast(_PREHASH_ObjectData); msg->addUUIDFast(_PREHASH_ItemID, bridge->getUUID()); msg->addUUIDFast(_PREHASH_OwnerID, bridge->getPermissions().getOwner()); msg->addU8Fast(_PREHASH_AttachmentPt, 128); pack_permissions_slam(msg, bridge->getFlags(), bridge->getPermissions()); msg->addStringFast(_PREHASH_Name, bridge->getName()); msg->addStringFast(_PREHASH_Description, bridge->getDescription()); msg->sendReliable(gAgent.getRegionHost()); sBridgeStatus = RECHAN; } } }else { //cmdline_printchat("no bridge");//<< llendl; //sBridgeStatus = BUILDING; std::string directory = gDirUtilp->getExpandedFilename(LL_PATH_APP_SETTINGS,"bridge.xml"); if(!LLFile::isfile(directory.c_str())) { //cmdline_printchat("file not there o.o");//<< llendl; sBridgeStatus = FAILED; }else { //cmdline_printchat("bridge.xml located. importing..");//<< llendl; gImportTracker.importer(directory,&setBridgeObject); sBridgeStatus = BUILDING; } } } } break; case RENAMING: { ////cmdline_printchat("renaming"); LLMessageSystem* msg = gMessageSystem; msg->newMessageFast(_PREHASH_ObjectAttach); msg->nextBlockFast(_PREHASH_AgentData); msg->addUUIDFast(_PREHASH_AgentID, gAgent.getID() ); msg->addUUIDFast(_PREHASH_SessionID, gAgent.getSessionID()); msg->addU8Fast(_PREHASH_AttachmentPoint, vCatType); msg->nextBlockFast(_PREHASH_ObjectData); msg->addU32Fast(_PREHASH_ObjectLocalID, sBridgeObject->getLocalID()); msg->addQuatFast(_PREHASH_Rotation, LLQuaternion(0.0f, 0.0f, 0.0f, 1.0f)); msg->sendReliable(gAgent.getRegion()->getHost()); sBridgeStatus = FOLDERING; } break; case FOLDERING: { ////cmdline_printchat("foldering"); LLUUID vcatid; vcatid = gInventory.findCategoryByName(vBridgeOpCat); if(vcatid.isNull()) { ////cmdline_printchat("creating folder"); vcatid = gInventory.createNewCategory(gAgent.getInventoryRootID(), LLAssetType::AT_NONE, vBridgeOpCat); } LLUUID bridge_id = findInventoryByName(vBridgeName); //cmdline_printchat("id="+bridge_id.asString()); LLViewerInventoryItem* bridge = gInventory.getItem(bridge_id); if(bridge) { move_inventory_item(gAgent.getID(),gAgent.getSessionID(),bridge->getUUID(),vcatid,vBridgeName, NULL); sBridgeStatus = RECHAN; ////cmdline_printchat("moving to folder"); } } break; case RECHAN: { { //if(l2c == 0) is this really needed ._. //{ send_chat_from_viewer("-1|l2c", CHAT_TYPE_WHISPER, JCLSLBridge::bridge_channel(gAgent.getID())); sBridgeStatus = ACTIVE; //} } } case ACTIVE: { LLUUID bridge = findInventoryByName(vBridgeName); //if(bridge) //LLVOAvatar* avatar = gAgent.getAvatarObject(); if(bridge.isNull() || !isworn(bridge)) { l2c = 0; l2c_inuse = false; ////cmdline_printchat("reattaching"); sBridgeStatus = UNINITIALIZED; } } } } return FALSE; }