예제 #1
0
파일: mqo.cpp 프로젝트: msakuta/VastSpace
bool Model::getBonePosInt(const char *boneName, const ysdnmv_t &v0, const Bone *bone, const Vec3d &spos, const Quatd &srot, Vec3d *pos, Quatd *rot)const{
	Vec3d apos = spos;
	Quatd arot = srot;
	for(const ysdnmv_t *v = &v0; v; v = v->next){
		ysdnm_bone_var *bonevar = v->bonevar;
		int bones = min(v->bones, this->n);
		for(int i = 0; i < bones; i++) if(!strcmp(bonevar[i].name, bone->name)){
			apos += arot.trans(bone->joint);
			apos += arot.trans(v->bonevar[i].pos);
			arot *= bonevar[i].rot;
			apos -= arot.trans(bone->joint);
		}
	}
	if(!strcmp(boneName, bone->name)){
		if(pos)
			*pos = apos + arot.trans(bone->joint);
		if(rot)
			*rot = arot;
		return true;
	}
	for(const Bone *nextbone = bone->children; nextbone; nextbone = nextbone->nextSibling){
		if(nextbone->suf){
			if(getBonePosInt(boneName, v0, nextbone, apos, arot, pos, rot))
				return true;
		}
	}
	return false;
}
예제 #2
0
파일: mqo.cpp 프로젝트: msakuta/VastSpace
bool Model::getBonePosInt(const char *boneName, const MotionPose &v0, const Bone *bone, const Vec3d &spos, const Quatd &srot, Vec3d *pos, Quatd *rot)const{
	Vec3d apos = spos;
	Quatd arot = srot;
	for(const MotionPose *v = &v0; v; v = v->next){
		MotionPose::const_iterator it = v->nodes.find(bone->name);
//		for(int i = 0; i < bones; i++) if(!strcmp(bonevar[i].name, bone->name)){
		if(it != v->nodes.end()){
			apos += arot.trans(bone->joint);
			apos += arot.trans(it->second.pos);
			arot *= it->second.rot;
			apos -= arot.trans(bone->joint);
		}
	}
	if(!strcmp(boneName, bone->name)){
		if(pos)
			*pos = apos + arot.trans(bone->joint);
		if(rot)
			*rot = arot;
		return true;
	}
	for(const Bone *nextbone = bone->children; nextbone; nextbone = nextbone->nextSibling){
		if(nextbone->suf){
			if(getBonePosInt(boneName, v0, nextbone, apos, arot, pos, rot))
				return true;
		}
	}
	return false;
}
예제 #3
0
void WarSpace::drawtra(wardraw_t *wd){
	Teline3DrawData dd;
	dd.viewdir = -wd->vw->rot.vec3(2);
	dd.viewpoint = wd->vw->pos;
	dd.invrot = wd->vw->irot;
	dd.fov = wd->vw->fov;
	dd.pgc = wd->vw->gc;
	dd.rot = wd->vw->qrot;
	dd.user = this;
	DrawTeline3D(tell, &dd);
	tepl->draw(wd->vw->pos, &static_cast<glcull>(*wd->vw->gc));

	for(int i = 0; i < 2; i++)
	for(WarField::EntityList::iterator it = (this->*list[i]).begin(); it != (this->*list[i]).end(); it++){
		if(!*it)
			continue;
		Entity *pe = *it;
		if(pe->w == this/* && wd->vw->zslice == (pl->chase && pl->mover == &Player::freelook && pl->chase->getUltimateOwner() == pe->getUltimateOwner() ? 0 : 1)*/){
			try{
				pe->drawtra(wd);
			}
			catch(std::exception e){
				fprintf(stderr, __FILE__"(%d) Exception in %p->%s::drawtra(): %s\n", __LINE__, pe, pe->idname(), e.what());
			}
			catch(...){
				fprintf(stderr, __FILE__"(%d) Exception in %p->%s::drawtra(): ?\n", __LINE__, pe, pe->idname());
			}
		}
	}

	if(g_debugdraw_bullet && bdw){
		static class DebugDraw : public btIDebugDraw{
			// Override only drawLine method for the moment.
			virtual void drawLine(const btVector3& from,const btVector3& to,const btVector3& color){
				glColor3fv(btvc(color).cast<float>());
				glBegin(GL_LINES);
				glVertex3dv(btvc(from));
				glVertex3dv(btvc(to));
				glEnd();
			}
			virtual void	drawContactPoint(const btVector3& PointOnB,const btVector3& normalOnB,btScalar distance,int lifeTime,const btVector3& color){}
			virtual void	reportErrorWarning(const char* warningString){}
			virtual void	draw3dText(const btVector3& location,const char* textString){}
			virtual void	setDebugMode(int debugMode){}
			virtual int		getDebugMode() const{return 1;}
		}debugDrawer;
		glDisable(GL_TEXTURE_2D);
		glDisable(GL_LIGHTING);
		glDisable(GL_CULL_FACE);
		glDepthMask(GL_FALSE);
		glEnable(GL_BLEND);
		bdw->getCollisionWorld()->setDebugDrawer(&debugDrawer);
		bdw->debugDrawWorld();
	}

	if(g_player_viewport){
		Game *game = wd->w->getGame();
		for(Game::PlayerList::iterator it = game->players.begin(); it != game->players.end(); ++it){
			Player *player = *it;
			if(player == game->player || player->cs != cs)
				continue;
			double f = player->fov;
			const Vec3d pos = player->getpos();
			const Quatd irot = player->getrot().cnj();
			glBegin(GL_LINES);
			for(int level = 4; 0 <= level; --level){
				double l = double(1 << level);
				glColor4f(!!((1 << level) & 8), !!((1 << level) & 5), !!((1 << level) & 19), 1);
				glVertex3dv(pos);
				glVertex3dv(pos + irot.trans(l * Vec3d(0,0,-1)));
				for(int y = -1; y <= 1; y++){
					glVertex3dv(pos + irot.trans(l * Vec3d(-f, y * f, -1)));
					glVertex3dv(pos + irot.trans(l * Vec3d(f, y * f, -1)));
				}
				for(int x = -1; x <= 1; x++){
					glVertex3dv(pos + irot.trans(l * Vec3d(x * f, -f,-1)));
					glVertex3dv(pos + irot.trans(l * Vec3d(x * f, f,-1)));
				}
				glVertex3dv(pos);
				glVertex3dv(pos + irot.trans(l * Vec3d(-1,-1,-1)));
				glVertex3dv(pos);
				glVertex3dv(pos + irot.trans(l * Vec3d(1,-1,-1)));
				glVertex3dv(pos);
				glVertex3dv(pos + irot.trans(l * Vec3d(-1,1,-1)));
				glVertex3dv(pos);
				glVertex3dv(pos + irot.trans(l * Vec3d(1,1,-1)));
			}
			glEnd();
		}
	}

	if(g_otdrawflags)
		ot_draw(this, wd);
}