Code/Resource
Windows Develop
Linux-Unix program
Internet-Socket-Network
Web Server
Browser Client
Ftp Server
Ftp Client
Browser Plugins
Proxy Server
Email Server
Email Client
WEB Mail
Firewall-Security
Telnet Server
Telnet Client
ICQ-IM-Chat
Search Engine
Sniffer Package capture
Remote Control
xml-soap-webservice
P2P
WEB(ASP,PHP,...)
TCP/IP Stack
SNMP
Grid Computing
SilverLight
DNS
Cluster Service
Network Security
Communication-Mobile
Game Program
Editor
Multimedia program
Graph program
Compiler program
Compress-Decompress algrithms
Crypt_Decrypt algrithms
Mathimatics-Numerical algorithms
MultiLanguage
Disk/Storage
Java Develop
assembly language
Applications
Other systems
Database system
Embeded-SCM Develop
FlashMX/Flex
source in ebook
Delphi VCL
OS Develop
MiddleWare
MPI
MacOS develop
LabView
ELanguage
Software/Tools
E-Books
Artical/Document
Rifle.cpp
Package: 3dexplorerTest.rar [view]
Upload User: hkb425
Upload Date: 2007-06-16
Package Size: 34191k
Code Size: 2k
Category:
Game Engine
Development Platform:
Visual C++
- // Rifle.cpp: implementation of the CRifle class.
- //
- //////////////////////////////////////////////////////////////////////
- #include "stdafx.h"
- #include "Rifle.h"
- //////////////////////////////////////////////////////////////////////
- // Construction/Destruction
- //////////////////////////////////////////////////////////////////////
- CRifle::CRifle()
- {
- m_bHit=false;
- }
- CRifle::~CRifle()
- {
- }
- bool CRifle::LunchBullet(int id,VERTEX startPos,float rotx,float roty,NORMAL direction)
- {
- m_id=id;
- m_bulletPos=startPos;
- m_rotX=rotx;
- m_rotY=roty;
- m_direction = direction;
- CalcDestinationPos();
- if(m_bHit)
- {
- m_bltParticle.InitParticle(EXPLOSION_P,startPos);
- }
- ///////////////Draw Bullet Track//////////////////////
- glDisable(GL_TEXTURE_2D);
- glColor3f(0.6f,0.7f,0.75f);
- glBegin(GL_LINES);
- glVertex3f(startPos.xpos, startPos.ypos, startPos.zpos);
- glVertex3f(m_bulletPos.xpos, m_bulletPos.ypos, m_bulletPos.zpos);
- /*
- glVertex3f(startPos.xpos, startPos.ypos, startPos.zpos);
- glVertex3f(m_bulletPos.xpos+2, m_bulletPos.ypos+2, m_bulletPos.zpos);
- glVertex3f(startPos.xpos, startPos.ypos, startPos.zpos);
- glVertex3f(m_bulletPos.xpos, m_bulletPos.ypos+5, m_bulletPos.zpos+2);
- glVertex3f(startPos.xpos, startPos.ypos, startPos.zpos);
- glVertex3f(m_bulletPos.xpos, m_bulletPos.ypos-6, m_bulletPos.zpos);
- */ glEnd();
- ////
- return true;
- }
- void CRifle::CalcDestinationPos()
- {
- float deltaH=8;
- float step=1;
- m_bHit=false;
- int count=0;
- while(deltaH >0 && count<1000)
- {
- // step=deltaH*0.5f;
- m_bulletPos.xpos+=m_direction.nx*step;
- m_bulletPos.ypos+=m_direction.ny*step;
- m_bulletPos.zpos+=m_direction.nz*step;
- deltaH=m_bulletPos.ypos-m_cHmap.GetHeight(&m_bulletPos);
- count++;
- }
- if(deltaH<0)
- {
- m_bHit=true;
- }
- }
- void CRifle::DrawRifleShot()
- {
- if(!m_bHit)return;
- glPushMatrix();
- glTranslatef(m_bulletPos.xpos,m_bulletPos.ypos,m_bulletPos.zpos);
- glRotatef(*m_cHmap.m_pViewRotY, 0.0f,1.0f,0.0f);
- glRotatef(-*m_cHmap.m_pViewRotX, 1.0f,0.0f,0.0f);
- m_bltParticle.DrawParticles(m_bulletPos);
- glPopMatrix();
- }