DriveHQ Start Menu
Cloud Drive Mapping
Folder Sync
True Drop Box
FTP/SFTP Hosting
Group Account
Team Anywhere
DriveHQ Start Menu
Online File Server
My Storage
|
Manage Shares
|
Publishes
|
Drop Boxes
|
Group Account
WebDAV Drive Mapping
Cloud Drive Home
|
WebDAV Guide
|
Drive Mapping Tool
|
Drive Mapping URL
Complete Data Backup
Backup Guide
|
Cloud-to-Cloud Backup
|
DVR/Camera Backup
FTP, Email & Web Service
FTP/SFTP Hosting
|
Email Hosting
|
Web Hosting
|
Webcam Hosting
Other Products & Services
Team Anywhere
|
Connect to Remote PC
|
Cloud Surveillance
|
Virtual CCTV NVR
Quick Links
Security and Privacy
Customer Support
Service Manual
Use Cases
Group Account
Online Help
Support Forum
Contact Us
About DriveHQ
Sign Up
Login
Features
Business Features
Online File Server
FTP Hosting
Cloud Drive Mapping
Cloud File Backup
Email Backup & Hosting
Cloud File Sharing
Folder Synchronization
Group Management
True Drop Box
Full-text Search
AD Integration/SSO
Mobile Access
Personal Features
Personal Cloud Drive
Backup All Devices
Mobile APPs
Personal Web Hosting
Sub-Account (for Kids)
Home/PC/Kids Monitoring
Other Features
Team Anywhere (Remote Desktop Service)
CameraFTP Cloud Surveillance
Software
DriveHQ Drive Mapping Tool
DriveHQ FileManager
DriveHQ Online Backup
DriveHQ Team Anywhere for Windows (Beta)
DriveHQ Mobile Apps
Pricing
Business Plans & Pricing
Personal Plans & Pricing
Price Comparison with Others
Feature Comparison with Others
Install Mobile App
Sign up
Creating account...
Invalid character in username! Only 0-9, a-z, A-Z, _, -, . allowed.
Username is required!
Invalid email address!
E-mail is required!
Password is required!
Password is invalid!
Password and confirmation do not match.
Confirm password is required!
I accept
Membership Agreement
Please read the Membership Agreement and check "I accept"!
Free Quick Sign-up
Sign-up Page
Log in
Signing in...
Username or e-mail address is required!
Password is required!
Keep me logged in
Quick Login
Forgot Password
Up
Upload
Download
Share
Publish
New Folder
New File
Copy
Cut
Delete
Paste
Rate
Upgrade
Rotate
Effect
Edit
Slide
History
#include "Soldier.h" #include "GameFactoryDemo.h" #include "Line3D.h" using namespace GameFactory; int Soldier::numSoldier = 0; SceneNode* Soldier::referenceNode = NULL; float Soldier::FireRange = 60; float Soldier::FireHeight = 8; int Soldier::EvaluateRange = 6; int Soldier::WayPointQueueLength = 10; Soldier* Soldier::selectedSoldier = NULL; void Soldier::SelectSoldier(NxShape* shape){ if (shape->getActor().readBodyFlag(NX_BF_KINEMATIC)){ if (selectedSoldier!=NULL){ selectedSoldier->mBody->setMaterialName("marine-body"); } selectedSoldier = (Soldier*)shape->getActor().userData; if (selectedSoldier!=NULL) selectedSoldier->mBody->setMaterialName("Examples/Rockwall"); } } bool Soldier::IsCovered(Vector3 from, Vector3 to){ return ((from-to).length()>Soldier::FireRange) || SkeletalApplication::GetSingleton()->RayCast(from + Vector3(0,0,Soldier::FireHeight), to + Vector3(0,0,Soldier::FireHeight),NULL,NULL); } Soldier::Soldier(SceneManager *pSceneMgr, RenderWindow* renderWindow, NxScene* gScene) { curBodyAnimation = NULL; curHeadAnimation = NULL; if (referenceNode==NULL){ referenceNode = pSceneMgr->getRootSceneNode()->createChildSceneNode(); OgreMax::OgreMaxScene* myScene = new OgreMax::OgreMaxScene(); myScene->Load("marine.scene",renderWindow,OgreMax::OgreMaxScene::NO_OPTIONS,pSceneMgr,referenceNode); //referenceNode->setScale(0.5f,0.5f,0.5f); referenceNode->setVisible(false); // Report whether hardware skinning is enabled or not Technique* t = ((Entity*)((SceneNode*)referenceNode->getChild("Marine-body"))->getAttachedObject(0))->getSubEntity(0)->getMaterial()->getBestTechnique(); Pass* p = t->getPass(0); if (p->hasVertexProgram() && p->getVertexProgram()->isSkeletalAnimationIncluded()) SkeletalApplication::GetSingleton()->mDebugText = "Hardware skinning is enabled"; else SkeletalApplication::GetSingleton()->mDebugText = "Software skinning is enabled"; } mNameSuffix = StringConverter::toString(numSoldier); //mNode = pSceneMgr->getRootSceneNode()->createChildSceneNode(); mNode = CloneSceneNode(referenceNode,(SceneNode*)referenceNode->getParent(),mNameSuffix); //mNode->showBoundingBox(true); //add bounding box to PhysX mNode->_updateBounds(); mNode->_update(true,false); mNode->_updateBounds(); //const AxisAlignedBox* pBoundingBox = &(mNode->_getWorldAABB()); AxisAlignedBox pBoundingBox = AxisAlignedBox(Vector3(-0.5,-0.5,-0.5),Vector3(0.5,0.5,0.5)); NxBodyDesc bodyDesc; bodyDesc.angularDamping = 0.5f; NxVec3 initialVelocityNX = NxVec3(0,0,0); NxBoxShapeDesc boxDesc; Vector3 vv = (pBoundingBox.getMaximum()-pBoundingBox.getMinimum())/2; boxDesc.dimensions = Vector3ToNxVec3(vv*Vector3(0.5f,0.5f,1.8f)); vv+= pBoundingBox.getMinimum(); NxActorDesc actorDesc; actorDesc.shapes.pushBack(&boxDesc); actorDesc.body = &bodyDesc; actorDesc.density = 10.0f; actorDesc.globalPose.t = Vector3ToNxVec3(vv); //gScene->createActor(actorDesc)->userData = (void*)size_t(size); actor = gScene->createActor(actorDesc); actor->raiseBodyFlag(NX_BF_KINEMATIC); actor->userData = (void*)this; //printf("Total: %d actors\n", gScene->getNbActors()); mBody = (Entity*)((SceneNode*)mNode->getChild("Marine-body"+mNameSuffix))->getAttachedObject(0); mHead = (Entity*)((SceneNode*)mNode->getChild("head"+mNameSuffix))->getAttachedObject(0); mWeapon = pSceneMgr->getEntity("gun-01"+mNameSuffix); setAnimation("idle_stand"); moving = false; rotating = false; numSoldier++; } Soldier::~Soldier(void) { } void Soldier::setAnimation(String name){ if (curBodyAnimation) curBodyAnimation->setEnabled(false); curBodyAnimation = mBody->getAnimationState(name); curBodyAnimation->setEnabled(true); curBodyAnimation->setLoop(true); if (curHeadAnimation) curHeadAnimation->setEnabled(false); curHeadAnimation = mHead->getAnimationState(name); curHeadAnimation->setEnabled(true); curHeadAnimation->setLoop(true); } bool Soldier::IsAt(Vector3 pos){ return (mNode->getPosition()-pos).length()<0.2f; } void Soldier::ReachTo(Vector3 pos){ if (!IsAt(pos)){ if (!moving) setAnimation("run_forward"); moving = true; movingTarget = pos; }else { if (moving) setAnimation("idle_stand"); moving = false; } } void Soldier::RotateTo(Vector3 pos, Real elapsedTime){ rotatingTarget = pos; pos.z=0.0f; Vector3 movingVector=(pos-mNode->getPosition()).normalisedCopy();//the displacement vector //Rotate(Vector3::UNIT_Y,Radian::Radian(Degree(45))); //movingVector.y = -movingVector.y; Real angle; if (movingVector.x==0){ if (movingVector.y>0) angle = 3.14159/2; else angle = -3.14159/2; }else{ angle = atanf(movingVector.y/movingVector.x); if (movingVector.x<0) angle+=3.14159; } angle+=3*3.14159/2;//to make this angle identical to character angle if (angle>3.14159*2) angle-=3.14159*2;//make sure it is not greater than 360 degrees Real curAngle; curAngle = mNode->getOrientation().getRoll().valueRadians(); if (curAngle<0) curAngle+=3.14159*2; Real distPlus,distMinus,dist; if (angle>curAngle){ distPlus = abs(angle-curAngle); distMinus = abs(3.14159*2-angle+curAngle); if (distPlus
3.14159/180*2){ Rotate(Quaternion(Radian(curAngle+dist*elapsedTime*4.0f),Vector3::UNIT_Z)); rotating = true; } else rotating = false; } void Soldier::ShotAt(Vector3 pos, Real elapsedTime){ setAnimation("shot_bullet");//shot_rocket RotateTo(pos,elapsedTime); Vector3 hitPos, hitNorm,from; from = mNode->getPosition()+Vector3(0,0,7); if (SkeletalApplication::GetSingleton()->RayCast(from,pos,&hitPos,&hitNorm,false,true)){ SkeletalApplication::GetSingleton()->smoke->AddSmoke(hitPos,hitNorm); } } void Soldier::MoveTo(Vector3 pos, Real elapsedTime){ setAnimation("run_forward"); pos.z=0.0f; Vector3 movingVector=(pos-mNode->getPosition()).normalisedCopy();//the displacement vector Translate(mNode->getPosition()+movingVector*1.0f*elapsedTime); //Rotate(Vector3::UNIT_Y,Radian::Radian(Degree(45))); //movingVector.y = -movingVector.y; Real angle; if (movingVector.x==0){ if (movingVector.y>0) angle = 3.14159/2; else angle = -3.14159/2; }else{ angle = atanf(movingVector.y/movingVector.x); if (movingVector.x<0) angle+=3.14159; } angle+=3*3.14159/2;//to make this angle identical to character angle if (angle>3.14159*2) angle-=3.14159*2;//make sure it is not greater than 360 degrees Real curAngle; curAngle = mNode->getOrientation().getRoll().valueRadians(); if (curAngle<0) curAngle+=3.14159*2; Real distPlus,distMinus,dist; if (angle>curAngle){ distPlus = abs(angle-curAngle); distMinus = abs(3.14159*2-angle+curAngle); if (distPlus
3.14159/180*2) Rotate(Quaternion(Radian(curAngle+dist*elapsedTime*4.0f),Vector3::UNIT_Z)); } void Soldier::FrameMove(Real time){ curBodyAnimation->addTime(time); curHeadAnimation->addTime(time); if (moving){ MoveTo(movingTarget,time); ReachTo(movingTarget); } if (rotating){ RotateTo(rotatingTarget,time); } }
Soldier.cpp
Page URL
File URL
Prev
42/45
Next
Download
( 7 KB )
Note: The DriveHQ service banners will NOT be displayed if the file owner is a paid member.
Comments
Total ratings:
0
Average rating:
Not Rated
Would you like to comment?
Join DriveHQ
for a free account, or
Logon
if you are already a member.