void CTinyCadView::SetScrollCentre(CDPoint c) { CRect rect; CDPoint p; GetClientRect(rect); p = GetTransform().DeScale(GetCurrentDocument()->m_snap, CPoint(rect.right / 2, rect.bottom / 2)); SetScroll(GetTransform().GetOrigin().x + c.x - p.x, GetTransform().GetOrigin().y + c.y - p.y); }
void CTinyCadView::SetScrollPoint(CDPoint c, CPoint p) { CRect rect; CDPoint p2; GetClientRect(rect); //p2=GetTransform().DeScale(GetCurrentDocument()->m_snap,p - GetTransform().GetPixelOffset()); p2 = GetTransform().DeScale(p - GetTransform().GetPixelOffset()); SetScroll(GetTransform().GetOrigin().x + c.x - p2.x, GetTransform().GetOrigin().y + c.y - p2.y); }
void VelocityRotator::Update(float dt) { if (body != nullptr) { XMFLOAT3 rot = GetTransform().GetRotation(); XMFLOAT4 velo = body->GetVelocity(); rot.z -= velo.x * speedScale * dt; rot.x += velo.z * speedScale * dt; GetTransform().SetRotation(rot); } }
void FixedCamera::Initialize() { //Camera Component m_pCamera = new CameraComponent(); AddComponent(m_pCamera); GetTransform()->Translate(2.5, -2, -2.5f); GetTransform()->RotateEuler(0, glm::radians(45.f), 0); GetTransform()->RotateEuler(glm::radians(20.f), 0, glm::radians(20.f)); }
Matrix4f Camera::GetViewProjection() const { //This comes from the conjugate rotation because the world should appear to rotate //opposite to the camera's rotation. Matrix4f cameraRotation = GetTransform().GetTransformedRot().Conjugate().ToRotationMatrix(); //Similarly, the translation is inverted because the world appears to move opposite //to the camera's movement. Matrix4f cameraTranslation = Matrix4f().InitTranslation(GetTransform().GetTransformedPos() * -1); return m_projection * cameraRotation * cameraTranslation; }
// The scroll bar functions: // These control the horizontal and vertical scrolling of the window // (uses OnSize to track the window's size to stop the user being able to place text off the max size) void CTinyCadView::SetScroll(double NewX, double NewY, bool first) { CRect rect; int px, py; // How big is the current window? GetClientRect(rect); // Convert region into internal co-ords px = static_cast<int> (GetTransform().doubleDeScale(rect.right)); py = static_cast<int> (GetTransform().doubleDeScale(rect.bottom)); // Allow a 10% overlap CDPoint xlap = GetCurrentDocument()->GetDetails().GetOverlap(); int Xlap = static_cast<int> (xlap.x); int Ylap = static_cast<int> (xlap.y); // Now does this fit? if (px + NewX > GetCurrentDocument()->GetDetails().GetPageBoundsAsPoint().x + Xlap) NewX = GetCurrentDocument()->GetDetails().GetPageBoundsAsPoint().x + Xlap - px; if (py + NewY > GetCurrentDocument()->GetDetails().GetPageBoundsAsPoint().y + Ylap) NewY = GetCurrentDocument()->GetDetails().GetPageBoundsAsPoint().y + Ylap - py; if (NewX < -Xlap) NewX = -Xlap; if (NewY < -Ylap) NewY = -Ylap; if (first || GetTransform().GetOrigin() != CDPoint(NewX, NewY) || m_old_zoom_factor != GetTransform().GetZoomFactor()) { GetTransform().SetOriginX(NewX); GetTransform().SetOriginY(NewY); SCROLLINFO si; si.cbSize = sizeof(SCROLLINFO); si.nMin = 0; si.nMax = GetCurrentDocument()->GetDetails().GetPageBoundsAsPoint().x + Xlap * 2; si.nPage = static_cast<int> (GetTransform().doubleDeScale(rect.Width())); si.nPos = static_cast<int> (GetTransform().GetOrigin().x) + Xlap; si.fMask = SIF_PAGE | SIF_POS | SIF_RANGE | SIF_DISABLENOSCROLL; SetScrollInfo(SB_HORZ, &si, TRUE); si.cbSize = sizeof(SCROLLINFO); si.nMin = 0; si.nMax = GetCurrentDocument()->GetDetails().GetPageBoundsAsPoint().y + Ylap * 2; si.nPage = static_cast<int> (GetTransform().doubleDeScale(rect.Height())); si.nPos = static_cast<int> (GetTransform().GetOrigin().y) + Ylap; si.fMask = SIF_PAGE | SIF_POS | SIF_RANGE | SIF_DISABLENOSCROLL; SetScrollInfo(SB_VERT, &si, TRUE); if (hRuler != NULL) hRuler->RedrawWindow(); if (vRuler != NULL) vRuler->RedrawWindow(); Invalidate(); } m_old_zoom_factor = GetTransform().GetZoomFactor(); }
void FreeLook::ProcessInput(const Input& input, float delta) { if (input.GetKeyUp(Input::KEY_LEFT)) { GetTransform()->Rotate(PxQuat(ToRadians(-90.0f), PxVec3(0, 1, 0))); } if (input.GetKeyUp(Input::KEY_RIGHT)) { GetTransform()->Rotate(PxQuat(ToRadians(90.0f), PxVec3(0, 1, 0))); } }
void TransformNDOF::GetJacobian(const scalarArray &q, se3Array &J) { SE3 T = GetTransform(q); scalarArray dq(m_iDOF); for ( int i = 0; i < m_iDOF; i++ ) dq[i] = q[i]; for ( int i = 0; i < m_iDOF; i++ ) { dq[i] += m_rEPS; J[i] = (SCALAR_1 / m_rEPS) * Linearize(T % GetTransform(dq)); dq[i] -= m_rEPS; } }
void ABaseCharacter::CheckAttackOverlap(){ //Overlapping actors for each box spawned will be stored here TArray<struct FOverlapResult> OutActorOverlaps; //Hit other actors only once TArray<AActor*> ProcessedActors; //The initial rotation of our box is the same as our character rotation FQuat Rotation = GetTransform().GetRotation(); FVector Start = GetTransform().GetLocation() + Rotation.Rotator().Vector() * 100.0f; FCollisionShape CollisionHitShape; FCollisionQueryParams CollisionParams; //We do not want the character to hit itself, don't store this character in the array, to ignore it's collision CollisionParams.AddIgnoredActor(this); //Set the channels that will respond to the collision FCollisionObjectQueryParams CollisionObjectTypes; CollisionObjectTypes.AddObjectTypesToQuery(ECollisionChannel::ECC_PhysicsBody); CollisionObjectTypes.AddObjectTypesToQuery(ECollisionChannel::ECC_Pawn); //CollisionObjectTypes.AddObjectTypesToQuery(ECollisionChannel::ECC_WorldStatic); // uncomment to enable bashing objects //Create the box and get the overlapping actors CollisionHitShape = FCollisionShape::MakeBox(AttackBox); GetWorld()->OverlapMulti(OutActorOverlaps, Start, Rotation, CollisionHitShape, CollisionParams, CollisionObjectTypes); AActor* ActorToProcess; //Process all hit actors for (int i = 0; i < OutActorOverlaps.Num(); ++i) { ActorToProcess = OutActorOverlaps[i].GetActor(); //We process each actor only once per Attack execution if (ActorToProcess && !ProcessedActors.Contains(ActorToProcess)) { //Add this actor to the array because we are spawning one box per tick and we don't want to hit the same actor twice during the same attack animation ProcessedActors.AddUnique(ActorToProcess); if ( dynamic_cast<APatrollingEnemyCharacter*>(ActorToProcess) ){ APatrollingEnemyCharacter* ennemy = (APatrollingEnemyCharacter*)ActorToProcess; ennemy->OnHit(this); } } } }
void ABomb::SimulateExplosionFX_Implementation() { if (ExplosionFX) { UGameplayStatics::SpawnEmitterAtLocation(GetWorld(), ExplosionFX, GetTransform(), true); } }
//TODO: need refine!!! void ctLineBorders::Draw() { //if(!rectDotIndexes) return; //glDisable(GL_DEPTH_TEST); GetOpenGLContext()->functions()->glBindBuffer(GL_ARRAY_BUFFER, meshVBO); if (posAtribLoc != -1) { GetOpenGLContext()->functions()->glVertexAttribPointer(posAtribLoc, 3, GL_FLOAT, GL_FALSE, (3 * sizeof(GLfloat)), (const GLvoid*)0); GetOpenGLContext()->functions()->glEnableVertexAttribArray(posAtribLoc); } else {qDebug()<<"isShit pos!!!";} m_currentShader->bind(); m_currentShader->setUniformValue(matrixUniform, GetProjectionMatrix().GetMatrix()); m_currentShader->setUniformValue(materialUniform, GetMaterial()->GetRGBA()); m_currentShader->setUniformValue(transformMatrixUniform, GetTransform()->GetGlobalTransformMatrix().GetMatrix()); glDrawElements(GL_LINE_LOOP, m_dots.count(), GL_UNSIGNED_SHORT, planeIndexes); GetOpenGLContext()->functions()->glBindBuffer(GL_ARRAY_BUFFER, 0); m_currentShader->release(); }
void GeometryGroup::Draw (cairo_t *cr) { Transform *transform = GetTransform (); cairo_matrix_t saved; cairo_get_matrix (cr, &saved); if (transform) { cairo_matrix_t matrix; transform->GetTransform (&matrix); cairo_transform (cr, &matrix); } GeometryCollection *children = GetChildren (); Geometry *geometry; // GeometryGroup is used for Clip (as a Geometry) so Fill (normally setting the fill rule) is never called cairo_set_fill_rule (cr, convert_fill_rule (GetFillRule ())); int children_count = children->GetCount (); for (int i = 0; i < children_count; i++) { geometry = children->GetValueAt (i)->AsGeometry (); geometry->Draw (cr); } cairo_set_matrix (cr, &saved); }
void Iglo::Initialize(const GameContext& gameContext) { UNREFERENCED_PARAMETER(gameContext); // ADD MODEL auto physX = PhysxManager::GetInstance()->GetPhysics(); auto igloModelComponent = new ModelComponent(L"./Resources/Meshes/Iglo.ovm"); auto igloMaterial = new DiffuseMaterial(); igloMaterial->SetDiffuseTexture(L"./Resources/Textures/Iglo.jpg"); gameContext.pMaterialManager->AddMaterial(igloMaterial, 1); igloModelComponent->SetMaterial(1); AddComponent(igloModelComponent); auto rigidbody = new RigidBodyComponent(); rigidbody->SetKinematic(true); AddComponent(rigidbody); auto defaultMaterial = physX->createMaterial(0.5f, 0.5f, 0.1f); auto igloMesh = ContentManager::Load<PxTriangleMesh>(L"./Resources/Meshes/Iglo.ovpt"); shared_ptr<PxGeometry> igloGeo(new PxTriangleMeshGeometry(igloMesh)); auto IgloCollider = new ColliderComponent(igloGeo, *defaultMaterial); AddComponent(IgloCollider); GetTransform()->Translate(m_Position); }
void Cube::Render(LPDIRECT3DDEVICE9 pd3dDevice, DWORD dwAttribId) { // Set texture if (!m_pTexture) { m_pTexture = LoadTexture(pd3dDevice, "snow.bmp"); } std::map<int, DWORD> mDwRenderState; pd3dDevice->SetTransform(D3DTS_WORLD, GetTransform()); if (m_bBlending) { DWORD dwState; pd3dDevice->GetRenderState(D3DRS_ALPHABLENDENABLE, &dwState); mDwRenderState[D3DRS_SRCBLEND] = dwState; pd3dDevice->SetRenderState(D3DRS_ALPHABLENDENABLE, TRUE); pd3dDevice->GetRenderState(D3DRS_SRCBLEND, &dwState); mDwRenderState[D3DRS_SRCBLEND] = dwState; pd3dDevice->SetRenderState(D3DRS_SRCBLEND, D3DBLEND_SRCALPHA); pd3dDevice->GetRenderState(D3DRS_DESTBLEND, &dwState); mDwRenderState[D3DRS_DESTBLEND] = dwState; pd3dDevice->SetRenderState(D3DRS_DESTBLEND, D3DBLEND_INVSRCALPHA); } /*else { pd3dDevice->SetRenderState(D3DRS_ALPHABLENDENABLE, FALSE); pd3dDevice->SetRenderState(D3DRS_ZENABLE, TRUE); } */ pd3dDevice->SetMaterial(&m_d3dMaterial); pd3dDevice->SetTexture(0, m_pTexture); m_pMesh->DrawSubset(dwAttribId); if (m_bBlending) { for (auto &it : mDwRenderState) { pd3dDevice->SetRenderState((D3DRENDERSTATETYPE)it.first, it.second); } } }
void AudioListener::OnTick() { if (!m_audio) return; m_audio->SetListenerTransform(GetTransform()); }
void Camera::UpdateMatrix() { int width = Screen::GetWidth(); int height = Screen::GetHeight(); auto transform = GetTransform(); m_view_matrix = Matrix4x4::LookTo( transform->GetPosition(), transform->GetForward(), transform->GetUp()); if(!m_orthographic) { m_projection_matrix = Matrix4x4::Perspective(m_field_of_view, width / (float) height, m_near_clip_plane, m_far_clip_plane); } else { float top = m_orthographic_size; float bottom = -m_orthographic_size; float plane_h = m_orthographic_size * 2; float plane_w = plane_h * (width * m_rect.width) / (height * m_rect.height); m_projection_matrix = Matrix4x4::Ortho(-plane_w/2, plane_w/2, bottom, top, m_near_clip_plane, m_far_clip_plane); } m_view_projection_matrix = m_projection_matrix * m_view_matrix; }
void CInstanceMesh::Render() { if ( !mStaticMesh || !GetActive() ) return; Math::Mat44f lTransform = GetTransform(); mCenter = lTransform* mStaticMesh->GetAABB().GetCenter(); if( mIsDynamic ) { mPhysicActor->GetMat44( lTransform ); Math::Vect3f lUp( 0.0f, -mStaticMesh->GetAABB().GetCenter().y, 0.0f ); Math::Mat44f lCenterTransform; lCenterTransform.SetIdentity(); lCenterTransform.Translate( lUp ); lTransform = lTransform * lCenterTransform; } CFrustum lCameraFrustum = CameraMInstance->GetCurrentCamera()->GetFrustum(); CGraphicsManager* lGM = GraphicsInstance; if ( lCameraFrustum.SphereVisible( D3DXVECTOR3( mCenter.u ), mRadius ) ) { lGM ->SetTransform( lTransform ); mStaticMesh->Render( lGM ); lGM ->SetTransform( Math::Mat44f() ); } }
void Camera::OneFrame(float delta) { InputSystem &is = *Engine::GetSingleton()->GetInputSystem(); int delta_x = is.GetMouseXMove(); int delta_y = is.GetMouseYMove(); GetTransform()->Rotate(delta_x/1000.0f, -delta_y/1000.0f, 0.0f); if(mouse_reset) { float mouse_x_p = is.GetMouseXPercent(), mouse_y_p = is.GetMouseYPercent(); if(mouse_x_p<0.4f || mouse_x_p>0.6f || mouse_y_p<0.4f || mouse_y_p>0.6f ) { is.SetMousePositionPercent(0.5f, 0.5f); } } if(is.IsKeyDown(InputSystem::K_W)) { TranslateForward(20.0f*delta); } else if(is.IsKeyDown(InputSystem::K_S)) { TranslateForward(-20.0f*delta); } if(is.IsKeyDown(InputSystem::K_D)) { TranslateRight(20.0f*delta); } else if(is.IsKeyDown(InputSystem::K_A)) { TranslateRight(-20.0f*delta); } }
void AMobileEnemy::BeginPlay() { Super::BeginPlay(); m_totalDistance = RightDistance + LeftDistance; m_currentDistance = LeftDistance; m_actualJumpSpeed = 0.0f; m_capsuleHeight = CapsuleComponent->GetScaledCapsuleHalfHeight(); m_capsuleRadious = CapsuleComponent->GetScaledCapsuleRadius(); m_capsuleHeightPadding = m_capsuleHeight * PADDING_ENEMY_COLLISION_PERCENT; m_capsuleRadiousPadding = m_capsuleRadious * 0.55f; m_lastPosition = GetActorLocation(); m_nextPosition = m_lastPosition; m_rightVector = GetActorRightVector(); { FVector right = GetActorRightVector(); right = right; m_rightPosition = (m_lastPosition + RightDistance * right) * right; m_leftPosition = (m_lastPosition + LeftDistance * -right) * right; } m_isMoving = !HasTrigger; m_initialMovement = m_isMoving; m_initialStatus = GetTransform(); if (Fly) m_enableGravity = false; RegisterDelegate(); }
void ABrainNormalInteractiveObject::BeginPlay() { Super::BeginPlay(); int8 flags = (_canBeRotate ? EAction::ROTATE : 0) | (_canBeTranslate ? EAction::TRANSLATE : 0) | (_canBeScale ? EAction::SCALE : 0) | (_canBeShear ? EAction::SHEAR : 0); _actions = FObjectAction(flags); // Init Rotate _currentRotation = GetActorRotation(); _targetRotation = GetActorRotation(); // Init Translate _currentTranslation = GetActorLocation(); _targetTranslation = GetActorLocation(); // Init Scale _targetScale = _initScale; _currentScale = _initScale; // Init Shear _currentShearFirstAxis = 0; _currentShearSecondAxis = 0; _targetShearFirstAxis = 0; _targetShearSecondAxis = 0; _cachedTransform = GetTransform(); if (this->GetClass()->ImplementsInterface(UBrainSaveInterface::StaticClass())) Load(); }
void Blast::OnTriggerStay(EDGameCore::ICollider* thisCollider, EDGameCore::ICollider* otherCollider, const EDCollision::Contact& contact) { if( otherCollider->GetAttachedRigidBody() != 0 ) { EDCollision::Contact contact2 = contact; Float3 delta = otherCollider->GetTransform()->GetWorldMatrix().WAxis - GetTransform()->GetWorldMatrix().WAxis; if( DotProduct( delta, contact.Normal ) < 0.0f ) contact2.negate(); float mag = delta.magnitude(); if( mag == 0.0f ) { delta = Float3(0.0f, 1.0f, 0.0f); mag = 1.0f; } else delta *= (1.0f / mag); delta *= 15000.0f / (mag*mag); delta *= (1.0f / EDGameCore::Game::GetDeltaTime()); otherCollider->GetAttachedRigidBody()->ApplyForceAtPoint( delta, contact2.Point[0] ); } }
/*! Subdivides the mesh uniformly one step */ void LoopSubdivisionMesh::Subdivide() { // Create new mesh and copy all the attributes HalfEdgeMesh subDivMesh; subDivMesh.SetTransform(GetTransform()); subDivMesh.SetName(GetName()); subDivMesh.SetColorMap(GetColorMap()); subDivMesh.SetWireframe(GetWireframe()); subDivMesh.SetShowNormals(GetShowNormals()); subDivMesh.SetOpacity(GetOpacity()); if (IsHovering()) subDivMesh.Hover(); if (IsSelected()) subDivMesh.Select(); subDivMesh.mMinCMap = mMinCMap; subDivMesh.mMaxCMap = mMaxCMap; subDivMesh.mAutoMinMax = mAutoMinMax; // loop over each face and create 4 new ones for (unsigned int i=0; i<mFaces.size(); i++){ // subdivide face std::vector< std::vector<Vector3<float> > > faces = Subdivide(i); // add new faces to subDivMesh for(unsigned int j=0; j<faces.size(); j++){ subDivMesh.AddFace(faces.at(j)); } } // Assigns the new mesh *this = LoopSubdivisionMesh(subDivMesh, ++mNumSubDivs); Update(); }
S2Matrix4x4 Camera::GetViewMatrix() const { const Transform &trans = *GetTransform(); //Use spherical coordinate for forward vector. const S2Vector3 & rotate = trans.GetRotate(); float theta = rotate[0], phi = rotate[1]; phi = phi > 1.57f ? 1.57f : phi; phi = phi < -1.57f ? -1.57f : phi; S2Vector3 zaxis(sin(theta)*cos(phi), sin(phi), cos(theta)*cos(phi)); S2Vector3 xaxis = S2Vector3(0.0f, 1.0f, 0.0f).Cross(zaxis); xaxis.Normalize(); S2Vector3 yaxis = zaxis.Cross(xaxis); S2Vector3 position = trans.GetTranslate(); float p_dot_x = position.Dot(xaxis); float p_dot_y = position.Dot(yaxis); float p_dot_z = position.Dot(zaxis); return S2Matrix4x4( xaxis[0], xaxis[1], xaxis[2], -p_dot_x, yaxis[0], yaxis[1], yaxis[2], -p_dot_y, zaxis[0], zaxis[1], zaxis[2], -p_dot_z, 0.0f, 0.0f, 0.0f, 1.0f ); }
void Terrain::Render(LPDIRECT3DDEVICE9 pd3dDevice, DWORD dwAttribId) { if (!m_pTexture) { LoadTexture(); } pd3dDevice->SetTransform(D3DTS_WORLD, GetTransform()); m_pd3dDevice->SetTexture(0, m_pTexture); m_pd3dDevice->SetMaterial(&m_d3dMaterial); m_pd3dDevice->SetStreamSource(0, m_pVertexBuffer, 0, sizeof(Vertex)); m_pd3dDevice->SetFVF(Vertex::FVF_Flags | D3DFVF_NORMAL); m_pd3dDevice->SetIndices(m_pIndexBuffer); // m_pd3dDevice->SetRenderState(D3DRS_LIGHTING, FALSE); // m_pd3dDevice->SetTransform(D3DTS_WORLD, &matWorld); m_pd3dDevice->DrawIndexedPrimitive(D3DPT_TRIANGLESTRIP, 0, 0, m_uNumVertices, 0, m_uNumIndices - 2); // m_pd3dDevice->SetRenderState(D3DRS_LIGHTING, TRUE); // m_pd3dDevice->SetTexture(0, 0); if (m_bRenderFrame) { m_pd3dDevice->SetRenderState(D3DRS_FILLMODE, D3DFILL_WIREFRAME); m_pd3dDevice->DrawIndexedPrimitive(D3DPT_TRIANGLELIST, 0, 0, m_uNumVertices, 0, m_uNumIndices - 2); m_pd3dDevice->SetRenderState(D3DRS_FILLMODE, D3DFILL_SOLID); } }
void mtsOSGBody::Body::UpdateTransform(){ if( GetPosition.IsValid() ){ // Get the position of the camera prmPositionCartesianGet prmRt; GetPosition( prmRt ); bool valid = false; prmRt.GetValid( valid ); // Set the transformation if( valid ) { SetTransform( prmRt.Position() ); } } // Update the transformation osaOSGBody::UpdateTransform(); { prmPositionCartesianSet prmRt; prmRt.SetGoal( GetTransform() ); bool valid = true; prmRt.SetValid( valid ); SetPosition( prmRt ); } }
void Character::InitTeamPosition() { switch ( m_Team ) { case TeamColor::RED: GetTransform()->SetPosition( RED_TEAM_POSITION + PLAYER_POSITIONS[m_CharacterId] ); GetTransform()->SetRotation( RED_TEAM_ROTATION ); break; case TeamColor::BLUE: GetTransform()->SetPosition( BLUE_TEAM_POSITION + PLAYER_POSITIONS[m_CharacterId] ); GetTransform()->SetRotation( BLUE_TEAM_ROTATION ); break; default: break; } }
void HorizontalLayout::Draw(DrawingContext & drawingContext) { UpdateLayout(); POMDOG_ASSERT(!needToUpdateLayout); auto transform = GetTransform() * drawingContext.Top(); #if 0 renderCommand.SetInvoker([transform, this](PrimitiveBatch& primitiveBatch) { const Color backgroundColor = {45, 45, 48, 225}; const Color borderColor = {40, 40, 40, 255}; const Color highlightColor = {106, 106, 106, 255}; const auto width = static_cast<float>(GetWidth()); const auto height = static_cast<float>(GetHeight()); primitiveBatch.DrawRectangle(transform, Vector2::Zero, width, height, backgroundColor); primitiveBatch.DrawLine(transform, Vector2{0.0f, 0.0f}, Vector2{width, 0.0f}, borderColor, 1.0f); primitiveBatch.DrawLine(transform, Vector2{0.0f, 0.0f}, Vector2{0.0f, height}, borderColor, 1.0f); primitiveBatch.DrawLine(transform, Vector2{0.0f, height}, Vector2{width, height}, borderColor, 1.0f); primitiveBatch.DrawLine(transform, Vector2{width, 0.0f}, Vector2{width, height}, borderColor, 1.0f); }); drawingContext.PushCommand(renderCommand); #endif drawingContext.Push(transform); for (auto & child : children) { POMDOG_ASSERT(child); child->Draw(drawingContext); } drawingContext.Pop(); }
void EdgeActor::DrawEdge() { TRACE_ENTER(); if(geode && geode->getDrawable(0)) geode->removeDrawable(geode->getDrawable(0)); osg::Geometry *g = new osg::Geometry; osg::Vec3Array *v = new osg::Vec3Array; // Get the position (translation) of the Edge Actor relative to the origin. dtCore::Transform edgeActorTrans; GetTransform(edgeActorTrans); osg::Vec3 edgeActorPos = edgeActorTrans.GetTranslation(); v->push_back(headPos-edgeActorPos); v->push_back(tailPos-edgeActorPos); osg::DrawArrays *da = new osg::DrawArrays(osg::PrimitiveSet::LINES,0,v->size()); g->setVertexArray(v); g->addPrimitiveSet(da); geode->addDrawable(g); geode->getOrCreateStateSet()->setMode(GL_LIGHTING, osg::StateAttribute::OFF); GetMatrixNode()->addChild(geode); TRACE_EXIT(); }
void CScriptPlayerActor::Render(const CStateManager& mgr) const { bool phazonSuit = x2e8_suitRes.GetCharacterNodeId() == 3; if (phazonSuit) { // Draw into alpha buffer CModelFlags flags = xb4_drawFlags; flags.x4_color = zeus::skWhite; flags.m_extendedShader = EExtendedShader::SolidColorBackfaceCullLEqualAlphaOnly; CModelData::EWhichModel which = CModelData::GetRenderingModel(mgr); x64_modelData->Render(which, x34_transform, x90_actorLights.get(), flags); } CPhysicsActor::Render(mgr); if (x314_beamModelData && !x314_beamModelData->IsNull() && x64_modelData && !x64_modelData->IsNull()) { zeus::CTransform modelXf = GetTransform() * x64_modelData->GetScaledLocatorTransform("GUN_LCTR"); CModelFlags flags(5, 0, 3, zeus::skWhite); flags.m_extendedShader = EExtendedShader::SolidColorBackfaceCullLEqualAlphaOnly; x314_beamModelData->Render(mgr, modelXf, x90_actorLights.get(), flags); flags.m_extendedShader = EExtendedShader::Lighting; flags.x4_color = zeus::CColor{1.f, xb4_drawFlags.x4_color.a()}; x314_beamModelData->Render(mgr, modelXf, x90_actorLights.get(), flags); } if (phazonSuit) { zeus::CVector3f vecFromCam = GetBoundingBox().center() - mgr.GetCameraManager()->GetCurrentCamera(mgr)->GetTranslation(); float radius = zeus::clamp(0.25f, (6.f - vecFromCam.magnitude()) / 6.f, 2.f); float offsetX = std::sin(x34c_phazonOffsetAngle); float offsetY = std::sin(x34c_phazonOffsetAngle) * 0.5f; g_Renderer->DrawPhazonSuitIndirectEffect(zeus::CColor(0.1f, 1.f), x338_phazonIndirectTexture, zeus::skWhite, radius, 0.05f, offsetX, offsetY); } }
void ParticleScene::Initialize(const GameContext& gameContext) { UNREFERENCED_PARAMETER(gameContext); m_pRootObject = new GameObject(); AddChild(m_pRootObject); auto particleObj = new GameObject(); auto particleEmitter = new ParticleEmitterComponent(L"./Resources/Textures/Smoke.png", 60); particleEmitter->SetVelocity(XMFLOAT3(0, 6.0f, 0)); particleEmitter->SetMinSize(1.0f); particleEmitter->SetMaxSize(2.0f); particleEmitter->SetMinEnergy(1.0f); particleEmitter->SetMaxEnergy(2.0f); particleEmitter->SetMinSizeGrow(3.5f); particleEmitter->SetMaxSizeGrow(5.5f); particleEmitter->SetMinEmitterRange(0.2f); particleEmitter->SetMaxEmitterRange(0.5f); particleEmitter->SetColor(XMFLOAT4(1.f, 1.f, 1.f, 0.6f)); particleObj->AddComponent(particleEmitter); m_pRootObject->AddChild(particleObj); auto mat = new ColorMaterial(); gameContext.pMaterialManager->AddMaterial(mat, 103); auto modelObj = new GameObject(); auto model = new ModelComponent(L"./Resources/Meshes/Teapot.ovm"); model->SetMaterial(103); modelObj->AddComponent(model); m_pRootObject->AddChild(modelObj); modelObj->GetTransform()->Scale(0.2f, 0.2f, 0.2f); }