void ClustMod::Move( TimeValue t, Matrix3& partm, Matrix3& tmAxis, Point3& val, BOOL localOrigin) { #ifdef DESIGN_VER t=0; #endif if (tmControl==NULL) { ReplaceReference(0,NewDefaultMatrix3Controller()); NotifyDependents(FOREVER,0,REFMSG_CONTROLREF_CHANGE); } if (ip && ip->GetSubObjectLevel()==1) { SetXFormPacket pckt(val,partm,tmAxis); tmControl->SetValue(t,&pckt,TRUE,CTRL_RELATIVE); } else { if (posControl==NULL) { ReplaceReference(1,NewDefaultPositionController()); NotifyDependents(FOREVER,0,REFMSG_CONTROLREF_CHANGE); } Matrix3 ptm = partm; Interval valid; if (tmControl) tmControl->GetValue(t,&ptm,valid,CTRL_RELATIVE); posControl->SetValue(t,-VectorTransform(tmAxis*Inverse(ptm),val),TRUE,CTRL_RELATIVE); SetXFormPacket pckt(val,partm,tmAxis); tmControl->SetValue(t,&pckt,TRUE,CTRL_RELATIVE); } }
void CreateMorphMode::Begin(INode *n,IObjParam *i) { ReplaceReference(0,n); svNode = node; assert(node); ip = i; proc.Init(ip); theHold.Begin(); theHold.Put(new CreateMorphRestore); obj = new MorphObject; theHold.Put(new CreateMorphNotify(obj,1)); TSTR name = TSTR(_T("M_")) + node->GetName(); SetMorphTargetPacket pckt(node->GetObjectRef(),name); obj->morphCont->SetValue(0,&pckt); node->SetObjectRef(obj); theHold.Put(new CreateMorphNotify(obj,0)); theHold.Accept(IDS_DS_CREATE); obj->BeginEditParams(i,BEGIN_EDIT_CREATE,NULL); }
void MorphObject::AddNewTarget(INode *node,TimeValue t,int m) { Object *obj = NULL; BOOL delnode = FALSE; switch (m) { case TARG_REF: obj = MakeObjectDerivedObject(node->GetObjectRef()); break; case TARG_INSTANCE: obj = node->GetObjectRef(); break; case TARG_COPY: obj = (Object*)CloneRefHierarchy(node->GetObjectRef()); break; case TARG_MOVE: obj = node->GetObjectRef(); delnode = TRUE; break; default: return; } theHold.Begin(); TSTR name = TSTR(_T("M_")) + node->GetName(); Matrix3 tm = node->GetObjectTM(t)*Inverse(node->GetNodeTM(t)); SetMorphTargetPacket pckt(obj,name,tm); morphCont->SetValue(t,&pckt); if (delnode && ip) { ip->DeleteNode(node); } theHold.Accept(GetString(IDS_RB_PICKMORPHTARGET)); }
int CInMapDraw::GotNetMsg(boost::shared_ptr<const netcode::RawPacket> &packet) { int playerID = -1; try { netcode::UnpackPacket pckt(packet, 2); unsigned char uPlayerID; pckt >> uPlayerID; if (uPlayerID >= playerHandler->ActivePlayers()) { throw netcode::UnpackPacketException("Invalid player number"); } playerID = uPlayerID; const CPlayer* sender = playerHandler->Player(playerID); unsigned char drawType; pckt >> drawType; switch (drawType) { case MAPDRAW_POINT: { short int x,z; pckt >> x; pckt >> z; const float3 pos(x, 0, z); unsigned char fromLua; pckt >> fromLua; string label; pckt >> label; if (!fromLua || allowLuaMapDrawing) { LocalPoint(pos, label, playerID); } break; } case MAPDRAW_LINE: { short int x1,z1,x2,z2; pckt >> x1; pckt >> z1; pckt >> x2; pckt >> z2; const float3 pos1(x1, 0, z1); const float3 pos2(x2, 0, z2); unsigned char fromLua; pckt >> fromLua; if (!fromLua || allowLuaMapDrawing) { LocalLine(pos1, pos2, playerID); } break; } case MAPDRAW_ERASE: { short int x,z; pckt >> x; pckt >> z; float3 pos(x, 0, z); LocalErase(pos, playerID); break; } } } catch (netcode::UnpackPacketException &e) { logOutput.Print("Got invalid MapDraw: %s", e.err.c_str()); playerID = -1; } return playerID; }
int CInMapDraw::GotNetMsg(boost::shared_ptr<const netcode::RawPacket>& packet) { int playerID = -1; try { netcode::UnpackPacket pckt(packet, 2); unsigned char uPlayerID; pckt >> uPlayerID; if (!playerHandler->IsValidPlayer(uPlayerID)) { throw netcode::UnpackPacketException("Invalid player number"); } playerID = uPlayerID; unsigned char drawType; pckt >> drawType; switch (drawType) { case MAPDRAW_POINT: { short int x, z; pckt >> x; pckt >> z; const float3 pos(x, 0, z); unsigned char fromLua; pckt >> fromLua; string label; pckt >> label; if (!fromLua || allowLuaMapDrawing) { inMapDrawerModel->AddPoint(pos, label, playerID); } break; } case MAPDRAW_LINE: { short int x1, z1, x2, z2; pckt >> x1; pckt >> z1; pckt >> x2; pckt >> z2; const float3 pos1(x1, 0, z1); const float3 pos2(x2, 0, z2); unsigned char fromLua; pckt >> fromLua; if (!fromLua || allowLuaMapDrawing) { inMapDrawerModel->AddLine(pos1, pos2, playerID); } break; } case MAPDRAW_ERASE: { short int x, z; pckt >> x; pckt >> z; float3 pos(x, 0, z); inMapDrawerModel->EraseNear(pos, playerID); break; } } } catch (const netcode::UnpackPacketException& ex) { LOG_L(L_WARNING, "Got invalid MapDraw: %s", ex.what()); playerID = -1; } return playerID; }
void CGame::ClientReadNet() { if (gu->gameTime - lastCpuUsageTime >= 1) { lastCpuUsageTime = gu->gameTime; if (playing) { net->Send(CBaseNetProtocol::Get().SendCPUUsage(profiler.GetPercent("CPU load"))); #if defined(USE_GML) && GML_ENABLE_SIM net->Send(CBaseNetProtocol::Get().SendLuaDrawTime(gu->myPlayerNum, luaDrawTime)); #endif } else { // the CPU-load percentage is undefined prior to SimFrame() net->Send(CBaseNetProtocol::Get().SendCPUUsage(0.0f)); } } boost::shared_ptr<const netcode::RawPacket> packet; // compute new timeLeft to "smooth" out SimFrame() calls if (!gameServer) { const unsigned int currentFrame = SDL_GetTicks(); if (timeLeft > 1.0f) timeLeft -= 1.0f; timeLeft += consumeSpeed * ((float)(currentFrame - lastframe) / 1000.f); if (skipping) timeLeft = 0.01f; lastframe = currentFrame; // read ahead to calculate the number of NETMSG_NEWFRAMES // we still have to process (in variable "que") int que = 0; // Number of NETMSG_NEWFRAMEs waiting to be processed. unsigned ahead = 0; while ((packet = net->Peek(ahead))) { if (packet->data[0] == NETMSG_NEWFRAME || packet->data[0] == NETMSG_KEYFRAME) ++que; ++ahead; } if(que < leastQue) leastQue = que; } else { // make sure ClientReadNet returns at least every 15 game frames // so CGame can process keyboard input, and render etc. timeLeft = (float)MAX_CONSECUTIVE_SIMFRAMES * gs->userSpeedFactor; } // always render at least 2FPS (will otherwise be highly unresponsive when catching up after a reconnection) unsigned procstarttime = SDL_GetTicks(); // really process the messages while (timeLeft > 0.0f && (SDL_GetTicks() - procstarttime) < 500 && (packet = net->GetData(gs->frameNum))) { const unsigned char* inbuf = packet->data; const unsigned dataLength = packet->length; const unsigned char packetCode = inbuf[0]; switch (packetCode) { case NETMSG_QUIT: { try { netcode::UnpackPacket pckt(packet, 3); std::string message; pckt >> message; logOutput.Print(message); if (!gameOver) { GameEnd(std::vector<unsigned char>()); } AddTraffic(-1, packetCode, dataLength); } catch (netcode::UnpackPacketException &e) { logOutput.Print("Got invalid QuitMessage: %s", e.err.c_str()); } break; } case NETMSG_PLAYERLEFT: { const unsigned char player = inbuf[1]; if (!playerHandler->IsValidPlayer(player)) { logOutput.Print("Got invalid player num (%i) in NETMSG_PLAYERLEFT", player); break; } playerHandler->PlayerLeft(player, inbuf[2]); eventHandler.PlayerRemoved(player, (int) inbuf[2]); AddTraffic(player, packetCode, dataLength); break; } case NETMSG_MEMDUMP: { MakeMemDump(); #ifdef TRACE_SYNC tracefile.Commit(); #endif AddTraffic(-1, packetCode, dataLength); break; } case NETMSG_STARTPLAYING: { unsigned timeToStart = *(unsigned*)(inbuf+1); if (timeToStart > 0) { GameSetupDrawer::StartCountdown(timeToStart); } else { StartPlaying(); } AddTraffic(-1, packetCode, dataLength); break; } case NETMSG_SENDPLAYERSTAT: { //logOutput.Print("Game over"); // Warning: using CPlayer::Statistics here may cause endianness problems // once net->SendData is endian aware! net->Send(CBaseNetProtocol::Get().SendPlayerStat(gu->myPlayerNum, playerHandler->Player(gu->myPlayerNum)->currentStats)); AddTraffic(-1, packetCode, dataLength); break; } case NETMSG_PLAYERSTAT: { const unsigned char player = inbuf[1]; if (!playerHandler->IsValidPlayer(player)) { logOutput.Print("Got invalid player num %i in playerstat msg",player); break; } playerHandler->Player(player)->currentStats = *(CPlayer::Statistics*)&inbuf[2]; if (gameOver) { CDemoRecorder* record = net->GetDemoRecorder(); if (record != NULL) { record->SetPlayerStats(player, playerHandler->Player(player)->currentStats); } } AddTraffic(player, packetCode, dataLength); break; } case NETMSG_PAUSE: { const unsigned char player = inbuf[1]; if (!playerHandler->IsValidPlayer(player)) { logOutput.Print("Got invalid player num %i in pause msg",player); break; } gs->paused=!!inbuf[2]; logOutput.Print(gs->paused ? "%s paused the game" : "%s unpaused the game" , playerHandler->Player(player)->name.c_str()); eventHandler.GamePaused(player, gs->paused); lastframe = SDL_GetTicks(); AddTraffic(player, packetCode, dataLength); break; } case NETMSG_INTERNAL_SPEED: { gs->speedFactor = *((float*) &inbuf[1]); sound->PitchAdjust(sqrt(gs->speedFactor)); // logOutput.Print("Internal speed set to %.2f",gs->speedFactor); AddTraffic(-1, packetCode, dataLength); break; } case NETMSG_USER_SPEED: { gs->userSpeedFactor = *((float*) &inbuf[2]); const unsigned char player = inbuf[1]; if (!playerHandler->IsValidPlayer(player) && player != SERVER_PLAYER) { logOutput.Print("Got invalid player num %i in user speed msg", player); break; } const char* pName = (player == SERVER_PLAYER)? "server": playerHandler->Player(player)->name.c_str(); logOutput.Print("Speed set to %.1f [%s]", gs->userSpeedFactor, pName); AddTraffic(player, packetCode, dataLength); break; } case NETMSG_CPU_USAGE: { logOutput.Print("Game clients shouldn't get cpu usage msgs?"); AddTraffic(-1, packetCode, dataLength); break; } case NETMSG_PLAYERINFO: { const unsigned char player = inbuf[1]; if (!playerHandler->IsValidPlayer(player)) { logOutput.Print("Got invalid player num %i in playerinfo msg", player); break; } playerHandler->Player(player)->cpuUsage = *(float*) &inbuf[2]; playerHandler->Player(player)->ping = *(boost::uint32_t*) &inbuf[6]; AddTraffic(player, packetCode, dataLength); break; } case NETMSG_PLAYERNAME: { try { netcode::UnpackPacket pckt(packet, 2); unsigned char player; pckt >> player; if (!playerHandler->IsValidPlayer(player)) throw netcode::UnpackPacketException("Invalid player number"); pckt >> playerHandler->Player(player)->name; playerHandler->Player(player)->readyToStart=(gameSetup->startPosType != CGameSetup::StartPos_ChooseInGame); playerHandler->Player(player)->active=true; wordCompletion->AddWord(playerHandler->Player(player)->name, false, false, false); // required? AddTraffic(player, packetCode, dataLength); } catch (netcode::UnpackPacketException &e) { logOutput.Print("Got invalid PlayerName: %s", e.err.c_str()); } break; } case NETMSG_CHAT: { try { ChatMessage msg(packet); HandleChatMsg(msg); AddTraffic(msg.fromPlayer, packetCode, dataLength); } catch (netcode::UnpackPacketException &e) { logOutput.Print("Got invalid ChatMessage: %s", e.err.c_str()); } break; } case NETMSG_SYSTEMMSG:{ try { netcode::UnpackPacket pckt(packet, 4); string s; pckt >> s; logOutput.Print(s); AddTraffic(-1, packetCode, dataLength); } catch (netcode::UnpackPacketException &e) { logOutput.Print("Got invalid SystemMessage: %s", e.err.c_str()); } break; } case NETMSG_STARTPOS:{ const unsigned char player = inbuf[1]; if (!playerHandler->IsValidPlayer(player) && player != SERVER_PLAYER) { logOutput.Print("Got invalid player num %i in start pos msg", player); break; } const int team = inbuf[2]; if (!teamHandler->IsValidTeam(team)) { logOutput.Print("Got invalid team num %i in startpos msg", team); } else { float3 pos(*(float*)&inbuf[4], *(float*)&inbuf[8], *(float*)&inbuf[12]); if (!luaRules || luaRules->AllowStartPosition(player, pos)) { teamHandler->Team(team)->StartposMessage(pos); if (inbuf[3] != 2 && player != SERVER_PLAYER) { playerHandler->Player(player)->readyToStart = !!inbuf[3]; } if (pos.y != -500) // no marker marker when no pos set yet { char label[128]; SNPRINTF(label, sizeof(label), "Start %i", team); inMapDrawer->LocalPoint(pos, label, player); // FIXME - erase old pos ? } } } AddTraffic(player, packetCode, dataLength); break; } case NETMSG_RANDSEED: { gs->SetRandSeed(*((unsigned int*)&inbuf[1]), true); AddTraffic(-1, packetCode, dataLength); break; } case NETMSG_GAMEID: { const unsigned char* p = &inbuf[1]; CDemoRecorder* record = net->GetDemoRecorder(); if (record != NULL) { record->SetGameID(p); } memcpy(gameID, p, sizeof(gameID)); logOutput.Print( "GameID: %02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x", p[ 0], p[ 1], p[ 2], p[ 3], p[ 4], p[ 5], p[ 6], p[ 7], p[ 8], p[ 9], p[10], p[11], p[12], p[13], p[14], p[15]); AddTraffic(-1, packetCode, dataLength); break; } case NETMSG_PATH_CHECKSUM: { const unsigned char playerNum = inbuf[1]; if (!playerHandler->IsValidPlayer(playerNum)) { logOutput.Print("Got invalid player num %i in path checksum msg", playerNum); break; } const boost::uint32_t playerCheckSum = *(boost::uint32_t*) &inbuf[2]; const boost::uint32_t localCheckSum = pathManager->GetPathCheckSum(); const CPlayer* player = playerHandler->Player(playerNum); if (playerCheckSum == 0) { logOutput.Print( "[DESYNC WARNING] path-checksum for player %d (%s) is 0; non-writable cache?", playerNum, player->name.c_str() ); } else { if (playerCheckSum != localCheckSum) { logOutput.Print( "[DESYNC WARNING] path-checksum %08x for player %d (%s) does not match local checksum %08x", playerCheckSum, playerNum, player->name.c_str(), localCheckSum ); } } } break; case NETMSG_KEYFRAME: { int serverframenum = *(int*)(inbuf+1); net->Send(CBaseNetProtocol::Get().SendKeyFrame(serverframenum)); if (gs->frameNum == (serverframenum - 1)) { } else { // error LogObject() << "Error: Keyframe difference: " << gs->frameNum - (serverframenum - 1); } /* Fall through */ } case NETMSG_NEWFRAME: { timeLeft -= 1.0f; SimFrame(); // both NETMSG_SYNCRESPONSE and NETMSG_NEWFRAME are used for ping calculation by server #ifdef SYNCCHECK net->Send(CBaseNetProtocol::Get().SendSyncResponse(gs->frameNum, CSyncChecker::GetChecksum())); if ((gs->frameNum & 4095) == 0) {// reset checksum every ~2.5 minute gametime CSyncChecker::NewFrame(); } #endif AddTraffic(-1, packetCode, dataLength); if (videoCapturing->IsCapturing()) { return; } break; } case NETMSG_COMMAND: { try { netcode::UnpackPacket pckt(packet, 1); short int psize; pckt >> psize; unsigned char player; pckt >> player; if (!playerHandler->IsValidPlayer(player)) throw netcode::UnpackPacketException("Invalid player number"); Command c; pckt >> c.id; pckt >> c.options; for(int a = 0; a < ((psize-9)/4); ++a) { float param; pckt >> param; c.params.push_back(param); } selectedUnits.NetOrder(c,player); AddTraffic(player, packetCode, dataLength); } catch (netcode::UnpackPacketException &e) { logOutput.Print("Got invalid Command: %s", e.err.c_str()); } break; } case NETMSG_SELECT: { try { netcode::UnpackPacket pckt(packet, 1); short int psize; pckt >> psize; unsigned char player; pckt >> player; if (!playerHandler->IsValidPlayer(player)) throw netcode::UnpackPacketException("Invalid player number"); vector<int> selected; for (int a = 0; a < ((psize-4)/2); ++a) { short int unitid; pckt >> unitid; if (uh->GetUnit(unitid) == NULL) throw netcode::UnpackPacketException("Invalid unit ID"); if ((uh->GetUnit(unitid)->team == playerHandler->Player(player)->team) || gs->godMode) { selected.push_back(unitid); } } selectedUnits.NetSelect(selected, player); AddTraffic(player, packetCode, dataLength); } catch (netcode::UnpackPacketException &e) { logOutput.Print("Got invalid Select: %s", e.err.c_str()); } break; } case NETMSG_AICOMMAND: case NETMSG_AICOMMAND_TRACKED: { try { netcode::UnpackPacket pckt(packet, 1); short int psize; pckt >> psize; unsigned char player; pckt >> player; if (!playerHandler->IsValidPlayer(player)) throw netcode::UnpackPacketException("Invalid player number"); short int unitid; pckt >> unitid; if (unitid < 0 || static_cast<size_t>(unitid) >= uh->MaxUnits()) throw netcode::UnpackPacketException("Invalid unit ID"); Command c; pckt >> c.id; pckt >> c.options; if (packetCode == NETMSG_AICOMMAND_TRACKED) { pckt >> c.aiCommandId; } // insert the command parameters for (int a = 0; a < ((psize - 11) / 4); ++a) { float param; pckt >> param; c.params.push_back(param); } selectedUnits.AiOrder(unitid, c, player); AddTraffic(player, packetCode, dataLength); } catch (netcode::UnpackPacketException &e) { logOutput.Print("Got invalid AICommand: %s", e.err.c_str()); } break; }
bool CheckLeafsetJob::Start() { std::string s; std::vector<Host> leafset = routing_->getLeafset(); for (std::vector<Host>::iterator it = leafset.begin(); it != leafset.end(); ++it) { if (*it && !chimera_->Ping(*it)) { it->SetFailureTime(time::dtime ()); pf_log[W_WARNING] << "message send to host: " << *it << " failed at time: " << it->GetFailureTime() << "!"; if (it->GetSuccessAvg() < BAD_LINK) { pf_log[W_DEBUG] << "Deleting " << *it; routing_->remove(*it); } } } std::vector<Host> table = routing_->getRoutingTable(); for (std::vector<Host>::iterator it = table.begin(); it != table.end(); ++it) { if (*it && !chimera_->Ping(*it)) { it->SetFailureTime(time::dtime ()); pf_log[W_WARNING] << "message send to host: " << *it << " failed at time: " << it->GetFailureTime() << "!"; if (it->GetSuccessAvg() < BAD_LINK) { pf_log[W_DEBUG] << "Deleting " << *it; routing_->remove(*it); } } } /* send leafset exchange data every 3 times that pings the leafset */ if (count_ == 2) { Packet pckt(ChimeraPiggyType, chimera_->GetMe().GetKey()); leafset = routing_->getLeafset(); leafset.push_back(chimera_->GetMe()); count_ = 0; addr_list addrlist; for(std::vector<Host>::iterator it = leafset.begin(); it != leafset.end(); ++it) addrlist.push_back(it->GetAddr()); pckt.SetArg(CHIMERA_PIGGY_ADDRESSES, addrlist); for (std::vector<Host>::iterator it = leafset.begin(); it != leafset.end(); ++it) { pckt.SetDst(it->GetKey()); if(!chimera_->Send(*it, pckt)) { pf_log[W_WARNING] << "sending leafset update to " << *it << " failed!"; if (it->GetSuccessAvg() < BAD_LINK) { routing_->remove(*it); } } } } else { count_++; } return true; }
static INT_PTR CALLBACK MorphParamDlgProc2( HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) { MorphObject *mo = DLGetWindowLongPtr<MorphObject*>(hWnd); if (!mo && message!=WM_INITDIALOG) return FALSE; switch (message) { case WM_INITDIALOG: { mo = (MorphObject*)lParam; DLSetWindowLongPtr(hWnd, lParam); mo->hParams2 = hWnd; mo->SetupTargetList(); break; } case WM_COMMAND: switch(LOWORD(wParam)) { case IDC_CREATE_MORPHKEY: { TSTR name; Matrix3 tm = mo->morphCont->GetMorphTargTM(mo->sel); SetMorphTargetPacket pckt( mo->morphCont->GetMorphTarg(mo->sel),name, tm,TRUE); theHold.Begin(); mo->morphCont->SetValue(mo->ip->GetTime(),&pckt); theHold.Accept(GetString(IDS_RB_CREATEMORPHKEY)); mo->ip->RedrawViews(mo->ip->GetTime()); break; } case IDC_MORPHTARG_LIST: if (HIWORD(wParam)==LBN_SELCHANGE) { mo->sel = SendMessage( GetDlgItem(mo->hParams2,IDC_MORPHTARG_LIST), LB_GETCURSEL,0,0); if (mo->sel < 0) { EnableWindow(GetDlgItem(hWnd,IDC_CREATE_MORPHKEY),FALSE); EnableWindow(GetDlgItem(hWnd,IDC_DELETE_MORPHTARG),FALSE); ICustEdit *edit = GetICustEdit(GetDlgItem(hWnd,IDC_MORPHTARG_NAME)); edit->Disable(); edit->SetText(_T("")); ReleaseICustEdit(edit); } else { EnableWindow(GetDlgItem(hWnd,IDC_CREATE_MORPHKEY),TRUE); EnableWindow(GetDlgItem(hWnd,IDC_DELETE_MORPHTARG),TRUE); ICustEdit *edit = GetICustEdit(GetDlgItem(hWnd,IDC_MORPHTARG_NAME)); edit->Enable(); edit->SetText(mo->SubAnimName(mo->sel)); ReleaseICustEdit(edit); } mo->NotifyDependents(FOREVER,(PartID) mo,REFMSG_BRANCHED_HISTORY_CHANGED); } break; case IDC_DELETE_MORPHTARG: if (mo->sel>=0) { theHold.Begin(); mo->morphCont->DeleteMorphTarg(mo->sel); theHold.Accept(GetString(IDS_RB_DELETEMORPHTARG)); mo->sel = -1; mo->SetupTargetList(); mo->ip->RedrawViews(mo->ip->GetTime()); //GetSystemSetting(SYSSET_CLEAR_UNDO); } break; } break; case WM_CUSTEDIT_ENTER: if (LOWORD(wParam)==IDC_MORPHTARG_NAME && mo->sel >= 0) { ICustEdit *edit = GetICustEdit(GetDlgItem(hWnd,IDC_MORPHTARG_NAME)); TCHAR buf[256]; edit->GetText(buf,256); mo->morphCont->SetMorphTargName(mo->sel,TSTR(buf)); mo->SetupTargetList(); mo->NotifyDependents(FOREVER,0,REFMSG_SUBANIM_STRUCTURE_CHANGED); ReleaseICustEdit(edit); } break; case WM_LBUTTONDOWN: case WM_LBUTTONUP: case WM_MOUSEMOVE: mo->ip->RollupMouseMessage(hWnd,message,wParam,lParam); return FALSE; default: return FALSE; } return TRUE; }
void SymmetryMod::Rotate(TimeValue t, Matrix3& partm, Matrix3& tmAxis, Quat& val, BOOL localOrigin) { SetXFormPacket pckt(val,localOrigin,partm,tmAxis); mp_mirror->SetValue(t,&pckt,TRUE,CTRL_RELATIVE); }
void MirrorMod::Scale(TimeValue t, Matrix3& partm, Matrix3& tmAxis, Point3& val, BOOL localOrigin) { SetXFormPacket pckt(val,localOrigin,partm,tmAxis); tmControl->SetValue(t,&pckt,TRUE,CTRL_RELATIVE); }
void ResetXForm::ResetNodes(const INodeTab& nodesToReset) { Interface *ip = GetCOREInterface(); for (int i = 0; i < nodesToReset.Count(); i++) { INode *node = nodesToReset[i]; if (!node || node->IsGroupMember() || node->IsGroupHead()) continue; if (SelectedAncestor(node)) continue; Matrix3 ntm, ptm, rtm(1), piv(1), tm; // Get Parent and Node TMs ntm = node->GetNodeTM(ip->GetTime()); ptm = node->GetParentTM(ip->GetTime()); // Compute the relative TM ntm = ntm * Inverse(ptm); // The reset TM only inherits position rtm.SetTrans(ntm.GetTrans()); // Set the node TM to the reset TM tm = rtm*ptm; node->SetNodeTM(ip->GetTime(), tm); // Compute the pivot TM piv.SetTrans(node->GetObjOffsetPos()); PreRotateMatrix(piv,node->GetObjOffsetRot()); ApplyScaling(piv,node->GetObjOffsetScale()); // Reset the offset to 0 node->SetObjOffsetPos(Point3(0,0,0)); node->SetObjOffsetRot(IdentQuat()); node->SetObjOffsetScale(ScaleValue(Point3(1,1,1))); // Take the position out of the matrix since we don't reset position ntm.NoTrans(); // Apply the offset to the TM ntm = piv * ntm; // Apply a derived object to the node's object Object *obj = node->GetObjectRef(); IDerivedObject *dobj = CreateDerivedObject(obj); // Create an XForm mod SimpleMod *mod = (SimpleMod*)ip->CreateInstance( OSM_CLASS_ID, Class_ID(CLUSTOSM_CLASS_ID,0)); // Apply the transformation to the mod. SetXFormPacket pckt(ntm); mod->tmControl->SetValue(ip->GetTime(),&pckt); // Add the modifier to the derived object. dobj->SetAFlag(A_LOCK_TARGET); // RB 3/11/99: When the macro recorder is on the derived object will get deleted unless it is locked. dobj->AddModifier(mod); dobj->ClearAFlag(A_LOCK_TARGET); // Replace the node's object node->SetObjectRef(dobj); } // Why on earth were we clearing the undo stack? // GetSystemSetting(SYSSET_CLEAR_UNDO); ip->RedrawViews(ip->GetTime()); SetSaveRequiredFlag(TRUE); }