示例#1
0
Object* bouteille(glm::vec3 pos)
{
	Container* c = new Container(pos);
    Mesh* m;

	m = CreateCylinder(1.0,1.0,3.0,20,10);
	c->addObject(m);

	m = CreateSphere(1.0f,20.0,20.0);
	m->setPosition(0.0,0.0,3.0);
	c->addObject(m);

	m = CreateCylinder(0.5,0.4,1.5,20.0,10.0);
	m->setPosition(0.0,0.0,3.7f);
	c->addObject(m);

  /*  glPushMatrix();
    glRotatef(90.0, 1.0, 0.0 ,0.0);
    glTranslatef(0.0,0.0,-2.3);
    glutSolidTorus(0.1,0.35,20.0,20.0);
    glTranslatef(0.0,0.0,-0.2);
    glutSolidTorus(0.1,0.3,20.0,20.0);
    glPopMatrix();*/
	return c;
}
示例#2
0
void Render::Draw(IDirect3DSurface9* renderTarget, D3DXMATRIX* view, D3DXMATRIX* projection)
{
    // Get or create device
    LPDIRECT3DDEVICE9 device = GetDevice();
    if (device == NULL) return;

    // Load shaders if it is required
//    if (!EnsureShaders()) return;

    // Prepare depth surface
    D3DSURFACE_DESC renderTargetDescription;
    renderTarget->GetDesc(&renderTargetDescription);
    D3DSURFACE_DESC depthSurfaceDescription;
    if (depthSurface != NULL) depthSurface->GetDesc(&depthSurfaceDescription);
    if (depthSurface == NULL || depthSurfaceDescription.Width != renderTargetDescription.Width || depthSurfaceDescription.Height != renderTargetDescription.Height)
    {
        if (depthSurface != NULL) depthSurface->Release();
        device->CreateDepthStencilSurface(renderTargetDescription.Width, renderTargetDescription.Height, D3DFMT_D24X8, D3DMULTISAMPLE_NONE, 0, FALSE, &depthSurface, NULL);
        if (depthSurface == NULL) return;
    }

    device->SetRenderTarget(0, renderTarget);
    device->SetDepthStencilSurface(depthSurface);
    device->Clear(0, NULL, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, D3DCOLOR_ARGB(0, 0, 0, 0), 1.0f, 0);

    if (lowPolySphere == NULL)
    {
        // Create spheres
        lowPolySphere = CreateSphere(2);
        middlePolySphere = CreateSphere(3);
        highPolySphere = CreateSphere(5);
        // Create cylinders
        lowPolyCylinder = CreateCylinder(3);
        middlePolyCylinder = CreateCylinder(12);
        highPolyCylinder = CreateCylinder(24);
    }



    // FIXME: light dir must be slightly different!
    D3DVECTOR lightDirection;
    lightDirection.x = view->_13;
    lightDirection.y = view->_23;
    lightDirection.z = view->_33;
    D3DVECTOR viewDirection;
    viewDirection.x = view->_13;
    viewDirection.y = view->_23;
    viewDirection.z = view->_33;
    elementMaterials[0].SetViewLightDirection(&viewDirection, &lightDirection);

    // Rendering
    device->BeginScene();


    DrawAtoms(view, projection);
    DrawBonds(view, projection);
    DrawResidues(view, projection);

    device->EndScene();
}
示例#3
0
	MeshUtil::MeshUtil()
	{
		m_MeshMap.emplace("quad_mesh", CreateQuad("quad_mesh", Vector4(-1.0f, -1.0f, 0.0f), Vector4(1.0f, 1.0f, 0.0f)));
		m_MeshMap.emplace("cube_mesh", CreateCube("cube_mesh", Vector4(-1.0f), Vector4(1.0f)));
		m_MeshMap.emplace("ico_sphere_mesh", CreateIcoSphere("ico_sphere_mesh", 1.0f, 2));
		m_MeshMap.emplace("sphere_mesh", CreateSphere("sphere_mesh", 1.0f, 20, 20));
		m_MeshMap.emplace("cylinder_mesh", CreateCylinder("cylinder_mesh", 1.0f, 1.0f, 1.0f, 4, 10));
		m_MeshMap.emplace("cone_mesh", CreateCylinder("cone_mesh", 0.0f, 1.0f, 1.0f, 4, 10));
	}
