void MyApplication::useSimpleArray() { const SceneManagerPtr& scene = BaseApplication::getSceneManager(); scene->clear(); for (s32 col = -2; col < 3; ++col) { for (s32 row = -2; row < 3; ++row) { for (s32 width = 0; width < 1; ++width) { CShape* model = scene->addCube(0, Vector3D((f32)row, (f32)col, -5)); if (model) { model->setName("cube_" + std::to_string(col) + "_" + std::to_string(row)); model->setScale(Vector3D(0.5f)); model->setRenderTechnique("shaders/default.xml"); model->getMaterial()->setTexture(0, "textures/box.jpg"); } } } } CNode* fpsCamera = scene->addFPSCamera(0, Vector3D(0, 0, 0), Vector3D(0.7f, 0, 0.7f)); fpsCamera->setName("fpsCamera"); CNode* camera = scene->addCamera(0, Vector3D(0, 0, 0), Vector3D(0.0f, 0, -5.0f)); camera->setName("camera"); scene->init(); }
void CEdge::Blend(double radius, bool chamfer_not_fillet){ try{ CShape* body = GetParentBody(); if(body){ if(chamfer_not_fillet) { BRepFilletAPI_MakeChamfer chamfer(body->Shape()); for(std::list<CFace*>::iterator It = m_faces.begin(); It != m_faces.end(); It++) { CFace* face = *It; chamfer.Add(radius, m_topods_edge, TopoDS::Face(face->Face())); } TopoDS_Shape new_shape = chamfer.Shape(); wxGetApp().AddUndoably(new CSolid(*((TopoDS_Solid*)(&new_shape)), _("Solid with edge chamfer"), *(body->GetColor()), body->GetOpacity()), NULL, NULL); } else { BRepFilletAPI_MakeFillet fillet(body->Shape()); fillet.Add(radius, m_topods_edge); TopoDS_Shape new_shape = fillet.Shape(); wxGetApp().AddUndoably(new CSolid(*((TopoDS_Solid*)(&new_shape)), _("Solid with edge blend"), *(body->GetColor()), body->GetOpacity()), NULL, NULL); } wxGetApp().DeleteUndoably(body); } } catch (Standard_Failure) { Handle_Standard_Failure e = Standard_Failure::Caught(); wxMessageBox(wxString(chamfer_not_fillet ?_("Error making fillet"):_("Error making fillet")) + _T(": ") + Ctt(e->GetMessageString())); } catch(...) { wxMessageBox(chamfer_not_fillet ? _("A fatal error happened during Chamfer"):_("A fatal error happened during Blend")); } }// end Blend function
void WarpLine(CImageOf<T> src, T* dstP, float *xyP, int n, int nBands, EWarpInterpolationMode interp, T minVal, T maxVal) { // Determine the interpolator's "footprint" const int o0 = int(interp)/2; // negative extent const int o1 = int(interp) - o0; // positive extent const int oH = nBands; // horizonal offset between pixels const int oV = &src.Pixel(0, 1, 0) - &src.Pixel(0, 0, 0); // vertical offset between pixels CShape sh = src.Shape(); // Resample a single output scanline for (int i = 0; i < n; i++, dstP += nBands, xyP += 2) { if (nBands == 4 && dstP[3] == 0) continue; // don't fill in if alpha = 0 // Round down pixel coordinates int x = int(floor(xyP[0])); int y = int(floor(xyP[1])); // Check if all participating pixels are in bounds if (! (sh.InBounds(x-o0, y-o0) && sh.InBounds(x+o1, y+o1))) { for (int j = 0; j < nBands; j++) dstP[j] = 0; continue; } T* srcP = &src.Pixel(x, y, 0); // Nearest-neighbor: just copy pixels if (interp == eWarpInterpNearest) { for (int j = 0; j < nBands; j++) dstP[j] = srcP[j]; continue; } float xf = xyP[0] - x; float yf = xyP[1] - y; // Bilinear and bi-cubic if (interp == eWarpInterpLinear) { for (int j = 0; j < nBands; j++) dstP[j] = __max(minVal, __min(maxVal, ResampleBiLinear(&srcP[j], oH, oV, xf, yf))); } if (interp == eWarpInterpCubic) { for (int j = 0; j < nBands; j++) dstP[j] = __max(minVal, __min(maxVal, ResampleBiCubic(&srcP[j], oH, oV, xf, yf))); } } }
CShape* CTreeWnd::ShapeFromNode(CTreeNode* pNode) { vector<CShape*>::iterator pos; for (pos = m_shapes.begin(); pos != m_shapes.end(); ++pos) { CShape* pShape = *pos; if ((CTreeNode*)pShape->GetData() == pNode) return pShape; } return NULL; }
void CDrawingView::OnDraw( CDC *pDC ) { CDrawingDoc *pDoc = GetDocument(); ASSERT_VALID( pDoc ); // Enumerate through the shapes and draw each one. POSITION position = pDoc->GetFirstShapePosition(); while( position != NULL ) { CShape *pShape = pDoc->GetNextShape( position ); pShape->Draw( pDC ); } }
//+==================================================================================== // // Method: ShapeChanged // // Synopsis: Hit the Layout for the size you should be and ask your adorner for it to give // you your position based on this // //------------------------------------------------------------------------------------ void CFocusAdorner::ShapeChanged() { Assert(_pView->IsInState(CView::VS_OPEN)); Assert(_pElement); delete _pShape; _pShape = NULL; _fTopLeftValid = FALSE; CDocument* pDoc = _pView->Doc(); CDocInfo dci(pDoc->_dci); CShape* pShape; if(_pElement->_etag==ETAG_DIV && DYNCAST(CDivElement, _pElement)->GetAAnofocusrect()) { pShape = NULL; } else { _pElement->GetFocusShape(_iDivision, &dci, &pShape); } if(pShape) { CRect rc; pShape->GetBoundingRect(&rc); if(rc.IsEmpty()) { delete pShape; } else { _pShape = pShape; } } EnsureDispNode(); if(_pDispNode) { CRect rc; Assert(_pShape); _pShape->GetBoundingRect(&rc); _pDispNode->SetSize(rc.Size(), TRUE); } }
CShape* CTreeWnd::HitTestShape(CPoint& pt) { //if (m_style & MTS_HEADER) // pt.y -= DEF_HDR_HEIGHT; vector<CShape*>::iterator pos; for (pos = m_shapes.begin(); pos != m_shapes.end(); ++pos) { CShape *pShape = *pos; if (pShape->PtInRect(pt)) return pShape; } return NULL; }
void vtk_setup() { vtkSmartPointer<vtkRenderWindow> renderWindow = vtkSmartPointer<vtkRenderWindow>::New(); vtkSmartPointer<vtkRenderWindowInteractor> interactor = vtkSmartPointer<vtkRenderWindowInteractor>::New(); m_source.initial_display(renderWindow,interactor); interactor->SetRenderWindow(renderWindow); // renderWindow->SetFullScreen(true); renderWindow->SetSize(600,600); int N=5; for (int i = 0; i < N; ++i) { switch(i+1) { case 1: vtk_draw_view1(renderWindow,interactor); break; case 2: vtk_draw_view2(renderWindow,interactor); break; case 3: vtk_draw_view3(renderWindow,interactor); break; case 4: vtk_draw_view4(renderWindow,interactor); break; case 5: vtk_draw_view5(renderWindow,interactor); break; } } renderWindow->Render(); interactor->Initialize(); interactor->Start(); }
void CShapeModel::GenerateShape(CVisDVector& param, CShape& desshape, EDataAnalysisMethod eMethod /*=ePCA*/) { desshape.Resize(m_AvgShape.PointNum()); if ( ePCA == eMethod ) { assert(m_PCA2Model.IsReady()); //m_Model.Reconstruct(eigenparam, desshape.Points()); m_PCA2Model.Generate(desshape.Points(), param); } else if ( eNMF == eMethod ) { assert(m_NMFModel.IsReady()); m_NMFModel.Reconstruct(param, desshape.Points()); } }
/* * 功能: 增加一个渐出操作对象 * 摘要: 通过该函数可以自动添加一个渐变对象模型 * 参数: pShape - 对象指针 * 返回值: - * 作者: lpf * 创建日期: 2008.10.13 * 修改日志: * 2009.05.07 - lpf * 由于特效渐出效果不大,且容易造成莫名的当机,故禁止了特效渐出效果; * 2009.05.21 - lpf * 由于修改了一些模型底层错误,故现将特效渐出效果恢复; */ void CAlphaFadeObjectList::AddFadeOutObject(CShape * pShape) { if (pShape->GetDisplayModel() == NULL || pShape->GetAnimInfo() == NULL/* || pShape->GetType() == TYPE_EFFECT*/) return; CShape * pTmp = NULL; pShape->CopyShapeDisplayInfo(pTmp); if (pTmp == NULL) return; pTmp->SetAlphaFadeInStartTime(timeGetTime()); pTmp->SetAlphaFadeInTimeLength(pShape->GetAlphaFadeInTimeLength()); pTmp->SetAlphaFadeMode(ALPHA_FADE_OUT); pTmp->SetAlphaValue(1.0f); m_vecObjectList.push_back(pTmp); }
/* * 功能: 更新列表中的对象 * 摘要: 完成渐出操作的对象需要删除 * 参数: - * 返回值: - * 作者: lpf * 创建日期: 2008.10.13 * 修改日志: */ void CAlphaFadeObjectList::Update() { long lElapseTime = 0; vector<CShape *>::iterator it = m_vecObjectList.begin(); while (it != m_vecObjectList.end()) { CShape * pTmp = (*it); lElapseTime = timeGetTime() - pTmp->GetAlphaFadeInStartTime(); if (lElapseTime <= pTmp->GetAlphaFadeInTimeLength()) { pTmp->SetAlphaValue((float)(pTmp->GetAlphaFadeInTimeLength() - lElapseTime) / (float)pTmp->GetAlphaFadeInTimeLength()); ++it; }else { SAFE_DELETE(pTmp); it = m_vecObjectList.erase(it); } } }
QVariant CShapeManager::data(const QModelIndex &index, int role) const { if (!index.isValid()) return QVariant(); CShape *item = _shapes.value(index.row()); if (role == Qt::DecorationRole) return item->GetPixmap(); // return QIcon(item->GetPixmap().scaled(100, 100, // Qt::KeepAspectRatio, Qt::SmoothTransformation)); else if (role == Qt::UserRole) return item->GetPixmap(); return QVariant(); // CShape *item = _shapes.value(index.row()); //return item->data(); }
// The ODENearCallback for CShape::Collide. // // 31-May-05 floh invert contact normal if necessary, the contact normal // in ODE always points into pShape1, however, we want // the contact normal always to point away from the // "other" object void CShape::ODENearCallback(void* data, dGeomID o1, dGeomID o2) { CShape* pThis = (CShape*)data; // collide geom with sub-space if (dGeomIsSpace(o1) || dGeomIsSpace(o2)) { dSpaceCollide2(o1, o2, data, &ODENearCallback); return; } CShape* pShape1 = CShape::GetShapeFromGeom(o1); CShape* pShape2 = CShape::GetShapeFromGeom(o2); CShape* pOtherShape; if (pShape1 == pThis) pOtherShape = pShape2; else if (pShape2 == pThis) pOtherShape = pShape1; else n_error("No self in collision"); if (CShape::CollideFilterSet->CheckShape(pOtherShape)) return; // do collision detection, only check for one contact dContactGeom ODEContact; int CurrCollCount; if (pShape1 == pThis) CurrCollCount = dCollide(o1, o2, 1, &ODEContact, sizeof(dContactGeom)); else CurrCollCount = dCollide(o2, o1, 1, &ODEContact, sizeof(dContactGeom)); CContactPoint ContactPt; if (CurrCollCount > 0) { ContactPt.Position.set(ODEContact.pos[0], ODEContact.pos[1], ODEContact.pos[2]); ContactPt.UpVector.set(ODEContact.normal[0], ODEContact.normal[1], ODEContact.normal[2]); ContactPt.Material = pOtherShape->GetMaterialType(); ContactPt.Depth = ODEContact.depth; CEntity* pEntity = pOtherShape->GetEntity(); if (pEntity) ContactPt.EntityID = pEntity->GetUniqueID(); CRigidBody* pRigidBody = pOtherShape->GetRigidBody(); if (pRigidBody) ContactPt.RigidBodyID = pRigidBody->GetUniqueID(); CShape::CollideContacts->Append(ContactPt); } }
void MyApplication::useInstancedObject() { const SceneManagerPtr& scene = BaseApplication::getSceneManager(); scene->clear(); CShape* model = scene->addCube(0, Vector3D(0, 0, -5)); if (model) { model->setName("cube"); model->setScale(Vector3D(0.5f)); model->setRenderTechnique("shaders/default_instancing.xml"); model->getMaterial()->setTexture(0, "textures/box.jpg"); const RenderPassPtr& pass = model->getRenderTechique()->getRenderPass(0); u32 index = 0; for (s32 col = -2; col < 3; ++col) { for (s32 row = -2; row < 3; ++row) { for (s32 width = 0; width < 1; ++width) { pass->getUserShaderData()->setUniform("offsets[" + std::to_string(index) + "]", Vector3D((f32)col, (f32)row, f32(- 5 - width))); ++index; } } } } CNode* fpsCamera = scene->addFPSCamera(0, Vector3D(0, 0, 0), Vector3D(0.7f, 0, 0.7f)); fpsCamera->setName("fpsCamera"); CNode* camera = scene->addCamera(0, Vector3D(0, 0, 0), Vector3D(0.0f, 0, -5.0f)); camera->setName("camera"); scene->init(); }
void init_data(CShape&m_source) { char currentPath[200]; getcwd(currentPath, sizeof(currentPath)); fstream fin("../config",ios_base::in); std::vector<string> vec_filename; string temp; if(fin.is_open()) { while(!fin.eof()) { fin>>temp; if(temp!="end") { vec_filename.push_back(temp); } } } m_source.initial(vec_filename); m_source.Setup(); m_source.Registration(); }
void CShapeModel::GetShapeParam(CVisDVector& param, const CShape& srcshape, EDataAnalysisMethod eMethod /*=ePCA*/) { if ( ePCA == eMethod ) { assert(m_PCA2Model.IsReady()); m_PCA2Model.GetEigenParam(srcshape.Points(), param); //m_Model.GetParam(srcshape.Points(), eigenparam); } else if ( eNMF == eMethod ) { assert(m_NMFModel.IsReady()); m_NMFModel.Encode(srcshape.Points(), param); /* // debug, begin SaveToFile("raw_shape.pts", srcshape); CShape newshape = srcshape; m_NMFModel.Regularize(srcshape.Points(), newshape.Points()); SaveToFile("reg_shape.pts", newshape); printf("point_dist: %lf", srcshape.Distance(newshape)); // debug, end */ } }
int _tmain(int argc, _TCHAR* argv[]) { cout << "도형 변호를 입력하세요. [1:사각형, 2:원]: " << endl; int nInput = 0; cin >> nInput; CShape *pShape = nullptr; if (nInput == 1) pShape = new CRectangle; else if (nInput == 2) pShape = new CCircle; else pShape = new CShape; // 좋은 예 pShape->Draw(); // '매우' 나쁜 예 // 가상 함수를 활용한다면 이런 코드를 작성할 이유가 없다! CRectangle *pRect = dynamic_cast<CRectangle*>(pShape); if (pRect != NULL) cout << "CRectangle::Draw()" << endl; else { CCircle *pCricle = dynamic_cast<CCircle*>(pShape); if (pCricle != NULL) cout << "CCircle::Draw()" << endl; else cout << "CShape::Draw()" << endl; } return 0; }
void CShapeModel::ApplyShapePos(double& Tx, double& Ty, double& s, double& theta, CShape& desShape, const CShape& normaledShape) { double a = s * cos(theta); double b = s * sin(theta); double x, y; int m_iNbPoint = normaledShape.PointNum(); desShape.Resize(m_iNbPoint); //rotate and scale for (int i = 0; i < m_iNbPoint; i++) { x = normaledShape.PointX(i); y = normaledShape.PointY(i); desShape.PointX(i) = a * x - b * y; desShape.PointY(i) = b * x + a * y; } //translate desShape.Translate(Tx, Ty); }
void CShapeModel::GenerateShapeWithPos(double Tx, double Ty, double s, double theta, CVisDVector& param, CShape& desshape,EDataAnalysisMethod eMethod /*=ePCA*/) { GenerateShape(param, desshape, eMethod); double a = s * cos(theta); double b = s * sin(theta); double x, y; int m_iNbPoint = desshape.PointNum(); //rotate and scale for (int i = 0; i < m_iNbPoint; i++) { x = desshape.PointX(i); y = desshape.PointY(i); desshape.PointX(i) = a * x - b * y; desshape.PointY(i) = b * x + a * y; } //translate desshape.Translate(Tx, Ty); }
void MyApplication::useInstancedAttrObject() { const SceneManagerPtr& scene = BaseApplication::getSceneManager(); scene->clear(); CShape* model = scene->addCube(0, Vector3D(0, 0, 0)); if (model) { model->setName("cube"); model->setScale(Vector3D(0.5f)); model->setRenderTechnique("shaders/default_instancing_attr.xml"); model->getMaterial()->setTexture(0, "textures/box.jpg"); const RenderPassPtr& pass = model->getRenderTechique()->getRenderPass(0); std::vector<Vector3D> offset; for (s32 col = -2; col < 3; ++col) { for (s32 row = -2; row < 3; ++row) { for (s32 width = 0; width < 1; ++width) { offset.push_back(Vector3D((f32)col, (f32)row, f32(-5 - width))); } } } pass->getUserShaderData()->setAttribute("offsets", 1, offset); } CNode* fpsCamera = scene->addFPSCamera(0, Vector3D(0, 0, 0), Vector3D(0.7f, 0, 0.7f)); fpsCamera->setName("fpsCamera"); CNode* camera = scene->addCamera(0, Vector3D(0, 0, 0), Vector3D(0.0f, 0, -5.0f)); camera->setName("camera"); scene->init(); }
CObject* build() { sys::info << "ogl::CBoxObjectBuilder::build()" << sys::endl; float dmax = hasOption(CObjectBuilder::NORMALIZED) ? math::max(mWidth, math::max(mHeight, mDepth)) : 1.0f; float hwidth = (mWidth / 2.0f) / dmax; float hheight = (mHeight / 2.0f) / dmax; float hdepth = (mDepth / 2.0f) / dmax; const size_t nNumVertices = 24; const size_t nNumIndices = 36; // bool bFlatface = hasOption(CObjectBuilder::FLATFACE); math::vec3* positions = new math::vec3[nNumVertices]; positions[ 0] = math::vec3(-hwidth,-hheight, hdepth); positions[ 1] = math::vec3(-hwidth,-hheight, hdepth); positions[ 2] = math::vec3(-hwidth,-hheight, hdepth); positions[ 3] = math::vec3( hwidth,-hheight, hdepth); positions[ 4] = math::vec3( hwidth,-hheight, hdepth); positions[ 5] = math::vec3( hwidth,-hheight, hdepth); positions[ 6] = math::vec3( hwidth, hheight, hdepth); positions[ 7] = math::vec3( hwidth, hheight, hdepth); positions[ 8] = math::vec3( hwidth, hheight, hdepth); positions[ 9] = math::vec3(-hwidth, hheight, hdepth); positions[10] = math::vec3(-hwidth, hheight, hdepth); positions[11] = math::vec3(-hwidth, hheight, hdepth); positions[12] = math::vec3(-hwidth,-hheight,-hdepth); positions[13] = math::vec3(-hwidth,-hheight,-hdepth); positions[14] = math::vec3(-hwidth,-hheight,-hdepth); positions[15] = math::vec3( hwidth,-hheight,-hdepth); positions[16] = math::vec3( hwidth,-hheight,-hdepth); positions[17] = math::vec3( hwidth,-hheight,-hdepth); positions[18] = math::vec3( hwidth, hheight,-hdepth); positions[19] = math::vec3( hwidth, hheight,-hdepth); positions[20] = math::vec3( hwidth, hheight,-hdepth); positions[21] = math::vec3(-hwidth, hheight,-hdepth); positions[22] = math::vec3(-hwidth, hheight,-hdepth); positions[23] = math::vec3(-hwidth, hheight,-hdepth); math::vec2* texcoords = new math::vec2[nNumVertices]; texcoords[ 0] = math::vec2(1.0f, 1.0f); texcoords[ 1] = math::vec2(0.0f, 1.0f); texcoords[ 2] = math::vec2(0.0f, 1.0f); texcoords[ 3] = math::vec2(0.0f, 1.0f); texcoords[ 4] = math::vec2(1.0f, 1.0f); texcoords[ 5] = math::vec2(1.0f, 1.0f); texcoords[ 6] = math::vec2(0.0f, 0.0f); texcoords[ 7] = math::vec2(1.0f, 0.0f); texcoords[ 8] = math::vec2(1.0f, 0.0f); texcoords[ 9] = math::vec2(1.0f, 0.0f); texcoords[10] = math::vec2(0.0f, 0.0f); texcoords[11] = math::vec2(0.0f, 0.0f); texcoords[12] = math::vec2(0.0f, 1.0f); texcoords[13] = math::vec2(1.0f, 1.0f); texcoords[14] = math::vec2(0.0f, 0.0f); texcoords[15] = math::vec2(1.0f, 1.0f); texcoords[16] = math::vec2(0.0f, 1.0f); texcoords[17] = math::vec2(1.0f, 0.0f); texcoords[18] = math::vec2(1.0f, 0.0f); texcoords[19] = math::vec2(0.0f, 0.0f); texcoords[20] = math::vec2(1.0f, 1.0f); texcoords[21] = math::vec2(0.0f, 0.0f); texcoords[22] = math::vec2(1.0f, 0.0f); texcoords[23] = math::vec2(0.0f, 1.0f); math::vec3* normals = new math::vec3[nNumVertices]; normals[ 0] = math::vec3( 0.0f, 0.0f, 1.0f); normals[ 1] = math::vec3(-1.0f, 0.0f, 0.0f); normals[ 2] = math::vec3( 0.0f,-1.0f, 0.0f); normals[ 3] = math::vec3( 0.0f, 0.0f, 1.0f); normals[ 4] = math::vec3( 1.0f, 0.0f, 0.0f); normals[ 5] = math::vec3( 0.0f,-1.0f, 0.0f); normals[ 6] = math::vec3( 0.0f, 0.0f, 1.0f); normals[ 7] = math::vec3( 1.0f, 0.0f, 0.0f); normals[ 8] = math::vec3( 0.0f, 1.0f, 0.0f); normals[ 9] = math::vec3( 0.0f, 0.0f, 1.0f); normals[10] = math::vec3(-1.0f, 0.0f, 0.0f); normals[11] = math::vec3( 0.0f, 1.0f, 0.0f); normals[12] = math::vec3( 0.0f, 0.0f,-1.0f); normals[13] = math::vec3(-1.0f, 0.0f, 0.0f); normals[14] = math::vec3( 0.0f,-1.0f, 0.0f); normals[15] = math::vec3( 0.0f, 0.0f,-1.0f); normals[16] = math::vec3( 1.0f, 0.0f, 0.0f); normals[17] = math::vec3( 0.0f,-1.0f, 0.0f); normals[18] = math::vec3( 0.0f, 0.0f,-1.0f); normals[19] = math::vec3( 1.0f, 0.0f, 0.0f); normals[20] = math::vec3( 0.0f, 1.0f, 0.0f); normals[21] = math::vec3( 0.0f, 0.0f,-1.0f); normals[22] = math::vec3(-1.0f, 0.0f, 0.0f); normals[23] = math::vec3( 0.0f, 1.0f, 0.0f); static GLushort indices[] = { 3, 0, 9, // triangle 0 // face 0 // +z 3, 9, 6, // triangle 1 // face 0 12, 15, 18, // triangle 2 // face 1 // -z 12, 18, 21, // triangle 3 // face 1 1, 13, 22, // triangle 4 // face 2 // -x 1, 22, 10, // triangle 5 // face 2 16, 4, 7, // triangle 6 // face 3 // +x 16, 7, 19, // triangle 7 // face 4 2, 5, 17, // triangle 8 // face 5 // -y 2, 17, 14, // triangle 9 // face 5 23, 20, 8, // triangle 10 // face 6 // +y 23, 8, 11 // triangle 11 // face 7 }; math::vec3* tangents = new math::vec3[nNumVertices]; math::vec3* binormals = new math::vec3[nNumVertices]; for(size_t i = 0; i < nNumIndices; i+=3) // for every triangle { ushort i0 = indices[i+0]; ushort i1 = indices[i+1]; ushort i2 = indices[i+2]; math::vec3& p0 = positions[i0]; math::vec3& p1 = positions[i1]; math::vec3& p2 = positions[i2]; math::vec2& t0 = texcoords[i0]; math::vec2& t1 = texcoords[i1]; math::vec2& t2 = texcoords[i2]; math::vec3 dp1(p1 - p0); // e1 math::vec3 dp2(p2 - p0); // e2 math::vec3 normal = math::normalize(math::cross(dp2, dp1)); normals[i0] += normal; // avarage the normals normals[i0] = math::normalize(normals[i0]); normals[i1] += normal; normals[i1] = math::normalize(normals[i1]); normals[i2] += normal; normals[i2] = math::normalize(normals[i2]); math::vec2 dt1 = t1 - t0; math::vec2 dt2 = t2 - t0; float r = 1.0f / (dt1.x * dt2.y - dt1.y * dt2.x); math::vec3 ta = (dp1 * dt2.y - dp2 * dt1.y) * r; // tangent math::vec3 bi = (dp2 * dt1.x - dp1 * dt2.x) * r; // binormal tangents[i0] = ta; tangents[i1] = ta; tangents[i2] = ta; binormals[i0] = bi; binormals[i1] = bi; binormals[i2] = bi; } if(hasOption(CObjectBuilder::INVERTED)) { for(size_t i = 0; i < nNumVertices; ++i) { normals[i] *= -1.0f; tangents[i] *= -1.0f; binormals[i] *= -1.0f; } for(ushort i = 0; i < nNumIndices; i+=3) { GLushort tmp = indices[i+1]; indices[i+1] = indices[i+2]; indices[i+2] = tmp; } } if(mTextureScale != 1.0f) { for(size_t i = 0; i < nNumVertices; ++i) texcoords[i] = texcoords[i] / mTextureScale; } //////////////////////////////////////////////////////////////////////////////////////////////////////////////// CObject* pObject = new CObject; pObject->mNumVertices = nNumVertices; pObject->mNumIndices = nNumIndices; pObject->setDrawStrategy(mDrawStrategy == nullptr ? new CDrawStrategy : mDrawStrategy); //////////////////////////////////////////////////////////////////////////////////////////////////////////////// { // shapes CShape* pShape = new CShape; pShape->setVertexBufferRange(0, pObject->mNumVertices, GL_FLOAT); pShape->setIndexBufferRange(0, pObject->mNumIndices, GL_UNSIGNED_SHORT); CMaterial* pMaterial = new CMaterial; CDdsTextureBuilder* pTextureBuilder = new CDdsTextureBuilder; pTextureBuilder->setFile("notfound.dds"); CTexture* pTexture = pTextureBuilder->build(); pTexture->setFiltering(CTexture::EFiltering::TRILINEAR); delete pTextureBuilder; pMaterial->setTexture(CTexture::EScope::DIFFUSE, pTexture); pShape->setMaterial(pMaterial); pObject->addShape(pShape); } //////////////////////////////////////////////////////////////////////////////////////////////////////////////// pObject->mBuffers.resize(5); glGenVertexArrays(1, &(pObject->mVAO)); glBindVertexArray(pObject->mVAO); // indices glGenBuffers(1, &(pObject->mBuffers[INDEX_BUFFER_INDEX])); glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, pObject->mBuffers[INDEX_BUFFER_INDEX]); glBufferData(GL_ELEMENT_ARRAY_BUFFER, nNumIndices * sizeof(GLushort), indices, GL_STATIC_DRAW); // positions glGenBuffers(1, &(pObject->mBuffers[POSITION_BUFFER_INDEX])); glBindBuffer(GL_ARRAY_BUFFER, pObject->mBuffers[POSITION_BUFFER_INDEX]); glBufferData(GL_ARRAY_BUFFER, nNumVertices * sizeof(math::vec3), positions, GL_STATIC_DRAW); glVertexAttribPointer(POSITION_ATTRIBUTE, 3, GL_FLOAT, GL_FALSE, sizeof(math::vec3), (const GLvoid*)(0)); glEnableVertexAttribArray(POSITION_ATTRIBUTE); // positions // texcoords glGenBuffers(1, &(pObject->mBuffers[TEXCOORD_BUFFER_INDEX])); glBindBuffer(GL_ARRAY_BUFFER, pObject->mBuffers[TEXCOORD_BUFFER_INDEX]); glBufferData(GL_ARRAY_BUFFER, nNumVertices * sizeof(math::vec2), texcoords, GL_STATIC_DRAW); glVertexAttribPointer(TEXCOORD_ATTRIBUTE, 2, GL_FLOAT, GL_FALSE, sizeof(math::vec2), (const GLvoid*)(0)); //(GLvoid*)((0 + 3) * sizeof(GLfloat))); glEnableVertexAttribArray(TEXCOORD_ATTRIBUTE); // texcoords // normals glGenBuffers(1, &(pObject->mBuffers[NORMAL_BUFFER_INDEX])); glBindBuffer(GL_ARRAY_BUFFER, pObject->mBuffers[NORMAL_BUFFER_INDEX]); glBufferData(GL_ARRAY_BUFFER, nNumVertices * sizeof(math::vec3), normals, GL_STATIC_DRAW); glVertexAttribPointer(NORMAL_ATTRIBUTE, 3, GL_FLOAT, GL_FALSE, sizeof(math::vec3), (const GLvoid*)(0)); //(GLvoid*)((0 + 3 + 2) * sizeof(GLfloat))); glEnableVertexAttribArray(NORMAL_ATTRIBUTE); // normals // tangents glGenBuffers(1, &(pObject->mBuffers[TANGENT_BUFFER_INDEX])); glBindBuffer(GL_ARRAY_BUFFER, pObject->mBuffers[TANGENT_BUFFER_INDEX]); glBufferData(GL_ARRAY_BUFFER, nNumVertices * sizeof(math::vec3), tangents, GL_STATIC_DRAW); glVertexAttribPointer(TANGENT_ATTRIBUTE, 3, GL_FLOAT, GL_FALSE, sizeof(math::vec3), (const GLvoid*)(0)); //(GLvoid*)((0 + 3 + 2) * sizeof(GLfloat))); glEnableVertexAttribArray(TANGENT_ATTRIBUTE); // tangents // clean glBindBuffer(GL_ARRAY_BUFFER, 0); glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0); glBindVertexArray(0); delete [] positions; delete [] texcoords; delete [] normals; delete [] tangents; delete [] binormals; //////////////////////////////////////////////////////////////////////////////////////////////////////////////// return pObject; }
void CTreeWnd::BuildNodeShapes(mtNode* pNode,CRect& area,CRect& clientArea,int indent) { //if (m_pTree && m_pTree->numColumns() > 2) // int x=1; if (area.bottom > clientArea.bottom+DEF_NODE_HEIGHT) return; if (pNode == m_firstVisible->getmtNode()) m_rendering = true; // add shape for ourselves. if (m_rendering) { CRect colArea = area; for (int i = 0; i < m_pTree->numColumns(); i++) { // Shapes are positioned according to column widths. // The tree display column also has indents added // to indicate the hierarchy. // int pos = area.left; for (int col = 0; col < i; col++) pos += m_pHeader->GetPaneWidth(col); colArea.left = pos; colArea.right = colArea.left + m_pHeader->GetPaneWidth(i); // Create new shape object and populate it. CShape* pShape = new CShape(); pShape->border.SetPreset(BorderStyleNone); map<int,COLORREF>::iterator cpos = m_colColours.find(i); if (cpos != m_colColours.end()) { pShape->SetFgColour(cpos->second); } else pShape->SetFgColour(m_fgColour); pShape->SetBgColour(m_bgColour); LPCTSTR text = pNode->getText(i); pShape->SetText(text ? text : ""); // don't give NULL text to shapes. if (i == m_treeColumn) { CTreeNode* pTreeNode = NodeFromMTNode(pNode); colArea.left += DEF_LINE_SPACE; pShape->SetData(pNode->getData2()); colArea.left += indent; pShape->SetRect(colArea); colArea.right -= indent; SetNodeShapeIcon(pTreeNode,pShape); //pShape->SetBitmap(m_pImageList); if (pNode->hasChildren()) { CTreeNode* pTreeNode = NodeFromMTNode(pNode); pTreeNode->CalcExpandBoxArea(colArea); } // remove left margin if this is the tree col // pShape->SetMargins(0,0,5,0); } else { pShape->SetData(pNode->getData2()); pShape->SetRect(colArea); CTreeNode* pTreeNode = NodeFromMTNode(pNode); short iconIdx = -1;//pTreeNode->GetColumnIcon(i); if (iconIdx != -1) { pShape->RemoveAllImages(); pShape->AddImage(m_pImageList,iconIdx,CSize(16,16)); pShape->AddProperty(CShape::SP_ALIGN_LEFT); } } // Set shape alignment if we have one for this column. // map<int,DWORD>::iterator mpos = m_colAlignments.find(i); if (mpos != m_colAlignments.end()) { pShape->RemoveProperty( CShape::SP_ALIGN_LEFT | CShape::SP_ALIGN_RIGHT | CShape::SP_ALIGN_CENTRE ); pShape->AddProperty(mpos->second); } m_shapes.push_back(pShape); } } // do children only if expanded. mtNode* pChild = pNode->firstChild(); if (pChild && pNode->isExpanded()) { // Don't indent here is pNode is root and tree style is not MTS_SHOWROOT. // Otherwise tree will indent as if the root was there. We want to pretend // it isn't... indent += DEF_NODE_INDENT; if (m_rendering) area.OffsetRect(0,DEF_NODE_HEIGHT); BuildNodeShapes(pChild,area,clientArea,indent); indent -= DEF_NODE_INDENT; } // do first sibling only. rest will be done recursively. mtNode* pSib = pNode->nextSibling(); if (pSib) { if (m_rendering) area.OffsetRect(0,DEF_NODE_HEIGHT); BuildNodeShapes(pSib,area,clientArea,indent); } }
void CTreeWnd::Render(CDC* pDC,CRect& area) { //Timer t1; //t1.start(); // Create offscreen dc & bitmap for double buffering. All // tree m_rendering is done to this. CRect ca; GetClientRect(ca); int width = mymax(m_scrollExtents.cx,ca.Width()); CRect ur; GetUpdateRect(ur); //CDC memdc; //memdc.CreateCompatibleDC(pDC); //CBitmap membm; //membm.CreateCompatibleBitmap(pDC,width,ca.Height()); //CBitmap* pOldBM = memdc.SelectObject(&membm); //memdc.FillSolidRect(0,0,width,ca.Height(),m_bgColour); CDC* pDrawDC = pDC; //pDrawDC->FillSolidRect(area,m_bgColour); // After all the nodes have been drawn, we'll fill in the rest of the space in the // background colour. We use this point to track where we've drawn. CPoint bottomRight = CPoint(-1,-1); CFont* pOldFont = (CFont*)pDrawDC->SelectStockObject(DEFAULT_GUI_FONT); int nodesrendered=0; bool currNodeSelected = false; int xidx = 0; vector<CShape*>::iterator pos; CShape* pPrevShape = NULL; for (pos = m_shapes.begin(); pos != m_shapes.end(); ++pos) { CShape *pShape = *pos; CRect inter; if (inter.IntersectRect(area,*pShape)) { CTreeNode* pNode = NodeFromShape(pShape); if (pNode && pNode->isSelected() && ( (xidx % m_pTree->numColumns()) >= m_treeColumn) ) { // TODO: get from prefs sytem. if (GetFocus() == this) pShape->SetBgColour(GetSysColor(COLOR_HIGHLIGHT)); else pShape->SetBgColour(RGB(192,192,192)); pShape->SetFgColour(RGB(255,255,255)); } else { pShape->SetBgColour(m_bgColour); } if ( (xidx % m_pTree->numColumns()) == m_treeColumn) { // Fill the connecting lines area in, to make sure // we're drawing every single pixel. // TODO: prevent flickering here. CRect a = *pShape; //if (pPrevShape) // a.left = pPrevShape->right; //else a.left = area.left; pDrawDC->FillSolidRect(a,m_bgColour); OnSetNodeDisplayProperties(pDrawDC,pNode); SetNodeShapeIcon(pNode,pShape); if (!pNode->isSelected()) pShape->SetFgColour(pNode->GetFgColour()); pNode->Draw(pDrawDC,*pShape); if (pNode == m_selection.GetFocusItem()) { pShape->Draw(pDrawDC); // pShape->RemoveProperty(CShape::SP_FOCUS_BORDER); } else pShape->Draw(pDrawDC); } else // non-tree columns { pShape->Draw(pDrawDC); } if (pShape->right > bottomRight.x) bottomRight.x = pShape->right; if (pShape->bottom > bottomRight.y) bottomRight.y = pShape->bottom; nodesrendered++; } xidx++; pPrevShape = pShape; } // Now fill in the blank area CRect emptySpace; emptySpace.left = bottomRight.x; emptySpace.top = area.top; emptySpace.right = area.right; emptySpace.bottom = area.bottom; pDrawDC->FillSolidRect(emptySpace,m_bgColour); // right emptySpace.left = area.left; emptySpace.top = bottomRight.y; emptySpace.right = bottomRight.x; emptySpace.bottom = area.bottom; pDrawDC->FillSolidRect(emptySpace,m_bgColour); // right //t1.stop(); //TRACE("TREE %x: Rendered %d nodes in %s\n",this,nodesrendered,t1.format().c_str()); pDrawDC->SelectObject(pOldFont); //int desty = area.top; //if (m_style & MTS_HEADER) // desty += DEF_HDR_HEIGHT; // blt to screen //int sp = GetScrollPos(SB_HORZ); //pDC->BitBlt(area.left,area.top,area.Width(),area.Height(),&memdc,area.left+sp,area.top,SRCCOPY); // clean up //memdc.SelectObject(&pOldBM); //memdc.DeleteDC(); //membm.DeleteObject(); }
// 响应其他消息 void CMoveShape::OnShapeMessage(CMessage* pMsg) { switch(pMsg->GetType()) { case MSG_C2S_SHAPE_CHANGELINEDRGN: { long linedID = pMsg->GetLong(); long templateID = pMsg->GetLong(); CGUID rgnID; pMsg->GetGUID(rgnID); CGUID playerID; pMsg->GetGUID(playerID); long lX = pMsg->GetLong(); long lY = pMsg->GetLong(); CPlayer* player = GetGame()->FindPlayer(playerID); if(player) { // 判断是否是分线场景的TemplateID map<long, vector<long>>::iterator linedId = GameManager::GetInstance()->GetRgnManager()->GetLinedRgnIdByLinedIdMap().find(linedID); if(linedId != GameManager::GetInstance()->GetRgnManager()->GetLinedRgnIdByLinedIdMap().end()) { vector<long>::iterator templateIdItr; // 判断玩家当前场景ID跟消息是否一致 templateIdItr = std::find(linedId->second.begin(), linedId->second.end(), player->GetRegionID()); if(templateIdItr == linedId->second.end()) // 未找到该场景ID { char szGuid[128]; playerID.tostring(szGuid); AddLogText("切换分线场景时:在场景%d上的玩家%s想切换到场景%d非法!", player->GetRegionID(), szGuid, templateID); return; } templateIdItr = std::find(linedId->second.begin(), linedId->second.end(), templateID); if(templateIdItr != linedId->second.end()) player->ChangeRegion(RGN_NORMAL, rgnID, lX, lY, -1, templateID); } } } break; // 改变玩家方向 case MSG_C2S_SHAPE_CHANGEDIR: { BYTE lDir = pMsg->GetByte(); float fDir = pMsg->GetFloat(); pMsg->GetPlayer()->SetDirEx(fDir); pMsg->SetType(MSG_S2C_SHAPE_CHANGEDIR); pMsg->Add(pMsg->GetPlayer()->GetType()); pMsg->Add(pMsg->GetPlayer()->GetExID()); pMsg->SendToNearestPlayer(this,true,pMsg->GetPlayer()); } break; case MSG_C2S_SHAPE_SETPOS: // 瞬移 { if (CGlobeSetup::GetSetup()->bAllowClientChangePos == false) break;; long lType = pMsg->GetLong(); CGUID guid; pMsg -> GetGUID(guid); CShape* pShape = (CShape*)pMsg->GetRegion()->FindChildObject(lType, guid); if( pShape ) { long x = pMsg->GetLong(); long y = pMsg->GetLong(); pMsg->SetType(MSG_S2C_SHAPE_SETPOS); pShape->SetPosXY( x+0.5f, y+0.5f ); pMsg->SendToAround(pShape); } } break; case MSG_C2S_SHAPE_MOVE: { #ifdef _RUNSTACKINFO1_ CMessage::AsyWriteFile(GetGame()->GetStatckFileName(),"CMoveShape::OnShapeMessage(MSG_C2S_SHAPE_MOVE) Start."); #endif float fCurX = pMsg->GetFloat(); float fCurY = pMsg->GetFloat(); float fDestX = pMsg->GetFloat(); float fDestY = pMsg->GetFloat(); #ifdef _RUNSTACKINFO1_ char pszStatckInfo[1024]=""; _snprintf(pszStatckInfo,1024,"CurX:%f,CurY:%f,DestX:%f,DestY:%f",fCurX,fCurY,fDestX,fDestY); CMessage::AsyWriteFile(GetGame()->GetStatckFileName(),pszStatckInfo); #endif CSMClient::GetSM()->SendWatchResult(GetName(),eGGC_Move); // 处理行走请求 OnQuestMoveStep(fCurX,fCurY,fDestX,fDestY); #ifdef _RUNSTACKINFO1_ CMessage::AsyWriteFile(GetGame()->GetStatckFileName(),"CMoveShape::OnShapeMessage(MSG_C2S_SHAPE_MOVE) End."); #endif } break; case MSG_C2S_SHAPE_STOPMOVE: { #ifdef _RUNSTACKINFO1_ CMessage::AsyWriteFile(GetGame()->GetStatckFileName(),"CMoveShape::OnShapeMessage(MSG_C2S_SHAPE_STOPMOVE) Start."); #endif float fCurX = pMsg->GetFloat(); float fCurY = pMsg->GetFloat(); short nDir = pMsg->GetByte(); OnQuestStopMove(fCurX,fCurY,nDir); #ifdef _RUNSTACKINFO1_ CMessage::AsyWriteFile(GetGame()->GetStatckFileName(),"CMoveShape::OnShapeMessage(MSG_C2S_SHAPE_STOPMOVE) End."); #endif } break; //改变移动模式 case MSG_C2S_SHAPE_CHANGEMOVEMODE: { bool bRun = pMsg->GetChar()==0?false:true; pMsg -> GetPlayer()->SetIsRun(bRun); if (pMsg->GetPlayer()->GetIsRide()) { if(!GetIsRun()) pMsg -> GetPlayer()->SetSpeed(CGlobeSetup::GetSetup()->fPlayerWalkSpeed); else pMsg -> GetPlayer()->SetSpeed(CGlobeSetup::GetSetup()->fPlayerRunSpeed); } else { if(!GetIsRun()) pMsg -> GetPlayer()->SetSpeed(CGlobeSetup::GetSetup()->fRidePlayerWalkSpeed); else pMsg -> GetPlayer()->SetSpeed(CGlobeSetup::GetSetup()->fRidePlayerRunSpeed); } pMsg -> GetPlayer()->SendChangedSpeedToClients(); } break; // 客户端主动请求shape数据 case MSG_C2S_SHAPE_QUESTINFO: { } break; case MSG_C2S_SHAPE_EMOTION: { LONG lType = pMsg -> GetLong(); CGUID guid; pMsg -> GetGUID(guid); DWORD dwEmotion = pMsg -> GetDWord(); CPlayer* pPlayer = pMsg -> GetPlayer(); if( pPlayer -> GetType() == lType && pPlayer -> GetExID() == guid ) { pPlayer -> PerformEmotion( dwEmotion ); } } break; case MSG_C2S_SHAPE_SETSELECTEDSHAPE: { //设定当前选择的目标 long lType = pMsg->GetLong(); CGUID guid = NULL_GUID; pMsg->GetGUID(guid); CPlayer *pPlayer = pMsg ->GetPlayer(); if (pPlayer) { CServerRegion *pRegion = dynamic_cast<CServerRegion*>(pPlayer->GetFather()); if(pRegion) { long lOldType = 0; CGUID OldGuid; pPlayer->GetTarget(OldGuid,lOldType); if(OldGuid != guid) { CMoveShape* pMoveShape = dynamic_cast<CMoveShape*>(pRegion->FindChildObject(lOldType,OldGuid)); if(pMoveShape) pMoveShape->RemoveSelectSelfPlayer(pPlayer->GetExID()); pPlayer->SetTarget(guid,lType); if(guid != NULL_GUID) { pMoveShape = dynamic_cast<CMoveShape*>(pRegion->FindChildObject(lType,guid)); if(pMoveShape) { pMoveShape->AddSelectSelfPlayer(pPlayer->GetExID()); set<string> setDirtyAttr; setDirtyAttr.insert("C_MaxHp"); setDirtyAttr.insert("Hp"); //更新属性 pMoveShape->UpdateHPMPToClient(setDirtyAttr); } } } } } } break; case MSG_C2S_SHAPE_GETTSELECTEDSHAPE: { // 获得当前选择的目标 CPlayer *pPlayer = pMsg->GetPlayer(); if (pPlayer) { long lType = 0; CGUID guid = NULL_GUID; pPlayer->GetTarget(guid,lType); CServerRegion* pServerRegion = (CServerRegion*)(pPlayer->GetFather()); if(NULL == pServerRegion || guid == NULL_GUID) return ; CBaseObject *pObj = pServerRegion->FindChildObject(lType,guid); CMoveShape *pMoveShape = dynamic_cast<CMoveShape*>(pObj); if (pMoveShape) { long lTargetType = 0; CGUID guidTarget = NULL_GUID; pMoveShape->GetTarget(guidTarget,lTargetType); if (guid != NULL_GUID) { CMessage msg(MSG_S2C_SHAPE_GETTSELECTEDSHAPE); msg.Add(lTargetType); msg.Add(guidTarget); msg.SendToPlayer(pPlayer->GetExID()); } } } } break; } }
/* * 功能: 响应其他消息 * 摘要: - * 参数: pMsg - 服务器发送的消息 * 返回值: - * 作者: - * 创建日期: - * 修改日志: * 2008.04.21 - lpf * 增加了对MSG_S2C_OTHER_EXPATC消息的响应,用来支持仪态动作的播放; * 2008.06.12 - lpf * 在MSG_S2C_OTHER_EXPATC消息的响应中,增加了"没有说话消息的判断"; * 2008.06.17 - lpf * 根据仪态动作新的结构修改了MSG_S2C_OTHER_EXPATC消息的响应,对得到仪态动作的处理; * 2008.08.14 - lpf * 在MSG_S2C_OTHER_EXPATC消息响应处增加了对得到场景指针是否为空的判断; * 2008.08.21 - lpf * 增加了对视频播放消息的处理; */ void OnOtherMessage(CMessage* pMsg) { CGlobeSetup::tagSetup *pSetup = CGlobeSetup::GetSetup(); switch(pMsg->GetType()) { /////////////////////////////////////////////////////////////////////////////////////// // 对话消息 /////////////////////////////////////////////////////////////////////////////////////// case MSG_S2C_OTHER_TALK: { if (GetGame()->GetMainPlayer() == NULL) break; CMainBarPageEx * pMainPage = GetGame()->GetCGuiEx()->GetMainBarPageEx(); if( ! pMainPage ) return; // 字符or索引 BYTE bFlag = pMsg->GetByte(); long lType = pMsg->GetLong(); // 聊天信息中,物品信息其实位置的调节长度 long lAdjustLen = 0; char str[1024] = ""; // 说话人type 和 GUID long lSenderType = pMsg->GetLong(); CGUID SenderID; pMsg->GetGUID(SenderID); string strName; string strmem; //=========================对话信息中的聊天信息======================= list<CEditField::stSpecialTextInfo> * pTextInfoList = pMainPage->GetSpecialText(); pTextInfoList->clear(); char strGoodsName[1024] = ""; long lNum = pMsg->GetLong(); for(long i=0; i<lNum; ++i) { CEditField::stSpecialTextInfo stInfo; pMsg->GetEx(&stInfo, sizeof(CEditField::stSpecialTextInfo)); stInfo.str = pMsg->GetStr(strGoodsName,1024); pTextInfoList->push_back(stInfo); } //==================================================================== TCHAR szChatWords[ 2056 ]; switch( lType ) { case RUN_HELP: case CHAT_NPC: case CHAT_NORMAL: { strName = pMsg->GetStr(str,1024); // 检查黑名单 if( GetGame()->GetCGuiEx()->GetFriendsPageEx()->IsInGroup( strName.c_str(), CFriendsPageEx::PANEL_BLACK ) ) break; if(bFlag==0) strmem = pMsg->GetStr(str,1024); else { DWORD dwType = pMsg->GetDWord(); DWORD dwIndex = pMsg->GetDWord(); strmem = CStringReading::LoadString(dwType,dwIndex); } // 脏话过滤 CClientWordsFilter::GetInstance()->Check(strmem, true, true); // 加入说话者的头上 CMoveShape* pSender = dynamic_cast<CMoveShape*>(GetGame()->GetRegion()->FindChildObject(lSenderType, SenderID)); if(pSender) { pSender->SetTalkText(strmem.c_str()); pSender->SetTalkLiveTimer(500); if(lSenderType == TYPE_MONSTER) pSender->SetTalkLiveTimer(1000); } // 格式化聊天字段,NPC说话和普通一样 所以 lType 固定为 Normal wsprintf( szChatWords, CStringReading::LoadString( 14, CHAT_NORMAL+101 ), strName.c_str(), strmem.c_str() ); // 前缀长度 lAdjustLen = lstrlen( szChatWords ) - strmem.size(); pMainPage->m_lAdjPos = lAdjustLen; pMainPage->AdjGoodsInfoPos(lAdjustLen); // if(lSenderType != TYPE_PLAYER) strName = ""; // 怪物说话不显示在聊天框上 if(lSenderType != TYPE_MONSTER) pMainPage->AddChatWords(szChatWords, pSetup->colorChatText[CHAT_NORMAL], pSetup->colorChatTextBack[CHAT_NORMAL], pSetup->colorChatTextShadow[CHAT_NORMAL], strName.c_str(), lType); } break; case CHAT_PRIVATE: { char strTargetName[256] = ""; char strSourceName[256] = ""; pMsg->GetStr(strTargetName,256); pMsg->GetStr(strSourceName,256); strName = strSourceName; // 检查是否是自己 if( !lstrcmp( strTargetName, strSourceName ) ) break; // 好友系统UI CFriendsPageEx* pFriendsPageEx = GetGame()->GetCGuiEx()->GetFriendsPageEx(); // 检查黑名单 if( pFriendsPageEx->IsInGroup( strName.c_str(), CFriendsPageEx::PANEL_BLACK ) ) break; // 屏蔽说话的的玩家 if( GetGame()->CheckDisableChatter(strSourceName) ) break; strmem = pMsg->GetStr(str,256); // 脏话过滤 CClientWordsFilter::GetInstance()->Check(strmem, true, true); // 王峰:陌生人的名字 std::string nameStanger; //发给别人的话在名字前加上"=>" if(strcmp(strSourceName, GetGame()->GetMainPlayer()->GetName())==0) { // 格式化聊天字段 wsprintf( szChatWords, CStringReading::LoadString( 14, lType+121 ), strTargetName, strmem.c_str() ); // 王峰:记录陌生人的名字 nameStanger = strTargetName; } else { // 格式化聊天字段 wsprintf( szChatWords, CStringReading::LoadString( 14, lType+101 ), strName.c_str(), strmem.c_str() ); // 王峰:记录陌生人的名字 nameStanger = strName; // 播放密聊声音 if(!GetGame()->GetAudioList()->IsPlaying( pFriendsPageEx->GetConfig( CFriendsPageEx::PANEL_STRANGER )->m_NotifySetup.szMusic_SecretTalk )) { GetGame()->GetAudioList()->Play2DSound( pFriendsPageEx->GetConfig( CFriendsPageEx::PANEL_STRANGER )->m_NotifySetup.szMusic_SecretTalk ); } } // 前缀长度 lAdjustLen = lstrlen( szChatWords ) - strmem.size(); pMainPage->m_lAdjPos = lAdjustLen; // 王峰:显示密聊文字 pMainPage->AdjGoodsInfoPos(lAdjustLen); GetGame()->GetCGuiEx()->GetMainBarPageEx()->AddChatWords( szChatWords, pSetup->colorChatText[lType], pSetup->colorChatTextBack[lType], pSetup->colorChatTextShadow[lType], nameStanger.c_str(), lType); //记录最后一个发密语给自己的人 if(!strcmp(GetGame()->GetMainPlayer()->GetName(),strTargetName)) { extern string g_strLastWisper; g_strLastWisper = strSourceName; } //记录最后一个主动密聊的对象 else if(!strcmp(GetGame()->GetMainPlayer()->GetName(),strSourceName)) { extern string g_strLastWisper; g_strLastWisper = strTargetName; } // 王峰:自动添加陌生人 CFriendsPageEx::ENUM_PANEL ePanelFind; tagLinkman* pstLinkmanFind; if( ! pFriendsPageEx->FindLinkman( nameStanger.c_str(), ePanelFind, pstLinkmanFind ) ) { tagLinkman* pstLinkman = new tagLinkman; ZeroMemory( pstLinkman, sizeof(tagLinkman) ); lstrcpy( pstLinkman->szName, nameStanger.c_str() ); pFriendsPageEx->AddLinkman( CFriendsPageEx::PANEL_STRANGER, pstLinkman ); } } break; case CHAT_TEAM: { strName = pMsg->GetStr(str,1024); strmem = pMsg->GetStr(str,1024); // 脏话过滤 CClientWordsFilter::GetInstance()->Check(strmem, true, true); // 格式化聊天字段 wsprintf( szChatWords, CStringReading::LoadString( 14, lType+101 ), strName.c_str(), strmem.c_str() ); // 前缀长度 lAdjustLen = lstrlen( szChatWords ) - strmem.size(); pMainPage->m_lAdjPos = lAdjustLen; pMainPage->AdjGoodsInfoPos(lAdjustLen); GetGame()->GetCGuiEx()->GetMainBarPageEx()->AddChatWords(szChatWords, pSetup->colorChatText[CHAT_TEAM], pSetup->colorChatTextBack[CHAT_TEAM], pSetup->colorChatTextShadow[CHAT_TEAM], strName.c_str(), CHAT_TEAM); } break; case CHAT_REGION: case CHAT_FACTION: case CHAT_UNION: { strName = pMsg->GetStr(str,1024); // 检查黑名单 if( GetGame()->GetCGuiEx()->GetFriendsPageEx()->IsInGroup( strName.c_str(), CFriendsPageEx::PANEL_BLACK ) ) break; strmem = pMsg->GetStr(str,1024); // 脏话过滤 CClientWordsFilter::GetInstance()->Check(strmem, true, true); // 格式化聊天字段 wsprintf( szChatWords, CStringReading::LoadString( 14, lType+101 ), strName.c_str(), strmem.c_str() ); // 前缀长度 lAdjustLen = lstrlen( szChatWords ) - strmem.size(); pMainPage->m_lAdjPos = lAdjustLen; pMainPage->AdjGoodsInfoPos(lAdjustLen); GetGame()->GetCGuiEx()->GetMainBarPageEx()->AddChatWords( szChatWords, pSetup->colorChatText[lType], pSetup->colorChatTextBack[lType], pSetup->colorChatTextShadow[lType], strName.c_str(), lType); } break; case CHAT_BOARDCAST: case GM_CMD: { strName = pMsg->GetStr(str,1024); strmem = pMsg->GetStr(str,1024); // 脏话过滤 CClientWordsFilter::GetInstance()->Check(strmem, true, true); GetGame()->GetCGuiEx()->GetMainBarPageEx()->AddChatWords( strmem.c_str(), pSetup->colorChatText[lType], pSetup->colorChatTextBack[lType], pSetup->colorChatTextShadow[lType], strName.c_str(), lType); } break; } } break; /////////////////////////////////////////////////////////////////////////////////////// // 打开TalkBox /////////////////////////////////////////////////////////////////////////////////////// case MSG_S2C_OTHER_OPENTALKBOX: { long lFlag = pMsg->GetLong(); if( pMsg->GetPlayer() ) { char str[2048]; string strText = ""; CGUID guScriptID; pMsg->GetGUID(guScriptID); // 传入的是字符串 if(lFlag == 0) { strText = pMsg->GetStr(str,2048); // 标题文字 } // 传入索引 else { DWORD dwType = pMsg->GetDWord(); DWORD dwIndex = pMsg->GetDWord(); strText = CStringReading::LoadString(dwType,dwIndex); } // 按钮相关信息 string strBtn1 = ""; string strBtn2 = ""; strBtn1 = pMsg->GetStr(str,2048); bool bEnable1 = pMsg->GetByte()>0?true:false; strBtn2 = pMsg->GetStr(str,2048); bool bEnable2 = pMsg->GetByte()>0?true:false; long lStyle = pMsg->GetLong(); // 新增TalkBox的数据 BYTE bIsCloseWindow = 0; long lPicID = 0; long lPicX = 0; long lPicY = 0; long lSoundID = 0; long lBkMusicID = 0; // 不是关闭TalkBox的时候需要解新增数据 if(lStyle) { bIsCloseWindow = pMsg->GetByte(); lPicID = pMsg->GetLong(); lPicX = pMsg->GetLong(); lPicY = pMsg->GetLong(); lBkMusicID = pMsg->GetLong(); lSoundID = pMsg->GetLong(); } CTalkBoxPageEx * pPage = GetGame()->GetCGuiEx()->GetTalkBoxPageEx(); // 先执行一次关闭操作 pPage->TidyPageOnClose(); pPage->Release(); if (lStyle == 0) // 关闭对话框 { return; } if (lStyle == 1) // 背景1 { pPage->OpenBox(CTalkBoxPageEx::NORMAL_TALKBOX); } else if (lStyle == 2) // 背景2 { pPage->OpenBox(CTalkBoxPageEx::NORMAL_TALKBOX); } if(bIsCloseWindow) { GetGame()->GetCGuiEx()->ClosePageExcept(pPage); } pPage->SetMessageText(strText.c_str()); pPage->SetScriptID(guScriptID); // 播放音乐和声音 pPage->PlaySounds(lSoundID); pPage->PlayBkMusic(lBkMusicID); pPage->SetBkImage(lPicID,lPicX,lPicY); // 设置链接按钮 pPage->SetAnchorBtn(strBtn1,bEnable1); pPage->SetAnchorBtn(strBtn2,bEnable2); // 记录打开对话框时候的坐标 extern CGUID g_OpenNpcTalkBoxRegionID; extern long g_lOpenNpcTalkBoxPosX; extern long g_lOpenNpcTalkBoxPosY; g_OpenNpcTalkBoxRegionID = GetGame()->GetRegion()->GetExID(); g_lOpenNpcTalkBoxPosX = pMsg->GetPlayer()->GetTileX(); g_lOpenNpcTalkBoxPosY = pMsg->GetPlayer()->GetTileY(); } } break; case MSG_S2C_OTHER_OPENSTORYTALKBOX: { long lFlag = pMsg->GetLong(); if( pMsg->GetPlayer() ) { char str[2048]; string strText = ""; CGUID guScriptID; pMsg->GetGUID(guScriptID); // 传入的是字符串 if(lFlag == 0) { strText = pMsg->GetStr(str,2048); // 标题文字 } // 传入索引 else { DWORD dwType = pMsg->GetDWord(); DWORD dwIndex = pMsg->GetDWord(); strText = CStringReading::LoadString(dwType,dwIndex); } // 按任意键继续标志 BYTE bIsContinue = pMsg->GetByte(); // 新增TalkBox的数据 BYTE bIsCloseWindow = pMsg->GetByte(); long lSoundID = pMsg->GetLong(); long lBkMusicID = pMsg->GetLong(); long lHeadID = pMsg->GetLong(); string strName = pMsg->GetStr(str,2048); // 表情动画队列 long lFaceID1 = pMsg->GetLong(); long lFaceTime1 = pMsg->GetLong(); long lFaceID2 = pMsg->GetLong(); long lFaceTime2 = pMsg->GetLong(); long lFaceID3 = pMsg->GetLong(); long lFaceTime3 = pMsg->GetLong(); long lFaceID4 = pMsg->GetLong(); long lFaceTime4 = pMsg->GetLong(); long lFaceID5 = pMsg->GetLong(); long lFaceTime5 = pMsg->GetLong(); CTalkBoxPageEx * pPage = GetGame()->GetCGuiEx()->GetTalkBoxPageEx(); // 打开 pPage->Release(); // 设置当前NPC的名字 pPage->SetCurNpcName(strName); pPage->OpenBox(CTalkBoxPageEx::STORY_TALKBOX); pPage->SetIsContinueByAnyKey(bIsContinue); if(bIsCloseWindow) { GetGame()->GetCGuiEx()->ClosePageExcept(pPage); } char facenum[5]; sprintf(facenum,"%04d",lFaceID1); lFaceID1 = *(DWORD*)facenum; sprintf(facenum,"%04d",lFaceID2); lFaceID2 = *(DWORD*)facenum; sprintf(facenum,"%04d",lFaceID3); lFaceID3 = *(DWORD*)facenum; sprintf(facenum,"%04d",lFaceID4); lFaceID4 = *(DWORD*)facenum; sprintf(facenum,"%04d",lFaceID5); lFaceID5 = *(DWORD*)facenum; pPage->SetModelIcon(TYPE_TALKBOXMODEL,lHeadID, lFaceID1,lFaceTime1, lFaceID2,lFaceTime2, lFaceID3,lFaceTime3, lFaceID4,lFaceTime4, lFaceID5,lFaceTime5, 40,320,D3DXToRadian(0.0f)); pPage->SetMessageText(strText.c_str()); pPage->SetScriptID(guScriptID); // 播放音乐和声音 pPage->PlaySoundsEx(lSoundID); pPage->PlayBkMusic(lBkMusicID); // 记录打开对话框时候的坐标 extern CGUID g_OpenNpcTalkBoxRegionID; extern long g_lOpenNpcTalkBoxPosX; extern long g_lOpenNpcTalkBoxPosY; g_OpenNpcTalkBoxRegionID = GetGame()->GetRegion()->GetExID(); g_lOpenNpcTalkBoxPosX = pMsg->GetPlayer()->GetTileX(); g_lOpenNpcTalkBoxPosY = pMsg->GetPlayer()->GetTileY(); } } break; case MSG_S2C_OTHER_OPENPIXYTALKBOX: { long lFlag = pMsg->GetLong(); char str[2048]; string strText = ""; CGUID guScriptID; pMsg->GetGUID(guScriptID); // 传入的是字符串 if(lFlag == 0) { strText = pMsg->GetStr(str,2048); // 标题文字 } // 传入索引 else { DWORD dwType = pMsg->GetDWord(); DWORD dwIndex = pMsg->GetDWord(); strText = CStringReading::LoadString(dwType,dwIndex); } //背景语音 long lSoundID = pMsg->GetLong(); long lHeadID = pMsg->GetLong(); // 表情动画队列 long lFaceID1 = pMsg->GetLong(); long lFaceTime1 = pMsg->GetLong(); long lFaceID2 = pMsg->GetLong(); long lFaceTime2 = pMsg->GetLong(); lFaceTime2 = 1; long lFaceID3 = pMsg->GetLong(); long lFaceTime3 = pMsg->GetLong(); long lFaceID4 = pMsg->GetLong(); long lFaceTime4 = pMsg->GetLong(); long lFaceID5 = pMsg->GetLong(); long lFaceTime5 = pMsg->GetLong(); CPixyTalkBoxPageEx * pPage = GetGame()->GetCGuiEx()->GetPixyTalkBoxPageEx(); // 打开 if(strcmp(strText.c_str(),"") != 0) { if(pPage->IsOpen()) { pPage->Release(); } pPage->Open(); pPage->SetMessageText(strText.c_str()); pPage->SetIsContinueByAnyKey(true); }else{ pPage->Release(); return; } char facenum[5]; sprintf(facenum,"%04d",lFaceID1); lFaceID1 = *(DWORD*)facenum; sprintf(facenum,"%04d",lFaceID2); lFaceID2 = *(DWORD*)facenum; sprintf(facenum,"%04d",lFaceID3); lFaceID3 = *(DWORD*)facenum; sprintf(facenum,"%04d",lFaceID4); lFaceID4 = *(DWORD*)facenum; sprintf(facenum,"%04d",lFaceID5); lFaceID5 = *(DWORD*)facenum; pPage->SetModelIcon(TYPE_TALKBOXMODEL,lHeadID, lFaceID1,lFaceTime1, lFaceID2,lFaceTime2, lFaceID3,lFaceTime3, lFaceID4,lFaceTime4, lFaceID5,lFaceTime5, 40,160,D3DXToRadian(0.0f)); pPage->SetScriptID(guScriptID); // 播放音乐和声音 pPage->PlaySoundsEx(lSoundID); } break; /////////////////////////////////////////////////////////////////////////////////////// // 接受对象属性 /////////////////////////////////////////////////////////////////////////////////////// case MSG_S2C_OTHER_SENDOBJECTPROPERTIY: { long lType = pMsg->GetLong(); CGUID id; pMsg->GetGUID(id); CBaseObject* pObj = GetGame()->GetRegion()->RecursiveFindObject( lType, id ); if( pObj ) { switch(lType) { case TYPE_PLAYER: { CPlayer* pPlayer = (CPlayer*)pObj; BYTE ByteData[102400]; pMsg->GetEx(ByteData,102400); long lPos = 0; pPlayer->DecordFromByteArray( ByteData, lPos ); pPlayer->SetPosX( pPlayer->GetPosX() ); pPlayer->SetPosY( pPlayer->GetPosY() ); } break; /*case TYPE_NPC: { CNpc* pNpc = (CNpc*)pObj; BYTE ByteData[102400]; pMsg->GetEx(ByteData,102400); long lPos = 0; pNpc->DecordFromByteArray( ByteData, lPos, false ); pNpc->SetPosX( pNpc->GetPosX() ); pNpc->SetPosY( pNpc->GetPosY() ); } break;*/ case TYPE_GOODS: { CGoods* pGoods = (CGoods*)pObj; BYTE ByteData[102400]; pMsg->GetEx(ByteData,102400); long lPos = 0; pGoods->DecordFromByteArray( ByteData, lPos ); } break; case TYPE_MONSTER: { CMonster* pMonster = (CMonster*)pObj; BYTE ByteData[102400]; pMsg->GetEx(ByteData,102400); long lPos = 0; pMonster->DecordFromByteArray(ByteData, lPos ); } break; } } } break; // 改变对象属性 case MSG_S2C_OTHER_CHANGESHAPEPROPERTIY: { long lType = pMsg->GetLong(); CGUID ID; pMsg->GetGUID(ID); char str[256] = ""; pMsg->GetStr(str,256); long lChangeNum = pMsg->GetLong(); CShape* p = (CShape*)GetGame()->GetRegion()->FindChildObject(lType, ID); if( p ) { p->ChangeValue(str, lChangeNum); if( p->GetType() == TYPE_PLAYER ) { //((CPlayer*)p)->UpdateProperty(); } } } break; // 设置对象属性 case MSG_S2C_OTHER_SETSHAPEPROPERTIY: { long lType = pMsg->GetLong(); CGUID ID; pMsg->GetGUID(ID); char str[256] = ""; pMsg->GetStr(str,256); long lSetNum = pMsg->GetLong(); CShape* p = (CShape*)GetGame()->GetRegion()->FindChildObject(lType, ID); if( p ) { p->SetValue(str, lSetNum); if( p->GetType() == TYPE_PLAYER ) { //((CPlayer*)p)->UpdateProperty(); } } } break; // 广播 case MSG_S2C_OTHER_BROADCAST: { char strVal[1024]; long lRegionID = pMsg->GetLong(); long lImportLevel = pMsg->GetLong(); D3DCOLOR colorText = pMsg->GetDWord(); D3DCOLOR colorBack = pMsg->GetDWord(); pMsg->GetStr(strVal,1024); GetGame()->GetCGuiEx()->GetMainBarPageEx()->AddChatWords(strVal, colorText, colorBack,0xff000000,"",CHAT_BOARDCAST); GetGame()->GetCGuiEx()->GetMainBarPageEx()->AddChatWords( strVal, colorText, colorBack, 0, "", CHAT_SYSTEM ); // 王峰:置顶广播 CTopMsg::GetInstance()->AddBroadcastMsg( strVal ); } break; // 王峰:紧急脚本公告(高优先级) case MSG_S2C_OTHER_NEWS_TOP_WORLD: { char szNews[1024]; long lLoop = pMsg->GetLong(); pMsg->GetStr( szNews, 1024 ); long lBKIndex = pMsg->GetLong(); GetGame()->GetCGuiEx()->GetMainBarPageEx()->AddChatWords( szNews, pSetup->colorScriptBroadcast, pSetup->colorScriptBroadcastBack, pSetup->colorScriptBroadcastShadow, "", CHAT_BOARDCAST ); GetGame()->GetCGuiEx()->GetMainBarPageEx()->AddChatWords( szNews, pSetup->colorScriptBroadcast, pSetup->colorScriptBroadcastBack, 0, "", CHAT_SYSTEM ); // CTopMsg::GetInstance()->AddBroadcastMsg( szNews, true, lLoop, lBKIndex ); } break; // 消息 case MSG_S2C_OTHER_ADDINFO: { char *strText = NULL; D3DCOLOR color = pMsg->GetDWord(); D3DCOLOR bkColor = pMsg->GetDWord(); BYTE bPos = pMsg->GetByte(); char str[1024]; strText = pMsg->GetStr(str,1024); GetGame()->GetCGuiEx()->GetMainBarPageEx()->AddText(bPos,strText,color,bkColor); } break; // 添加提示消息(索引) case MSG_S2C_OTHER_ADDINFO_BYINDEX: { D3DCOLOR color = pMsg->GetDWord(); // 文本颜色 D3DCOLOR bkColor = pMsg->GetDWord(); // 文本背景色 BYTE bPos = pMsg->GetByte(); // 文本的显示位置 DWORD dwType = pMsg->GetDWord(); // 字符串类型 DWORD dwIndex = pMsg->GetDWord(); // 字符串的索引 string strText = CStringReading::LoadString(dwType,dwIndex); GetGame()->GetCGuiEx()->GetMainBarPageEx()->AddText(bPos,strText.c_str(),color,bkColor); } break; case MSG_S2C_OTHER_ADDSYSTEMINFO: { D3DCOLOR color = pMsg->GetDWord(); char str[1024]; pMsg->GetStr(str,1024); GetGame()->GetCGuiEx()->GetMainBarPageEx()->AddText(eNOTIFYPOS_SYSTEM,str,color); } break; // 消息 case MSG_S2C_OTHER_GAMEMESSAGE: { char str[1024]; pMsg->GetStr(str,1024); long type = pMsg->GetLong(); CGUID guScriptID; pMsg->GetGUID(guScriptID); CMessageBoxPageEx *pMsgPage = GetGame()->GetCGuiEx()->GetMessageBoxPageEx(); if (type == 1) { type = CMessageBoxPageEx::MSG_OK_NO; } else { type = CMessageBoxPageEx::MSG_OK; } pMsgPage->SetScriptID(guScriptID); pMsgPage->Open(pMsgPage,str,type,true); //GetGame()->GetInterface()->GetMsgBox()->Run(str, type, true); //GetGame()->GetInterface()->GetMsgBox()->SetScriptID(lScriptID); } break; // 定时PING case MSG_S2C_OTHER_PING: { //WORD wState = pMsg->GetWord(); //GetGame()->GetMainPlayer()->SetState(wState); GetGame()->SetLastPingTime(GetCurTickCount()); //pMsg->Send(); } break; case MSG_S2C_OTHER_VIEWGOODSLINK: { long lPlayerID=pMsg->GetLong(); long bSuccessful=pMsg->GetLong(); if(bSuccessful==1) { CGoods* pGoods=new CGoods; BYTE ByteData[102400]; pMsg->GetEx(ByteData,102400); long lPos = 0; pGoods->DecordFromByteArray(ByteData,lPos); /*CGoodsLinkPage* pGoodsLinkPage=new CGoodsLinkPage; pGoodsLinkPage->Init(pGoods); pGoodsLinkPage->Open(); CGoodsLinkPage::SetLinkRequestSendedFlag(false);*/ } } break; case MSG_S2C_OTHER_SCRIPTTIMERRUN: { long lTime = pMsg->GetLong(); GetGame()->SetScriptTimer(lTime); } break; case MSG_S2C_OTHER_CHANGENAME_OPENUI: { if (GetGame()->GetMainPlayer() == NULL) break; char ret=pMsg->GetChar(); if(ret==0) { //GetGame()->GetInterface()->GetMsgBox()->Run("你不能更改名字!"); break; } //GetGame()->GetInterface()->GetInputPasswordPage()->SetShowText("请输入您的新名字"); /*if(GetGame()->GetInterface()->GetInputPasswordPage()->Run()==1) { if(strlen(GetGame()->GetInterface()->GetInputPasswordPage()->GetPassword())>3) { CMessage msg(MSG_C2S_OTHER_CHANGENAME); msg.Add(GetGame()->GetMainPlayer()->GetID()); msg.Add(GetGame()->GetInterface()->GetInputPasswordPage()->GetPassword()); msg.Send(); } }*/ } break; case MSG_S2C_OTHER_CHANGENAME: { if (GetGame()->GetMainPlayer() == NULL) break; CGUID ID; pMsg->GetGUID(ID); char strName[32]; pMsg->GetStr(strName,sizeof(strName)); char ret=(char)pMsg->GetByte(); CPlayer* pPlayer=(CPlayer *)GetGame()->GetRegion()->FindChildObject(TYPE_PLAYER,ID); if(pPlayer==NULL) break; if(ret==1)//成功 { pPlayer->SetName(strName); if(ID==GetGame()->GetMainPlayer()->GetExID()) { //GetGame()->GetInterface()->GetMsgBox()->Run("你更改名字成功!"); GetGame()->GetCGuiEx()->GetMainBarPageEx()->AddText(eNOTIFYPOS_CENTER,CStringReading::LoadString(206,216)); GetGame()->GetCGuiEx()->GetMainBarPageEx()->UpdateName(); } else { string str=pPlayer->GetName(); //str+="更改名字为:"; //str+=strName; //GetGame()->GetInterface()->AddText((char *)str.c_str(),0xffff0000); } } else if(ID==GetGame()->GetMainPlayer()->GetExID()) { if(ret==-1) { // 名字已存在 GetGame()->GetCGuiEx()->GetMainBarPageEx()->AddText(eNOTIFYPOS_CENTER,CStringReading::LoadString(206,217)); }else if(ret==-2) { // 名字不合法 GetGame()->GetCGuiEx()->GetMainBarPageEx()->AddText(eNOTIFYPOS_CENTER,CStringReading::LoadString(206,218)); }else if(ret==0) { GetGame()->GetCGuiEx()->GetMainBarPageEx()->AddText(eNOTIFYPOS_CENTER,CStringReading::LoadString(206,219)); } //GetGame()->GetInterface()->GetMsgBox()->Run("你更改名字失败!"); } } break; case MSG_S2C_OTHER_AddTopInfo: { CGUID lPlayerID; pMsg->GetGUID(lPlayerID); long lTopInfoID = pMsg->GetLong(); long lFlag = pMsg->GetLong(); long lParam = pMsg->GetLong(); char strInfo[256]=""; pMsg->GetStr(strInfo,256); GetGame()->AddTopInfo(lTopInfoID,lFlag,lParam,string(strInfo)); } break; case MSG_S2C_OTHER_ADDPLAYERINFO: { if (GetGame()->GetMainPlayer() == NULL) break; // 字符or索引 long lFlag = pMsg->GetLong(); char *strText = NULL; DWORD dwForeColor=pMsg->GetDWord(); DWORD dwBackColor=pMsg->GetDWord(); char str[256]; if(lFlag==0) strText = pMsg->GetStr(str,256); else { DWORD dwType = pMsg->GetDWord(); DWORD dwIndex = pMsg->GetDWord(); strText = CStringReading::LoadString(dwType,dwIndex); } if(GetGame()->GetCGuiEx()->GetMainBarPageEx()) GetGame()->GetCGuiEx()->GetMainBarPageEx()->AddText(eNOTIFYPOS_CENTER,strText,dwForeColor); //信息提示音效 //if(lFlag==0) //GetGame()->GetAudioList()->Play2DSound("SOUNDS\\interfaces\\i-39.wav"); } break; case MSG_S2C_OTHER_SHOWREADMEWINDOW: { //GetGame()->GetInterface()->GetReadmePage()->Open(); } break; // NPC名字列表 case MSG_S2C_OTHER_ANSWERNPCLIST: { vector<CNpcListPageEx::tagNpcList>* pList = GetGame()->GetCGuiEx()->GetNpcListPageEx()->GetNpcList(); pList->clear(); long lNum = pMsg->GetLong(); long lLen = pMsg->GetLong(); BYTE* str = new BYTE[lLen+1]; pMsg->GetEx(str,lLen); long pos = 0; char strName[256]; int lX, lY; for (int i=0; i<lNum; i++) { _GetStringFromByteArray(str,pos,strName); lX = _GetDwordFromByteArray(str,pos); lY = _GetDwordFromByteArray(str,pos); if(strcmp(strName,"$space")) { CNpcListPageEx::tagNpcList st(strName, lX, lY); pList->push_back(st); } } SAFE_DELETE_ARRAY(str); GetGame()->GetCGuiEx()->GetNpcListPageEx()->Close(); GetGame()->GetCGuiEx()->GetNpcListPageEx()->UpdateList(); } break; case MSG_S2C_OTHER_TALK_WORLD: { if (GetGame()->GetMainPlayer() == NULL) break; BYTE bIsOk; char szName[256]; char szContent[1024]; char szOutText[2056]; string strContent; memset(szName,'\0',256); //=========================对话信息中的聊天信息======================= long lAdjustLen = 0; CMainBarPageEx * pMainPage = GetGame()->GetCGuiEx()->GetMainBarPageEx(); list<CEditField::stSpecialTextInfo> * pTextInfoList = pMainPage->GetSpecialText(); pTextInfoList->clear(); char strGoodsName[1024] = ""; long lNum = pMsg->GetLong(); for(long i=0; i<lNum; ++i) { CEditField::stSpecialTextInfo stInfo; pMsg->GetEx(&stInfo, sizeof(CEditField::stSpecialTextInfo)); stInfo.str = pMsg->GetStr(strGoodsName,1024); pTextInfoList->push_back(stInfo); } //==================================================================== bIsOk = pMsg->GetByte(); if(bIsOk) { pMsg->GetStr(szName, 256); lAdjustLen = lstrlen(szName)+11; pMsg->GetStr(szContent,1024); // 脏话过滤 strContent = szContent; CClientWordsFilter::GetInstance()->Check(strContent, true, true); // 格式化聊天字段 wsprintf( szOutText, CStringReading::LoadString( 14, CHAT_WOLRD+101 ), szName, strContent.c_str() ); } else { sprintf(szOutText,CStringReading::LoadString(eIDS_BASEUI,eIDS_STR_WORLDCHAT_UNSUCCESS)); } // 前缀长度 lAdjustLen = lstrlen( szOutText ) - lstrlen( szContent ); pMainPage->m_lAdjPos = lAdjustLen; pMainPage->AdjGoodsInfoPos(lAdjustLen); GetGame()->GetCGuiEx()->GetMainBarPageEx()->AddChatWords(szOutText, CGlobeSetup::GetSetup()->colorChatText[CHAT_WOLRD], CGlobeSetup::GetSetup()->colorChatTextBack[CHAT_WOLRD], CGlobeSetup::GetSetup()->colorChatTextShadow[CHAT_WOLRD], szName,CHAT_WOLRD); } break; // 盟国 case MSG_S2C_OTHER_TALK_COUNTRY_UNION: { if (GetGame()->GetMainPlayer() == NULL) break; BYTE bIsOk; char szName[256]; char szContent[1024]; char szOutText[2056]; string strContent; memset(szName,'\0',256); //=========================对话信息中的聊天信息======================= long lAdjustLen = 0; CMainBarPageEx * pMainPage = GetGame()->GetCGuiEx()->GetMainBarPageEx(); list<CEditField::stSpecialTextInfo> * pTextInfoList = pMainPage->GetSpecialText(); pTextInfoList->clear(); char strGoodsName[1024] = ""; long lNum = pMsg->GetLong(); for(long i=0; i<lNum; ++i) { CEditField::stSpecialTextInfo stInfo; pMsg->GetEx(&stInfo, sizeof(CEditField::stSpecialTextInfo)); stInfo.str = pMsg->GetStr(strGoodsName,1024); pTextInfoList->push_back(stInfo); } //==================================================================== bIsOk = pMsg->GetByte(); if(bIsOk) { pMsg->GetStr(szName, 256); lAdjustLen = lstrlen(szName)+11; // 检查黑名单 if( GetGame()->GetCGuiEx()->GetFriendsPageEx()->IsInGroup( szName, CFriendsPageEx::PANEL_BLACK ) ) break; pMsg->GetStr(szContent,1024); // 脏话过滤 strContent = szContent; CClientWordsFilter::GetInstance()->Check(strContent, true, true); // 格式化聊天字段 wsprintf( szOutText, CStringReading::LoadString( 14, CHAT_COUNTRY_UNION+101 ), szName, strContent.c_str() ); } else { sprintf(szOutText,CStringReading::LoadString(eIDS_BASEUI,eIDS_STR_UNIONCOUNCHAT_UNSUCCESS)); } // 前缀长度 lAdjustLen = lstrlen( szOutText ) - lstrlen( szContent ); pMainPage->m_lAdjPos = lAdjustLen; pMainPage->AdjGoodsInfoPos(lAdjustLen); GetGame()->GetCGuiEx()->GetMainBarPageEx()->AddChatWords(szOutText, CGlobeSetup::GetSetup()->colorChatText[CHAT_COUNTRY_UNION], CGlobeSetup::GetSetup()->colorChatTextBack[CHAT_COUNTRY_UNION], CGlobeSetup::GetSetup()->colorChatTextShadow[CHAT_COUNTRY_UNION], szName,CHAT_COUNTRY_UNION); } break; case MSG_S2C_OTHER_TALK_COUNTRY: { if (GetGame()->GetMainPlayer() == NULL) break; BYTE bIsOk; char szName[256]; char szContent[1024]; char szOutText[2056]; string strContent; memset(szName,'\0',256); //=========================对话信息中的聊天信息======================= long lAdjustLen = 0; CMainBarPageEx * pMainPage = GetGame()->GetCGuiEx()->GetMainBarPageEx(); list<CEditField::stSpecialTextInfo> * pTextInfoList = pMainPage->GetSpecialText(); pTextInfoList->clear(); char strGoodsName[1024] = ""; long lNum = pMsg->GetLong(); for(long i=0; i<lNum; ++i) { CEditField::stSpecialTextInfo stInfo; pMsg->GetEx(&stInfo, sizeof(CEditField::stSpecialTextInfo)); stInfo.str = pMsg->GetStr(strGoodsName,1024); pTextInfoList->push_back(stInfo); } //==================================================================== bIsOk = pMsg->GetByte(); if(bIsOk) { pMsg->GetStr(szName, 256); lAdjustLen = lstrlen(szName)+11; // 检查黑名单 if( GetGame()->GetCGuiEx()->GetFriendsPageEx()->IsInGroup( szName, CFriendsPageEx::PANEL_BLACK ) ) break; pMsg->GetStr(szContent,1024); // 脏话过滤 strContent = szContent; CClientWordsFilter::GetInstance()->Check(strContent, true, true); // 格式化聊天字段 wsprintf( szOutText, CStringReading::LoadString( 14, CHAT_COUNTRY+101 ), szName, strContent.c_str() ); } else { sprintf(szOutText,CStringReading::LoadString(eIDS_BASEUI,eIDS_STR_COUNCHAT_UNSUCCESS)); } // 前缀长度 lAdjustLen = lstrlen( szOutText ) - lstrlen( szContent ); pMainPage->m_lAdjPos = lAdjustLen; pMainPage->AdjGoodsInfoPos(lAdjustLen); GetGame()->GetCGuiEx()->GetMainBarPageEx()->AddChatWords(szOutText, CGlobeSetup::GetSetup()->colorChatText[CHAT_COUNTRY], CGlobeSetup::GetSetup()->colorChatTextBack[CHAT_COUNTRY], CGlobeSetup::GetSetup()->colorChatTextShadow[CHAT_COUNTRY], szName,CHAT_COUNTRY); } break; // 王峰:置顶聊天 case MSG_S2C_OTHER_TALK_TOP_WORLD: { CTopMsg::GetInstance()->RecvTopChatMsg( pMsg ); } // 国家通知 case MSG_S2C_OTHER_TALK_NOTIFY: { BYTE btType; char szContent[1024]; btType = pMsg->GetByte(); pMsg->GetStr(szContent,1024); switch( btType) { case 1: // 本国人被杀 //GetGame()->GetInterface()->AddOtherInfo(szContent); break; case 2: // 杀死敌人 //GetGame()->GetInterface()->AddSystemInfo(szContent,0XFF00FF00,10000); break; case 0: default: // 被袭击 //GetGame()->GetInterface()->AddOtherInfo(szContent); break; } } break; //转换摄像机 case MSG_S2C_OTHER_TRANSFORCAMERA: { //转换方式 long lTransformMode = pMsg->GetLong(); long lParam1 = pMsg->GetLong(); long lParam2 = pMsg->GetLong(); long lParam3 = pMsg->GetLong(); GetGame()->GetRegion()->TransformCamer(lTransformMode,lParam1,lParam2,lParam3); } break; //操作界面 case MSG_S2C_OTHER_OPERAINTERFACE: { //转换方式 long lOperaMode = pMsg->GetLong(); //界面名字 char pszInterfaceName[256]; pMsg->GetStr(pszInterfaceName,256); /*CComponent * pParentComp = NULL; CComponent * pComp = NULL; if(IGUIRoot::GetGUIInstance()->GetGUIComp()) { pParentComp = IGUIRoot::GetGUIInstance()->GetGUIComp()->GetContentContainer(); if(pParentComp) pComp = pParentComp->GetComponent(pszInterfaceName); }*/ switch(lOperaMode) { //打开指定界面 case 1: { GetGame()->GetCGuiEx()->OpenPageByName(pszInterfaceName); } break; //关闭指定界面 case 2: { GetGame()->GetCGuiEx()->ClosePageByName(pszInterfaceName); } break; //关闭所有界面 case 3: { GetGame()->GetCGuiEx()->CloseAllPage(); } break; } } break; //设置帮助提示 case MSG_S2C_OTHER_SETHELPHINT: { BYTE bDel = pMsg->GetByte(); long lHintID = pMsg->GetLong(); //删除提示 if(bDel) { GetGame()->GetCGuiEx()->GetClewInfo()->DeleteClewInfo(lHintID); } //添加帮助提示 else { //标志位,向服务器发消息的时候,需要返回 long lFlag = pMsg->GetLong(); //删除的超时时间 long lFutureDelTime = pMsg->GetLong(); GetGame()->GetCGuiEx()->GetClewInfo()->AddClewInfo(lHintID,lFlag,lFutureDelTime); } } break; //设置界面提示 case MSG_S2C_OTHER_SETINTERFACEHINT: { BYTE bDel = pMsg->GetByte(); long lHintID = pMsg->GetLong(); //删除界面提示 if(bDel) { GetGame()->GetCGuiEx()->GetTopPage()->DeleteRectFocus(lHintID); } //添加界面提示 else { //标志位,向服务器发消息的时候,需要返回 long lFlag = pMsg->GetLong(); //删除的超时时间 long lFutureDelTime = pMsg->GetLong(); //主窗口的名字 char pszInterfaceName[256]=""; pMsg->GetStr(pszInterfaceName,256); //聚焦框的相对于主窗口的相对位置和大小 long lX = pMsg->GetLong(); long lY = pMsg->GetLong(); long lWidth = pMsg->GetLong(); long lHeight = pMsg->GetLong(); // 根据名字打开对应的页面 CGuiExPage *pPage = GetGame()->GetCGuiEx()->OpenPageByName(pszInterfaceName); // 查找对应的主界面 CGUIComp * pParentComp = IGUIRoot::GetGUIInstance()->GetGUIComp(); if(pParentComp) { CComponent * pComp = pParentComp->GetComponentByName(pszInterfaceName); if(pComp) { RECT rt; rt.left = pComp->GetXOnWindow() + lX; rt.right = rt.left + lWidth; rt.top = pComp->GetYOnWindow() + lY; rt.bottom = rt.top + lHeight; GetGame()->GetCGuiEx()->GetTopPage()->AddRectFocus(pPage,lHintID,lFlag,lFutureDelTime,rt); } } } } break; // 播放动画特效 case MSG_S2C_OTHER_EFFECT: { GetGame()->GetCGuiEx()->GetEffectUIManager()->AddGroup( pMsg->GetDWord() ); } break; // 播放仪态动作 - add by lpf(2008.04.11) case MSG_S2C_OTHER_EXPATC: { //string sChatMsg; CMoveShape * pSourceMoveShape = NULL; CMoveShape * pTargetMoveShape = NULL; tagFaceAction * stpFaceAction = NULL; // 得到服务器数据 DWORD dwFaceActionID = pMsg->GetDWord(); long lSourceObjType = pMsg->GetLong(); CGUID SourceObjGUID; pMsg->GetGUID(SourceObjGUID); long lTargetObjType = pMsg->GetLong(); CGUID TargetObjGUID; pMsg->GetGUID(TargetObjGUID); // 得到需要处理的对象 CClientRegion * pRegion = GetGame()->GetRegion(); if (pRegion == NULL) break; pSourceMoveShape = dynamic_cast<CMoveShape *>(pRegion->FindChildObject(lSourceObjType, SourceObjGUID)); pTargetMoveShape = dynamic_cast<CMoveShape *>(pRegion->FindChildObject(lTargetObjType, TargetObjGUID)); // 设定表情动画 GetGame()->GetFaceActionList()->SetupFaceAction(dwFaceActionID, pSourceMoveShape, lSourceObjType, pTargetMoveShape, lTargetObjType); if(pSourceMoveShape) { pSourceMoveShape->InitActionAudio(dwFaceActionID); } } break; // 物品信息回复 case MSG_S2C_OTHER_GoodsInfo_Re: { CGUID PlayerGUID; pMsg->GetGUID(PlayerGUID); CGUID GUID; pMsg->GetGUID(GUID); DWORD dwSize=pMsg->GetDWord(); if( dwSize==0 ) break; BYTE *pBuff=new BYTE[dwSize]; pMsg->GetEx(pBuff,dwSize); CGoods *pGoods=new CGoods(); LONG lPos=0; pGoods->DecordFromByteArray(pBuff,lPos); SAFE_DELETE_ARRAY(pBuff); list<CGame::stChatGoodsInfo> * pChatGoodsInfo = GetGame()->GetChatGoodsInfoList(); if(pChatGoodsInfo) { if(pChatGoodsInfo->size() >= 120) { SAFE_DELETE(pChatGoodsInfo->front().pGoods); pChatGoodsInfo->erase(pChatGoodsInfo->begin()); } CGame::stChatGoodsInfo info; info.idEx = GUID; info.pGoods = pGoods; pChatGoodsInfo->push_back(info); } } break; //! 一条带物品信息的消息 case MSG_S2C_OTHER_ADDINFO_AND_GOODSINFO: { char str[256]=""; pMsg->GetStr(str,256); char strName[256]=""; pMsg->GetStr(strName,256); tagChatsGoodsInfo tgGoodsInfo; pMsg->GetEx(&tgGoodsInfo,sizeof(tagChatsGoodsInfo)); CMainBarPageEx * pMainPage = GetGame()->GetCGuiEx()->GetMainBarPageEx(); if(pMainPage) { // 本次信息中的特殊字符 list<CEditField::stSpecialTextInfo> * pTextInfoList = pMainPage->GetSpecialText(); pTextInfoList->clear(); CEditField::stSpecialTextInfo stInfo; stInfo.str = strName; stInfo.stInfo = tgGoodsInfo; pTextInfoList->push_back(stInfo); pMainPage->m_lAdjPos = 0; pMainPage->AdjGoodsInfoPos(0); GetGame()->GetCGuiEx()->GetMainBarPageEx()->AddChatWords(str, CGlobeSetup::GetSetup()->colorChatText[CHAT_SYSTEM], CGlobeSetup::GetSetup()->colorChatTextBack[CHAT_SYSTEM], CGlobeSetup::GetSetup()->colorChatTextShadow[CHAT_SYSTEM], "",CHAT_SYSTEM); } } break; // 视频播放 case MSG_S2C_OTHER_PLAY_VIDEO: { RECT rc; char szFileName[MAX_PATH]; int iLoop; pMsg->GetStr(szFileName, MAX_PATH); iLoop = pMsg->GetLong(); rc.left = pMsg->GetLong(); rc.top = pMsg->GetLong(); rc.right = pMsg->GetLong(); rc.bottom = pMsg->GetLong(); CVideoManager::GetInstance()->PlayVideo(szFileName, iLoop, &rc); } break; //停止视频播放 case MSG_S2C_OTHER_STOP_VIDEO: { int iIndex = pMsg->GetLong(); CVideoManager::GetInstance()->StopVideo(iIndex); } break; //背包闪烁 case MSG_S2C_OTHER_PackGlint: { CItemPageEx * pItems = GetGame()->GetCGuiEx()->GetItemPageEx(); CMainBarPageEx * pMainbar = GetGame()->GetCGuiEx()->GetMainBarPageEx(); if(pMainbar && pItems && !pItems->IsOpen() && !pItems->HasSubPackOpen()) { // 在Mainbar上的任务按钮添加闪动效果 if(pMainbar->GetInterfaceComp()) { CButton *pQuestBtn = (CButton *)pMainbar->GetInterfaceComp()->GetComponent("Item"); if(pQuestBtn && pQuestBtn->GetSpecialIcon()) ((CImageIcon *)pQuestBtn->GetSpecialIcon())->SetIsChangeAlpha(true); } } } break; // 帐号重复登陆 case MSG_S2C_OTHER_REPEATLOGIN: { char str[256]=""; pMsg->GetStr(str, 256); CLoginPageEx * pPage = GetGame()->GetCGuiEx()->GetLoginPageEx(); CMessageBoxPageEx * pMesBox = GetGame()->GetCGuiEx()->GetMessageBoxPageEx(); if(pPage && pMesBox) { pMesBox->Open(pPage,str,CMessageBoxPageEx::MSG_OK,true); } } break; //打开脚本输入框 case MSG_S2C_OTHER_UPDATEVARVALUEOPEN: { //脚本ID CGUID ScriptsID; pMsg->GetGUID(ScriptsID); GetGame()->GetCGuiEx()->GetInputBoxPageEx()->SetScriptsGuid(ScriptsID); //显示文本 char strTextOut[MAX_PATH]; pMsg->GetStr(strTextOut, MAX_PATH); GetGame()->GetCGuiEx()->GetInputBoxPageEx()->SetTextOut(strTextOut); //存储变量 char strValue[MAX_PATH]; pMsg->GetStr(strValue, MAX_PATH); GetGame()->GetCGuiEx()->GetInputBoxPageEx()->CheckBoxType(strValue); //打开输入框 CPlayer *pPlayer = GetGame()->GetMainPlayer(); if(pPlayer) GetGame()->GetCGuiEx()->GetInputBoxPageEx()->SetPlayerMoveRange( pPlayer->GetTileX(), pPlayer->GetTileY(), 4 ); GetGame()->GetCGuiEx()->GetInputBoxPageEx()->Open(); GetGame()->GetCGuiEx()->GetInputBoxPageEx()->SetChangeName(false); } break; case MSG_S2C_OTHER_UPDATENAMEOPEN: { //脚本ID CGUID ScriptsID; pMsg->GetGUID(ScriptsID); GetGame()->GetCGuiEx()->GetInputBoxPageEx()->SetScriptsGuid(ScriptsID); //显示文本 char str[256]=""; sprintf(str,"%s",CStringReading::LoadString(206,220)); GetGame()->GetCGuiEx()->GetInputBoxPageEx()->SetTextOut(str); //存储变量 GetGame()->GetCGuiEx()->GetInputBoxPageEx()->CheckBoxType("#"); //打开输入框 CPlayer *pPlayer = GetGame()->GetMainPlayer(); if(pPlayer) GetGame()->GetCGuiEx()->GetInputBoxPageEx()->SetPlayerMoveRange( pPlayer->GetTileX(), pPlayer->GetTileY(), 4 ); GetGame()->GetCGuiEx()->GetInputBoxPageEx()->Open(); GetGame()->GetCGuiEx()->GetInputBoxPageEx()->SetChangeName(true); } break; // 王峰:活动公告 case MSG_S2C_OTHER_SHOW_STRING: { // 是否显示开关 if( pMsg->GetLong() ) { // xy坐标 long x = pMsg->GetLong(); long y = pMsg->GetLong(); // 显示的字符串 TCHAR szPlacard[2056]; pMsg->GetStr( szPlacard, 2056 ); // 设置 if( CMainBarPageEx* pMainBarPage = GetGame()->GetCGuiEx()->GetMainBarPageEx() ) { if( lstrlen( szPlacard ) ) { pMainBarPage->SetPlacardVisibled( false ); pMainBarPage->SetPlacard( szPlacard, x, y ); pMainBarPage->SetPlacardVisibled( true ); } } } else { // 关闭公告显示 if( CMainBarPageEx* pMainBarPage = GetGame()->GetCGuiEx()->GetMainBarPageEx() ) { pMainBarPage->SetPlacardVisibled( false ); } } } break; } }
void PrintGreetingFromShape(const CShape & shape) { shape.Hello(); shape.Draw(42); }
unsigned int EffRect::GetEffectObjs( list<CMoveShape*> &listObjs ) { if ( m_strNum!="" ) { /// by:expter 2010/08/31 技能增加一个参数 m_nNum = m_pParam->pFirer->GetSkillValue(m_pParam->nID,m_pParam->nLvl,m_strNum); } if( m_nNum < 0 ) m_nNum = 0; uint nNum = 0; // 取得作用点 Graph::PosPair poss = GetOperPos(); // 取得可能影响的SHAPE std::vector<CShape*> shapes; if( GetAroundShapes( poss, shapes ) == 0 ) { return 0; } // 取得矩形4条边 Graph::Line l1, l2, l3, l4; GetRectLines( poss, l1, l2, l3, l4 ); if ( m_pExcept ) { #ifdef _SKILL_INFO_D_ Log4c::Trace(SKILL_MODULE, "EffRect:作用于对象外的玩家\n"); #endif } // 判定每个SHAPE是否确实在矩形内 for( std::vector<CShape*>::iterator it = shapes.begin(); it != shapes.end(); ++ it ) { CShape *shape = *it; if( shape == m_pParam->pUser ) continue; if( Graph::IsInLineRange( shape->GetPosX(), shape->GetPosY(), l1, l2 ) && Graph::IsInLineRange( shape->GetPosX(), shape->GetPosY(), l3, l4 ) ) { ++nNum; if (m_nNum>0) { if (m_nNum<(int)nNum) { break; } } CMoveShape *moveShape = (CMoveShape*) shape; /// 除去范围内对象 if( m_pExcept && m_pExcept == moveShape ) { continue; } listObjs.push_back( moveShape ); } } return nNum; }
/* * 功能: 渲染列表中的对象 * 摘要: - * 参数: - * 返回值: - * 作者: lpf * 创建日期: 2008.10.13 * 修改日志: * 2008.10.21 - lpf * 增加了在渲染特效时,对其进行纹理动画,可见动画,UV流动等等的处理; * 2008.10.23 - lpf * 增加了对坐骑显示的处理; * 2008.10.31 - lpf * 增加了处理渐出效果时,对投影纹理的渐出; * 2008.12.12 - lpf * 取消了渐出时的阴影渲染; * 2008.12.30 - lpf * 增加了对渐出模型列表中,显示模型是否读取完毕的判断,避免由此带来的当机问题; * 2009.04.24 - lpf * 玩家显示时,传入对象指针采用了dynamic_cast形式,检查错误的转换; */ void CAlphaFadeObjectList::Render() { CClientRegion * pRegion = GetGame()->GetRegion(); if (pRegion == NULL) return; for (size_t st = 0; st < m_vecObjectList.size(); ++st) { CShape * pTmp = m_vecObjectList[st]; if (pTmp->GetDisplayModel() == NULL || pTmp->GetDisplayModel()->GetLoadState() != Load_Did) continue; pTmp->GetDisplayModel()->SetDirLightEnable(GetGame()->GetSetup()->lLight>0); pTmp->GetAnimInfo()->SetViewMatrix(pRegion->GetCamera()->GetViewMatrix()); pTmp->GetAnimInfo()->SetProjectedMatrix(pRegion->GetCamera()->GetProjectionMatrix()); switch (pTmp->GetType()) { case TYPE_PLAYER: { CPlayer * pPlayer = (CPlayer *)pTmp; if (pPlayer->IsRide()) pPlayer->GetHorse()->Display(dynamic_cast<CMoveShape *>(pTmp), false); pTmp->GetDisplayModel()->ProcessAnimJoint(pTmp->GetAnimInfo()); pTmp->GetDisplayModel()->ProcessLocator(pTmp->GetAnimInfo()); pTmp->GetDisplayModel()->MultiplyModelAlpha(pTmp->GetAlphaValue()); pTmp->GetDisplayModel()->RenderModelTransparent(); pPlayer->GetLeftHandWeapon()->Display(dynamic_cast<CShape *>(pTmp)); pPlayer->GetRightHandWeapon()->Display(dynamic_cast<CShape *>(pTmp)); pPlayer->GetWing()->Display(dynamic_cast<CShape *>(pTmp)); //RenderShadow(pTmp); //渲染阴影 } break; case TYPE_PET: case TYPE_MONSTER: case TYPE_COLLECTION: { pTmp->GetDisplayModel()->ProcessAnimJoint(pTmp->GetAnimInfo()); pTmp->GetDisplayModel()->ProcessLocator(pTmp->GetAnimInfo()); pTmp->GetDisplayModel()->MultiplyModelAlpha(pTmp->GetAlphaValue()); pTmp->GetDisplayModel()->RenderModelTransparent(); //RenderShadow(pTmp); //渲染阴影 } break; case TYPE_EFFECT: { float fX = pTmp->GetPosX(); float fY = pTmp->GetPosY(); float fH = pTmp->GetHeight(); float fNowDir = pTmp->GetNowDir(); CEffect * pEffect = dynamic_cast<CEffect *>(pTmp); if (pEffect && pEffect->GetHostType() !=0 && pEffect->GetHostID() != CGUID::GUID_INVALID) { CShape * pShape = dynamic_cast<CShape *>(pRegion->FindChildObject(pEffect->GetHostType(), pEffect->GetHostID())); if (pShape) { pShape->GetLocatorPos(pEffect->GetHostLocator(), fX, fY, fH); fNowDir = pShape->GetNowDir(); } } pTmp->GetAnimInfo()->SetupAnimInfo(fX, fY, fH, fNowDir, pRegion->GetCamera()); pTmp->GetAnimInfo()->SetTextureProjectiveAlpha(pTmp->GetAlphaValue()); pTmp->GetDisplayModel()->ProcessAnimJoint(pTmp->GetAnimInfo()); pTmp->GetDisplayModel()->ProcessLocator(pTmp->GetAnimInfo()); pTmp->GetDisplayModel()->ProcessVisibility(pTmp->GetAnimInfo()); pTmp->GetDisplayModel()->ProcessAnimUV(pTmp->GetAnimInfo()); pTmp->GetDisplayModel()->ProcessAnimTexture(pTmp->GetAnimInfo()); pTmp->GetDisplayModel()->ProcessTextureProjective(pTmp->GetAnimInfo()); pTmp->GetDisplayModel()->MultiplyModelAlpha(pTmp->GetAlphaValue()); pTmp->GetDisplayModel()->RenderModelTransparent(); } break; } } }
extern void InverseWarp(CImageOf<T>& src, CImageOf<T>& dst, CFloatImage& disp, float d_scale, float disp_gap, int order) { // Warps src into dst using disparities disp. // Each disparity is scaled by d_scale // Note that "empty" pixels are left at their original value CShape sh = src.Shape(); int w = sh.width, h = sh.height, n_bands = sh.nBands; int n = w * n_bands; if (! sh.SameIgnoringNBands(disp.Shape())) throw CError("InverseWarp: disparity image has wrong size"); if (sh != dst.Shape()) dst.ReAllocate(sh); // Optional forward warped depth map if checking for visibility CFloatImage fwd, fwd_tmp; if (disp_gap > 0.0f) { ScaleAndOffset(disp, fwd_tmp, d_scale, 0.0f); fwd.ReAllocate(disp.Shape()); fwd.FillPixels(-9999.0f); ForwardWarp(fwd_tmp, fwd, disp, d_scale, true, disp_gap); } // Allocate line buffers std::vector<float> src_buf, dst_buf, dsp_buf; src_buf.resize(n); dst_buf.resize(n); dsp_buf.resize(n); CFloatImage fimg; // dummy, used for MinVal(), MaxVal() for (int y = 0; y < h; y++) { // Set up (copy) the line buffers ScaleAndOffsetLine(&src .Pixel(0, y, 0), &src_buf[0], n, 1.0f, 0.0f, fimg.MinVal(), fimg.MaxVal()); ScaleAndOffsetLine(&disp.Pixel(0, y, 0), &dsp_buf[0], w, d_scale, 0.0f, 0.0f, 0.0f); ScaleAndOffsetLine(&dst .Pixel(0, y, 0), &dst_buf[0], n, 1.0f, 0.0f, fimg.MinVal(), fimg.MaxVal()); // Forward warp the depth map float *fwd_buf = (disp_gap > 0.0f) ? &fwd.Pixel(0, y, 0) : 0; // Process (warp) the line InverseWarpLine(&src_buf[0], &dst_buf[0], &dsp_buf[0], w, n_bands, order, fwd_buf, disp_gap); // Convert back to native type T minVal = dst.MinVal(); T maxVal = dst.MaxVal(); float offset = (typeid(T) == typeid(float)) ? 0.0f : 0.5; // rounding if (minVal <= fimg.MinVal() && maxVal >= fimg.MaxVal()) minVal = maxVal = 0; ScaleAndOffsetLine(&dst_buf[0], &dst.Pixel(0, y, 0), n, 1.0f, offset, minVal, maxVal); } }
extern void ForwardWarp(CImageOf<T>& src, CImageOf<T>& dst, CFloatImage& disp, float d_scale, bool line_interpolate, float disp_gap) { // Warps src into dst using disparities disp. // Each disparity is scaled by d_scale // Note that "empty" pixels are left at their original value CShape sh = src.Shape(); int w = sh.width, h = sh.height, n_bands = sh.nBands; float round_offset = (typeid(T) == typeid(float)) ? 0.0f : 0.5f; if (! sh.SameIgnoringNBands(disp.Shape())) throw CError("ForwardWarp: disparity image has wrong size"); if (sh != dst.Shape()) dst.ReAllocate(sh); // Optional clipping (if necessary) CFloatImage flt; T minVal = dst.MinVal(); T maxVal = dst.MaxVal(); if (minVal <= flt.MinVal() && maxVal >= flt.MaxVal()) minVal = maxVal = 0; for (int y = 0; y < h; y++) { // determine correct warping direction int xstart = (d_scale>0 ? 0 : w-1); int xend = (d_scale>0 ? w : -1 ); int xincr = (d_scale>0 ? 1 : -1 ); float *dp = &disp.Pixel(0, y, 0); T *ps = &src .Pixel(0, y, 0); T *pd = &dst .Pixel(0, y, 0); for (int x = xstart; x != xend; x += xincr) { // determine if a line should be drawn int x2 = x + xincr; float d_diff = fabs(dp[x] - dp[x2]); bool draw_line = line_interpolate && (x2 != xend) && (d_diff < disp_gap); // scaled disparity: float d = d_scale * dp[x]; // line drawing if (draw_line) { float d2 = d_scale * dp[x2]; if (xincr > 0) draw_intensity_line(&ps[x * n_bands], &ps[x2 * n_bands], pd, x - d, x2 - d2, w, n_bands, round_offset, minVal, maxVal); else draw_intensity_line(&ps[x2 * n_bands], &ps[x * n_bands], pd, x2 - d, x - d2, w, n_bands, round_offset, minVal, maxVal); continue; } // splatting int xx = x - ROUND(d); if (xx >= 0 && xx < w) memcpy(&pd[xx * n_bands], &ps[x * n_bands], n_bands*sizeof(T)); } } }