Example #1
0
DungeonArea::DungeonArea(veci _pos, veci _size)
{
    pos = _pos;
    size = _size;

    center = vecd((double)pos.x,(double)pos.y) + 0.5*vecd((double)size.x, (double)size.y);
}
Example #2
0
allsh::allsh( unsigned int Nprt, unsigned int Nshell, vecd &velx, double tmpr_initial )
{
    mNprt = Nprt;
    mNshell = Nshell;
    mMR = 1.0;
    madidx = 5.0/3;
    mshwidth = 0.1;
    // initialize positions of shells
    mpos = vecd(mNshell,0);
    for( int i=0; i<mNshell; i++)
    {
        mpos[i] = i*mshwidth;
    }
    //
    mvelx = velx;
    mvely = vecd(mNshell,0);
    mvelz = mvely;
    mtmpr = vecd(mNshell, tmpr_initial);

    //calculate the following
    mxleftbdry = vecd(mNshell,0);
    mvelxleftbdry = vecd(mNshell,0);
    mvelyleftbdry = vecd(mNshell,0);
    mvelzleftbdry = vecd(mNshell,0);
    mvol = vecd(mNshell,0);
    mprsr = vecd(mNshell,0);
    mNpes = mNprt / mNshell;
    mtotvol = mshwidth * mNshell;
    updateleftbdry();
    updatevelleftbdry();
    updatevolume();
    updatepressure();
}
Example #3
0
void writeFrameBvh(ostream &os, Character::Pose &pose, vector< int > order) {
	Quatd rot = rotation( -(double)M_PI * 0.5, make_vector(1.0, 0.0, 0.0) );
	Quatd xrot;
	Quatd yrot;
	Quatd zrot;
	xrot.x = 1/sqrt(2); xrot.y = 0; xrot.z = 0; xrot.w = -1/sqrt(2);
	yrot.y = 1/sqrt(2); yrot.x = 0; yrot.z = 0; yrot.w = -1/sqrt(2);
	zrot.z = 1/sqrt(2); zrot.x = 0; zrot.y = 0; zrot.w = 1/sqrt(2);

	Vector3d root_position = vecd(pose.root_position);
	//root_position = rotate(root_position, conjugate(rot));
	// GOOD, but root doesn't match

	// old
	root_position = rotate(root_position, frame_rot());
	os  << FACTOR * root_position.x << " " << FACTOR * root_position.y << " " << FACTOR * root_position.z;
	//os << "0 0 0";

	double d[3];
	//Quatd root_orientation = multiply(quatd(pose.root_orientation), xrot);
	// rotate 180 degrees about the z axis, and -90 about the x-axis
	Quatd root_orientation = quatd(pose.root_orientation);
	root_orientation = normalize(multiply(frame_rot(), multiply(root_orientation, -frame_rot())));
	root_orientation = normalize(multiply(xrot, root_orientation));

	put_dof_rot(DOF_ORDER, root_orientation, d, 0);
	os << " " << d[0] << " " << d[1] << " " << d[2];
	//os << " 0 0 0";

	/*Character::Angles angles;
	Library::Skeleton trans;
	to_euler_angles(pose, angles, trans);*/

	//cout << "Root xyz " << d[0] << " " << d[1] << " " << d[2] << endl;
	//os << " 0 0 0";
	//cout << "Frame start: " << endl;
	for (unsigned int i = 0; i < order.size(); i++) {
		int b = order[i];
		/*os << " " << angles.angles[angles.skeleton->bones[b].frame_offset + 0] << " ";
		os << -angles.angles[angles.skeleton->bones[b].frame_offset + 1] << " ";
		os << angles.angles[angles.skeleton->bones[b].frame_offset + 2];*/

		//local, parent-relative, orientation.
		Quatd orientation = quatd(pose.bone_orientations[b]);
		orientation = normalize(multiply(frame_rot(), multiply(orientation, -frame_rot())));
		put_dof_rot(DOF_ORDER, orientation, d, 0);

		Quatd check = get_dof_rot(DOF_ORDER, d, 0);
		if (length(orientation.xyzw - check.xyzw) > 0.001 && length(-orientation.xyzw - check.xyzw) > 0.001) {
			cout << "Back quaternion conversion: " << orientation << " -> " << check << endl;
			cout << " via " << d[0] << " " << d[1] << " " << d[2] << endl;
		}
		os << " " << d[0] << " " << d[1] << " " << d[2];
		
		// GOOD - don't delete! - xyz order, plain old writing 0 1 2
		//os << " " << d[0] << " " << d[1] << " " << d[2];
	}
	os << endl;
}