static void AddMerryGoRound(DemoEntityManager* const scene, const dVector& location)
{
	NewtonBody* const pole = CreateCylinder(scene, location, 0.0f, 0.2f, 3.0f);

	dVector platformPosit(location);
	platformPosit.m_y += 0.2f;
	NewtonBody* const platform = CreateCylinder(scene, platformPosit, 200.0f, 10.0f, 0.2f);

	dMatrix pivot;
	NewtonBodyGetMatrix(platform, &pivot[0][0]);
	dCustomHinge* const hinge = new dCustomHinge(pivot, platform, pole);
	hinge;
}
static void AddCylindrical (DemoEntityManager* const scene, const dVector& origin)
{
    // make a reel static
    NewtonBody* const box0 = CreateCylinder (scene, origin + dVector (0.0f, 4.0f, 0.0f, 0.0f), 0.25f, 8.0f);
    NewtonBody* const box1 = CreateWheel (scene, origin + dVector (0.0f, 4.0f, 0.0f, 0.0f), 1.0f, 0.5f);

    dMatrix matrix;
	//connect the box0 to the base by a fix joint (a hinge with zero limit)
	//NewtonBodyGetMatrix(box0, &matrix[0][0]);
	//CustomHinge* const fixJoint = new CustomHinge(matrix, box0, NULL);
	//fixJoint->EnableLimits(true);
	//fixJoint->SetLimis(0.0f, 0.0f);
	NewtonBodySetMassMatrix(box0, 0.0f, 0.0f, 0.0f, 0.0f);

	// connect the bodies by a CorkScrew joint
    NewtonBodyGetMatrix (box1, &matrix[0][0]);
    CustomCorkScrew* const cylinder = new CustomCorkScrew (matrix, box1, box0);

    // enable limit of first axis
    cylinder->EnableLinearLimits(true);

    // set limit on second axis
    cylinder->SetLinearLimis (-4.0f, 4.0f);

#ifdef _USE_HARD_JOINTS
	NewtonSkeletonContainer* const skeleton = NewtonSkeletonContainerCreate(scene->GetNewton(), box0, NULL);
	NewtonSkeletonContainerAttachBone(skeleton, box1, box0);
	NewtonSkeletonContainerFinalize(skeleton);
#endif
}
static void AddGear (DemoEntityManager* const scene, const dVector& origin)
{
    NewtonBody* const box0 = CreateCylinder(scene, origin + dVector (0.0f, 4.0f, 0.0f), 0.25f, 4.0f);

	// this is a fix joint
	NewtonBodySetMassMatrix(box0, 0.0f, 0.0f, 0.0f, 0.0f);

	// connect two bodies with a hinge 
    CustomHinge* const hinge0 = AddHingeWheel (scene, origin + dVector (-1.0f, 4.0f, 0.0f), 0.5f, 1.0f, box0);
    CustomHinge* const hinge1 = AddHingeWheel (scene, origin + dVector ( 1.0f, 4.0f, 0.0f), 0.5f, 1.0f, box0);

    NewtonBody* const body0 = hinge0->GetBody0();
    NewtonBody* const body1 = hinge1->GetBody0();

    dMatrix matrix0;
    dMatrix matrix1;
    NewtonBodyGetMatrix (body0, &matrix0[0][0]);
    NewtonBodyGetMatrix (body1, &matrix1[0][0]);

	// relate the two body motion with a gear joint
    dVector pin0 (matrix0.RotateVector(dVector (1.0f, 0.0f, 0.0f)));
    dVector pin1 (matrix1.RotateVector(dVector (1.0f, 0.0f, 0.0f)));
    new CustomGear (4.0f, pin0, pin1, body0, body1);

#ifdef _USE_HARD_JOINTS
	NewtonSkeletonContainer* const skeleton = NewtonSkeletonContainerCreate(scene->GetNewton(), box0, NULL);
//	NewtonSkeletonContainerAttachBone(skeleton, box0, NULL);
	NewtonSkeletonContainerAttachBone(skeleton, hinge0->GetBody0(), box0);
	NewtonSkeletonContainerAttachBone(skeleton, hinge1->GetBody0(), box0);
	NewtonSkeletonContainerFinalize(skeleton);
#endif

}
示例#7
0
/*
void futBiere()
{
    GLUquadric* params;
    params = gluNewQuadric();
    glPushMatrix();
    glRotatef(270.0, 1.0, 0.0 ,0.0);
    glTranslatef(0.0,0.0,1.5);
    glutSolidTorus(0.1,1.5,100.0,100.0);
    gluCylinder(params,1.5,1.0,1.5,100.0,1.0);
    glTranslatef(0.0,0.0,-1.5);
    glutSolidTorus(0.1,1.6,100.0,100.0);
    gluCylinder(params,1.5,1.5,1.5,100.0,1.0);
    glRotatef(180, 1.0, 0.0 ,0.0);
    gluCylinder(params,1.5,1.0,1.5,100.0,1.0);
    glPushMatrix();
    glTranslatef(0.0,0.0,-3.0);
    glScalef( 1.0, 1.0, 0.0);
    //attention
    glutSolidSphere(1.0,20.0,20.0);
    glPopMatrix();
    glPushMatrix();
    glTranslatef(0.0,0.0,1.5);
    glScalef( 1.0, 1.0, 0.0);
    //attention
    glutSolidSphere(1.0,20.0,20.0);
    glPopMatrix();
    glTranslatef(0.0,0.0,-3.3);
    glTranslatef(0.0,0.7,0.0);
    gluCylinder(params,0.1,0.1,0.5,100.0,1.0);
    glTranslatef(0.0,-0.7,0.0);
    glScalef( 0.2,0.2,0.2);
    robinet();
    glPopMatrix();
}
void robinet()
{
    GLUquadric* params;
    params = gluNewQuadric();
    glutSolidTorus(0.5,1.5,100.0,8.0);
    gluCylinder(params,0.2,0.2,4.0,100.0,1.0);
    glPushMatrix();
    glTranslatef(0.0,1.0,0.0);
    glRotatef(90, 1.0, 0.0 ,0.0);
    gluCylinder(params,0.2,0.2,2.0,100.0,1.0);
    glPopMatrix();
    glPushMatrix();
    glTranslatef(-1.0,0.0,0.0);
    glRotatef(90, 1.0, 0.0 ,0.0);
    glRotatef(90, 0.0, 1.0 ,0.0);
    gluCylinder(params,0.2,0.2,2.0,100.0,1.0);
    glPopMatrix();
}

void cigarette()
{
    GLUquadric* params;
    params = gluNewQuadric();
    glColor3f(0.2,0.2,0.2);
    gluCylinder(params,0.25,0.25,0.2,100.0,1.0);
    glTranslatef(0.0,0.0,0.2);
    glColor3f(1.0,1.0,1.0);
    gluCylinder(params,0.25,0.25,3.0,100.0,1.0);
    glTranslatef(0.0,0.0,3.0);
    glColor3f(1.0,0.5,0.0);
    gluCylinder(params,0.25,0.25,1.0,100.0,1.0);
    glTranslatef(0.0,0.0,1.0);
    glPushMatrix();
    glScalef( 1.0, 1.0, 0.0);
    glColor3f(1.0,1.0,1.0);
    //glutSolidSphere(0.25,20.0,20.0);
    Sphere(0.25,20.0,20.0);
    glPopMatrix();
    glColor3f(1.0,0.0,0.0);
    glTranslatef(0.0,0.0,-4.2);
    glScalef( 1.0, 1.0, 0.5);
    glutSolidSphere(0.25,20.0,20.0);
    glColor3f(1.0,1.0,1.0);
}*/
Object* chaise(glm::vec3 pos)
{
	Texture* t1 = ObjectAccessor::getObjMgr()->getTexture("../../src/img/chaise1.bmp");
	Mesh* m;
	Container* c = new Container(pos); 

	//siege
	m = CreateBox(2.0,2.0,0.4);
	m->setTexture(t1);
	m->setPosition(0.0,0.0,1.7);
	c->addObject(m);

	//dossier
	m = CreateBox(2.0,0.4,1.0);
	m->setTexture(t1);
	m->setPosition(0.0,-0.75,3.9);
	c->addObject(m);

	//support dossier
	m = CreateCylinder(0.2,0.2,1.5,20.0,1.0);
	m->setTexture(t1);
	m->setPosition(0.0,-0.75,1.9);
	c->addObject(m);
	//pied

	m = CreateCylinder(0.2,0.2,1.5,20.0,1.0);
	m->setPosition(0.75,0.75,0);
	m->setTexture(t1);
	c->addObject(m);

	m = CreateCylinder(0.2,0.2,1.5,20.0,1.0);
	m->setPosition(0.75,-0.75,0);
	m->setTexture(t1);
	c->addObject(m);

	m = CreateCylinder(0.2,0.2,1.5,20.0,1.0);
	m->setPosition(-0.75,0.75,0);
	m->setTexture(t1);
	c->addObject(m);

	m = CreateCylinder(0.2,0.2,1.5,20.0,1.0);
	m->setPosition(-0.75,-0.75,0);
	m->setTexture(t1);
	c->addObject(m);

	return c;
}
示例#8
0
Object* lustre(glm::vec3 pos)
{
	Object* amp;
	Container* c = new Container(pos);
	Mesh* m;

	m = CreateCylinder(5.0*COEF2,0.0*COEF2,3.0*COEF2,20.0,10.0);
	c->addObject(m);

	m = CreateCylinder(0.1*COEF2,0.1*COEF2,3.0*COEF2,20.0,1.0);
	m->setPosition(0.0,0.0,2.8);
	c->addObject(m);

	amp = ampoule(glm::vec3(0,0,0.5));
	amp->rotate(180,glm::vec3(1,0,0));
	c->addObject(amp);

	return c;
}/*
static void AddGearAndRack (DemoEntityManager* const scene, const dVector& origin)
{
    NewtonBody* const reel0 = CreateCylinder(scene, origin + dVector (0.0f, 4.0f, 0.0f), 0.25f, 4.0f);
    NewtonBody* const reel1 = CreateBox(scene, origin + dVector (0.0f, 4.0f, 2.0f), dVector(4.0f, 0.25f, 0.25f));
    
	dMatrix matrix;
	//connect the box0 to the base by a fix joint (a hinge with zero limit)
	NewtonBodyGetMatrix(reel0, &matrix[0][0]);
	CustomHinge* const fixJoint0 = new CustomHinge(matrix, reel0, NULL);
	fixJoint0->EnableLimits(true);
	fixJoint0->SetLimis(0.0f, 0.0f);

	NewtonBodyGetMatrix(reel1, &matrix[0][0]);
	CustomHinge* const fixJoint1 = new CustomHinge(matrix, reel1, NULL);
	fixJoint1->EnableLimits(true);
	fixJoint1->SetLimis(0.0f, 0.0f);

    CustomHinge* const hinge0 = AddHingeWheel (scene, origin + dVector (-1.0f, 4.0f, 0.0f), 0.5f, 0.5f, reel0);
    CustomHinge* const hinge1 = AddHingeWheel (scene, origin + dVector ( 1.0f, 4.0f, 0.0f), 0.5f, 0.5f, reel0);
    CustomCorkScrew* const cylinder = AddCylindricalWheel(scene, origin + dVector (0.0f, 4.0f, 2.0f), 0.5f, 1.0f, reel1);

    cylinder->EnableLinearLimits(true);
    cylinder->SetLinearLimis(-2.0f, 2.0f);

    NewtonBody* const body0 = hinge0->GetBody0();
    NewtonBody* const body1 = hinge1->GetBody0();
    NewtonBody* const body2 = cylinder->GetBody0();

    dMatrix matrix0;
    dMatrix matrix1;
    dMatrix matrix2;

    NewtonBodyGetMatrix (body0, &matrix0[0][0]);
    NewtonBodyGetMatrix (body1, &matrix1[0][0]);
    NewtonBodyGetMatrix (body2, &matrix2[0][0]);

    dVector pin0 (matrix0.RotateVector(dVector( 1.0f, 0.0f, 0.0f)));
    dVector pin1 (matrix1.RotateVector(dVector( 1.0f, 0.0f, 0.0f)));
    dVector pin2 (matrix2.RotateVector(dVector( 1.0f, 0.0f, 0.0f)));

    new CustomGear (1.0f, pin0, pin2, body0, body2);
    new CustomRackAndPinion (1.0f, pin1, pin2, body1, body2);

#ifdef _USE_HARD_JOINTS
	NewtonSkeletonContainer* const skeleton = NewtonSkeletonContainerCreate(scene->GetNewton(), NULL, NULL);
	NewtonSkeletonContainerAttachBone(skeleton, reel0, NULL);
	NewtonSkeletonContainerAttachBone(skeleton, hinge0->GetBody0(), reel0);
	NewtonSkeletonContainerAttachBone(skeleton, hinge1->GetBody0(), reel0);

	NewtonSkeletonContainerAttachBone(skeleton, reel1, NULL);
	NewtonSkeletonContainerAttachBone(skeleton, cylinder->GetBody0(), reel1);
	NewtonSkeletonContainerFinalize(skeleton);
#endif
}
示例#10
0
void BaseMesh::CreateCylinder(float radius, const Vec3f &pt1, const Vec3f &pt2, UINT slices, UINT stacks)
{
    float height = (pt2 - pt1).Length();
    CreateCylinder(radius, height, slices, stacks);    //create a basic cylinder of the appropriate height

    Matrix4 Face = Matrix4::Face(Vec3f::eZ, pt2 - pt1);                    //make it face the direction pt2 - pt1 instead of eZ
    Matrix4 T2 = Matrix4::Translation(pt1);                                //translate it so it goes from pt1 -> pt2

    ApplyMatrix(Face * T2);
    GenerateNormals();
}
示例#11
0
static void AddGearAndRack (DemoEntityManager* const scene, const dVector& origin)
{
    NewtonBody* const reel0 = CreateCylinder(scene, origin + dVector (0.0f, 4.0f, 0.0f), 0.25f, 4.0f);
    NewtonBody* const reel1 = CreateBox(scene, origin + dVector (0.0f, 4.0f, 2.0f), dVector(4.0f, 0.25f, 0.25f));
    
	dMatrix matrix;
	NewtonBodySetMassMatrix(reel0, 0.0f, 0.0f, 0.0f, 0.0f);
	NewtonBodySetMassMatrix(reel1, 0.0f, 0.0f, 0.0f, 0.0f);

    CustomHinge* const hinge0 = AddHingeWheel (scene, origin + dVector (-1.0f, 4.0f, 0.0f), 0.5f, 0.5f, reel0);
    CustomHinge* const hinge1 = AddHingeWheel (scene, origin + dVector ( 1.0f, 4.0f, 0.0f), 0.5f, 0.5f, reel0);
    CustomCorkScrew* const cylinder = AddCylindricalWheel(scene, origin + dVector (0.0f, 4.0f, 2.0f), 0.5f, 1.0f, reel0);

    cylinder->EnableLinearLimits(true);
    cylinder->SetLinearLimis(-2.0f, 2.0f);

    NewtonBody* const body0 = hinge0->GetBody0();
    NewtonBody* const body1 = hinge1->GetBody0();
    NewtonBody* const body2 = cylinder->GetBody0();

    dMatrix matrix0;
    dMatrix matrix1;
    dMatrix matrix2;

    NewtonBodyGetMatrix (body0, &matrix0[0][0]);
    NewtonBodyGetMatrix (body1, &matrix1[0][0]);
    NewtonBodyGetMatrix (body2, &matrix2[0][0]);

    dVector pin0 (matrix0.RotateVector(dVector( 1.0f, 0.0f, 0.0f)));
    dVector pin1 (matrix1.RotateVector(dVector( 1.0f, 0.0f, 0.0f)));
    dVector pin2 (matrix2.RotateVector(dVector( 1.0f, 0.0f, 0.0f)));

    new CustomGear (1.0f, pin0, pin2, body0, body2);
    new CustomRackAndPinion (1.0f, pin1, pin2, body1, body2);

#ifdef _USE_HARD_JOINTS
	NewtonSkeletonContainer* const skeleton = NewtonSkeletonContainerCreate(scene->GetNewton(), reel0, NULL);
	NewtonSkeletonContainerAttachBone(skeleton, hinge0->GetBody0(), reel0);
	NewtonSkeletonContainerAttachBone(skeleton, hinge1->GetBody0(), reel0);
	NewtonSkeletonContainerAttachBone(skeleton, cylinder->GetBody0(), reel0);
	NewtonSkeletonContainerFinalize(skeleton);
#endif

	// make an aggregate for disabling collisions
	void* const aggregate = NewtonCollisionAggregateCreate(scene->GetNewton());
	NewtonCollisionAggregateSetSelfCollision(aggregate, 0);
	NewtonCollisionAggregateAddBody(aggregate, reel0);
	NewtonCollisionAggregateAddBody(aggregate, reel1);
	NewtonCollisionAggregateAddBody(aggregate, body0);
	NewtonCollisionAggregateAddBody(aggregate, body1);
	NewtonCollisionAggregateAddBody(aggregate, body2);
}
Ogre::SceneNode* LuaScriptUtilities::CreateLine(
    Ogre::SceneNode* const parentNode,
    const Ogre::Vector3& start,
    const Ogre::Vector3& end)
{
    assert(parentNode);

    Ogre::SceneNode* const line = CreateCylinder(parentNode, 1.0f, 1.0f);

    SetLineStartEnd(line, start, end);

    return line;
}
示例#13
0
Object* table(glm::vec3 pos)
{
	Texture* t1 = ObjectAccessor::getObjMgr()->getTexture("../../src/img/metal.bmp");
	Texture* t2 = ObjectAccessor::getObjMgr()->getTexture("../../src/img/table.bmp");
	Mesh* m;
	Container* c = new Container(pos); 

	m = CreateCylinder(2.0,0.2,0.5,20.0,10.0);
	c->addObject(m);
	m->setTexture(t1);

	m = CreateCylinder(0.2,0.2,3.3,20.0,1.0);
	m->setPosition(0.0,0.0,0.5);
	c->addObject(m);
	m->setTexture(t1);

	m = CreateBox(4.0,4.0,0.2);
	m->setPosition(0.0,0.0,4.0);
	c->addObject(m);
	m->setTexture(t2);
	return c;
}
示例#14
0
Object* ampoule(glm::vec3 pos)
{
	Container* c = new Container(pos);
	Mesh* m;

	m = CreateSphere(COEF2*1.5,20,20);
	m->setPosition(0,0,0.5);
	c->addObject(m);

	m = CreateCylinder(COEF2*0.5,COEF2*0.5,COEF2*1.0,20.0,1.0);
	m->setPosition(0,0,-1.60+0.25*COEF2);
	c->addObject(m);

	m = CreateCylinder(COEF2*0.25,COEF2*0.5,COEF2*0.25,20.0,10.0);
	m->setPosition(0,0,-1.60);
	c->addObject(m);

	m = CreateSphere(COEF2*0.25,20.0,20.0);
	m->setPosition(0,0,-1.60);
	c->addObject(m);
	return c;
}
示例#15
0
void CreatePipe( const AcGePoint3d& start, const AcGePoint3d& end, const double& radius)
{
	acutPrintf(L"开始绘制管体\n");

	//得到线段的长度
	double length = start.distanceTo(end);
	if( length < 0.1 )
		return;

	acutPrintf(L"得到管体高度%lf\n",length);

	//绘制圆柱体
	AcDb3dSolid* p3dPipe = CreateCylinder(radius,length);
	if( p3dPipe == NULL )
		return;

	//得到线段与Z轴的垂直向量
	AcGeVector3d line3dVector(end.x - start.x,end.y - start.y, end.z-start.z);
	AcGeVector3d rotateVctor = line3dVector.crossProduct(AcGeVector3d::kZAxis);

	//得到旋转的角度
	double angle = -line3dVector.angleTo(AcGeVector3d::kZAxis);
	acutPrintf(L"得到旋转角度%lf\n",angle);

	//进行旋转
	AcGeMatrix3d rotateMatrix = AcGeMatrix3d::rotation( angle, rotateVctor, AcGePoint3d::kOrigin);
	p3dPipe->transformBy(rotateMatrix);
	
	//得到线段的中心点
	AcGePoint3d center(start.x + end.x, start.y + end.y, start.z + end.z); 
	center /= 2;
	acutPrintf(L"得到中心点[%lf][%lf][%lf]\n",center.x,center.y,center.z);

	//进行偏移
	AcGeMatrix3d moveMatrix;
	moveMatrix.setToTranslation(AcGeVector3d(center.x,center.y,center.z));

	p3dPipe->transformBy(moveMatrix);

	//加入到3D模型中
	PostToModelSpace(p3dPipe);

#ifdef DEBUG
	acutPrintf(L"插入中心线,用于矫正");

	AcDbLine *pLine = new AcDbLine(start, end);
    PostToModelSpace(pLine);
#endif
}
示例#16
0
	dCustomInverseDynamicsEffector* AddLeg(DemoEntityManager* const scene, void* const rootNode, const dMatrix& matrix, dFloat partMass, dFloat limbLenght)
	{
		NewtonBody* const parent = NewtonInverseDynamicsGetBody(m_kinematicSolver, rootNode);

		dFloat inertiaScale = 4.0f;
		// make limb base
		dMatrix baseMatrix(dRollMatrix(dPi * 0.5f));
		dMatrix cylinderMatrix(baseMatrix * matrix);
		NewtonBody* const base = CreateCylinder(scene, cylinderMatrix, partMass, inertiaScale, 0.2f, 0.1f);
		dCustomInverseDynamics* const baseHinge = new dCustomInverseDynamics(cylinderMatrix, base, parent);
		baseHinge->SetJointTorque(1000.0f);
		baseHinge->SetTwistAngle(-0.5f * dPi, 0.5f * dPi);
		void* const baseHingeNode = NewtonInverseDynamicsAddChildNode(m_kinematicSolver, rootNode, baseHinge->GetJoint());

		//make limb forward arm
		dMatrix forwardArmMatrix(dPitchMatrix(-30.0f * dDegreeToRad));
		dVector forwardArmSize(limbLenght * 0.25f, limbLenght * 0.25f, limbLenght, 0.0f);
		forwardArmMatrix.m_posit += forwardArmMatrix.m_right.Scale(forwardArmSize.m_z * 0.5f);
		NewtonBody* const forwardArm = CreateBox(scene, forwardArmMatrix * matrix, forwardArmSize, partMass, inertiaScale);
		dMatrix forwardArmPivot(forwardArmMatrix);
		forwardArmPivot.m_posit -= forwardArmMatrix.m_right.Scale(forwardArmSize.m_z * 0.5f);
		dCustomInverseDynamics* const forwardArmHinge = new dCustomInverseDynamics(forwardArmPivot * matrix, forwardArm, base);
		forwardArmHinge->SetJointTorque(1000.0f);
		forwardArmHinge->SetTwistAngle(-0.5f * dPi, 0.5f * dPi);
		void* const forwardArmHingeNode = NewtonInverseDynamicsAddChildNode(m_kinematicSolver, baseHingeNode, forwardArmHinge->GetJoint());

		//make limb forward arm
		dMatrix armMatrix(dPitchMatrix(-90.0f * dDegreeToRad));
		dFloat armSize = limbLenght * 1.25f;
		armMatrix.m_posit += forwardArmMatrix.m_right.Scale(limbLenght);
		armMatrix.m_posit.m_y -= armSize * 0.5f;
		NewtonBody* const arm = CreateCapsule(scene, armMatrix * matrix, partMass, inertiaScale, armSize * 0.2f, armSize);
		dMatrix armPivot(armMatrix);
		armPivot.m_posit.m_y += armSize * 0.5f;
		dCustomInverseDynamics* const armHinge = new dCustomInverseDynamics(armPivot * matrix, arm, forwardArm);
		armHinge->SetJointTorque(1000.0f);
		armHinge->SetTwistAngle(-0.5f * dPi, 0.5f * dPi);
		void* const armHingeNode = NewtonInverseDynamicsAddChildNode(m_kinematicSolver, forwardArmHingeNode, armHinge->GetJoint());

		dMatrix effectorMatrix(dGetIdentityMatrix());
		effectorMatrix.m_posit = armPivot.m_posit;
		effectorMatrix.m_posit.m_y -= armSize;
		dHexapodEffector* const effector = new dHexapodEffector(m_kinematicSolver, armHingeNode, parent, effectorMatrix * matrix);
		effector->SetAsThreedof();
		effector->SetMaxLinearFriction(partMass * DEMO_GRAVITY * 10.0f);
		effector->SetMaxAngularFriction(partMass * DEMO_GRAVITY * 10.0f);

		return effector;
	}
示例#17
0
void TW_CALL SetScale(const void *value, void *clientData)
{
	//Pointer auf gesetzten Typ casten (der Typ der bei TwAddVarCB angegeben wurde)
	const unsigned int* uintptr = static_cast<const unsigned int*>(value);

	//Setzen der Variable auf neuen Wert
	scale = *uintptr;

	//Hier kann nun der Aufruf gemacht werden um die Geometrie mit neuem Scalefaktor zu erzeugen
	//CreateCone(0.0f, 0.0f, -100.0f);
	CreateCube(-75.0f, 0.0f, 0.0f);
	CreateCylinder(0.0f, 125.0f, 0.0f);
	CreateSphere(100.0f, 0.0f, 0.0f);

	RenderScene();
}
void PezInitialize()
{
    const PezConfig cfg = PezGetConfig();

    // Assign the vertex attributes to integer slots:
    GLuint* pAttr = (GLuint*) &Attr;
    for (int a = 0; a < sizeof(Attr) / sizeof(GLuint); a++) {
        *pAttr++ = a;
    }

    // Compile shaders
    Globals.SimpleProgram = LoadProgram("Simple.VS", 0, "Simple.FS");
    Globals.QuadProgram = LoadProgram("Quad.VS", 0, "Quad.FS");
    Globals.GridProgram = LoadProgram("Grid.VS", 0, "Grid.FS");
    Globals.LitProgram = LoadProgram("Lit.VS", "Lit.GS", "Lit.FS");

    // Set up viewport
    float fovy = 16 * TwoPi / 180;
    float aspect = (float) cfg.Width / cfg.Height;
    float zNear = 0.1, zFar = 300;
    Globals.Projection = M4MakePerspective(fovy, aspect, zNear, zFar);
    Point3 eye = {0, 1, 4};
    Point3 target = {0, 0, 0};
    Vector3 up = {0, 1, 0};
    Globals.View = M4MakeLookAt(eye, target, up);

    // Create offscreen buffer:
    Globals.FboHandle = CreateRenderTarget(&Globals.FboTexture);
    glUseProgram(Globals.QuadProgram);
    Globals.QuadVao = CreateQuad();
    Globals.Grid = CreateGrid(GridRows, GridCols);

    // Create geometry
    Globals.Cylinder = CreateCylinder();

    // Misc Initialization
    Globals.Theta = 0;
    glClearColor(0.9, 0.9, 1.0, 1);
    glLineWidth(1.5);
    glEnable(GL_LINE_SMOOTH);
    glHint(GL_LINE_SMOOTH_HINT, GL_NICEST);
    glEnable(GL_BLEND);
    glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
    glEnable(GL_POLYGON_OFFSET_FILL);
    glPolygonOffset(1,1);
}
示例#19
0
// Initialisierung des Rendering Kontextes
void SetupRC() {
	// Schwarzer Hintergrund
	glClearColor(0.1f, 0.1f, 0.1f, 1.0f);
	// In Uhrzeigerrichtung zeigende Polygone sind die Vorderseiten.
	// Dies ist umgekehrt als bei der Default-Einstellung weil wir Triangle_Fans benützen
	glFrontFace(GL_CW);

	//initialisiert die standard shader
	shaderManager.InitializeStockShaders();
	transformPipeline.SetMatrixStacks(modelViewMatrix, projectionMatrix);

	//erzeuge die geometrie
	CreateCone(0, 0, 0);
	CreateCube(0, 0, 0);
	CreateCylinder(0, 0, 0);
	CreateSphere(0, 0, 0);

	InitGUI();
}
示例#20
0
//----------------------------------------------------------------------------
bool Skinning::Setup ()
{
    m_spkScene = new Node(1);

    int iRadialSamples = 10;
    Vector3f kCenter(0.0f,0.0f,100.0f);
    Vector3f kU(0.0f,0.0f,-1.0f);
    Vector3f kV(0.0f,1.0f,0.0f);
    Vector3f kAxis(1.0f,0.0f,0.0f);
    float fRadius = 10.0f;
    float fHeight = 80.0f;

    m_spkTriMesh = CreateCylinder(iRadialSamples,kCenter,kU,kV,kAxis,fRadius,
        fHeight,true,true,true);

    m_spkTriMesh->SetVertexShader(m_spkVertShader);
    m_spkScene->AttachChild(m_spkTriMesh); 
    return true;
}
示例#21
0
Object* porte(glm::vec3 pos)
{
	Container* c = new Container(pos);
	Mesh* m;
	Texture* t = TextureMgr::getTextureMgr()->getTexture("../../src/img/interieur.bmp");
	m = CreateBox(5.0, 0.8, 10.0);
	m->setPosition(0.0,0.0,5.0);
	
	c->addObject(m);

	m = CreateCylinder(0.1,0.1,1.2,20.0,1.0);
	m->rotate(-90,glm::vec3(1,0,0));
	m->setPosition(2.0,-0.6,5.0);
	c->addObject(m);

	//glScalef(1.0,1.0,0.5);
	m = CreateSphere(0.2,20.0,20.0);
	m->setPosition(2.0,0.6,5.0);
	c->addObject(m);

	//glScalef(1.0,1.0,0.5);
	m = CreateSphere(0.2,20.0,20.0);
	m->setPosition(2.0,-0.6,5.0);
	c->addObject(m);

	m = CreateBox(1.0, 1.0, 25.0);
	m->setPosition(-3.0,0.0,12.5);
	m->setTexture(t);
	c->addObject(m);

	m = CreateBox(1.0, 1.0, 25.0);
	m->setPosition(3.0,0.0,12.5);
	m->setTexture(t);
	c->addObject(m);

	m = CreateBox(6.0, 1.0, 15.0);
	m->setPosition(0.0,0.0,17.5);
	m->setTexture(t);
	c->addObject(m);

	return c;
}
示例#22
0
void TW_CALL SetTesselation(const void *value, void *clientData)
{
	//Pointer auf gesetzten Typ casten (der Typ der bei TwAddVarCB angegeben wurde)
	const unsigned int* uintptr = static_cast<const unsigned int*>(value);

	//Setzen der Variablen auf neuen Wert
	tess = *uintptr;
	tesselation = pow(2, tess);
	arraySize = 2 * tesselation + 2;
	doubleArraySize = 2 * arraySize;
	sphereArraySize = (tesselation*(arraySize - 1) + 1) * 2;

	//Hier kann nun der Aufruf gemacht werden um die Geometrie mit neuem Tesselierungsfaktor zu erzeugen
	//CreateCone(0.0f, 0.0f, -100.0f);
	CreateCube(-75.0f, 0.0f, 0.0f);
	CreateCylinder(0.0f, 125.0f, 0.0f);
	CreateSphere(100.0f, 0.0f, 0.0f);

	RenderScene();
}
示例#23
0
//-------------------------------------------------------------------------------
// @ Player::Player()
//-------------------------------------------------------------------------------
// Constructor
//-------------------------------------------------------------------------------
Player::Player()
{
    mRotate.Identity();
    mScale = 1.0f;
    mTranslate.Zero();

    mRadius = 3.0f;

    mCylinderVerts = 0;
    mCylinderIndices = 0;

    mBlendMode = kOpacityBlendMode;

    unsigned int i;

    mBaseTexture = nullptr;

    for (i = 0; i < NUM_BLEND_TEX; i++)
        mBlendTextures[i] = nullptr;

    mCurrentBlendTexIndex = 0;

    mBaseTexture = CreateTextureFromFile("image.tga");
    mBlendTextures[0] = CreateTextureFromFile("fence.tga");
    mBlendTextures[1] = CreateTextureFromFile("darkdots.tga");
    mBlendTextures[2] = CreateTextureFromFile("glowdots.tga");

    mShader = IvRenderer::mRenderer->GetResourceManager()->CreateShaderProgram(
        IvRenderer::mRenderer->GetResourceManager()->CreateVertexShaderFromFile(
        "textureShader"),
        IvRenderer::mRenderer->GetResourceManager()->CreateFragmentShaderFromFile(
        "textureShader"));

    mTextureUniform = mShader->GetUniform("Texture");

    mTextureUniform->SetValue(mBaseTexture);

    IvRenderer::mRenderer->SetShaderProgram(mShader);

    CreateCylinder();
}   // End of Player::Player()
示例#24
0
文件: app.c 项目: RorschachUK/Trakr
//Setup world
void InitialiseWorld() {
	world=CreateNewWorld();
	Point3d centre;
	//Camera starting point - raised 5cm off ground.
	cameraPos=CreatePoint(0.0,5.0,0.0);
	cameraAngle=CreatePoint(0.0,0.0,0.0);
	baselinePos=cameraPos;
	arrowRefAngle=0;

	//The tank
	tank=CreateTank(GREEN, CreatePoint(0,0,0), 4.5);
	tankObjectIndex=AddObjectToWorld(&world, tank);
	PlaceTank(cameraPos, cameraAngle);

	//Populate with a few shapes
	int i;
	for (i=0; i<4; i++) {
		//Random blue cubes
		centre=CreatePoint(Random(-100.0, 100.0),0.0,Random(-100.0, 100.0));
		obj=CreateCube(BLUE, centre, 4.0);
		RotateObjectYAxis(&obj, Random(0.0, 2 * PI));
		AddObjectToWorld(&world,obj);

		//Random yellow pyramids
		centre=CreatePoint(Random(-100.0, 100.0),0.0,Random(-100.0, 100.0));
		obj=CreatePyramid(YELLOW, centre, 4.0);
		RotateObjectYAxis(&obj, Random(0.0, 2 * PI));
		AddObjectToWorld(&world,obj);

		//Random red barrels
		centre=CreatePoint(Random(-100.0, 100.0),0.0,Random(-100.0, 100.0));
		obj=CreateCylinder(RED,centre, 4.0);
		RotateObjectYAxis(&obj, Random(0.0, 2 * PI));
		AddObjectToWorld(&world,obj);
	}
}
示例#25
0
void Draw3DCylinder (const dMatrix& location, int segments, dFloat radius, dFloat height, const dVector& color)
{
#ifdef COMPILE_OPENGL
	SetMaterial (color);

	dVector points[128 * 3];  
	dVector normals[128];  
	int count = CreateCylinder (points, normals, segments, radius, height, 128);

	glPushMatrix();
	glMultMatrix(&location[0][0]);
	glBegin(GL_TRIANGLES);
	for (int i = 0; i < count; i ++) {
		glNormal3f(normals[i].m_x, normals[i].m_y, normals[i].m_z);
		glVertex3f(points[i * 3 + 0].m_x, points[i * 3 + 0].m_y, points[i * 3 + 0].m_z); 
		glNormal3f(normals[i].m_x, normals[i].m_y, normals[i].m_z);
		glVertex3f(points[i * 3 + 1].m_x, points[i * 3 + 1].m_y, points[i * 3 + 1].m_z); 
		glNormal3f(normals[i].m_x, normals[i].m_y, normals[i].m_z);
		glVertex3f(points[i * 3 + 2].m_x, points[i * 3 + 2].m_y, points[i * 3 + 2].m_z); 
	}
	glEnd();
	glPopMatrix();
#endif
}
示例#26
0
void BaseMesh::CreateLozenge(float Radius, const Vec3f &Start, const Vec3f &End, UINT slices, UINT stacks)
{
    //allocate space for the lozenge and call ReCreateLozenge
    CreateCylinder(1.0f, 1.0f, slices, stacks);
    ReCreateLozenge(Radius, Start, End, slices, stacks);
}
void RagdollDemo::initPhysics()
{
	// Setup the basic world

	setTexturing(true);
	setShadows(true);

	setCameraDistance(btScalar(5.));

	m_collisionConfiguration = new btDefaultCollisionConfiguration();

	m_dispatcher = new btCollisionDispatcher(m_collisionConfiguration);

	btVector3 worldAabbMin(-10000,-10000,-10000);
	btVector3 worldAabbMax(10000,10000,10000);
	m_broadphase = new btAxisSweep3 (worldAabbMin, worldAabbMax);

	m_solver = new btSequentialImpulseConstraintSolver;

	m_dynamicsWorld = new btDiscreteDynamicsWorld(m_dispatcher,m_broadphase,m_solver,m_collisionConfiguration);
	//m_dynamicsWorld->getDispatchInfo().m_useConvexConservativeDistanceUtil = true;
	//m_dynamicsWorld->getDispatchInfo().m_convexConservativeDistanceThreshold = 0.01f;



	// Setup a big ground box
	{
		btCollisionShape* groundShape = new btBoxShape(btVector3(btScalar(200.),btScalar(10.),btScalar(200.)));
		m_collisionShapes.push_back(groundShape);
		btTransform groundTransform;
		groundTransform.setIdentity();
		groundTransform.setOrigin(btVector3(0,-10,0));

#define CREATE_GROUND_COLLISION_OBJECT 1
#ifdef CREATE_GROUND_COLLISION_OBJECT
		btCollisionObject* fixedGround = new btCollisionObject();
		fixedGround->setCollisionShape(groundShape);
		fixedGround->setWorldTransform(groundTransform);
		m_dynamicsWorld->addCollisionObject(fixedGround);
#else
		localCreateRigidBody(btScalar(0.),groundTransform,groundShape);
#endif //CREATE_GROUND_COLLISION_OBJECT

	}

	// Spawn one ragdoll
	btVector3 startOffset(1,0.5,0);
	//spawnRagdoll(startOffset);
	startOffset.setValue(-1,0.5,0);
	//spawnRagdoll(startOffset);
    
    CreateBox(0, 0., 2., 0., 1., 0.2, 1.); // Create the box
    
    //leg components
    CreateCylinder(1, 2. , 2., 0., .2, 1., 0., 0., M_PI_2); //xleft horizontal
    CreateCylinder(2, -2., 2., 0., .2, 1., 0., 0., M_PI_2); //xright (negative) horizontal
    CreateCylinder(3, 0, 2., 2., .2, 1., M_PI_2, 0., 0.);    //zpositive (into screen)
    CreateCylinder(4, 0, 2., -2., .2, 1., M_PI_2, 0., 0.);   //znegative (out of screen)
    CreateCylinder(5, 3.0, 1., 0., .2, 1., 0., 0., 0.);       //xleft vertical
    CreateCylinder(6, -3.0, 1., 0., .2, 1., 0., 0., 0.);      //xright vertical
    CreateCylinder(7, 0., 1., 3.0, .2, 1., 0., 0., 0.);     //zpositive vertical
    CreateCylinder(8, 0., 1., -3.0, .2, 1., 0., 0., 0.);    //znegative vertical
    
    //The axisworldtolocal defines a vector perpendicular to the plane that you want the bodies to rotate in
    
    
    //hinge the legs together
    //xnegative -- right
    //two bodies should rotate in y-plane through x--give axisworldtolocal it a z vector
    btVector3 local2 = PointWorldToLocal(2, btVector3(-3., 2., 0));
    btVector3 local6 = PointWorldToLocal(6, btVector3(-3., 2., 0));
    btVector3 axis2 = AxisWorldToLocal(2, btVector3(0., 0., 1.));
    btVector3 axis6 = AxisWorldToLocal(6, btVector3( 0., 0., 1.));
    
    
    CreateHinge(0, *body[2], *body[6], local2, local6, axis2, axis6);
    joints[0]->setLimit(btScalar(0.), btScalar(M_PI_2+M_PI_4));
    
   
    //positive -- left
    //give axisworldtolocal a z vector
    btVector3 local1 = PointWorldToLocal(1, btVector3(3., 2., 0));
    btVector3 local5 = PointWorldToLocal(5, btVector3(3., 2., 0));
    btVector3 axis1 = AxisWorldToLocal(1, btVector3( 0., 0., 1.));
    btVector3 axis5 = AxisWorldToLocal(5, btVector3(0., 0., 1.));
    
    CreateHinge(1, *body[1], *body[5], local1, local5, axis1, axis5);
    joints[1]->setLimit(btScalar(M_PI_4), btScalar(M_PI_4));
    
    //zpositive -- back
    //rotates in y-plane through z--give it an x vector
    btVector3 local3 = PointWorldToLocal(3, btVector3(0, 2., 3.));
    btVector3 local7 = PointWorldToLocal(7, btVector3(0, 2., 3.));
    btVector3 axis3 = AxisWorldToLocal(3, btVector3(1., 0., 0.));
    btVector3 axis7 = AxisWorldToLocal(7, btVector3(1., 0., 0.));
    
    CreateHinge(2, *body[3], *body[7], local3, local7, axis3, axis7);
    joints[2]->setLimit(btScalar(0.), btScalar(M_PI_2+M_PI_4));
    
    //znegative -- front
    
    btVector3 local4 = PointWorldToLocal(4, btVector3(0, 2., -3.));
    btVector3 local8 = PointWorldToLocal(8, btVector3(0, 2., -3.));
    btVector3 axis4 = AxisWorldToLocal(4, btVector3(1., 0., 0.));
    btVector3 axis8 = AxisWorldToLocal(8, btVector3(1., 0., 0.));
    
    CreateHinge(3, *body[4], *body[8], local4, local8, axis4, axis8);
    joints[3]->setLimit(btScalar(M_PI_4), btScalar(M_PI_4));
    
    //hinge the legs to the body
    //xright to main
    btVector3 localHinge2 = PointWorldToLocal(2, btVector3(-1, 2., 0));
    btVector3 mainHinge2 = PointWorldToLocal(0, btVector3(-1, 2., 0));
    btVector3 localAxis2 = AxisWorldToLocal(2, btVector3(0., 0., 1.));
    btVector3 mainAxis2 = AxisWorldToLocal(0, btVector3( 0., 0., 1.));
    
    CreateHinge(4, *body[0], *body[2], mainHinge2, localHinge2, mainAxis2, localAxis2);
    //joints[4]->setLimit(btScalar(-M_PI_2-M_PI_4), btScalar(M_PI_4));
    
    
    //xleft to main
    btVector3 localHinge1 = PointWorldToLocal(1, btVector3(1, 2., 0));
    btVector3 mainHinge1 = PointWorldToLocal(0, btVector3(1, 2., 0));
    btVector3 localAxis1 = AxisWorldToLocal(1, btVector3(0., 0., 1.));
    btVector3 mainAxis1 = AxisWorldToLocal(0, btVector3( 0., 0., 1.));
    
    
    CreateHinge(5, *body[0], *body[1], mainHinge1, localHinge1, mainAxis1, localAxis1);
    //joints[5]->setLimit(btScalar(-M_PI_2), btScalar(M_PI_2));
    
    //zpositive (back) to main
    btVector3 localHinge3 = PointWorldToLocal(3, btVector3(0., 2., 1));
    btVector3 mainHinge3 = PointWorldToLocal(0, btVector3(0., 2., 1));
    btVector3 localAxis3 = AxisWorldToLocal(3, btVector3(1., 0., 0.));
    btVector3 mainAxis3 = AxisWorldToLocal(0, btVector3( 1., 0., 0.));
    
    CreateHinge(6, *body[0], *body[3], mainHinge3, localHinge3, mainAxis3, localAxis3);
    //joints[6]->setLimit(btScalar(-M_PI_2-M_PI_4), btScalar(M_PI_4));
    
    btVector3 localHinge4 = PointWorldToLocal(4, btVector3(0., 2., -1));
    btVector3 mainHinge4= PointWorldToLocal(0, btVector3(0., 2., -1));
    btVector3 localAxis4 = AxisWorldToLocal(4, btVector3(1., 0., 0. ));
    btVector3 mainAxis4 = AxisWorldToLocal(0, btVector3( 1., 0., 0.));
    
    
    CreateHinge(7, *body[0], *body[4], mainHinge4, localHinge4, mainAxis4, localAxis4);
    //joints[7]->setLimit(btScalar(-M_PI_2), btScalar(M_PI_2));
    
	clientResetScene();
}
示例#28
0
void BaseMesh::CreateCylinder(Vec3f (*PositionFunction) (float), float Start, float End, float radius, UINT slices, UINT stacks)
{
    //this function allocates space for ReCreateCylinder then just rerouts to ReCreateCylinder.
    CreateCylinder(radius, 0.0f, slices, stacks);
    ReCreateCylinder(PositionFunction, Start, End, radius, slices, stacks);
}
void RagdollDemo::initPhysics()
{
	// Setup the basic world

	setTexturing(true);
	setShadows(true);

	setCameraDistance(btScalar(5.));

	m_collisionConfiguration = new btDefaultCollisionConfiguration();

	m_dispatcher = new btCollisionDispatcher(m_collisionConfiguration);

	btVector3 worldAabbMin(-10000,-10000,-10000);
	btVector3 worldAabbMax(10000,10000,10000);
	m_broadphase = new btAxisSweep3 (worldAabbMin, worldAabbMax);

	m_solver = new btSequentialImpulseConstraintSolver;

	m_dynamicsWorld = new btDiscreteDynamicsWorld(m_dispatcher,m_broadphase,m_solver,m_collisionConfiguration);
	//m_dynamicsWorld->getDispatchInfo().m_useConvexConservativeDistanceUtil = true;
	//m_dynamicsWorld->getDispatchInfo().m_convexConservativeDistanceThreshold = 0.01f;



	// Setup a big ground box
	{
		btCollisionShape* groundShape = new btBoxShape(btVector3(btScalar(200.),btScalar(10.),btScalar(200.)));
		m_collisionShapes.push_back(groundShape);
		btTransform groundTransform;
		groundTransform.setIdentity();
		groundTransform.setOrigin(btVector3(0,-10,0));

#define CREATE_GROUND_COLLISION_OBJECT 1
#ifdef CREATE_GROUND_COLLISION_OBJECT
		btCollisionObject* fixedGround = new btCollisionObject();
		fixedGround->setCollisionShape(groundShape);
		fixedGround->setWorldTransform(groundTransform);
		m_dynamicsWorld->addCollisionObject(fixedGround);
#else
		localCreateRigidBody(btScalar(0.),groundTransform,groundShape);
#endif //CREATE_GROUND_COLLISION_OBJECT

	}

	// Spawn one ragdoll
	btVector3 startOffset(1,0.5,0);
	//spawnRagdoll(startOffset);
	startOffset.setValue(-1,0.5,0);
	//spawnRagdoll(startOffset);

  CreateBox(0, 0., 0., 1., 1., 1., 0.2);
  // fore limbs
  CreateCylinder(1, 1., 0., 1., 0.1, 1., 1);
  CreateCylinder(2, -1., 0., 1., 0.1, 1., 1);
  CreateCylinder(3, 0., 1., 1., 0.1, 1., 2);
  CreateCylinder(4, 0., -1., 1., 0.1, 1., 2);

  CreateCylinder(5, 1.5,  0., .5, 0.1, 1., 3);
  CreateCylinder(6, -1.5, 0., .5, 0.1, 1., 3);
  CreateCylinder(7, 0.,  1.5, .5, 0.1, 1., 3);
  CreateCylinder(8, 0., -1.5, .5, 0.1, 1., 3);

  btVector3 v = PointWorldToLocal(0, btVector3(0,1,0)); 
  /* std::cerr << "v " << v[0] << " " << v[1] << " " << v[2] << std::endl; */
  printf("(%f, %f, %f)\n", v[0], v[1], v[2]);


  CreateHinge(0, 
              0, 1, 
              0.5, 0., 1., 
              0.,  -1., 0.);

  CreateHinge(1, 0, 2, 
              -.5, 0., 1., 
              0., 1., 0.);

  CreateHinge(2, 0, 3, 
              0., .5, 1., 
              1., 0., 0.);

  CreateHinge(3, 0, 4, 
              0., -.5, 1., 
              -1., 0., 0.);

  CreateHinge(4, 1, 5, 
              1.5, 0., 1., 
              0., -1., 0.);

  CreateHinge(5, 2, 6, 
              -1.5, 0., 1., 
              0., 1., 0.);

  CreateHinge(6, 3, 7, 
              0., 1.5, 1., 
              1., 0., 0.);

  CreateHinge(7, 4, 8, 
              0., -1.5, 1., 
              -1., 0., 0.);


	clientResetScene();		
}