void initPlatform(platform_s* pf, room_s* r, vect3Di_s orig, vect3Di_s dest, u8 id, bool BAF) { if(!pf || !r)return; // orig=vect3Df(orig.x+r->position.x, orig.y, orig.z+r->position.y); // dest=vect3Df(dest.x+r->position.x, dest.y, dest.z+r->position.y); pf->id=id; pf->origin=convertRectangleVector(orig); pf->destination=convertRectangleVector(dest); pf->position=pf->origin; pf->velocity=vdivf(vnormf(vsubf(pf->destination,pf->origin)),16); pf->direction=true; pf->touched=false; pf->backandforth=true; initActivatableObject(&pf->ao); pf->ao.active=true; pf->aar=createAAR(vaddf(pf->position, vect3Df(-PLATFORMSIZE, PLATFORMHEIGHT, -PLATFORMSIZE)), vect3Df(2*PLATFORMSIZE, 0.0f, 2*PLATFORMSIZE), vect3Df(0.0f, 1.0f, 0.0f)); // addPlatform(id,vmulf(pf->origin,4),vmulf(pf->destination,4),BAF); //TEMP pf->used=true; }
void initEmancipator(emancipator_s* e, md2_instance_t* mi, vect3Df_s pos, float* m) { if(!e)return; e->position=pos; e->modelInstance=*mi; if(m)memcpy(e->transformationMatrix,m,sizeof(float)*9); else{ m=e->transformationMatrix; m[0]=m[4]=m[8]=1.0f; m[1]=m[2]=m[3]=0; m[5]=m[6]=m[7]=0; } e->counter=0; e->angle=0; e->velocity=vect3Df(randFloat(-1.0f, 1.0f),1.0f,randFloat(-1.0f, 1.0f)); e->velocity=vdivf(vnormf(e->velocity),16); e->axis=vect3Df(randFloat(-1.0f, 1.0f),randFloat(-1.0f, 1.0f),randFloat(-1.0f, 1.0f)); e->axis=vnormf(e->axis); playSFX(emancipationSFX); e->used=true; }
// topscreen void renderFrame() { GPU_SetViewport((u32*)osConvertVirtToPhys((u32)gpuDOut),(u32*)osConvertVirtToPhys((u32)gpuOut),0,0,240*2,400); GPU_DepthRange(-1.0f, 0.0f); GPU_SetFaceCulling(GPU_CULL_BACK_CCW); GPU_SetStencilTest(false, GPU_ALWAYS, 0x00, 0xFF, 0x00); GPU_SetStencilOp(GPU_KEEP, GPU_KEEP, GPU_KEEP); GPU_SetBlendingColor(0,0,0,0); GPU_SetDepthTestAndWriteMask(true, GPU_GREATER, GPU_WRITE_ALL); GPUCMD_AddSingleParam(0x00010062, 0); GPUCMD_AddSingleParam(0x000F0118, 0); //setup shader SHDR_UseProgram(shader, 0); GPU_SetAlphaBlending(GPU_BLEND_ADD, GPU_BLEND_ADD, GPU_SRC_ALPHA, GPU_ONE_MINUS_SRC_ALPHA, GPU_SRC_ALPHA, GPU_ONE_MINUS_SRC_ALPHA); GPU_SetAlphaTest(false, GPU_ALWAYS, 0x00); GPU_SetTextureEnable(GPU_TEXUNIT0); GPU_SetTexEnv(0, GPU_TEVSOURCES(GPU_TEXTURE0, GPU_PRIMARY_COLOR, GPU_PRIMARY_COLOR), GPU_TEVSOURCES(GPU_TEXTURE0, GPU_PRIMARY_COLOR, GPU_PRIMARY_COLOR), GPU_TEVOPERANDS(0,0,0), GPU_TEVOPERANDS(0,0,0), GPU_MODULATE, GPU_MODULATE, 0xFFFFFFFF); GPU_SetDummyTexEnv(1); GPU_SetDummyTexEnv(2); GPU_SetDummyTexEnv(3); GPU_SetDummyTexEnv(4); GPU_SetDummyTexEnv(5); //texturing stuff GPU_SetTexture(GPU_TEXUNIT0, (u32*)osConvertVirtToPhys((u32)texData),128,128,GPU_TEXTURE_MAG_FILTER(GPU_NEAREST)|GPU_TEXTURE_MIN_FILTER(GPU_NEAREST),GPU_RGBA8); GPU_SetAttributeBuffers(3, (u32*)osConvertVirtToPhys((u32)texData), GPU_ATTRIBFMT(0, 3, GPU_FLOAT)|GPU_ATTRIBFMT(1, 2, GPU_FLOAT)|GPU_ATTRIBFMT(2, 3, GPU_FLOAT), 0xFFC, 0x210, 1, (u32[]){0x00000000}, (u64[]){0x210}, (u8[]){3}); //setup lighting (this is specific to our shader) vect3Df_s lightDir=vnormf(vect3Df(cos(lightAngle), -1.0f, sin(lightAngle))); GPU_SetUniform(SHDR_GetUniformRegister(shader, "lightDirection", 0), (u32*)(float[]){0.0f, -lightDir.z, -lightDir.y, -lightDir.x}, 1);
void shootPlayerGun(player_s* p, room_s* r, portal_s* portal) { if(!p)return; if(p->gunInstance.currentAnim == PORTALGUN_SHOOT)return; md2InstanceChangeAnimation(&p->gunInstance, PORTALGUN_IDLE, false); md2InstanceChangeAnimation(&p->gunInstance, PORTALGUN_SHOOT, true); vect3Df_s position; rectangle_s* rec = collideLineMapClosest(r, NULL, p->camera.position, vect3Df(-p->camera.orientation[2][0], -p->camera.orientation[2][1], -p->camera.orientation[2][2]), 1000.0f, &position, NULL); if(rec && rec->portalable) { portal_s oldPortal = *portal; vect3Df_s normal = rec->normal; vect3Df_s plane0 = vect3Df(p->camera.orientation[0][0], p->camera.orientation[0][1], p->camera.orientation[0][2]); plane0 = vnormf(vsubf(plane0, vmulf(normal, vdotf(normal, plane0)))); position = vaddf(position, vmulf(normal, -0.05f)); portal->position = position; updatePortalOrientation(portal, plane0, normal); isPortalOnWall(r, portal, true); portal->draw = true; portal->open = true; if(isPortalOnWall(r, portal, false)) { ejectPortalOBBs(portal); ejectPortalOBBs(portal->target); }else{ *portal = oldPortal; } } }
// topscreen void renderFrame() { //setup lighting (specific to our vertex shader) vect3Df_s lightDir = vnormf(vect3Df(cos(lightAngle), -1.0f, sin(lightAngle))); glUniform4fv(lightDirection, 1, (float[]){0.0f, -lightDir.z, -lightDir.y, -lightDir.x});