void CreateAABBOX(BOX& _out, const MATRIX& _mat) { VEC3 v1, v2; D3DXVec3TransformCoord(&v1, &VEC3(-2,-2,-2), &_mat); D3DXVec3TransformCoord(&v2, &VEC3(2,2,2), &_mat); _out.Create(v1, v2); }
//------------------------------------------------------------------------------------ Mesh* SceneManager::CreatePlaneMesh( float w, float h ) { float halfW = w / 2; float halfH = h / 2; SVertex vert[4] = { SVertex(VEC3(-w,0,+h), VEC2(0,0), VEC3::UNIT_Y), SVertex(VEC3(+w,0,+h), VEC2(1,0), VEC3::UNIT_Y), SVertex(VEC3(+w,0,-h), VEC2(1,1), VEC3::UNIT_Y), SVertex(VEC3(-w,0,-h), VEC2(0,1), VEC3::UNIT_Y), }; DWORD dwIndex[6] = {0,1,3,1,2,3}; Mesh* pMesh = new Mesh; SubMesh* pSubmesh = new SubMesh; pSubmesh->InitVertData(eVertexType_General, vert, 4, true); pSubmesh->InitIndexData(dwIndex, 6, true); pMesh->AddSubMesh(pSubmesh); return pMesh; }
SimpleGMap2::SimpleGMap2() { position = myMap.addAttribute<VEC3, VERTEX, MAP>("position"); Dart d = Algo::Surface::Modelisation::createTetrahedron<PFP>(myMap); position[d] = VEC3(0,0,0); position[myMap.phi1(d)] = VEC3(10,0,15); position[myMap.phi_1(d)] = VEC3(10,20,15); position[myMap.phi_1(myMap.phi2(d))] = VEC3(0,0,30); VEC3 mid = (position[d] + position[myMap.phi1(d)]) / 2.0f; myMap.cutEdge(d); position[myMap.phi1(d)] = mid; Algo::Surface::Tilings::Square::Cylinder<PFP> poly(myMap, 5 ,1, false, false); d = poly.getDart(); poly.embedIntoCylinder(position, 10, 10, 5); d = myMap.phi1(d); Dart dd = myMap.beta2(d); myMap.unsewFaces(d); myMap.sewFaces(d, dd); position[d][1] += 3.0f; }
//================================================================================ //! メソッド名 CYAMAKAGE_WEAPON::コンストラクタ // // 引数 inDev Direct3Dデバイス // inKind ボールの種類 // 更新 2009/02/17 <新規> //================================================================================ CYAMAKAGE_WEAPON::CYAMAKAGE_WEAPON(CONST DEV inDev) : CSKIN_MESH(inDev, NAME_YAMAKAGE_WEAPON) { // 属性の初期化 this->player = NULL; this->viewG = NULL; this->stageG = NULL; this->weaponAction = eOPEYW_MAX; this->iSmokeFrame = 0; this->iMoveFrame = 0; this->targetLoc = VEC3(0.0f, 0.0f, 0.0f); this->ssEnemyBallShot = new SSTATIC("shot_shadow"); // オリジナル「エネミーボール」の生成 this->originEnemyBall = new CENEMY_BALL(inDev, eENEMYB_STRAIGHT, "shadow_ball", EFFECT_SHADOW); this->originEnemyBall->setEffectColor(D3DCOLOR_RGBA(100,100,100,255)); this->originEnemyBall->setReactMessage(eREAMSG_ENEMY_ATTACK_LV1); // エフェクトの登録 C3D_EFFECT_CENTER* effectCenter = C3D_EFFECT_CENTER::getInstance(); effectCenter->addEffects( EFFECT_SMOKE, new C3D_EFFECT(inDev, EFFECT_SMOKE, VEC3(0.0f,0.0f,0.0f))); // 浮遊中に変更 this->setWeaponAction(eOPEYW_FLOATING); // アニメーションの初期化 this->changeAnimationAndBlend(0); // オブジェクトの種類を見える影に変更 this->setThisMessage(eTMSG_SEE_SHADOW); }
void quat_vector_vector(quat_t *q, const vec3_t *a, const vec3_t *b) { float cost = vec3_dot(a, b); if (cost > 0.99999f) { /* parallel */ *q = QUAT_IDENT; } else if (cost < -0.99999f) { /* opposite */ vec3_t t = VEC3(0, a->x, -a->y); /* cross with (1,0,0) */ if (vec3_magnitude(&t) < EPSILON) t = VEC3(-a->z, 0, a->x); /* nope, use (0,1,0) */ vec3_normalize(&t); q->v = t; q->w = 0.f; } else { vec3_t t; vec3_cross(&t, a, b); vec3_normalize(&t); /* sin^2 t = (1 - cos(2t)) / 2 */ float ss = sqrt(.5f * (1.f - cost)); vec3_scale(&t, ss); q->v = t; /* cos^2 t = (1 + cos(2t) / 2 */ q->w = sqrt(.5f * (1.f + cost)); } }
bool PropertyPaneEffect::_OnCreate() { CXTPPropertyGridItem* pCategory = m_wndPropertyGrid.AddCategory(L"Shadow"); PROPERTY_REG(pCategory, Double , L"Far Distance" , 300 , propShadowFarDist); PROPERTY_REG(pCategory, Double , L"Split Padding" , 1 , propShadowSplitPadding); PROPERTY_REG(pCategory, Vec3 , L"Optimal Adjust Factor" , VEC3(0.5f,0.8f,2) , propShadowOptimalAdjustFactor); PROPERTY_REG(pCategory, Bool , L"Use Simple Optimal Adjust" , TRUE , propShadowUseSimpleOptimalAdjust); PROPERTY_REG(pCategory, Number , L"Camera Light Direction Threshold", 45 , propShadowCameraLightDirectionThreshold); PROPERTY_REG(pCategory, Vec3 , L"Shadow Map Size" , VEC3(2048,1024,1024) , propShadowMapSize); PROPERTY_REG(pCategory, Bool , L"Self Shadow" , FALSE , propShadowSelfShadow); PROPERTY_REG(pCategory, Bool , L"Render Back Faces" , TRUE , propShadowCasterRenderBackFaces); PROPERTY_REG(pCategory, Double , L"Lambda" , 0.75f , propShadowLambda); PROPERTY_REG(pCategory, Double , L"Extrusion Distance" , 10000 , propShadowDirectionalLightExtrusionDistance); pCategory->Expand(); pCategory = m_wndPropertyGrid.AddCategory(L"SSAO"); PROPERTY_REG(pCategory, Double , L"Sample Length" , 20 , propSSAOSampleLength); PROPERTY_REG(pCategory, Double , L"Offset Scale" , 1 , propSSAOOffsetScale); PROPERTY_REG(pCategory, Double , L"Default Accessibility" , 0.5f , propSSAODefaultAccessibility); PROPERTY_REG(pCategory, Double , L"Edge Highlight" , 1.99f , propSSAOEdgeHighlight); pCategory->Expand(); (dynamic_cast<CXTPPropertyGridItemVec3*>(m_mapItem[propShadowOptimalAdjustFactor]))->SetChildItemID(propOptimalAdjustFactor0, propOptimalAdjustFactor1, propOptimalAdjustFactor2); (dynamic_cast<CXTPPropertyGridItemVec3*>(m_mapItem[propShadowMapSize]))->SetChildItemID(propShadowMapSize0, propShadowMapSize1, propShadowMapSize2); return true; }
SimpleGMap2::SimpleGMap2() { position = myMap.addAttribute<VEC3, VERTEX>("position"); Dart d = Algo::Modelisation::createTetrahedron<PFP>(myMap); position[d] = VEC3(0,0,0); position[myMap.phi1(d)] = VEC3(10,0,15); position[myMap.phi_1(d)] = VEC3(10,20,15); position[myMap.phi_1(myMap.phi2(d))] = VEC3(0,0,30); VEC3 mid = (position[d] + position[myMap.phi1(d)]) / 2.0f; myMap.cutEdge(d); position[myMap.phi1(d)] = mid; Algo::Modelisation::Polyhedron<PFP> poly(myMap, position); d = poly.cylinder_topo(5, 1, false, false); poly.embedCylinder(10, 10, 5); d = myMap.phi1(d); Dart dd = myMap.beta2(d); myMap.unsewFaces(d); myMap.sewFaces(d, dd); position[d][1] += 3.0f; }
//================================================================================================= void CreateCharacterPanel::RenderUnit() { // rysuj obrazek HRESULT hr = game->device->TestCooperativeLevel(); if(hr != D3D_OK) return; game->SetAlphaBlend(false); game->SetAlphaTest(false); game->SetNoCulling(false); game->SetNoZWrite(false); // ustaw render target SURFACE surf = NULL; if(game->sChar) V( game->device->SetRenderTarget(0, game->sChar) ); else { V( game->tChar->GetSurfaceLevel(0, &surf) ); V( game->device->SetRenderTarget(0, surf) ); } // pocz¹tek renderowania V( game->device->Clear(0, NULL, D3DCLEAR_ZBUFFER | D3DCLEAR_TARGET, 0, 1.f, 0) ); V( game->device->BeginScene() ); static vector<Lights> lights; game->SetOutsideParams(); MATRIX matView, matProj; D3DXMatrixLookAtLH(&matView, &VEC3(0.f,2.f,dist), &VEC3(0.f,1.f,0.f), &VEC3(0,1,0)); D3DXMatrixPerspectiveFovLH(&matProj, PI/4, 0.5f, 1.f, 5.f); game->tmp_matViewProj = matView * matProj; D3DXMatrixInverse(&game->tmp_matViewInv, NULL, &matView); game->camera_frustum.Set(game->tmp_matViewProj); game->ListDrawObjectsUnit(NULL, game->camera_frustum, true, *unit); game->DrawSceneNodes(game->draw_batch.nodes, lights, true); game->draw_batch.Clear(); // koniec renderowania V( game->device->EndScene() ); // kopiuj jeœli jest mipmaping if(game->sChar) { V( game->tChar->GetSurfaceLevel(0, &surf) ); V( game->device->StretchRect(game->sChar, NULL, surf, NULL, D3DTEXF_NONE) ); } surf->Release(); // przywróc poprzedni render target V( game->device->GetBackBuffer(0, 0, D3DBACKBUFFER_TYPE_MONO, &surf) ); V( game->device->SetRenderTarget(0, surf) ); surf->Release(); }
float goursat(vec3 p, vec3 mods) { vec3 res; float p2; p2 = sum(pow(p, VEC3(2))); return (-(sum(pow(p, VEC3(4))) + mods.x * pow(p2, 2) + mods.y * p2 + mods.z)); }
StorageChunk StorageChunk::new_from_buffer(const Vec3i &location, const Vector<uint8_t> &contents, Error *err) { if (contents.length() < 4 || slice_cast<const char>(contents.sub(0, 4)) != "NGSC") { err->set("Bad magic, NGSC expected"); return StorageChunk(location); } ByteReader br(contents.sub(4)); Vec3i chunk_size, storage_chunk_size; chunk_size.x = br.read_int32(err); chunk_size.y = br.read_int32(err); chunk_size.z = br.read_int32(err); if (*err) return StorageChunk(location); if (chunk_size != CHUNK_SIZE) { err->set("Mismatching chunk sizes, file: (%d %d %d), expected: (%d %d %d)", VEC3(chunk_size), VEC3(CHUNK_SIZE)); return StorageChunk(location); } storage_chunk_size.x = br.read_int32(err); storage_chunk_size.y = br.read_int32(err); storage_chunk_size.z = br.read_int32(err); if (*err) return StorageChunk(location); if (storage_chunk_size != STORAGE_CHUNK_SIZE) { err->set("Mismatching storage chunk sizes, file: (%d %d %d), expected: (%d %d %d)", VEC3(storage_chunk_size), VEC3(STORAGE_CHUNK_SIZE)); return StorageChunk(location); } auto tmp = br.read_compressed(err); if (*err) return StorageChunk(location); StorageChunk msc(location); br = ByteReader(tmp); for (int i = 0, n = volume(storage_chunk_size); i < n; i++) { Chunk &c = msc.chunks[i]; c.lods[0].deserialize(&br, CHUNK_SIZE + Vec3i(1), err); if (*err) return StorageChunk(location); } return msc; }
void vec3_majoraxis(vec3_t *out, const vec3_t *v) { float x, y, z; x = fabsf(v->x); y = fabsf(v->y); z = fabsf(v->z); if (x > y && x > z) *out = VEC3(v->x < 0 ? -1 : 1, 0, 0); else if (y > x && y > z) *out = VEC3(0, v->y < 0 ? -1 : 1, 0); else *out = VEC3(0, 0, v->z < 0 ? -1 : 1); }
//================================================================================ //! メソッド名 CENEMY_SHADOG::コンストラクタ // // 引数 inDev Direct3Dデバイス // inName Xファイルの名称 // inResource メッシュフォルダ名 // inTexture テクスチャフォルダ名 // 更新 2009/01/19 <新規> //================================================================================ CENEMY_SHADOG::CENEMY_SHADOG( CONST DEV inDev, CONST LPSTR inName, CONST LPSTR inResource, CONST LPSTR inTexture) : CKAGETOKI_ADVENT_ENEMY(inDev, inName, inResource, inTexture) { // 属性の初期化 this->fFloorSpace = 15.0f; //!< 床との間隔 this->fWallSpace = 10.0f; //!< 壁との間隔 this->fJumpHeight = 50.0f; //!< ジャンプ力 // アニメーションの割り当てを行う this->iAnimTemp[eESHADOGA_WAIT] = 0; this->iAnimTemp[eESHADOGA_RUN] = 1; this->iAnimTemp[eESHADOGA_JUMP] = 2; this->iAnimTemp[eESHADOGA_ATTACK] = 3; this->iMaxLife = 2; //!< 最大体力 this->iLife = this->iMaxLife; //!< 残り体力 this->iHitFrame = 0; //!< 衝突して点滅する時間 // フラグ群 this->action = eESHADOGA_MAX; //!< 最初は待機以外何でも良い this->changeAction(eESHADOGA_WAIT); //!< 初期状態は出現 this->setThisMessage(eTMSG_ENEMY); //!< 敵表示 this->stepCnt = 0; // 音のセット this->sStaticStep = new SSTATIC(SOUND_STEP); this->sStaticJumpStart = new SSTATIC(SOUND_JUMP_START); this->sStaticJumpEnd = new SSTATIC(SOUND_JUMP_START); this->sStaticBark1 = new SSTATIC(SOUND_BARK1); this->sStaticBark2 = new SSTATIC(SOUND_BARK2); this->sStaticStep->setVolume(-1500); this->sStaticJumpStart->setVolume(-1500); this->sStaticJumpEnd->setVolume(-1500); this->sStaticBark1->setVolume(-1000); this->sStaticBark2->setVolume(-1000); // エフェクトの登録 C3D_EFFECT_CENTER* effectCenter = C3D_EFFECT_CENTER::getInstance(); effectCenter->addEffects( EFFECT_SMOKE, new C3D_EFFECT(inDev, EFFECT_SMOKE, VEC3(0.0f,0.0f,0.0f))); // ローカル座標の変更 this->sd_ptr->mesh->localCenter = VEC3(0.0f, 50.0f, 0.0f); this->sd_ptr->mesh->localRadius = 100.0f; }
//---------------------------------------------------------------------------------------- D3D11RenderTarget::D3D11RenderTarget() :m_pRenderSystem(g_env.pRenderSystem) ,m_pRenderTexture(nullptr) ,m_clearColor(SColor::BLACK) ,m_bClearColor(true) ,m_bClearZBuffer(true) ,m_bHasDepthBuffer(false) ,m_bNoFrameBuffer(false) ,m_bUpdateRatioAspect(true) ,m_phaseFlag(eRenderPhase_Geometry) ,m_pDepthStencil(nullptr) ,m_sizeRatio(0, 0) { // Create screen quad static bool bCreate = false; if (!bCreate) { m_pQuadMesh = new Mesh; SubMesh* pSubMesh = new SubMesh; SVertex v[4] = { SVertex(VEC3(-1,1,0), VEC2(0,0)), SVertex(VEC3(1,1,0), VEC2(1,0)), SVertex(VEC3(-1,-1,0), VEC2(0,1)), SVertex(VEC3(1,-1,0), VEC2(1,1)) }; DWORD index[6] = { 0,1,2, 1,3,2 }; // Store index to frustum far corner v[0].normal.x = 0; v[1].normal.x = 1; v[2].normal.x = 2; v[3].normal.x = 3; pSubMesh->InitVertData(eVertexType_General, v, ARRAYSIZE(v), true); pSubMesh->InitIndexData(index, ARRAYSIZE(index), true); m_pQuadMesh->AddSubMesh(pSubMesh); m_pQuadEntity = new Entity(m_pQuadMesh); m_pQuadEntity->SetCastShadow(false); m_pQuadEntity->SetReceiveShadow(false); bCreate = true; } }
//================================================================================ //! メソッド名 CKAGEO_BALL::コンストラクタ // // 引数 inDev Direct3Dデバイス // inKind ボールの種類 // 更新 2008/08/26 <新規> //================================================================================ CKAGEO_BALL::CKAGEO_BALL(CONST DEV inDev, KAGEO_BALL_KIND inKind) : CMESH(inDev, getBallTextureName(inKind)) { // 属性の初期化 this->activate = FALSE; this->hitG = NULL; this->iFrame = 0; this->sStaticHit = NULL; // ボールの種類により、初期化処理分岐 switch(inKind) { // シャドウボール case eKOBALL_SHADOW: // 見えない影を、見える影にするメッセージ this->judgMessage = eTMSG_NO_SEE_SHADOW; this->reactMessage = eREAMSG_SHADOW_HIT; this->setThisMessage(eTMSG_SHADOW_BALL); // エフェクト関連 this->iEffectCnt = 3; strcpy_s(this->effectName, sizeof(effectName), EFFECT_SHADOW); // 煙の色 this->smokeColor = D3DCOLOR_RGBA(10, 10, 10, 255); // 音を生成 this->sStaticHit = new SSTATIC(SOUND_SHADOWB_HIT); break; // シャインボール case eKOBALL_SHINE: // 見える影を、見えない影にするメッセージ this->judgMessage = eTMSG_SEE_SHADOW; this->reactMessage = eREAMSG_SHINE_HIT; this->setThisMessage(eTMSG_SHINE_BALL); // エフェクト関連 this->iEffectCnt = 3; strcpy_s(this->effectName, sizeof(effectName), EFFECT_SHINE); // 音を生成 this->sStaticHit = new SSTATIC(SOUND_SHINEB_HIT); // 煙の色 this->smokeColor = D3DCOLOR_RGBA(255, 255, 200, 255); break; // 上記以外(エラー数値) default: this->judgMessage = eTMSG_NOMSG; this->reactMessage = eREAMSG_NOMSG; this->setThisMessage(eTMSG_NOMSG); this->iEffectCnt = 100000; strcpy_s(this->effectName, sizeof(effectName), ""); this->smokeColor = D3DCOLOR_RGBA(255, 255, 255, 255); return; } // エフェクトの登録 C3D_EFFECT_CENTER* effectCenter = C3D_EFFECT_CENTER::getInstance(); effectCenter->addEffects( this->effectName, new C3D_EFFECT(inDev, this->effectName, VEC3(0.0f,0.0f,0.0f))); }
void MaterialBuffer::dump(int n) const { printf("Material Pack dump ---------------------------------------------\n"); printf("BC1 Textures:\n"); for (const String &s : bc1_textures) printf(" - %s\n", s.c_str()); printf("BC4 Textures:\n"); for (const String &s : bc4_textures) printf(" - %s\n", s.c_str()); printf("BC5 Textures:\n"); for (const String &s : bc5_textures) printf(" - %s\n", s.c_str()); auto dump_face = [](const MaterialFace &face) { printf(" - Base Color Texture: %f\n", face.base_color_texture); printf(" - Normal Texture: %f\n", face.normal_texture); printf(" - Metallic Texture: %f\n", face.metallic_texture); printf(" - Roughness Texture: %f\n", face.roughness_texture); printf(" - Base Color: %f %f %f\n", VEC3(face.base_color)); printf(" - Scale: %f\n", face.scale); printf(" - Metallic: %f\n", face.metallic); printf(" - Roughness: %f\n", face.roughness); }; int i = 0; for (const Material &m : materials) { printf("Material %d\n", i++); printf("Top:\n"); dump_face(m.top); printf("Side:\n"); dump_face(m.side); if (i == n) break; } printf("----------------------------------------------------------------\n"); }
s_texmod get_texture(s_mat mat, vec3 pos, vec3 normal) { int val; vec3 tmp; vec4 v; tmp = pos / mat.m_param.xyz; if (mat.m_id == CHECKBOARD) { if (INT(floor(tmp.x) + floor(tmp.y) + floor(tmp.z)) % 2 == 1) return (S_TEXMOD(mat.m_color, normal, mat.m_prop.x, mat.m_prop.y)); return (S_TEXMOD(mat.color, normal, mat.smoothness, mat.metallic)); } if (mat.m_id == BUMP) { tmp = VEC3(sin(tmp.x), 0, cos(tmp.z)); v.x = length(tmp); return (S_TEXMOD(mat.color, normalize(normal + mat.m_param.w * tmp), mat.smoothness * v.x, mat.metallic * v.x)); } if (mat.m_id == WAVE) { tmp = floor(tmp + sin(tmp.zyx)); if (INT(tmp.x + tmp.y + tmp.z) % 2 == 1) return (S_TEXMOD(mat.m_color, normal, mat.m_prop.x, mat.m_prop.y)); } return (get_texture2(mat, pos, normal)); }
//================================================================================ //! メソッド名 CKAGEO_BALL::intersectG // // 機能 衝突判定 // 更新 2008/08/26 <新規> //================================================================================ void CKAGEO_BALL::intersectG(void) { // 衝突判定グループが設定されていないなら、処理をしない if( !this->hitG) return; // 衝突判定 if( this->hitG->intersect(this, this->getLine())) { // 見えない影オブジェクトなら、シャドウボールと衝突した意味のメッセージを与える if( this->hitG->getPrevHitObject()->getThisMessage() == this->judgMessage) { this->hitG->getPrevHitObject()->reactionMessage(this->reactMessage); } // 球消滅 this->setVisible(FALSE); this->activate = FALSE; // 衝突音発生 this->soundHit(); // 煙エフェクト発生 C3D_EFFECT_CENTER::occuEffectsInstance( "smoke", this->getLoc(), 2.0f, VEC3(0.0f,0.0f,0.0f), this->smokeColor); // 球に消滅メッセージ与える this->setOrderMessage(eOMSG_DELETE); } }
VEC3 VEC3 :: operator*=(const float scalar) { components[0] = scalar * components[0]; components[1] = scalar * components[1]; components[2] = scalar * components[2]; return(VEC3(components[0], components[1], components[2])); }
//================================================================================ //! メソッド名 CADVENT_KAGEMI::skillEnergyShoot // // 機能 技「エナジーシュート」 // 更新 2009/01/24 <新規> //================================================================================ void CADVENT_KAGEMI::skillEnergyShoot(void) { // エナジーパワーに、エナジーシュートを撃つだけの余裕がある時 // エナジーシュートを生成 CKAGEMI_BALL* newBall = new CKAGEMI_BALL(this->originEnergyBall); // エナジーシュートの設定 newBall->shot( &this->ballAngle, //!< 角度 &this->getWorldCenter(), //!< 発射位置 this->stageG, //!< ステージオブジェクトグループ this->enemyG, //!< 敵オブジェクトグループ this->energyShootFrame); //!< 消滅時間 newBall->setMoveQuantity(this->energyShootSpeed); //!< スピード設定 newBall->setScale(3.0f); //!< 拡大 newBall->setLine(ADVENT_FRONTHIT); //!< 向き(3D空間に対して) newBall->setOrderMessage(eOMSG_DELETE_IN); //!< 他解放 // 煙エフェクト発生 C3D_EFFECT_CENTER::occuEffectsInstance( EFFECT_SMOKE, newBall->getLoc(), 0.5f, VEC3(0.0f,0.0f,0.0f), D3DCOLOR_RGBA(255, 200, 200, 255)); // エナジーボール発射音 this->soundShotEnergy(); // エナジーボール操作対象に登録 this->viewG->add(newBall); }
VEC3 VEC3 :: operator/=(const float scalar) { components[0] = components[0] / scalar; components[1] = components[1] / scalar; components[2] = components[2] / scalar; return(VEC3(components[0], components[1], components[2])); }
/*-----------------------------------------------------------------* | <<< ヒットポイント表示 >>> | 入力 iNum = 0 : プレイヤー、 1 : エネミー | fLen = バーの長さ(0.0f 〜 1.0f ) *-------------------------------------------------------------------*/ void HitPointDraw(int iNum, float fLen) { d3_stat_zwrite_set(false); d3_stat_zread_set( false); //--- HP描画 ---------------------------------------------------- VEC2 p0, p1; float a = 264.f; if(iNum == 0){ p0 = VEC2( 8, 8); p1 = VEC2( 8 + a, 40);} else { p0 = VEC2(368, 8); p1 = VEC2(368 + a, 40);} d3_2d_box_fill_draw(&p0, &p1, D3_COL(255, 255, 255, 0));// 下地 p0.x += 1, p1.x += -1; // 一回り小さくする p0.y += 1, p1.y += -1; if(iNum == 0){ p0.x += (a - a * fLen);} // プレイヤー else { p1.x -= (a - a * fLen);} // エネミー d3_2d_box_fill_draw(&p0, &p1, D3_COL(255, 255, 255, 0)); // ライフはボックスで //--- KO描画 ----------------------------------------------------- if(iNum == 1) // エネミーの時のみKO描画 { d3_spr_draw(TEX_KO_BAR, NULL, &VEC3(320, 24, 0)); } d3_stat_zread_set( true); d3_stat_zwrite_set(true); }
static void keyboardDown(unsigned char key, int x, int y) { Vec3f look_dir, up, right; switch (key) { case 'Q': case 'q': case 27: exit(0); break; case 'w': camera_state |= PCS_MOVING_FORWARD; break; case 'a': camera_state |= PCS_MOVING_LEFT; break; case 's': camera_state |= PCS_MOVING_BACKWARD; break; case 'd': camera_state |= PCS_MOVING_RIGHT; break; case 'p': printf("pos: %f %f %f\n", VEC3(camera.translation)); printf("orient %f %f %f %f\n", VEC4(camera.orientation)); break; } }
t_hitpoint hitcone(t_ray *r, t_cone *c) { t_hitpoint h; t_param p; double k; t_vec3 e; e = VEC3(r->o.x - c->p.x, r->o.y - c->p.y, r->o.z - c->p.z); k = c->r / c->h; k = k * k; p.a = r->dir.x * r->dir.x + r->dir.z * r->dir.z - r->dir.y * r->dir.y * k; p.b = 2 * (r->dir.x * e.x + r->dir.z * e.z - r->dir.y * e.y * k); p.c = e.x * e.x + e.z * e.z - e.y * e.y * k; if ((p.det = p.b * p.b - 4 * p.a * p.c) < EPSILON) return (miss()); p.det = sqrt(p.det); h.t = (-p.b - p.det) / (2 * p.a); if (h.t < EPSILON) h.t = (-p.b + p.det) / (2 * p.a); if (h.t < EPSILON) return (miss()); h.p = vec_add(r->o, vec_scalar(r->dir, h.t)); h.n = normalize((t_vec3){h.p.x - c->p.x, 0, h.p.z - c->p.z}); h.c = c->color; // h.m = p->m; return (h); }
vec3 ellipse_norm(s_cam cam, s_res ret, s_geo sp) { vec3 pos; pos = 2 * (cam.pos + cam.ray * ret.dst - sp.pos) / pow(sp.a.xyz, VEC3(2)); return (normalize(pos)); }
//================================================================================ //! メソッド名 CBACK_SKY::コンストラクタ // // 引数 inViewPoint 生成時のカメラ視点 // 更新 2008/09/26 <新規> //================================================================================ CBACK_SKY::CBACK_SKY(CONST DEV inDev, VEC3* inViewPoint) : CBACK(inViewPoint) { // 背景テクスチャの生成 this->sky = new CMESH(inDev, NAME_SKY); this->sky->setLoc(&(*inViewPoint+VEC3(0.0f,0.0f,0.0f))); }
//================================================================================ //! メソッド名 CSCENE_MOVIE3::コンストラクタ // // 引数 inFlag 現在のシーンフラグ // inNextFlag 次のシーンフラグ // inData シーン共有データ // 更新 2009/02/10 <新規> //================================================================================ CSCENE_MOVIE3::CSCENE_MOVIE3(SCENE_SHARE_DATA* inData) : //! ゲームシーン CSCENE_MOVIE_BASE(eSCENE_CHAPTER1_MOVIE3, eSCENE_CHAPTER1_STAGE3, inData) { // 初期化 this->camera = NULL; this->cameraTarget = NULL; this->kageo = NULL; this->kagemi = NULL; this->shabird = NULL; this->clime = NULL; this->tima = NULL; this->feather = NULL; this->yamakage = NULL; this->exe = NULL; this->objMapForest = NULL; this->objMapCave = NULL; this->back = NULL; this->cave = NULL; this->movieFlag = eM3F_FOREST; this->backSound = NULL; this->shaderZTexture = NULL; this->shaderDepthBuf = NULL; D3DXMatrixIdentity(&this->lightView); D3DXMatrixIdentity(&this->lightProj); this->lightShift = VEC3(0.0f, 0.0f, 0.0f); this->lightNearFar = VEC2(0.0f, 0.0f); }
VEC3 VEC3 :: operator -() { components[0] = -1 * components[0]; components[1] = -1 * components[1]; components[2] = -1 * components[2]; return(VEC3(components[0], components[1], components[2])); }
void TCompCharacterController::ChangeSpeed(float speed) { m_accel = VEC3(0, 0, 0); assert(isValid(m_speed)); m_speed.Normalize(); m_speed *= speed; assert(isValid(m_speed)); }
t_vec3 ft_vec3sub(t_vec3 v1, t_vec3 v2) { return (VEC3( v1.x - v2.x, v1.y - v2.y, v1.z - v2.z )); }
VEC3 cross(const VEC3& a, const VEC3& b) { float x = (a.y()*b.z())-(b.y()*a.z()); float y = (a.z()*b.x())-(b.z()*b.x()); float z = (a.x()*b.y())-(b.x()*a.y()); return (VEC3(x, y, z)); }