예제 #1
0
// Create the ship (called only once, at start)
void initShip(object *o) {
	object ship;
	vector* v = (vector *)malloc(sizeof(vector)*3);
	ship.verts = v;
	v->x = 0.0; v->y = -1.0; v++;
	v->x = -0.5; v->y = 1.0; v++;
	v->x = 0.5; v->y = 1.0;
	ship.size = 3;
	ship.pos = zeroVec();
	ship.dir = makeVec(0.0, -1.0);;
	ship.ang = 0.0;
	ship.turn = 10.0;
	ship.vel = zeroVec();
	ship.spd = 25.0;
	ship.type = SHIP;
	ship.mode = GL_LINE_LOOP;
	ship.state = SHIP_INACTIVE;
	LAZORZ = (object *)malloc(sizeof(object)*MAXSHOTS);  
	*o = ship;
}
예제 #2
0
///-------------------------------------------------------------
/// Creates initial list of constraints.
///-------------------------------------------------------------
void IKSolver::CreateConstraints(int frameNum)
{
	// clear any old data that might exist
	mConstraintList.clear();

	// get all handles on model
	MarkerList & modelHandles = mModel->mHandleList;

	Vec3d zeroVec(0, 0, 0);
	zeroVec.MakeZero();

	// loop over all handles on model, evaluating constraint
	for (int i = 0; i < modelHandles.size(); i++)
	{
		// get handle on model and contraint position
		Marker * handle = modelHandles[i];
		Vec3d & constraintPos = mModel->mOpenedC3dFile->GetMarkerPos(frameNum, i);

		// if constraint is 0, 0, 0, then we don't have a constraint to actually deal with,
		// so only create and add constraint if this is not the case
		// all of these checks are in place to absolutely make sure, because somehow some of
		// these constraints snuck through
		if (constraintPos != vl_zero && constraintPos != vl_0)
		{
			if (len(constraintPos) != 0)
			{
				if ( !(constraintPos[0] == 0 && constraintPos[1] == 0 && constraintPos[2] == 0) )
				{
					if (zeroVec != constraintPos)
					{
						mConstraintList.push_back(Constraint(mModel, i));
					}
				}
			}

		}
	}

#ifdef _DEBUG
	//LogConstraintList(0, false);
#endif
}
예제 #3
0
// Create star that twinkles occasionally
void initStar(object *o, vector *l) {
	object star;
	vector* v = (vector*)malloc(sizeof(vector)*8);
	star.verts = v;
	int i; for(i=0;i<8;i+=2) {
		*v = makeVec(0.1*cos(pi*(float)i/4.0), 
			0.1*sin(pi*(float)i/4.0));
		v++;
		*v = makeVec(0.1*cos(pi*(float)(i+1)/4.0), 
				0.1*sin(pi*(float)(i+1)/4.0));
		v++;
	}
	star.size = 8;
	star.pos = copyVec(l);
	star.dir = upVec();
	star.ang = 0.0;
	star.turn = 0.0;
	star.vel = zeroVec();
	star.spd = 50.0;
	star.type = STAR;
	star.mode = GL_LINE_LOOP;
	star.state = 0;
	*o = star;
}
예제 #4
0
// Create message (called at start, activated on player death)
void initMessage() {
	message = (object*)malloc(sizeof(object)*5);
	vector** letters = (vector**)malloc(sizeof(vector*)*5);
	letters[0] = (vector*)malloc(sizeof(vector)*7);
	vector* vi = letters[0];
	vi->x = 3.0; vi->y = -5.0; vi++;
	vi->x = 3.0; vi->y = 4.0; vi++;
	vi->x = 1.0; vi->y = 5.0; vi++;	
	vi->x = -1.0; vi->y = 5.0; vi++;	
	vi->x = -3.0; vi->y = 4.0; vi++;
	vi->x = -3.0; vi->y = 4.0; vi++;
	vi->x = -3.0; vi->y = -5.0;
	letters[1] = (vector*)malloc(sizeof(vector)*7);
	vi = letters[1];
	float n = 0.0;
	int i;
	for(i=0;i<7;i++){vi->x=n;vi->y=n;vi++;}
	letters[2] = (vector*)malloc(sizeof(vector)*7);
	vi = letters[2];
	vi->x = 3.0; vi->y = -5.0; vi++;
	vi->x = -1.0; vi->y = -5.0; vi++;
	vi->x = -3.0; vi->y = -3.0; vi++;	
	vi->x = -3.0; vi->y = 3.0; vi++;	
	vi->x = -1.0; vi->y = 5.0; vi++;
	vi->x = 3.0; vi->y = 5.0; vi++;
	vi->x = 3.0; vi->y = -5.0;
	letters[3] = (vector*)malloc(sizeof(vector)*7);
	vi = letters[3];
	vi->x = -3.0; vi->y = -5.0; vi++;
	vi->x = 3.0; vi->y = -5.0; vi++;
	vi->x = 3.0; vi->y = 0.0; vi++;	
	vi->x = -3.0; vi->y = 0.0; vi++;	
	vi->x = 3.0; vi->y = 0.0; vi++;
	vi->x = 3.0; vi->y = 5.0; vi++;
	vi->x = -3.0; vi->y = 5.0;
	letters[4] = (vector*)malloc(sizeof(vector)*7);
	vi = letters[4];
	vi->x = 3.0; vi->y = -5.0; vi++;
	vi->x = -1.0; vi->y = -5.0; vi++;
	vi->x = -3.0; vi->y = -3.0; vi++;	
	vi->x = -3.0; vi->y = 3.0; vi++;	
	vi->x = -1.0; vi->y = 5.0; vi++;
	vi->x = 3.0; vi->y = 5.0; vi++;
	vi->x = 3.0; vi->y = -5.0;

	int li;
	for (li=0; li<5; li++) {
		object L;
		L.verts = letters[li];
		L.size = 7;
		L.pos = makeVec(16.0-8.0*(float)li, 0.0);
		L.dir = upVec();
		L.ang = 0.0;
		L.turn = 0.0;
		L.vel = zeroVec();
		L.spd = 0.0;
		L.type = MESSAGE;
		L.mode = GL_LINE_STRIP;
		L.state = 0;
		*(message+li) = L;
	}
}
예제 #5
0
void sixdofConstraintNode::draw( M3dView & view, const MDagPath &path,
                             M3dView::DisplayStyle style,
                             M3dView::DisplayStatus status )
{
    update();
	vec3f zeroVec(0.f,0.f,0.f);
	vec3f minusXVec(-0.2f,0.f,0.f);
	vec3f posXVec(0.2f,0.f,0.f);
	vec3f minusYVec (0.f,-0.2f,0.f);
	vec3f posYVec (0.f,0.2f,0.f);
	vec3f minusZVec (0.f,0.f,-0.2f);
	vec3f posZVec (0.f,0.f,0.2f);
	
    view.beginGL();
    glPushAttrib( GL_ALL_ATTRIB_BITS );

    glDisable(GL_LIGHTING);

    if( !(status == M3dView::kActive ||
        status == M3dView::kLead ||
        status == M3dView::kHilite ||
        ( style != M3dView::kGouraudShaded && style != M3dView::kFlatShaded )) ) {
        glColor3f(1.0, 1.0, 0.0); 
    }

	vec3f posA, posB, pivB;
	rigid_body_t::pointer rigid_bodyB = NULL;
	if (m_constraint) 
	{
		vec3f pos;
		quatf rot;
		m_constraint->rigid_bodyA()->get_transform(pos, rot);
		m_constraint->worldToA(pos, posA);
		rigid_bodyB = m_constraint->rigid_bodyB();
		if(rigid_bodyB)
		{
			rigid_bodyB->get_transform(pos, rot);
			m_constraint->worldToA(pos, posB);
		}
		m_constraint->worldFromB(zeroVec, pos);
		m_constraint->worldToA(pos, pivB);
	}

    glBegin(GL_LINES);
    glVertex3f(0.0, 0.0, 0.0);
    glVertex3f(posA[0], posA[1], posA[2]);

	//glVertex3f(0.0, 0.0, 0.0);
	//glVertex3f(pivB[0], pivB[1], pivB[2]);

	if(rigid_bodyB)
	{
		glVertex3f(pivB[0], pivB[1], pivB[2]);
		glVertex3f(posB[0], posB[1], posB[2]);
	}


    glVertex3f(-0.2, 0.0, 0.0);
    glVertex3f(0.2, 0.0, 0.0);

    glVertex3f(0.0, -0.2, 0.0);
    glVertex3f(0.0, 0.2, 0.0);

    glVertex3f(0.0, 0.0, -0.2);
    glVertex3f(0.0, 0.0, 0.2);

	vec3f posT, posP, posM;

	m_constraint->worldFromB(minusXVec, posT);
	m_constraint->worldToA(posT, posM);
	m_constraint->worldFromB(posXVec, posT);
	m_constraint->worldToA(posT, posP);
    glVertex3f(posM[0], posM[1], posM[2]);
    glVertex3f(posP[0], posP[1], posP[2]);
	m_constraint->worldFromB(minusYVec, posT);
	m_constraint->worldToA(posT, posM);
	m_constraint->worldFromB(posYVec, posT);
	m_constraint->worldToA(posT, posP);
    glVertex3f(posM[0], posM[1], posM[2]);
    glVertex3f(posP[0], posP[1], posP[2]);
	m_constraint->worldFromB(minusZVec, posT);
	m_constraint->worldToA(posT, posM);
	m_constraint->worldFromB(posZVec, posT);
	m_constraint->worldToA(posT, posP);
    glVertex3f(posM[0], posM[1], posM[2]);
    glVertex3f(posP[0], posP[1], posP[2]);
	

    glEnd();

    glPopAttrib();
    view.endGL();
}
예제 #6
0
파일: triang.c 프로젝트: nixberg/lumo
Triang zeroTriang(void)
{
    return (Triang) {
        zeroVec(), zeroVec(), zeroVec(), zeroVec(), false, 0
    };
}
예제 #7
0
파일: point.c 프로젝트: nixberg/lumo
Point zeroPoint(void)
{
    return (Point) {zeroVec(), 0};
}
예제 #8
0
파일: photon.c 프로젝트: nixberg/lumo
Photon randPhoton()
{
    return (Photon) {zeroVec(), randDir(), WL_MAXLUM};
}
예제 #9
0
파일: photon.c 프로젝트: nixberg/lumo
Photon zeroPhoton()
{
    return (Photon) {zeroVec(), zeroVec(), WL_MAXLUM};
}