// Sets both the X and Y-coordinate of one vertex. global func SetVertexXY(int index, int x, int y) { // Set vertices. SetVertex(index, VTX_X, x); SetVertex(index, VTX_Y, y); return; }
///////////////////////////////////////////////////////// // renderShape // ///////////////////////////////////////////////////////// void rectangle :: renderShape(GemState *state) { #ifdef __GNUC__ # warning rectangle: look at SetVertex #endif /* __GNUC__ */ if(m_drawType==GL_DEFAULT_GEM)m_drawType=GL_QUADS; glNormal3f(0.0f, 0.0f, 1.0f); if (GemShape::m_texType && GemShape::m_texNum) { glBegin(m_drawType); SetVertex(state, -m_size, -m_height, 0.0f,0.,0.,0); SetVertex(state, m_size, -m_height, 0.0f,1.,0.,1); SetVertex(state, m_size, m_height, 0.0f,1.,1.,2); SetVertex(state, -m_size, m_height, 0.0f,0.,1.,3); glEnd(); } else { glBegin(m_drawType); glTexCoord2f(0.0f, 0.0f); glVertex3f(-m_size, -m_height, 0.0f); glTexCoord2f(1.0f, 0.0f); glVertex3f( m_size, -m_height, 0.0f); glTexCoord2f(1.0f, 1.0f); glVertex3f( m_size, m_height, 0.0f); glTexCoord2f(0.0f, 1.0f); glVertex3f(-m_size, m_height, 0.0f); glEnd(); } }
protected func Initialize() { // Local 0 und 1 sind die Lininenfarben SetLocal(0,66); SetLocal(1,66); // Die ersten beiden Vertices auf aktuelle Position legen SetVertex(0,0,GetX()); SetVertex(0,1,GetY()); SetVertex(1,0,GetX()); SetVertex(1,1,GetY()); }
void ESVideo::PresentFrame (GLuint aID, uint32_t aWidth, uint32_t aHeight, const Area& aViewPort, bool aFlip) { //Enter present state EnterPresentState(); //Calculate output area Area presentArea; if(NoAspect) { uint32_t x = PresentArea.X, y = PresentArea.Y, w = PresentArea.Width, h = PresentArea.Height; Utility::CenterAndScale(x, y, w, h, aViewPort.Width, aViewPort.Height); presentArea = Area(x, y, w, h); } else { presentArea = PresentArea; } //Call kiddie present if possible if(SupportsShaders()) { Present(aID, aWidth, aHeight, aViewPort, presentArea, aFlip); /* Reset vertex buffer */ ApplyVertexBuffer(VertexBuffer); } else { float xl = (float)aViewPort.X / (float)aWidth; float xr = (float)aViewPort.Right() / (float)aWidth; float yl = (float)aViewPort.Y / (float)aHeight; float yr = (float)aViewPort.Bottom() / (float)aHeight; if(aFlip) { std::swap(yl, yr); } glBindTexture(GL_TEXTURE_2D, aID); glSplat(); SetVertex(&VertexBuffer[0 * VertexSize], presentArea.X, presentArea.Y, 1.0f, 1.0f, 1.0f, 1.0f, xl, yl); SetVertex(&VertexBuffer[1 * VertexSize], presentArea.Right(), presentArea.Y, 1.0f, 1.0f, 1.0f, 1.0f, xr, yl); SetVertex(&VertexBuffer[2 * VertexSize], presentArea.Right(), presentArea.Bottom(), 1.0f, 1.0f, 1.0f, 1.0f, xr, yr); SetVertex(&VertexBuffer[3 * VertexSize], presentArea.X, presentArea.Bottom(), 1.0f, 1.0f, 1.0f, 1.0f, xl, yr); glDrawArrays(GL_QUADS, 0, 4); glSplat(); } //Exit present state ExitPresentState(); }
// Used by the rendering functions to render a single glyph quad. void GxTextRenderer::myEmitQuad(const Glyph& glyph, int& index, float x, float y) { const float a = floor(x + glyph.coords.l); const float b = floor(y + glyph.coords.t); const float c = floor(x + glyph.coords.r); const float d = floor(y + glyph.coords.b); const float e = glyph.uvs.l; const float f = glyph.uvs.t; const float g = glyph.uvs.r; const float h = glyph.uvs.b; const GxColor ct = myColorT; const GxColor cb = myColorB; const GxColor cs = myColorS; GxVertex* v = &myVertexBuffer.front() + (index << 2); if(cs.a) { SetVertex(v, a+1.f, b+1.f, e, f, cs); ++v; SetVertex(v, a+1.f, d+1.f, e, h, cs); ++v; SetVertex(v, c+1.f, b+1.f, g, f, cs); ++v; SetVertex(v, c+1.f, d+1.f, g, h, cs); ++v; ++index; } SetVertex(v, a, b, e, f, ct); ++v; SetVertex(v, a, d, e, h, cb); ++v; SetVertex(v, c, b, g, f, ct); ++v; SetVertex(v, c, d, g, h, cb); ++index; }
void rImmediateBuffer::TransformVertex(size_t i, const rMatrix4& matrix){ size_t index = VertexDataArrayIndex(i); rVector3 v(m_vertexData[index], m_vertexData[index + 1], m_vertexData[index + 2]); matrix.TransformVector3(v); SetVertex(i, v); }
Model::Model( const char * filename ) : Geometry( GL_LINES, filename, FLAG_LINE ) { // LOGI("Model::cstr() file %s", filename ); FILE * fp = fopen( filename, "r" ); if ( fp != NULL ) { int ns; int nl; int nx; fscanf(fp, "%d %d %d", &ns, &nl, &nx ); // Nr.Stations Nr.Legs Nr.splays my_vertex = new float[ 3 * ( ns + nx ) ]; my_index = new unsigned short[ 2 * (nl + nx) ]; char name[32]; char name2[32]; for ( int k=0; k<ns; ++k ) { float x, y, z; if ( fscanf( fp, "%s %f %f %f", name, &x, &y, &z ) != 4 ) break; my_vertex[ 3*k + 0 ] = x; my_vertex[ 3*k + 1 ] = y; my_vertex[ 3*k + 2 ] = z; stations.insert( std::pair<std::string, int>( name, k ) ); } for ( int k=0; k<nl; ++k ) { int a, b; fscanf(fp, "%s %s", name, name2 ); StationMapIterator it1 = stations.find( name ); StationMapIterator it2 = stations.find( name2 ); if ( it1 != stations.end() && it2 != stations.end() ) { my_index[ 2*k + 0 ] = it1->second; my_index[ 2*k + 1 ] = it2->second; } else { break; } } int cx = 0; for ( int k=0; k<nx; ++k ) { int a, b; float x, y, z; fscanf(fp, "%s %f %f %f", name, &x, &y, &z ); StationMapIterator it1 = stations.find( name ); if ( it1 == stations.end() ) break; sprintf(name2, "%s-%d", name, cx ); ++ cx; my_vertex[ 3*ns + 3*k + 0 ] = x; my_vertex[ 3*ns + 3*k + 1 ] = y; my_vertex[ 3*ns + 3*k + 2 ] = z; // station name not inserted in the stations map for the TO of the splay my_index[ 2 * nl + 2*k + 0 ] = it1->second; my_index[ 2 * nl + 2*k + 1 ] = ns + k; } SetVertex( my_vertex ); SetNVertex( ns + nx ); SetIndex( my_index ); SetNIndex( 2 * (nl+nx) ); InitBBox(); } }
CBoard::CBoard(float left, float top, float right, float bottom): m_lpTex( NULL ), m_Color( 1.f, 1.f, 1.f, 1.f ) { CBoard(); SetVertex( left, top, right, bottom ); }
void VertexGroup::Init(const vector<Vertex> &vertices) { if(data) free(data); data = malloc(vertices.size() * vertexFormat->GetStride()); for(unsigned int i = 0; i < vertices.size(); ++i) { SetVertex(i, vertices[i]); } }
CBoard::CBoard(const D3DXVECTOR3 &v1, const D3DXVECTOR3 &v2, const D3DXVECTOR3 &v3, const D3DXVECTOR3 &v4) { CBoard(); SetVertex( v1, v2, v3, v4 ); }
private func Timer() { // Positionen var x0 = GetX(GetActionTarget(1)), y0 = GetY(GetActionTarget(1)), x1 = GetX(GetActionTarget(0)), y1 = GetY(GetActionTarget(0)); // Einzelne Vertexe mit Partikeln verschönern var i=0; var iVtxNum = GetVertexNum(); while(i<iVtxNum) { SetVertex(i, 0, (x0+(x1-x0)*i/iVtxNum)+RandomX(5,-5)); SetVertex(i, 1, (y0+(y1-y0)*i/iVtxNum)+RandomX(5,-5)); DrawParticleLine ("LightningSpark", GetVertex(i)-GetX(), GetVertex(i, 1)-GetY(), GetVertex(i+1)-GetX(), GetVertex(i+1,1)-GetY(), 6, 60, RGB(250,0,0), RGB(250,0,0)); DrawParticleLine ("BloodSpark", GetVertex(i)-GetX(), GetVertex(i, 1)-GetY(), GetVertex(i+1)-GetX(), GetVertex(i+1,1)-GetY(), 3, 25, RGB(250,100,100), RGB(250,100,100)); i++; } }
// e.g. clonk->SetVertexCNAT(k, CNAT_CollideHalfVehicle, true); for k != 2 makes the clonk behave correctly wrt. to HalfVehicle global func SetVertexCNAT(int vtx, int val, bool set) { if (val == nil || set == nil) return FatalError("this function requires its second and third parameter to be non-nil"); if (!this) return FatalError("this function requires object context"); if (vtx == nil) for (var i = GetVertexNum(); i-->0;) SetVertexCNAT(i, val, set); else SetVertex(vtx, VTX_CNAT, GetVertex(vtx, VTX_CNAT) & ~val | (set && val), 2); }
void ESVideo::PlaceTexture (Texture* aTexture, const Area& aDestination, const Area& aSource, uint32_t aColor) { float r = (float)((aColor >> 24) & 0xFF) / 256.0f; float g = (float)((aColor >> 16) & 0xFF) / 256.0f; float b = (float)((aColor >> 8) & 0xFF) / 256.0f; float a = (float)((aColor >> 0) & 0xFF) / 256.0f; float xl = ((float)aSource.X + .5f) / (float)aTexture->GetWidth(); float xr = ((float)aSource.Right() - .5f) / (float)aTexture->GetWidth(); float yl = ((float)aSource.Y + .5f) / (float)aTexture->GetHeight(); float yr = ((float)aSource.Bottom() - .5f) / (float)aTexture->GetHeight(); const Area& Clip = ESVideo::GetClip(); aTexture->Apply(); SetVertex(&VertexBuffer[0 * VertexSize], Clip.X + aDestination.X, Clip.Y + aDestination.Y, r, g, b, a, xl, yl); SetVertex(&VertexBuffer[1 * VertexSize], Clip.X + aDestination.Right(), Clip.Y + aDestination.Y, r, g, b, a, xr, yl); SetVertex(&VertexBuffer[2 * VertexSize], Clip.X + aDestination.Right(), Clip.Y + aDestination.Bottom(), r, g, b, a, xr, yr); SetVertex(&VertexBuffer[3 * VertexSize], Clip.X + aDestination.X, Clip.Y + aDestination.Bottom(), r, g, b, a, xl, yr); glDrawArrays(GL_QUADS, 0, 4); }
VOID BBXParser::CreateCube( INT _iNumBoundBox, LPDATA _pData ) { for( INT i=0 ; i<_iNumBoundBox ; i++ ) { D3DXVECTOR3 vPivot = _pData[ i ].Info.vPivot; SetVertex( &_pData[ i ] ); /*SetVertex( &m_pData[ i ].aVertex[ 0 ], vPivot.x + m_pData[ i ].Info.fMinusSize[ 0 ], vPivot.y + m_pData[ i ].Info.fPlusSize[ 1 ], vPivot.z + m_pData[ i ].Info.fPlusSize[ 2 ], m_pData[ i ].Info.Color ); SetVertex( &m_pData[ i ].aVertex[ 1 ], vPivot.x + m_pData[ i ].Info.fPlusSize[ 0 ], vPivot.y + m_pData[ i ].Info.fPlusSize[ 1 ], vPivot.z + m_pData[ i ].Info.fPlusSize[ 2 ], m_pData[ i ].Info.Color ); SetVertex( &m_pData[ i ].aVertex[ 2 ], vPivot.x + m_pData[ i ].Info.fPlusSize[ 0 ], vPivot.y + m_pData[ i ].Info.fPlusSize[ 1 ], vPivot.z + m_pData[ i ].Info.fMinusSize[ 2 ], m_pData[ i ].Info.Color ); SetVertex( &m_pData[ i ].aVertex[ 3 ], vPivot.x + m_pData[ i ].Info.fMinusSize[ 0 ], vPivot.y + m_pData[ i ].Info.fPlusSize[ 1 ], vPivot.z + m_pData[ i ].Info.fMinusSize[ 2 ], m_pData[ i ].Info.Color ); SetVertex( &m_pData[ i ].aVertex[ 4 ], vPivot.x + m_pData[ i ].Info.fMinusSize[ 0 ], vPivot.y + m_pData[ i ].Info.fMinusSize[ 1 ], vPivot.z + m_pData[ i ].Info.fPlusSize[ 2 ], m_pData[ i ].Info.Color ); SetVertex( &m_pData[ i ].aVertex[ 5 ], vPivot.x + m_pData[ i ].Info.fPlusSize[ 0 ], vPivot.y + m_pData[ i ].Info.fMinusSize[ 1 ], vPivot.z + m_pData[ i ].Info.fPlusSize[ 2 ], m_pData[ i ].Info.Color ); SetVertex( &m_pData[ i ].aVertex[ 6 ], vPivot.x + m_pData[ i ].Info.fPlusSize[ 0 ], vPivot.y + m_pData[ i ].Info.fMinusSize[ 1 ], vPivot.z + m_pData[ i ].Info.fMinusSize[ 2 ], m_pData[ i ].Info.Color ); SetVertex( &m_pData[ i ].aVertex[ 7 ], vPivot.x + m_pData[ i ].Info.fMinusSize[ 0 ], vPivot.y + m_pData[ i ].Info.fMinusSize[ 1 ], vPivot.z + m_pData[ i ].Info.fMinusSize[ 2 ], m_pData[ i ].Info.Color );*/ SetIndex( _pData[ i ].aIndex ); } }
///////////////////////////////////////////////////////// // renderShape // ///////////////////////////////////////////////////////// void trapezoid :: renderShape(GemState *state) { float top=m_size*m_top; float tx = m_scale_texcoord * m_top; int drawType = m_drawType; if(drawType==GL_DEFAULT_GEM)drawType=GL_QUADS; if (drawType == GL_LINE_LOOP) glLineWidth(m_linewidth); if (m_top<0) top*=-1; glNormal3f(0.0f, 0.0f, 1.0f); glBegin(drawType); SetVertex(state,-m_size, -m_size, 0.0f, 0., 0., 0); SetVertex(state, m_size, -m_size, 0.0f, 1., 0., 1); SetVertex(state, top, m_size, 0.0f, tx, tx, 0., tx, 2); SetVertex(state, -top, m_size, 0.0f, 0., tx, 0., tx, 3); #if 0 glTexCoord2f( 0, 0); glVertex2f (-1, -1); glTexCoord2f( 256, 0); glVertex2f ( 1, -1); glTexCoord4f( 256*tx, 256*tx, 0, tx); glVertex2f ( m_size, 1); glTexCoord4f( 0, 256*tx, 0, tx); glVertex2f (-m_size, 1); #endif glEnd(); }
void CTextureQuad::CalcSize(double maxW,double maxH) { if (Texture) { double ratioT=double(Texture->GetW())/Texture->GetH(); if (maxW/maxH>ratioT) { h=maxH; w=h*ratioT; } else { w=maxW; h=w/ratioT; } } else { w=maxW; h=maxH; } SVertex VertexArray[4]; double w2=w/2; double h2=h/2; double tx=double(Texture->GetW())/Texture->GetWT(); double ty=double(Texture->GetH())/Texture->GetHT(); SetVertex(VertexArray[0],-w2,-h2,0,0); SetVertex(VertexArray[1],w2,-h2,tx,0); SetVertex(VertexArray[2],-w2,h2,0,ty); SetVertex(VertexArray[3],w2,h2,tx,ty); glGenBuffers(1,&VBObuffer); glBindBuffer(GL_ARRAY_BUFFER,VBObuffer); glBufferData(GL_ARRAY_BUFFER,sizeof(VertexArray),VertexArray,GL_STATIC_DRAW); }
AParticle::AParticle(const AParticle& apart) { SetID(apart.GetID()); SetParticleName(apart.GetParticleName()); SetIsPrimary(apart.GetIsPrimary()); SetCharge(apart.GetCharge()); SetVertex(apart.GetVertex()); SetP4(apart.GetP4()); SetMotherID(apart.GetMotherId()); SetDebug(apart.GetDebug()); std::map <std::string, std::string> props = apart.GetProperties(); for (auto prop : props) SetProperty(prop.first, prop.second); }
protected func Initialize() { SetVertex(1, VTX_X, 0, 2); SetVertex(1, VTX_Y, 0, 2); SetVertex(2, VTX_X, 0, 2); SetVertex(2, VTX_Y, 0, 2); SetVertex(3, VTX_X, 0, 2); SetVertex(3, VTX_Y, 0, 2); return _inherited(...); }
void QuadPane::Draw(const BannerResources& resources, u8 render_alpha, const float ws_scale, Mtx &modelview, u16 material_index, u8 texture_flip) const { if(!header) return; if (material_index < resources.materials.size()) { bool modulate_color = IsModulateColor(header->vertex_colors, render_alpha); resources.materials[material_index]->Apply(resources, render_alpha, modulate_color); } Mtx m, mv; guMtxIdentity (m); guMtxTransApply(m,m, -0.5f * GetOriginX(), -0.5f * GetOriginY(), 0.f); guMtxScaleApply(m,m, GetWidth(), GetHeight(), 1.f); guMtxConcat (modelview, m, mv); GX_LoadPosMtxImm (mv, GX_PNMTX0); GX_ClearVtxDesc(); GX_InvVtxCache(); GX_SetVtxDesc(GX_VA_POS, GX_DIRECT); GX_SetVtxDesc(GX_VA_CLR0, GX_DIRECT); for(u32 i = 0; i < header->tex_coord_count; i++) GX_SetVtxDesc(GX_VA_TEX0+i, GX_DIRECT); GX_Begin(GX_QUADS, GX_VTXFMT0, 4); if(texture_flip) { SetVertex(0, 0.f, 0.f, render_alpha); SetVertex(1, 1.f, 0.f, render_alpha); SetVertex(3, 1.f, 1.f, render_alpha); SetVertex(2, 0.f, 1.f, render_alpha); } else { SetVertex(2, 0.f, 0.f, render_alpha); SetVertex(3, 1.f, 0.f, render_alpha); SetVertex(1, 1.f, 1.f, render_alpha); SetVertex(0, 0.f, 1.f, render_alpha); } GX_End(); }
int APIENTRY wWinMain(_In_ HINSTANCE hInstance, _In_opt_ HINSTANCE hPrevInstance, _In_ LPWSTR lpCmdLine, _In_ int nCmdShow) { glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH); glutInitWindowPosition(0, 0); glutInitWindowSize(512, 512); glutCreateWindow("ColorCube"); SetVertex(); glutReshapeFunc(ChangeSize); glutSpecialFunc(ControlKey); glutDisplayFunc(RenderScene); SetupRC(); glutMainLoop(); }
AParticle::AParticle(int Id, std::string name, bool isPrimary, double charge, TVector3 vertex, TLorentzVector p4, int motherID) { SetID(Id); SetParticleName(name); SetIsPrimary(isPrimary); SetCharge(charge); SetVertex(vertex); SetP4(p4); SetMotherID(motherID); InitLogger("Aparticle"); fDebug = "WARN"; SetDebugLevel(fDebug,"Aparticle"); }
CBoard::CBoard(float w, float h): m_lpTex( NULL ), m_Color( 1.f, 1.f, 1.f, 1.f ) { m_Vertex[ 0 ].Pos = D3DXVECTOR3( -10.f, 10.f, 0.f ); m_Vertex[ 1 ].Pos = D3DXVECTOR3( 10.f, 10.f, 0.f ); m_Vertex[ 2 ].Pos = D3DXVECTOR3( 10.f, -10.f, 0.f ); m_Vertex[ 3 ].Pos = D3DXVECTOR3( -10.f, -10.f, 0.f ); SetColor( m_Color ); m_Vertex[ 0 ].Tex = D3DXVECTOR2( 0.0f, 0.0f ); m_Vertex[ 1 ].Tex = D3DXVECTOR2( 1.0f, 0.0f ); m_Vertex[ 2 ].Tex = D3DXVECTOR2( 1.0f, 1.0f ); m_Vertex[ 3 ].Tex = D3DXVECTOR2( 0.0f, 1.0f ); SetVertex( w, h ); }
CBoard::CBoard( float size, bool is_wall): m_lpTex( NULL ), m_Color( 1.f, 1.f, 1.f, 1.f ) { m_Vertex[ 0 ].Pos = D3DXVECTOR3( -10.f, 10.f, 0.f ); m_Vertex[ 1 ].Pos = D3DXVECTOR3( 10.f, 10.f, 0.f ); m_Vertex[ 2 ].Pos = D3DXVECTOR3( 10.f, -10.f, 0.f ); m_Vertex[ 3 ].Pos = D3DXVECTOR3( -10.f, -10.f, 0.f ); SetColor( m_Color ); m_Vertex[ 0 ].Tex = D3DXVECTOR2( 0.0f, 0.0f ); m_Vertex[ 1 ].Tex = D3DXVECTOR2( 1.0f, 0.0f ); m_Vertex[ 2 ].Tex = D3DXVECTOR2( 1.0f, 1.0f ); m_Vertex[ 3 ].Tex = D3DXVECTOR2( 0.0f, 1.0f ); SetVertex( size, is_wall ); }
main() { int x,y,vertex,*result; char input[1000],*num; tGraph *graph; printf("input vertex count of your gragdddp:") ; scanf("%d",&vertex); graph=CreateGraph(vertex); printf("input your graph use matrix \n"); for (x=0;x<vertex;x++) { scanf("%s",input); num=strtok(input,SP); y=0; while(num!=NULL) { if(isdigit(num[0])) SetVertex(graph,x,y,atoi(num)); num=strtok(NULL,SP); y++; } } for (x=0;x<vertex;x++) for(y=0;y<vertex;y++) printf("%d ",GetVertex(graph,x,y)),y==vertex-1?printf("\n"):0; result=CalcShortestPath(graph,0,vertex-1); x=0; if (result!=NULL) { while (result[x]!=vertex-1) printf("%d-->",result[x++]); printf("%d\n",result[x]); } else printf("no way!\n"); system("pause"); }
void Enemy::Initialize(Graphics *graphics) { if (GetCurrentTime() % 2) _direction = LEFT; else _direction = RIGHT; _projectile = new Projectile(_transform.position); _projectile->SetSpeed(9); size = 0; vertices = new Vector3[8](); colours = new Vector4[8](); SetVertex(0, /*pos*/-0.3f, 0.3f, 0.3f, /*color*/ 0.7f, 0.0f, 0.2f, 1.0f); SetVertex(1, /*pos*/0.3f, 0.3f, 0.3f, /*color*/ 0.7f, 0.0f, 0.2f, 1.0f); SetVertex(2, /*pos*/-0.3f, -0.3f, 0.3f, /*color*/ 0.7f, 0.0f, 0.2f, 1.0f); SetVertex(3, /*pos*/0.3f, -0.3f, 0.3f, /*color*/ 0.7f, 0.0f, 0.2f, 1.0f); SetVertex(4, /*pos*/-0.3f, 0.3f, -0.3f, /*color*/ 0.7f, 0.0f, 0.2f, 1.0f); SetVertex(5, /*pos*/0.3f, 0.3f, -0.3f, /*color*/ 0.7f, 0.0f, 0.2f, 1.0f); SetVertex(6, /*pos*/-0.3f, -0.3f, -0.3f,/*color*/ 0.7f, 0.0f, 0.2f, 1.0f); SetVertex(7, /*pos*/0.3f, -0.3f, -0.3f, /*color*/ 0.7f, 0.0f, 0.2f, 1.0f); indices = new unsigned int[30]; glFrontFace(GL_CW); glCullFace(GL_BACK); // front indices[0] = 0; indices[1] = 1; indices[2] = 2; indices[3] = 1; indices[4] = 3; indices[5] = 2; // right indices[6] = 1; indices[7] = 5; indices[8] = 3; indices[9] = 5; indices[10] = 7; indices[11] = 3; // back indices[12] = 5; indices[13] = 4; indices[14] = 7; indices[15] = 4; indices[16] = 6; indices[17] = 7; // left indices[18] = 4; indices[19] = 0; indices[20] = 6; indices[21] = 6; indices[22] = 0; indices[23] = 2; // top indices[24] = 4; indices[25] = 5; indices[26] = 0; indices[27] = 5; indices[28] = 1; indices[29] = 0; // bottom indices[30] = 2; indices[31] = 3; indices[32] = 6; indices[33] = 3; indices[34] = 7; indices[35] = 6; _projectile->Initialize(graphics); }
void Cube::Initialize(Graphics *graphics) { size = 0; //vertices = new Vertex[8](); vertices = new Vector3[8](); colours = new Vector4[8](); SetVertex(0, /*pos*/-0.5f, 0.5f, 0.5f, /*color*/ 1.0f, 0.0f, 0.0f, 1.0f); SetVertex(1, /*pos*/0.5f, 0.5f, 0.5f, /*color*/ 1.0f, 1.0f, 0.0f, 1.0f); SetVertex(2, /*pos*/-0.5f, -0.5f, 0.5f, /*color*/ 1.0f, 0.0f, 1.0f, 1.0f); SetVertex(3, /*pos*/0.5f, -0.5f, 0.5f, /*color*/ 0.0f, 1.0f, 0.0f, 1.0f); SetVertex(4, /*pos*/-0.5f, 0.5f, -0.5f, /*color*/ 0.0f, 0.0f, 1.0f, 1.0f); SetVertex(5, /*pos*/0.5f, 0.5f, -0.5f, /*color*/ 0.0f, 0.0f, 1.0f, 1.0f); SetVertex(6, /*pos*/-0.5f, -0.5f, -0.5f,/*color*/ 0.0f, 0.0f, 1.0f, 1.0f); SetVertex(7, /*pos*/0.5f, -0.5f, -0.5f, /*color*/ 0.0f, 0.0f, 1.0f, 1.0f); indices = new unsigned int[30]; glFrontFace(GL_CW); glCullFace(GL_BACK); // front indices[0] = 0; indices[1] = 1; indices[2] = 2; indices[3] = 1; indices[4] = 3; indices[5] = 2; // right indices[6] = 1; indices[7] = 5; indices[8] = 3; indices[9] = 5; indices[10] = 7; indices[11] = 3; // back indices[12] = 5; indices[13] = 4; indices[14] = 7; indices[15] = 4; indices[16] = 6; indices[17] = 7; // left indices[18] = 4; indices[19] = 0; indices[20] = 6; indices[21] = 6; indices[22] = 0; indices[23] = 2; // top indices[24] = 4; indices[25] = 5; indices[26] = 0; indices[27] = 5; indices[28] = 1; indices[29] = 0; // bottom indices[30] = 2; indices[31] = 3; indices[32] = 6; indices[33] = 3; indices[34] = 7; indices[35] = 6; }
void BonesDefMod::ApplyPaintWeights(BOOL alt, INode *incNode) { //5.1.03 BOOL blendMode = FALSE; pblock_param->GetValue(skin_paintblendmode,0,blendMode,FOREVER); INode *node = NULL; for (int i =0;i < painterData.Count(); i++) { painterData[i].alt = alt; if (incNode == NULL) node = painterData[i].node; else node = incNode; if (node == painterData[i].node) { BoneModData *bmd = painterData[i].bmd; int count; float *str = pPainterInterface->RetrievePointGatherStr(node, count); int *isMirror = pPainterInterface->RetrievePointGatherIsMirror(node, count); for (int j =0; j < count; j++) { if (str[j] != 0.0f) { //get original amount float amount = 0.0f; int boneID = ModeBoneIndex; if (isMirror[j] == MIRRRORED) boneID = mirrorIndex; if(boneID != -1) { //add to it str for (int k =0; k < bmd->VertexData[j]->d.Count(); k++) { if (bmd->VertexData[j]->d[k].Bones == boneID) { amount = bmd->VertexData[j]->d[k].normalizedInfluences; k = bmd->VertexData[j]->d.Count(); } } //5.1.03 if (blendMode) { float blurAmount = bmd->blurredWeights[j]; amount += (bmd->blurredWeights[j] - amount) * str[j]; } else { if (alt) amount -= str[j]; else amount += str[j]; if (amount > 1.0f) amount = 1.0f; if (amount < 0.0f) amount = 0.0f; } //set it back SetVertex(bmd, j, boneID, amount); } } } } } }
RudeSkybox::RudeSkybox() { const float scale = 150.0f; const bool adjustUV = true; const int textureSize = 512; float *Vertices = m_verts; float *UVs = m_uvs; float unit = 1.0f; float a0 = 0, a1 = unit; if (adjustUV) { float oneover = 1.0f / textureSize; a0 = 1.0f * oneover; a1 = unit - a0; } // Front SetVertex(Vertices, 0, -unit, +unit, -unit); SetVertex(Vertices, 1, +unit, +unit, -unit); SetVertex(Vertices, 2, -unit, -unit, -unit); SetVertex(Vertices, 3, +unit, -unit, -unit); SetUV(UVs, 0, a0, a1); SetUV(UVs, 1, a1, a1); SetUV(UVs, 2, a0, a0); SetUV(UVs, 3, a1, a0); // Right SetVertex(Vertices, 4, +unit, +unit, -unit); SetVertex(Vertices, 5, +unit, +unit, +unit); SetVertex(Vertices, 6, +unit, -unit, -unit); SetVertex(Vertices, 7, +unit, -unit, +unit); SetUV(UVs, 4, a0, a1); SetUV(UVs, 5, a1, a1); SetUV(UVs, 6, a0, a0); SetUV(UVs, 7, a1, a0); // Back SetVertex(Vertices, 8 , +unit, +unit, +unit); SetVertex(Vertices, 9 , -unit, +unit, +unit); SetVertex(Vertices, 10, +unit, -unit, +unit); SetVertex(Vertices, 11, -unit, -unit, +unit); SetUV(UVs, 8 , a0, a1); SetUV(UVs, 9 , a1, a1); SetUV(UVs, 10, a0, a0); SetUV(UVs, 11, a1, a0); // Left SetVertex(Vertices, 12, -unit, +unit, +unit); SetVertex(Vertices, 13, -unit, +unit, -unit); SetVertex(Vertices, 14, -unit, -unit, +unit); SetVertex(Vertices, 15, -unit, -unit, -unit); SetUV(UVs, 12, a0, a1); SetUV(UVs, 13, a1, a1); SetUV(UVs, 14, a0, a0); SetUV(UVs, 15, a1, a0); // Top SetVertex(Vertices, 16, -unit, +unit, +unit); SetVertex(Vertices, 17, +unit, +unit, +unit); SetVertex(Vertices, 18, -unit, +unit, -unit); SetVertex(Vertices, 19, +unit, +unit, -unit); SetUV(UVs, 16, a0, a1); SetUV(UVs, 17, a1, a1); SetUV(UVs, 18, a0, a0); SetUV(UVs, 19, a1, a0); // Bottom SetVertex(Vertices, 20, -unit, -unit, -unit); SetVertex(Vertices, 21, +unit, -unit, -unit); SetVertex(Vertices, 22, -unit, -unit, +unit); SetVertex(Vertices, 23, +unit, -unit, +unit); SetUV(UVs, 20, a0, a1); SetUV(UVs, 21, a1, a1); SetUV(UVs, 22, a0, a0); SetUV(UVs, 23, a1, a0); for (int i=0; i<24*3; i++) (Vertices)[i] = (Vertices)[i] * (scale); }
/*!*************************************************************************** @Function PVRTCreateSkybox @Input scale Scale the skybox @Input adjustUV Adjust or not UVs for PVRT compression @Input textureSize Texture size in pixels @Output Vertices Array of vertices @Output UVs Array of UVs @Description Creates the vertices and texture coordinates for a skybox *****************************************************************************/ void PVRTCreateSkybox(float scale, bool adjustUV, int textureSize, VERTTYPE** Vertices, VERTTYPE** UVs) { *Vertices = new VERTTYPE[24*3]; *UVs = new VERTTYPE[24*2]; VERTTYPE unit = f2vt(1); VERTTYPE a0 = 0, a1 = unit; if (adjustUV) { VERTTYPE oneover = f2vt(1.0f / textureSize); a0 = VERTTYPEMUL(f2vt(4.0f), oneover); a1 = unit - a0; } // Front SetVertex(Vertices, 0, -unit, +unit, -unit); SetVertex(Vertices, 1, +unit, +unit, -unit); SetVertex(Vertices, 2, -unit, -unit, -unit); SetVertex(Vertices, 3, +unit, -unit, -unit); SetUV(UVs, 0, a0, a1); SetUV(UVs, 1, a1, a1); SetUV(UVs, 2, a0, a0); SetUV(UVs, 3, a1, a0); // Right SetVertex(Vertices, 4, +unit, +unit, -unit); SetVertex(Vertices, 5, +unit, +unit, +unit); SetVertex(Vertices, 6, +unit, -unit, -unit); SetVertex(Vertices, 7, +unit, -unit, +unit); SetUV(UVs, 4, a0, a1); SetUV(UVs, 5, a1, a1); SetUV(UVs, 6, a0, a0); SetUV(UVs, 7, a1, a0); // Back SetVertex(Vertices, 8 , +unit, +unit, +unit); SetVertex(Vertices, 9 , -unit, +unit, +unit); SetVertex(Vertices, 10, +unit, -unit, +unit); SetVertex(Vertices, 11, -unit, -unit, +unit); SetUV(UVs, 8 , a0, a1); SetUV(UVs, 9 , a1, a1); SetUV(UVs, 10, a0, a0); SetUV(UVs, 11, a1, a0); // Left SetVertex(Vertices, 12, -unit, +unit, +unit); SetVertex(Vertices, 13, -unit, +unit, -unit); SetVertex(Vertices, 14, -unit, -unit, +unit); SetVertex(Vertices, 15, -unit, -unit, -unit); SetUV(UVs, 12, a0, a1); SetUV(UVs, 13, a1, a1); SetUV(UVs, 14, a0, a0); SetUV(UVs, 15, a1, a0); // Top SetVertex(Vertices, 16, -unit, +unit, +unit); SetVertex(Vertices, 17, +unit, +unit, +unit); SetVertex(Vertices, 18, -unit, +unit, -unit); SetVertex(Vertices, 19, +unit, +unit, -unit); SetUV(UVs, 16, a0, a1); SetUV(UVs, 17, a1, a1); SetUV(UVs, 18, a0, a0); SetUV(UVs, 19, a1, a0); // Bottom SetVertex(Vertices, 20, -unit, -unit, -unit); SetVertex(Vertices, 21, +unit, -unit, -unit); SetVertex(Vertices, 22, -unit, -unit, +unit); SetVertex(Vertices, 23, +unit, -unit, +unit); SetUV(UVs, 20, a0, a1); SetUV(UVs, 21, a1, a1); SetUV(UVs, 22, a0, a0); SetUV(UVs, 23, a1, a0); for (int i=0; i<24*3; i++) (*Vertices)[i] = VERTTYPEMUL((*Vertices)[i], f2vt(scale)); }
void CGraph::SetElement(int nRow, int nCol, int n) { SetVertex(nRow*CGameControl_G::s_nCols + nCol, n); }