void rxScreenTriangle::Initialize() { if( ! vertexLayout ) { vertexLayout = RX_GET_INPUT_LAYOUT( ScreenVertex ); } if( ! vertexBuffer ) { // NOTE: z = 1 (the farthest possible distance) -> optimization for deferred lighting/shading engines: // skybox outputs z = w = 1 -> if we set depth test to less than the sky won't be shaded // const ScreenVertex vertices[VERTEX_COUNT] = { ScreenVertex( Vec4D( -1.0f, -3.0f, 1.0f, 1.0f ), Vec2D( 0.0f, 2.0f ) ), // lower-left ScreenVertex( Vec4D( -1.0f, 1.0f, 1.0f, 1.0f ), Vec2D( 0.0f, 0.0f ) ), // upper-left ScreenVertex( Vec4D( 3.0f, 1.0f, 1.0f, 1.0f ), Vec2D( 2.0f, 0.0f ) ), // upper-right }; vertexBuffer = rxResourceServer::Get().NewVertexBuffer( sizeof( vertices ), sizeof(vertices[0]), vertices ); } }
void CFrustum::buildNoNear(const Matrix& matProjView) { // 求得view * proj的逆矩阵. Matrix mat = matProjView; mat.Invert(); //xyzw = {proj*View}[-1]*{-1,-1,0,1} //xyz = ({proj*View}[-1]*{-1,-1,0,1})/w //取逆 m_vtx[0] = (mat*Vec4D(-1.0f, -1.0f, 0.0f, 1.0f)).xyzDivideByW(); // xyz m_vtx[1] = (mat*Vec4D( 1.0f, -1.0f, 0.0f, 1.0f)).xyzDivideByW(); // Xyz m_vtx[2] = (mat*Vec4D(-1.0f, 1.0f, 0.0f, 1.0f)).xyzDivideByW(); // xYz m_vtx[3] = (mat*Vec4D( 1.0f, 1.0f, 0.0f, 1.0f)).xyzDivideByW(); // XYz m_vtx[4] = (mat*Vec4D(-1.0f, -1.0f, 1.0f, 1.0f)).xyzDivideByW(); // xyZ m_vtx[5] = (mat*Vec4D( 1.0f, -1.0f, 1.0f, 1.0f)).xyzDivideByW(); // XyZ m_vtx[6] = (mat*Vec4D(-1.0f, 1.0f, 1.0f, 1.0f)).xyzDivideByW(); // xYZ m_vtx[7] = (mat*Vec4D( 1.0f, 1.0f, 1.0f, 1.0f)).xyzDivideByW(); // XYZ // 通过得到的世界坐标制作平截头体平面. // 向量由平截头体内部指向外部的平面. m_planes.resize(5); m_planes[0]=Plane(m_vtx[6], m_vtx[7], m_vtx[5]); // Far m_planes[1]=Plane(m_vtx[2], m_vtx[6], m_vtx[4]); // Left m_planes[2]=Plane(m_vtx[7], m_vtx[3], m_vtx[5]); // Right m_planes[3]=Plane(m_vtx[2], m_vtx[3], m_vtx[6]); // Top m_planes[4]=Plane(m_vtx[1], m_vtx[0], m_vtx[4]); // Bottom }
void ModelCanvas::RenderADT() { if (!init) InitGL(); InitView(); // From what I can tell, WoW OpenGL only uses 4 g_modelViewer->lightControl->lights for (int i=0; i<4; i++) { GLuint light = GL_LIGHT0 + i; glLightf(light, GL_CONSTANT_ATTENUATION, 0.0f); glLightf(light, GL_LINEAR_ATTENUATION, 0.7f); glLightf(light, GL_QUADRATIC_ATTENUATION, 0.03f); glDisable(light); } glLightModelfv(GL_LIGHT_MODEL_AMBIENT, Vec4D(0.35f, 0.35f, 0.35f, 1.0f)); glColor3f(1.0f, 1.0f, 1.0f); glEnable(GL_TEXTURE_2D); glEnable(GL_DEPTH_TEST); glDisable(GL_CULL_FACE); root->draw(this); //root->drawParticles(true); }
void WMOLight::init(MPQFile* f) { char type[4]; f->read(&type, 4); f->read(&color, 4); f->read(pos, 12); f->read(&intensity, 4); f->read(unk, 4 * 5); f->read(&r, 4); pos = Vec3D(pos.x, pos.z, -pos.y); // rgb? bgr? hm float fa = ((color & 0xff000000) >> 24) / 255.0f; float fr = ((color & 0x00ff0000) >> 16) / 255.0f; float fg = ((color & 0x0000ff00) >> 8) / 255.0f; float fb = ((color & 0x000000ff)) / 255.0f; fcolor = Vec4D(fr, fg, fb, fa); fcolor *= intensity; fcolor.w = 1.0f; /* // light logging gLog("Light %08x @ (%4.2f,%4.2f,%4.2f)\t %4.2f, %4.2f, %4.2f, %4.2f, %4.2f, %4.2f, %4.2f\t(%d,%d,%d,%d)\n", color, pos.x, pos.y, pos.z, intensity, unk[0], unk[1], unk[2], unk[3], unk[4], r, type[0], type[1], type[2], type[3]); */ }
void WMOLight::setupOnce(GLint light, Vec3D dir, Vec3D lcol) { Vec4D position(dir, 0); //Vec4D position(0,1,0,0); Vec4D ambient = Vec4D(lcol * 0.3f, 1); //Vec4D ambient = Vec4D(0.101961f, 0.062776f, 0, 1); Vec4D diffuse = Vec4D(lcol, 1); //Vec4D diffuse = Vec4D(0.439216f, 0.266667f, 0, 1); glLightfv(light, GL_AMBIENT, ambient); glLightfv(light, GL_DIFFUSE, diffuse); glLightfv(light, GL_POSITION, position); glEnable(light); }
void ParticleSystem::init(const MPQFile& f, const ModelParticleEmitterDef &mta, int *globals) { speed.init(mta.EmissionSpeed, f, globals); variation.init(mta.SpeedVariation, f, globals); spread.init(mta.VerticalRange, f, globals); lat.init(mta.HorizontalRange, f, globals); gravity.init(mta.Gravity, f, globals); lifespan.init(mta.Lifespan, f, globals); rate.init(mta.EmissionRate, f, globals); areal.init(mta.EmissionAreaLength, f, globals); areaw.init(mta.EmissionAreaWidth, f, globals); deacceleration.init(mta.Gravity2, f, globals); enabled.init(mta.en, f, globals); Vec3D colors2[3]; memcpy(colors2, f.getBuffer() + mta.p.colors.ofsKeys, sizeof(Vec3D) * 3); for (size_t i = 0; i<3; ++i) { float opacity = *reinterpret_cast<int16_t*>(f.getBuffer() + mta.p.opacity.ofsKeys + i * 2); colors[i] = Vec4D(colors2[i].x / 255.0f, colors2[i].y / 255.0f, colors2[i].z / 255.0f, opacity / 32767.0f); sizes[i] = (*reinterpret_cast<float*>(f.getBuffer() + mta.p.sizes.ofsKeys + i * 4))*mta.p.scales[i]; } mid = 0.5; slowdown = mta.p.slowdown; rotation = mta.p.rotation; pos = fixCoordSystem(mta.pos); _texture = model->_textures[mta.texture]; blend = mta.blend; rows = mta.rows; cols = mta.cols; type = mta.ParticleType; //order = mta.s2; order = mta.ParticleType>0 ? -1 : 0; parent = model->bones + mta.bone; switch (mta.EmitterType) { case 1: emitter = new PlaneParticleEmitter(this); break; case 2: emitter = new SphereParticleEmitter(this); break; } //transform = mta.flags & 1024; billboard = !(mta.flags & 4096); manim = mtime = 0; rem = 0; tofs = misc::frand(); // init tiles for (int i = 0; i<rows*cols; ++i) { TexCoordSet tc; initTile(tc.tc, i); tiles.push_back(tc); } }
Vec4D fromARGB(uint32_t color) { const float a = ((color & 0xFF000000) >> 24) / 255.0f; const float r = ((color & 0x00FF0000) >> 16) / 255.0f; const float g = ((color & 0x0000FF00) >> 8) / 255.0f; const float b = ((color & 0x000000FF)) / 255.0f; return Vec4D(r, g, b, a); }
void ModelLight::setup(int time, GLuint l) { Vec4D ambcol(ambColor.getValue(0, time) * ambIntensity.getValue(0, time), 1.0f); Vec4D diffcol(diffColor.getValue(0, time) * diffIntensity.getValue(0, time), 1.0f); Vec4D p; if (type==0) { // directional p = Vec4D(tdir, 0.0f); } else { // point p = Vec4D(tpos, 1.0f); } //gLog("Light %d (%f,%f,%f) (%f,%f,%f) [%f,%f,%f]\n", l-GL_LIGHT4, ambcol.x, ambcol.y, ambcol.z, diffcol.x, diffcol.y, diffcol.z, p.x, p.y, p.z); glLightfv(l, GL_POSITION, p); glLightfv(l, GL_DIFFUSE, diffcol); glLightfv(l, GL_AMBIENT, ambcol); glEnable(l); }
void WMOUnhighlight() { glEnable(GL_ALPHA_TEST); glDisable(GL_BLEND); glEnable(GL_CULL_FACE); glActiveTexture(GL_TEXTURE0); glEnable(GL_TEXTURE_2D); glColor4fv(Vec4D(1, 1, 1, 1)); glDepthMask(GL_TRUE); }
Term *TVec4D(const Term &t0,const Term &t1, const Term &t2,const Term &t3) { if (t0.Type()=='V' || t0.Type()=='C' || t0.Type()=='S' || t1.Type()=='V' || t1.Type()=='C' || t1.Type()=='S' || t2.Type()=='V' || t2.Type()=='C' || t2.Type()=='S' || t3.Type()=='V' || t3.Type()=='C' || t3.Type()=='S') THROW(fatal_error,"Invalid syntax"); return DV4Term::New(Vec4D(t0.Get<double>(),t1.Get<double>(), t2.Get<double>(),t3.Get<double>())); }
void ModelLight::setup(size_t time, GLuint l) { Vec4D ambcol(ambColor.getValue(0, time) * ambIntensity.getValue(0, time), 1.0f); Vec4D diffcol(diffColor.getValue(0, time) * diffIntensity.getValue(0, time), 1.0f); Vec4D p; if (type==MODELLIGHT_DIRECTIONAL) { // directional p = Vec4D(tdir, 0.0f); } else if (type==MODELLIGHT_POINT) { // point p = Vec4D(tpos, 1.0f); } else { p = Vec4D(tpos, 1.0f); wxLogMessage(wxT("Error: Light type %d is unknown."), type); } //gLog("Light %d (%f,%f,%f) (%f,%f,%f) [%f,%f,%f]\n", l-GL_LIGHT4, ambcol.x, ambcol.y, ambcol.z, diffcol.x, diffcol.y, diffcol.z, p.x, p.y, p.z); glLightfv(l, GL_POSITION, p); glLightfv(l, GL_DIFFUSE, diffcol); glLightfv(l, GL_AMBIENT, ambcol); glEnable(l); }
void RibbonEmitter::setup(int anim, int time) { Vec3D ntpos = parent->mat * pos; Vec3D ntup = parent->mat * (pos + Vec3D(0, 0, 1)); ntup -= ntpos; ntup.normalize(); float dlen = (ntpos - tpos).length(); manim = anim; mtime = time; // move first segment RibbonSegment &first = *segs.begin(); if (first.len > seglen) { // add new segment first.back = (tpos - ntpos).normalize(); first.len0 = first.len; RibbonSegment newseg; newseg.pos = ntpos; newseg.up = ntup; newseg.len = dlen; segs.push_front(newseg); } else { first.up = ntup; first.pos = ntpos; first.len += dlen; } // kill stuff from the end float l = 0; bool erasemode = false; for (std::list<RibbonSegment>::iterator it = segs.begin(); it != segs.end();) { if (!erasemode) { l += it->len; if (l > length) { it->len = l - length; erasemode = true; } } else { segs.erase(it); } ++it; } tpos = ntpos; tcolor = Vec4D(color.getValue(anim, time), opacity.getValue(anim, time)); tabove = above.getValue(anim, time); tbelow = below.getValue(anim, time); }
void CRenderSystem::world2Screen(const Vec3D& vWorldPos, Pos2D& posScreen) { Matrix mProj; Matrix View; getProjectionMatrix(mProj); getViewMatrix(View); Vec4D vOut = mProj*View*Vec4D(vWorldPos,1); float fW = vOut.w; CRect<int> rc; getViewport(rc); posScreen.x = int(rc.left+(rc.right-rc.left)*(0.5f+vOut.x*0.5f/fW)); posScreen.y = int(rc.top+(rc.bottom-rc.top)*(0.5f-vOut.y*0.5f/fW)); }
ATOOLS::Vec4D_Vector Combine (const Cluster_Amplitude &l,int i,int j,int k,const ATOOLS::Flavour &mo) { Mass_Selector *p_ms=ampl.MS(); if (i>j) std::swap<int>(i,j); Vec4D_Vector after(ampl.Legs().size()-1); double mb2(0.0); if (i<2) { mb2=ampl.Leg(1-i)->Mom().Abs2(); double mfb2(p_ms->Mass2(ampl.Leg(1-i)->Flav())); if ((mfb2==0.0 && IsZero(mb2,1.0e-6)) || IsEqual(mb2,mfb2,1.0e-6)) mb2=mfb2; } Vec4D pi(ampl.Leg(i)->Mom()), pj(ampl.Leg(j)->Mom()); Vec4D pk(ampl.Leg(k)->Mom()), pb(i<2?ampl.Leg(1-i)->Mom():Vec4D()); double mi2=pi.Abs2(), mfi2=p_ms->Mass2(ampl.Leg(i)->Flav()); double mj2=pj.Abs2(), mfj2=p_ms->Mass2(ampl.Leg(j)->Flav()); double mk2=pk.Abs2(), mfk2=p_ms->Mass2(ampl.Leg(k)->Flav()); if ((mfi2==0.0 && IsZero(mi2,1.0e-6)) || IsEqual(mi2,mfi2,1.0e-6)) mi2=mfi2; if ((mfj2==0.0 && IsZero(mj2,1.0e-6)) || IsEqual(mj2,mfj2,1.0e-6)) mj2=mfj2; if ((mfk2==0.0 && IsZero(mk2,1.0e-6)) || IsEqual(mk2,mfk2,1.0e-6)) mk2=mfk2; double mij2=p_ms->Mass2(mo); Kin_Args lt; if (i>1) { if (k>1) lt=ClusterFFDipole(mi2,mj2,mij2,mk2,pi,pj,pk,2); else lt=ClusterFIDipole(mi2,mj2,mij2,mk2,pi,pj,-pk,2); if ((k==0 && lt.m_pk[3]<0.0) || (k==1 && lt.m_pk[3]>0.0) || lt.m_pk[0]<0.0) return Vec4D_Vector(); } else { if (k>1) { lt=ClusterIFDipole(mi2,mj2,mij2,mk2,mb2,-pi,pj,pk,-pb,2); } else lt=ClusterIIDipole(mi2,mj2,mij2,mk2,-pi,pj,-pk,2); if ((i==0 && lt.m_pi[3]<0.0) || (i==1 && lt.m_pi[3]>0.0) || lt.m_pi[0]<0.0) return Vec4D_Vector(); } if (lt.m_stat<0) return Vec4D_Vector(); for (size_t l(0), m(0);m<ampl.Legs().size();++m) { if (m==(size_t)j) continue; if (m==(size_t)i) after[l]=i>1?lt.m_pi:-lt.m_pi; else if (m==(size_t)k) after[l]=k>1?lt.m_pk:-lt.m_pk; else after[l]=lt.m_lam*ampl.Leg(m)->Mom(); ++l; } return after; }
void InitialiseGenerator(int argc, char *argv[]) { if(argc<2) { cout<<"Usage: ./SingleDecay <PDG_CODE>"<<endl; THROW(normal_exit,"you didn't specify the decaying particle by PDG code."); } small_sherpa_init(argc, argv); hadrons = new SHERPA::Hadron_Decay_Handler(".", "Fragmentation.dat"); Data_Reader * reader = new Data_Reader(" ",";","!","="); reader->AddWordSeparator("\t"); reader->SetInputPath("./"); reader->SetInputFile("YFS.dat"); photons = new PHOTONS::Photons(reader,true); mother_flav = Flavour( (kf_code) abs(ToType<int>(argv[1])) ); mother_flav.SetStable(false); if(ToType<int>(argv[1])<0) mother_flav=mother_flav.Bar(); rpa->gen.SetEcms(mother_flav.HadMass()); msg_Info()<<"Welcome. I am decaying a "<<mother_flav<<endl; Particle* mother_part = new Particle( 1,mother_flav, Vec4D(mother_flav.HadMass(),0.,0.,0.) ); mother_part->SetTime(); mother_part->SetFinalMass(mother_flav.HadMass()); ref_blob = new Blob(); ref_blob->SetType(btp::Hadron_Decay); ref_blob->SetStatus(blob_status::needs_hadrondecays); ref_blob->AddToInParticles(mother_part); try { hadrons->FillOnshellDecay(ref_blob, NULL); } catch (Return_Value::code ret) { msg_Error()<<METHOD<<" Something went wrong for blob: "<<ref_blob<<endl; return; } }
Blob_List* GenerateEvent() { Blob_List* blobs = new Blob_List(); Particle* mother_part = new Particle( 1,mother_flav,Vec4D(mother_flav.HadMass(),0.,0.,0.) ); mother_part->SetTime(); mother_part->SetFinalMass(mother_flav.HadMass()); Blob* blob = blobs->AddBlob(btp::Hadron_Decay); blob->SetStatus(blob_status::needs_hadrondecays); blob->AddToInParticles(mother_part); try { hadrons->FillOnshellDecay(blob, NULL); } catch (Return_Value::code ret) { msg_Error()<<METHOD<<" Something went wrong for event: "<<*blobs <<endl; return blobs; } hadrons->CleanUp(); msg_Events()<<*blobs<<std::endl; return blobs; }
void ModelControl::Update() { if (!model) return; // Loop through all the views. cbLod->Clear(); if (model->header.nViews == 1) { cbLod->Append(wxT("1 (Only View)")); } else if (model->header.nViews == 2) { cbLod->Append(wxT("1 (Worst)")); cbLod->Append(wxT("2 (Best)")); } else { cbLod->Append(wxT("1 (Worst)")); for (size_t i=1; i<(model->header.nViews-1); i++) { cbLod->Append(wxString::Format(wxT("%i"), i+1)); } cbLod->Append(wxString::Format(wxT("%i (Best)"), model->header.nViews)); } cbLod->SetSelection(0); // Loop through all the geosets. wxArrayString geosetItems; //geosets->Clear(); // enum CharGeosets wxString meshes[NUM_GEOSETS] = { wxT("Main"), wxT("Facial1"), wxT("Facial2"), wxT("Facial3"), wxT("Braces"), wxT("Boots"), wxT("Tail"), wxT("Ears"), wxT("Wristbands"), wxT("Kneepads"), wxT("Pants"), wxT("Pants2"), wxT("Tabard"), wxT("Trousers"), wxT("Tabard2"), wxT("Cape"), wxT("Feet"), wxT("Eyeglows"), wxT("Belt"), wxT("Tail"), wxT("Feet") }; std::map <size_t,wxTreeItemId> geosetGroupsMap; clbGeosets->DeleteAllItems(); clbGeosets->SetWindowStyle(wxTR_HIDE_ROOT); wxTreeItemId root = clbGeosets->AddRoot("Model Geosets"); for (size_t i=0; i<model->geosets.size(); i++) { /* size_t mesh = model->geosets[i].id / 100; if (mesh < WXSIZEOF(meshes) && meshes[mesh] != wxEmptyString) geosetItems.Add(wxString::Format(wxT("%i [%s, %i, %i]"), i, meshes[mesh].c_str(), model->geosets[i].id % 100, model->geosets[i].id), 1); else geosetItems.Add(wxString::Format(wxT("%i [%i, %i, %i]"), i, mesh, (model->geosets[i].id % 100), model->geosets[i].id ), 1); */ size_t mesh = model->geosets[i].id / 100; if(geosetGroupsMap.find(mesh) == geosetGroupsMap.end()) { if (mesh < WXSIZEOF(meshes) && meshes[mesh] != wxEmptyString) geosetGroupsMap[mesh] = clbGeosets->AppendItem(root, meshes[mesh]); else geosetGroupsMap[mesh] = clbGeosets->AppendItem(root, wxString::Format(wxT("%i"),mesh)); } GeosetTreeItemData * data = new GeosetTreeItemData(); data->geosetId = i; wxTreeItemId item = clbGeosets->AppendItem(geosetGroupsMap[mesh], wxString::Format(wxT("%i [%i, %i, %i]"), i, mesh, (model->geosets[i].id % 100), model->geosets[i].id ),-1,-1,data); if (model->showGeosets[i] == true) clbGeosets->SetItemBackgroundColour(item, *wxGREEN); } //for (size_t i=0; i<model->geosets.size(); i++) // clbGeosets->Check((unsigned int)i, model->showGeosets[i]); bones->SetValue(model->showBones); box->SetValue(model->showBounds); render->SetValue(model->showModel); wireframe->SetValue(model->showWireframe); particles->SetValue(model->showParticles); texture->SetValue(model->showTexture); alpha->SetValue(int(model->alpha * 100)); scale->SetValue(att->scale*100); txtX->SetValue(wxString::Format(wxT("%f"), model->pos.x)); txtY->SetValue(wxString::Format(wxT("%f"), model->pos.y)); txtZ->SetValue(wxString::Format(wxT("%f"), model->pos.z)); rotX->SetValue(wxString::Format(wxT("%f"), model->rot.x)); rotY->SetValue(wxString::Format(wxT("%f"), model->rot.y)); rotZ->SetValue(wxString::Format(wxT("%f"), model->rot.z)); txtsize->SetValue(wxString::Format(wxT("%.2f"), att->scale)); if (modelPCRSaves.find(model->modelname) != modelPCRSaves.end()) { pcr = modelPCRSaves[model->modelname]; } else { pcr.clear(); particleColorSet cols11, cols12, cols13; cols11 = { Vec4D(0.0, 0.0, 0.0, 1.0), Vec4D(0.0, 0.0, 0.0, 1.0), Vec4D(0.0, 0.0, 0.0, 1.0) }; cols12 = { Vec4D(0.0, 0.0, 0.0, 1.0), Vec4D(0.0, 0.0, 0.0, 1.0), Vec4D(0.0, 0.0, 0.0, 1.0) }; cols13 = { Vec4D(0.0, 0.0, 0.0, 1.0), Vec4D(0.0, 0.0, 0.0, 1.0), Vec4D(0.0, 0.0, 0.0, 1.0) }; pcr = { cols11, cols12, cols13 }; } particlecolreplace->SetValue(false); PC11S->SetColour(wxColour(pcr[0][0][0]*255, pcr[0][0][1]*255, pcr[0][0][2]*255)); PC11M->SetColour(wxColour(pcr[0][1][0]*255, pcr[0][1][1]*255, pcr[0][1][2]*255)); PC11E->SetColour(wxColour(pcr[0][2][0]*255, pcr[0][2][1]*255, pcr[0][2][2]*255)); PC12S->SetColour(wxColour(pcr[1][0][0]*255, pcr[1][0][1]*255, pcr[1][0][2]*255)); PC12M->SetColour(wxColour(pcr[1][1][0]*255, pcr[1][1][1]*255, pcr[1][1][2]*255)); PC12E->SetColour(wxColour(pcr[1][2][0]*255, pcr[1][2][1]*255, pcr[1][2][2]*255)); PC13S->SetColour(wxColour(pcr[2][0][0]*255, pcr[2][0][1]*255, pcr[2][0][2]*255)); PC13M->SetColour(wxColour(pcr[2][1][0]*255, pcr[2][1][1]*255, pcr[2][1][2]*255)); PC13E->SetColour(wxColour(pcr[2][2][0]*255, pcr[2][2][1]*255, pcr[2][2][2]*255)); UpdatePCRTexts(); TogglePCRFields(); }
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /// Negation inline Vec4D operator - ( const Vec4D& v ) { return Vec4D( -v.r0, -v.r ); }
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /// Operator * for right scalar division inline Vec4D operator / ( const Vec4D& v, VEC3D_T a ) { return Vec4D( v.r0/a, v.r/a ); }
Vec4D Vec4D::operator-(void) const { return Vec4D(-coord[0],-coord[1],-coord[2],-coord[3]); }
void AnalyseEvent(Blob_List* blobs) { #ifdef USING__ROOT // int outgoing = 1; // int incoming = -1; // Particle_List outparts = blobs->ExtractParticles(part_status::active, outgoing); /////////////////////////////////////////////////////////////////////////////////// // analyse primary decay blob, ignore subsequent decays // /////////////////////////////////////////////////////////////////////////////////// Blob * primarydecayblob = blobs->FindFirst(btp::Hadron_Decay); // msg_Out()<<"primary decay blob:"<<endl<<*primarydecayblob<<endl; // photon multiplicity and decay frame radiated energy (total) unsigned int photmult = 0; double photener = 0.; for (int i=0; i<primarydecayblob->NOutP(); i++) { if ((primarydecayblob->OutParticle(i)->Flav().IsPhoton() == true) && (primarydecayblob->OutParticle(i)->Info() == 'S')) { photmult++; photener = photener + primarydecayblob->OutParticle(i)->Momentum()[0]; } } photonmultiplicity->Fill(photmult); if (photener != 0.) decayframeenergy->Fill(photener); // multipole rest frame angles Vec4D multipolesum = Vec4D(0.,0.,0.,0.); Vec4D axis = Vec4D(0.,0.,0.,1.); std::list<Vec4D> multipole; std::list<Vec4D> newphot; for (int i=0; i<primarydecayblob->NOutP(); i++) { if (primarydecayblob->OutParticle(i)->Flav().Charge() != 0.) { multipolesum = multipolesum + primarydecayblob->OutParticle(i)->Momentum(); multipole.push_back(primarydecayblob->OutParticle(i)->Momentum()); } } if (primarydecayblob->InParticle(0)->Flav().Charge() != 0) { multipolesum = multipolesum + primarydecayblob->InParticle(0)->Momentum(); multipole.push_front(primarydecayblob->InParticle(0)->Momentum()); } Poincare boost(multipolesum); Poincare rotate; // charged initial state: rotate such that initial state at theta = 0 if (mother_flav.Charge() != 0.) { Vec4D inmom = *multipole.begin(); boost.Boost(inmom); rotate = Poincare(inmom,axis); } // neutral initial state: rotate such that heaviest charged final state at theta = 0 else { std::list<Vec4D>::iterator heaviest = multipole.begin(); for (std::list<Vec4D>::iterator iter=multipole.begin(); iter!=multipole.end(); iter++) { if (abs((iter->Abs2() - heaviest->Abs2())/(iter->Abs2() + heaviest->Abs2())) > 1E-6) { heaviest = iter; } } boost.Boost(*heaviest); rotate = Poincare(*heaviest,axis); } for (int i=0; i<primarydecayblob->NOutP(); i++) { if (primarydecayblob->OutParticle(i)->Flav().IsPhoton() == true) { Vec4D mom = primarydecayblob->OutParticle(i)->Momentum(); boost.Boost(mom); rotate.Rotate(mom); double theta = acos((Vec3D(mom)*Vec3D(axis))/(Vec3D(mom).Abs()*Vec3D(axis).Abs())); multipoleframeangles->Fill(theta); } } /////////////////////////////////////////////////////////////////////////////////// // inclusive analysis of whole decay chain // /////////////////////////////////////////////////////////////////////////////////// // to be done .. #endif }
bool OBJExporter::exportModelMaterials(WoWModel * model, QTextStream & file, QString mtlFile) const { std::map<std::string, std::string> texToExport; for (size_t i=0; i<model->passes.size(); i++) { ModelRenderPass &p = model->passes[i]; if (p.init(model)) { QString tex = model->TextureList[p.tex]->fullname(); QString texfile = QFileInfo(tex).completeBaseName(); tex = QFileInfo(mtlFile).completeBaseName() + "_" + texfile + ".png"; float amb = 0.25f; Vec4D diff = p.ocol; QString val; val.sprintf("Geoset_%03i",p.geoset); QString material = QString(model->modelname.c_str()) + "_" + val; material.replace("\\","_"); if (p.unlit == true) { // Add Lum, just in case there's a non-luminous surface with the same name. material = material + "_Lum"; amb = 1.0f; diff = Vec4D(0,0,0,0); } // If Doublesided if (!p.cull) { material = material + "_Dbl"; } file << "newmtl " << material << "\n"; file << "illum 2" << "\n"; val.sprintf("Kd %.06f %.06f %.06f", diff.x, diff.y, diff.z); file << val << "\n"; val.sprintf("Ka %.06f %.06f %.06f", amb, amb, amb); file << val << "\n"; val.sprintf("Ks %.06f %.06f %.06f", p.ecol.x, p.ecol.y, p.ecol.z); file << val << "\n"; file << "Ke 0.000000 0.000000 0.000000" << "\n"; val.sprintf("Ns %0.6f", 0.0f); file << val << "\n"; file << "map_Kd " << tex << "\n"; tex = QFileInfo(mtlFile).absolutePath() + "\\" + tex; texToExport[tex.toStdString()] = model->TextureList[p.tex]->fullname().toStdString(); } } LOG_INFO << "nb textures to export :" << texToExport.size(); for(std::map<std::string, std::string>::iterator it = texToExport.begin(); it != texToExport.end(); ++it) { if(it->second.find("Body") != std::string::npos) { exportGLTexture(model->replaceTextures[TEXTURE_BODY], it->first); } else { GLuint texID = texturemanager.get(it->second.c_str()); exportGLTexture(texID, it->first); } } return true; }
bool ModelRenderPass::init(Model *m) { // May aswell check that we're going to render the geoset before doing all this crap. if (m->showGeosets[geoset]) { // COLOUR // Get the colour and transparency and check that we should even render ocol = Vec4D(1.0f, 1.0f, 1.0f, m->trans); ecol = Vec4D(0.0f, 0.0f, 0.0f, 0.0f); //if (m->trans == 1.0f) // return false; // emissive colors if (color!=-1 && m->colors[color].color.uses(0)) { Vec3D c = m->colors[color].color.getValue(0,m->animtime); if (m->colors[color].opacity.uses(m->anim)) { float o = m->colors[color].opacity.getValue(m->anim,m->animtime); ocol.w = o; } if (unlit) { ocol.x = c.x; ocol.y = c.y; ocol.z = c.z; } else { ocol.x = ocol.y = ocol.z = 0; } ecol = Vec4D(c, ocol.w); glMaterialfv(GL_FRONT, GL_EMISSION, ecol); } // opacity if (opacity!=-1) { if (m->transparency[opacity].trans.uses(0)) ocol.w *= m->transparency[opacity].trans.getValue(0, m->animtime); } // exit and return false before affecting the opengl render state if (!((ocol.w > 0) && (color==-1 || ecol.w > 0))) return false; // TEXTURE // bind to our texture GLuint bindtex = 0; if (m->specialTextures[tex]==-1) bindtex = m->textures[tex]; else bindtex = m->replaceTextures[m->specialTextures[tex]]; glBindTexture(GL_TEXTURE_2D, bindtex); // -- // TODO: Add proper support for multi-texturing. // blend mode switch (blendmode) { case BM_OPAQUE: // 0 break; case BM_TRANSPARENT: // 1 glEnable(GL_ALPHA_TEST); glAlphaFunc(GL_GEQUAL,0.7f); break; case BM_ALPHA_BLEND: // 2 glEnable(GL_BLEND); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); break; case BM_ADDITIVE: // 3 glEnable(GL_BLEND); glBlendFunc(GL_SRC_COLOR, GL_ONE); break; case BM_ADDITIVE_ALPHA: // 4 glEnable(GL_BLEND); glBlendFunc(GL_SRC_ALPHA, GL_ONE); break; case BM_MODULATE: // 5 glEnable(GL_BLEND); glBlendFunc(GL_DST_COLOR, GL_SRC_COLOR); break; case BM_MODULATE2: // 6 glEnable(GL_BLEND); glBlendFunc(GL_DST_COLOR,GL_SRC_COLOR); break; default: gLog("Error: Unknown blendmode: %d\n", blendmode); glEnable(GL_BLEND); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); } //if (cull) // glEnable(GL_CULL_FACE); // Texture wrapping around the geometry if (swrap) glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_WRAP_S,GL_REPEAT); if (twrap) glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_WRAP_T,GL_REPEAT); // no writing to the depth buffer. if (noZWrite) glDepthMask(GL_FALSE); if (unlit) { glDisable(GL_LIGHTING); // unfogged = unlit? glDisable(GL_FOG); } // Environmental mapping, material, and effects if (useEnvMap) { // Turn on the 'reflection' shine, using 18.0f as that is what WoW uses based on the reverse engineering // This is now set in InitGL(); - no need to call it every render. glMaterialf(GL_FRONT_AND_BACK, GL_SHININESS, 18.0f); // env mapping glEnable(GL_TEXTURE_GEN_S); glEnable(GL_TEXTURE_GEN_T); const GLint maptype = GL_SPHERE_MAP; //const GLint maptype = GL_REFLECTION_MAP_ARB; glTexGeni(GL_S, GL_TEXTURE_GEN_MODE, maptype); glTexGeni(GL_T, GL_TEXTURE_GEN_MODE, maptype); } if (texanim!=-1) { glMatrixMode(GL_TEXTURE); glPushMatrix(); m->texAnims[texanim].setup(texanim); } // color glColor4fv(ocol); //glMaterialfv(GL_FRONT, GL_SPECULAR, ocol); // don't use lighting on the surface if (unlit) glDisable(GL_LIGHTING); if (blendmode<=1 && ocol.w<1.0f) glEnable(GL_BLEND); return true; } return false; }
void WMO::draw(int doodadset, const Vec3D &ofs, const float rot, bool boundingbox, bool groupboxes, bool /*highlight*/) const { if (gWorld && gWorld->drawfog) glEnable(GL_FOG); else glDisable(GL_FOG); for (unsigned int i = 0; i<nGroups; ++i) { groups[i].draw(ofs, rot, false); if (gWorld->drawdoodads) { groups[i].drawDoodads(doodadset, ofs, rot); } groups[i].drawLiquid(); } if (boundingbox) { glDisable(GL_LIGHTING); glDisable(GL_COLOR_MATERIAL); glActiveTexture(GL_TEXTURE0); glDisable(GL_TEXTURE_2D); glActiveTexture(GL_TEXTURE1); glDisable(GL_TEXTURE_2D); glEnable(GL_BLEND); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); for (unsigned int i = 0; i < nGroups; ++i) DrawABox(groups[i].BoundingBoxMin, groups[i].BoundingBoxMax, Vec4D(1.0f, 1.0f, 1.0f, 1.0f), 1.0f); DrawABox(Vec3D(extents[0].x, extents[0].z, -extents[0].y), Vec3D(extents[1].x, extents[1].z, -extents[1].y), Vec4D(1.0f, 0.0f, 0.0f, 1.0f), 2.0f); /*glColor4fv( Vec4D( 1.0f, 0.0f, 0.0f, 1.0f ) ); glBegin( GL_LINES ); glVertex3f( 0.0f, 0.0f, 0.0f ); glVertex3f( this->header.BoundingBoxMax.x + header.BoundingBoxMax.x / 5.0f, 0.0f, 0.0f ); glEnd(); glColor4fv( Vec4D( 0.0f, 1.0f, 0.0f, 1.0f ) ); glBegin( GL_LINES ); glVertex3f( 0.0f, 0.0f, 0.0f ); glVertex3f( 0.0f, header.BoundingBoxMax.z + header.BoundingBoxMax.z / 5.0f, 0.0f ); glEnd(); glColor4fv( Vec4D( 0.0f, 0.0f, 1.0f, 1.0f ) ); glBegin( GL_LINES ); glVertex3f( 0.0f, 0.0f, 0.0f ); glVertex3f( 0.0f, 0.0f, header.BoundingBoxMax.y + header.BoundingBoxMax.y / 5.0f ); glEnd();*/ glActiveTexture(GL_TEXTURE1); glDisable(GL_TEXTURE_2D); glActiveTexture(GL_TEXTURE0); glEnable(GL_TEXTURE_2D); glEnable(GL_LIGHTING); } /* { // draw boundingboxe and axis // Turn light off and highlight the following glDisable(GL_LIGHTING); glDisable(GL_COLOR_MATERIAL); glActiveTexture(GL_TEXTURE0); glDisable(GL_TEXTURE_2D); glActiveTexture(GL_TEXTURE1); glDisable(GL_TEXTURE_2D); glEnable(GL_BLEND); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glEnable (GL_LINE_SMOOTH); glLineWidth(1.0); glHint (GL_LINE_SMOOTH_HINT, GL_NICEST); glColor4f( 1, 1, 1, 1 ); glLineWidth(1.0); glHint (GL_LINE_SMOOTH_HINT, GL_NICEST); for (int i=0; i<nGroups; ++i) { WMOGroup &header = groups[i]; /// Bounding box glColor4f( 1, 1, 1, 1 ); glBegin( GL_LINE_STRIP ); glVertex3f( header.BoundingBoxMin.x, header.BoundingBoxMax.y, header.BoundingBoxMin.z ); glVertex3f( header.BoundingBoxMin.x, header.BoundingBoxMin.y, header.BoundingBoxMin.z ); glVertex3f( header.BoundingBoxMax.x, header.BoundingBoxMin.y, header.BoundingBoxMin.z ); glVertex3f( header.BoundingBoxMax.x, header.BoundingBoxMin.y, header.BoundingBoxMax.z ); glVertex3f( header.BoundingBoxMax.x, header.BoundingBoxMax.y, header.BoundingBoxMax.z ); glVertex3f( header.BoundingBoxMax.x, header.BoundingBoxMax.y, header.BoundingBoxMin.z ); glVertex3f( header.BoundingBoxMin.x, header.BoundingBoxMax.y, header.BoundingBoxMin.z ); glVertex3f( header.BoundingBoxMin.x, header.BoundingBoxMax.y, header.BoundingBoxMax.z ); glVertex3f( header.BoundingBoxMin.x, header.BoundingBoxMin.y, header.BoundingBoxMax.z ); glVertex3f( header.BoundingBoxMin.x, header.BoundingBoxMin.y, header.BoundingBoxMin.z ); glEnd(); glBegin( GL_LINES ); glVertex3f( header.BoundingBoxMin.x, header.BoundingBoxMin.y, header.BoundingBoxMax.z ); glVertex3f( header.BoundingBoxMax.x, header.BoundingBoxMin.y, header.BoundingBoxMax.z ); glEnd(); glBegin( GL_LINES ); glVertex3f( header.BoundingBoxMax.x, header.BoundingBoxMax.y, header.BoundingBoxMin.z ); glVertex3f( header.BoundingBoxMax.x, header.BoundingBoxMin.y, header.BoundingBoxMin.z ); glEnd(); glBegin( GL_LINES ); glVertex3f( header.BoundingBoxMin.x, header.BoundingBoxMax.y, header.BoundingBoxMax.z ); glVertex3f( header.BoundingBoxMax.x, header.BoundingBoxMax.y, header.BoundingBoxMax.z ); glEnd(); // draw axis glColor4fv( Vec4D( 1, 0, 0, 1 ) ); glBegin( GL_LINES ); glVertex3f( 0, 0, 0 ); glVertex3f( header.BoundingBoxMax.x + 6, 0, 0 ); glEnd(); glColor4fv( Vec4D( 0, 1, 0, 1 ) ); glBegin( GL_LINES ); glVertex3f( 0, 0, 0 ); glVertex3f( 0, header.BoundingBoxMax.y + 6, 0 ); glEnd(); glColor4fv( Vec4D( 0, 0, 1, 1 ) ); glBegin( GL_LINES ); glVertex3f( 0, 0, 0 ); glVertex3f( 0, 0, header.BoundingBoxMax.x + 6 ); glEnd(); } // Back to normal light rendering glActiveTexture(GL_TEXTURE1); glDisable(GL_TEXTURE_2D); glActiveTexture(GL_TEXTURE0); glEnable(GL_TEXTURE_2D); glEnable(GL_LIGHTING); } // end bounding boxes.*/ if (false && groupboxes) { //WIP STEFF // draw group boundingboxes // Turn light off and highlight the following glDisable(GL_LIGHTING); glDisable(GL_COLOR_MATERIAL); glActiveTexture(GL_TEXTURE0); glDisable(GL_TEXTURE_2D); glActiveTexture(GL_TEXTURE1); glDisable(GL_TEXTURE_2D); glEnable(GL_BLEND); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glEnable(GL_LINE_SMOOTH); glLineWidth(1.0); glHint(GL_LINE_SMOOTH_HINT, GL_NICEST); glColor4f(1, 1, 0, 1); glLineWidth(1.0); glHint(GL_LINE_SMOOTH_HINT, GL_NICEST); for (unsigned int i = 0; i<nGroups; ++i) { WMOGroup &header = groups[i]; glBegin(GL_LINE_STRIP); //A glVertex3f(header.VertexBoxMin.x, header.VertexBoxMax.y, header.VertexBoxMin.z); //C glVertex3f(header.VertexBoxMin.x, header.VertexBoxMin.y, header.VertexBoxMin.z); //D glVertex3f(header.VertexBoxMax.x, header.VertexBoxMin.y, header.VertexBoxMin.z); //G glVertex3f(header.VertexBoxMax.x, header.VertexBoxMin.y, header.VertexBoxMax.z); //H glVertex3f(header.VertexBoxMax.x, header.VertexBoxMax.y, header.VertexBoxMax.z); //B glVertex3f(header.VertexBoxMax.x, header.VertexBoxMax.y, header.VertexBoxMin.z); //A glVertex3f(header.VertexBoxMin.x, header.VertexBoxMax.y, header.VertexBoxMin.z); //E glVertex3f(header.VertexBoxMin.x, header.VertexBoxMax.y, header.VertexBoxMax.z); //F glVertex3f(header.VertexBoxMin.x, header.VertexBoxMin.y, header.VertexBoxMax.z); //C glVertex3f(header.VertexBoxMin.x, header.VertexBoxMin.y, header.VertexBoxMin.z); glEnd(); glBegin(GL_LINES); // F G glVertex3f(header.VertexBoxMin.x, header.VertexBoxMin.y, header.VertexBoxMax.z); glVertex3f(header.VertexBoxMax.x, header.VertexBoxMin.y, header.VertexBoxMax.z); glEnd(); glBegin(GL_LINES); // B D glVertex3f(header.VertexBoxMax.x, header.VertexBoxMax.y, header.VertexBoxMin.z); glVertex3f(header.VertexBoxMax.x, header.VertexBoxMin.y, header.VertexBoxMin.z); glEnd(); glBegin(GL_LINES); // E H glVertex3f(header.VertexBoxMin.x, header.VertexBoxMax.y, header.VertexBoxMax.z); glVertex3f(header.VertexBoxMax.x, header.VertexBoxMax.y, header.VertexBoxMax.z); glEnd(); } // Back to normal light rendering glActiveTexture(GL_TEXTURE1); glDisable(GL_TEXTURE_2D); glActiveTexture(GL_TEXTURE0); glEnable(GL_TEXTURE_2D); glEnable(GL_LIGHTING); } // end drow groupe boxes. /* // draw portal relations glBegin(GL_LINES); for (size_t i=0; i<prs.size(); ++i) { WMOPR &pr = prs[i]; WMOPV &pv = pvs[pr.portal]; if (pr.dir>0) glColor4f(1,0,0,1); else glColor4f(0,0,1,1); Vec3D pc = (pv.a+pv.b+pv.c+pv.d)*0.25f; Vec3D gc = (groups[pr.group].b1 + groups[pr.group].b2)*0.5f; glVertex3fv(pc); glVertex3fv(gc); } glEnd(); glColor4f(1,1,1,1); // draw portals for (int i=0; i<nP; ++i) { glBegin(GL_LINE_STRIP); glVertex3fv(pvs[i].d); glVertex3fv(pvs[i].c); glVertex3fv(pvs[i].b); glVertex3fv(pvs[i].a); glEnd(); } glEnable(GL_TEXTURE_2D); glEnable(GL_LIGHTING); */ }
void ParticleSystem::drawHighlight() { /* // just draw points: glDisable(GL_TEXTURE_2D); glDisable(GL_LIGHTING); glColor4f(1,1,1,1); glBegin(GL_POINTS); for (ParticleList::iterator it = particles.begin(); it != particles.end(); ++it) { glVertex3fv(it->tpos); } glEnd(); glEnable(GL_LIGHTING); glEnable(GL_TEXTURE_2D); */ Vec3D bv0, bv1, bv2, bv3; // setup blend mode switch (blend) { case 0: glDisable(GL_BLEND); glDisable(GL_ALPHA_TEST); break; case 1: glEnable(GL_BLEND); glBlendFunc(GL_SRC_COLOR, GL_ONE); glDisable(GL_ALPHA_TEST); break; case 2: glEnable(GL_BLEND); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glDisable(GL_ALPHA_TEST); break; case 3: glDisable(GL_BLEND); glEnable(GL_ALPHA_TEST); break; case 4: glEnable(GL_BLEND); glDisable(GL_ALPHA_TEST); glBlendFunc(GL_SRC_ALPHA, GL_ONE); break; } glDisable(GL_LIGHTING); glDisable(GL_CULL_FACE); glDepthMask(GL_FALSE); // glPushName(texture); _texture->bind(); Matrix mbb; mbb.unit(); ModelHighlight(Vec4D(1.00, 0.25, 0.25, 0.50)); if (billboard) { // get a billboard matrix Matrix mtrans; glGetFloatv(GL_MODELVIEW_MATRIX, &(mtrans.m[0][0])); mtrans.transpose(); mtrans.invert(); Vec3D camera = mtrans * Vec3D(0, 0, 0); Vec3D look = (camera - pos).normalize(); Vec3D up = ((mtrans * Vec3D(0, 1, 0)) - camera).normalize(); Vec3D right = (up % look).normalize(); up = (look % right).normalize(); // calculate the billboard matrix mbb.m[0][1] = right.x; mbb.m[1][1] = right.y; mbb.m[2][1] = right.z; mbb.m[0][2] = up.x; mbb.m[1][2] = up.y; mbb.m[2][2] = up.z; mbb.m[0][0] = look.x; mbb.m[1][0] = look.y; mbb.m[2][0] = look.z; } if (type == 0 || type == 2) { //! \todo figure out type 2 (deeprun tram subway sign) // - doesn't seem to be any different from 0 -_- // regular particles float f = 0.707106781f; // sqrt(2)/2 if (billboard) { bv0 = mbb * Vec3D(0, -f, +f); bv1 = mbb * Vec3D(0, +f, +f); bv2 = mbb * Vec3D(0, +f, -f); bv3 = mbb * Vec3D(0, -f, -f); } else { bv0 = Vec3D(-f, 0, +f); bv1 = Vec3D(+f, 0, +f); bv2 = Vec3D(+f, 0, -f); bv3 = Vec3D(-f, 0, -f); } //! \todo per-particle rotation in a non-expensive way?? :| glBegin(GL_QUADS); for (ParticleList::iterator it = particles.begin(); it != particles.end(); ++it) { //glColor4fv(it->color); glColor4f(1.0f, 0.25f, 0.25f, it->color.w*0.5f); glTexCoord2fv(tiles[it->tile].tc[0]); glVertex3fv(it->pos + bv0 * it->size); glTexCoord2fv(tiles[it->tile].tc[1]); glVertex3fv(it->pos + bv1 * it->size); glTexCoord2fv(tiles[it->tile].tc[2]); glVertex3fv(it->pos + bv2 * it->size); glTexCoord2fv(tiles[it->tile].tc[3]); glVertex3fv(it->pos + bv3 * it->size); } glEnd(); } else if (type == 1) { // particles from origin to position bv0 = mbb * Vec3D(0, -1.0f, 0); bv1 = mbb * Vec3D(0, +1.0f, 0); glBegin(GL_QUADS); for (ParticleList::iterator it = particles.begin(); it != particles.end(); ++it) { glColor4fv(it->color); glTexCoord2fv(tiles[it->tile].tc[0]); glVertex3fv(it->pos + bv0 * it->size); glTexCoord2fv(tiles[it->tile].tc[1]); glVertex3fv(it->pos + bv1 * it->size); glTexCoord2fv(tiles[it->tile].tc[2]); glVertex3fv(it->origin + bv1 * it->size); glTexCoord2fv(tiles[it->tile].tc[3]); glVertex3fv(it->origin + bv0 * it->size); } glEnd(); } ModelUnhighlight(); glEnable(GL_LIGHTING); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glDepthMask(GL_TRUE); glColor4f(1, 1, 1, 1); // glPopName(); }
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /// Operator * for right scalar multiplication inline Vec4D operator * ( const Vec4D& v, VEC3D_T a ) { return Vec4D(v.r0*a, v.r*a); }
bool ModelRenderPass::init(Model *m) { // blend mode switch (blendmode) { case BM_OPAQUE: // 0 glDisable(GL_BLEND); glDisable(GL_ALPHA_TEST); break; case BM_TRANSPARENT: // 1 glDisable(GL_BLEND); glEnable(GL_ALPHA_TEST); break; case BM_ALPHA_BLEND: // 2 glDisable(GL_ALPHA_TEST); glEnable(GL_BLEND); // glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); // default blend func break; case BM_ADDITIVE: // 3 glDisable(GL_ALPHA_TEST); glEnable(GL_BLEND); glBlendFunc(GL_SRC_COLOR, GL_ONE); break; case BM_ADDITIVE_ALPHA: // 4 glDisable(GL_ALPHA_TEST); glEnable(GL_BLEND); glBlendFunc(GL_SRC_ALPHA, GL_ONE); break; default: // ??? glDisable(GL_ALPHA_TEST); glEnable(GL_BLEND); glBlendFunc(GL_DST_COLOR, GL_SRC_COLOR); } if (nozwrite) { glDepthMask(GL_FALSE); } if (cull) { glEnable(GL_CULL_FACE); } else { glDisable(GL_CULL_FACE); } glBindTexture(GL_TEXTURE_2D, texture); if (usetex2) { glActiveTextureARB(GL_TEXTURE1); glEnable(GL_TEXTURE_2D); glBindTexture(GL_TEXTURE_2D, texture2); } if (unlit) { glDisable(GL_LIGHTING); // unfogged = unlit? glDisable(GL_FOG); } if (useenvmap) { // env mapping glEnable(GL_TEXTURE_GEN_S); glEnable(GL_TEXTURE_GEN_T); const GLint maptype = GL_SPHERE_MAP; //const GLint maptype = GL_REFLECTION_MAP_ARB; glTexGeni(GL_S, GL_TEXTURE_GEN_MODE, maptype); glTexGeni(GL_T, GL_TEXTURE_GEN_MODE, maptype); } if (texanim!=-1) { glMatrixMode(GL_TEXTURE); glPushMatrix(); m->texanims[texanim].setup(); } Vec4D ocol(1,1,1,m->trans); Vec4D ecol(0,0,0,0); // emissive colors if (color!=-1) { Vec3D c = m->colors[color].color.getValue(m->anim,m->animtime); ocol.w *= m->colors[color].opacity.getValue(m->anim,m->animtime); if (unlit) { ocol.x = c.x; ocol.y = c.y; ocol.z = c.z; } else { ocol.x = ocol.y = ocol.z = 0; } ecol = Vec4D(c, 1.0f); } glMaterialfv(GL_FRONT, GL_EMISSION, ecol); // opacity if (opacity!=-1) { ocol.w *= m->transparency[opacity].trans.getValue(m->anim,m->animtime); } // color glColor4fv(ocol); if (blendmode<=1 && ocol.w!=1.0f) glEnable(GL_BLEND); return (ocol.w > 0) || (ecol.lengthSquared() > 0); }
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /// Operator * for left scalar multiplication inline Vec4D operator * ( VEC3D_T a, const Vec4D& v ) { return Vec4D(a*v.r0, a*v.r); }
Vec4D ModelControl::fromColWidget(wxColour col) { return Vec4D((float)col.Red()/255.0f, (float)col.Green()/255.0f, (float)col.Blue()/255.0f, 1.0); }
inline Vec4D operator*( double x, const Vec4D &vec ) { return( Vec4D( x*vec[0], x*vec[1], x*vec[2], vec[3] ) ); }