GeezerVisonThe World Wide Web, restored to 800 pixels of glory. |
| Home|About|Gaming cabinet|Archives|How it works|Starter sites |
GeezerVison is showing github.com — Gamingcode/Chapter06/MoveComponent.cpp at master · Bhavan-R/Gamingcode Expand file tree/ Copy pathMoveComponent.cppMore file actions 40 lines (35 loc) · 1.08 KB / Copy pathMoveComponent.cppFile metadata and controls40 lines (35 loc) · 1.08 KB 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 // ---------------------------------------------------------------- // From Game Programming in C++ by Sanjay Madhav // Copyright (C) 2017 Sanjay Madhav. All rights reserved. // // Released under the BSD License // See LICENSE in root directory for full details. // ---------------------------------------------------------------- #include "MoveComponent.h" #include "Actor.h" MoveComponent::MoveComponent(class Actor* owner, int updateOrder) :Component(owner, updateOrder) ,mAngularSpeed(0.0f) ,mForwardSpeed(0.0f) { } void MoveComponent::Update(float deltaTime) { if (!Math::NearZero(mAngularSpeed)) { Quaternion rot = mOwner->GetRotation(); float angle = mAngularSpeed * deltaTime; // Create quaternion for incremental rotation // (Rotate about up axis) Quaternion inc(Vector3::UnitZ, angle); // Concatenate old and new quaternion rot = Quaternion::Concatenate(rot, inc); mOwner->SetRotation(rot); } if (!Math::NearZero(mForwardSpeed)) { Vector3 pos = mOwner->GetPosition(); pos += mOwner->GetForward() * mForwardSpeed * deltaTime; mOwner->SetPosition(pos); } } |
| You are visitor 01402775 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |