NFVector3 operator/= (float s) { //if (std::abs(s) > 0.001f) { return NFVector3(x / s, y / s, z / s); } //return Zero(); }
NFVector3 operator/ (float s) const { if (std::abs(s) > 0.001f) { return NFVector3(x / s, y / s, z / s); } return Zero(); }
NFVector3 NFCSceneAOIModule::GetRelivePosition(const int nSceneID, const int nIndex) { NF_SHARE_PTR<NFCSceneInfo> pSceneInfo = GetElement(nSceneID); if (pSceneInfo) { return pSceneInfo->GetReliveInfo(nIndex); } return NFVector3(); }
NFVector3 NFCSceneAOIModule::GetTagPosition(const int nSceneID, const int nIndex, const bool bRoll) { NF_SHARE_PTR<NFCSceneInfo> pSceneInfo = GetElement(nSceneID); if (pSceneInfo) { return pSceneInfo->GetTagInfo(nIndex, bRoll); } return NFVector3(); }
//---------------------------------------------------------------------------- inline NFVector3 Direction() const { if (this->IsZero()) { return Zero(); } float lenSquared = SquaredMagnitude(); float invSqrt = 1.0f / sqrtf(lenSquared); return NFVector3(x * invSqrt, y * invSqrt, z * invSqrt); }
// 移动 void NFCPlayerLogic::OnObjectMove(const NFSOCK nSockIndex, const int nMsgID, const char* msg, const uint32_t nLen) { NFGUID nPlayerID; NFMsg::ReqAckPlayerMove xMsg; if (!NFINetModule::ReceivePB(nMsgID, msg, nLen, xMsg, nPlayerID)) { return; } float fMove = g_pKernelModule->GetPropertyInt(NFINetModule::PBToNF(xMsg.mover()), "MOVE_SPEED")/10000.0f; NFDataList var; var.AddObject(NFINetModule::PBToNF(xMsg.mover())); var.AddFloat(fMove); const NFMsg::Vector3 &pos = xMsg.target_pos(0); var.AddVector3(NFVector3(pos.x(), pos.y(), pos.z())); DoEvent(E_PlayerEvent_PlayerMove, var); }
void NFCRecordLogic::AddRecord(const NF_SHARE_PTR<NFIObject>& object, const std::string &strRecordName, const NFMsg::RecordAddRowStruct &data) { NF_SHARE_PTR<NFIRecordManager> recordMgr = object->GetRecordManager(); NF_SHARE_PTR<NFDataList> varData = NF_SHARE_PTR<NFDataList>(NF_NEW NFDataList()); NF_SHARE_PTR<NFDataList> varInit = NF_SHARE_PTR<NFDataList>(NF_NEW NFDataList()); NF_SHARE_PTR<NFDataList> varTag = NF_SHARE_PTR<NFDataList>(NF_NEW NFDataList()); for(int j = 0; j < data.record_float_list_size(); j++) { varInit->AddFloat(0); varData->AddFloat(data.record_float_list(j).data()); } for(int j = 0; j < data.record_int_list_size(); j++) { varInit->AddInt(0); varData->AddInt(data.record_int_list(j).data()); } for(int j = 0; j < data.record_string_list_size(); j++) { varInit->AddString(""); varData->AddString(data.record_string_list(j).data()); } for(int j = 0; j < data.record_object_list_size(); j++) { varInit->AddObject(NFGUID()); varData->AddObject(NFINetModule::PBToNF(data.record_object_list(j).data())); } for(int j = 0; j < data.record_vector2_list_size(); j++) { varInit->AddVector2(NFVector2()); varData->AddVector2(NFINetModule::PBToNF(data.record_vector2_list(j).data())); } for(int j = 0; j < data.record_vector3_list_size(); j++) { varInit->AddVector3(NFVector3()); varData->AddVector3(NFINetModule::PBToNF(data.record_vector3_list(j).data())); } NF_SHARE_PTR<NFIRecord> record = recordMgr->GetElement(strRecordName); if(record == nullptr) { record = recordMgr->AddRecord(NFGUID(), strRecordName, varInit, varTag, 255); } record->AddRow(data.row(), *varData); }
void NFCGameScene::onTouchMoved(Touch *touch, Event *unused_event) { Vec2 toPos = this->convertTouchToNodeSpace(touch); g_pPlayerLogic->RequireMove(NFVector3(toPos.x, toPos.y, 0)); }
bool NFCRecord::QueryRow(const int nRow, NFDataList& varList) { if (!ValidRow(nRow)) { return false; } if (!IsUsed(nRow)) { return false; } varList.Clear(); for (int i = 0; i < GetCols(); ++i) { NF_SHARE_PTR<NFData>& pVar = mtRecordVec.at(GetPos(nRow, i)); if (pVar) { varList.Append(*pVar); } else { switch (GetColType(i)) { case TDATA_INT: varList.Add(NFINT64(0)); break; case TDATA_FLOAT: varList.Add(0.0f); break; case TDATA_STRING: varList.Add(NULL_STR.c_str()); break; case TDATA_OBJECT: varList.Add(NFGUID()); break; case TDATA_VECTOR2: varList.Add(NFVector2()); break; case TDATA_VECTOR3: varList.Add(NFVector3()); break; default: return false; break; } } } if (varList.GetCount() != GetCols()) { return false; } return true; }
bool NFCCreateRoleModule::ConvertPBToPropertyManager(const NFMsg::ObjectPropertyList& pPropertyData, NF_SHARE_PTR<NFIPropertyManager> pProps) { if (pProps) { for (int i = 0; i < pPropertyData.property_int_list_size(); ++i) { const NFMsg::PropertyInt& xData = pPropertyData.property_int_list(i); if (pProps->ExistElement(xData.property_name())) { pProps->AddProperty(pProps->Self(), xData.property_name(), NFDATA_TYPE::TDATA_INT); } pProps->SetPropertyInt(xData.property_name(), xData.data()); } for (int i = 0; i < pPropertyData.property_float_list_size(); ++i) { const NFMsg::PropertyFloat& xData = pPropertyData.property_float_list(i); if (pProps->ExistElement(xData.property_name())) { pProps->AddProperty(pProps->Self(), xData.property_name(), NFDATA_TYPE::TDATA_FLOAT); } pProps->SetPropertyFloat(xData.property_name(), xData.data()); } for (int i = 0; i < pPropertyData.property_string_list_size(); ++i) { const NFMsg::PropertyString& xData = pPropertyData.property_string_list(i); if (pProps->ExistElement(xData.property_name())) { pProps->AddProperty(pProps->Self(), xData.property_name(), NFDATA_TYPE::TDATA_STRING); } pProps->SetPropertyString(xData.property_name(), xData.data()); } for (int i = 0; i < pPropertyData.property_object_list_size(); ++i) { const NFMsg::PropertyObject& xData = pPropertyData.property_object_list(i); if (pProps->ExistElement(xData.property_name())) { pProps->AddProperty(pProps->Self(), xData.property_name(), NFDATA_TYPE::TDATA_OBJECT); } pProps->SetPropertyObject(xData.property_name(), NFGUID(xData.data().svrid(), xData.data().index())); } for (int i = 0; i < pPropertyData.property_vector2_list_size(); ++i) { const NFMsg::PropertyVector2& xData = pPropertyData.property_vector2_list(i); if (pProps->ExistElement(xData.property_name())) { pProps->AddProperty(pProps->Self(), xData.property_name(), NFDATA_TYPE::TDATA_VECTOR2); } pProps->SetPropertyVector2(xData.property_name(), NFVector2(xData.data().x(), xData.data().y())); } for (int i = 0; i < pPropertyData.property_vector3_list_size(); ++i) { const NFMsg::PropertyVector3& xData = pPropertyData.property_vector3_list(i); if (pProps->ExistElement(xData.property_name())) { pProps->AddProperty(pProps->Self(), xData.property_name(), NFDATA_TYPE::TDATA_VECTOR3); } pProps->SetPropertyVector3(xData.property_name(), NFVector3(xData.data().x(), xData.data().y(), xData.data().z())); } } return true; }
NFVector3 operator* (float s) const { return NFVector3(x * s, y * s, z * s); }
NFVector3 operator- () const { return NFVector3(-x, -y, -z); }