Example #1
0
static void CreateBitmapWindow(Container& owner, TitleBitmapWindow*& bitmap, /*IceGroupBox*& group,*/ TitleWindow* parent, sdword x, sdword y, udword width, udword height, const char* label)
{
	const udword OffsetY = 4;	// ### not sure why this is needed

	// Create bitmap window
	WindowDesc WD;
	WD.mParent	= parent;
	WD.mX		= x + GROUP_BOX_BORDER_SIZE;
	WD.mY		= y + GROUP_BOX_BORDER_SIZE + OffsetY;
	WD.mWidth	= width;
	WD.mHeight	= height;
	WD.mLabel	= "BitmapWindow";
	WD.mType	= WINDOW_POPUP;
	WD.mStyle	= WSTYLE_NORMAL;
// ### the better style works but not all pixels get displayed
//	WD.mStyle	= WSTYLE_CLIENT_EDGES|WSTYLE_STATIC_EDGES;
	bitmap = ICE_NEW(TitleBitmapWindow)(WD);
	bitmap->SetVisible(true);
	bitmap->mMainW = parent;
	owner.Add(udword(bitmap));

/*	if(0)
	{
		GroupBoxDesc GBD;
		GBD.mParent	= parent;
		GBD.mX		= x;
		GBD.mY		= y;
		GBD.mWidth	= width + GROUP_BOX_BORDER_SIZE*2;
		GBD.mHeight	= height + GROUP_BOX_BORDER_SIZE*2 + OffsetY;
		GBD.mLabel	= label;
		group = ICE_NEW(IceGroupBox)(GBD);
		owner.Add(udword(group));
	}
	else*/
	{
		EditBoxDesc EBD;
		EBD.mParent		= parent;
		EBD.mX			= x;
		EBD.mY			= y;
		EBD.mWidth		= width + GROUP_BOX_BORDER_SIZE*2;
		EBD.mHeight		= height + GROUP_BOX_BORDER_SIZE*2 + OffsetY;
		EBD.mLabel		= label;
		EBD.mFilter		= EDITBOX_TEXT;
		EBD.mType		= EDITBOX_READ_ONLY;
		IceEditBox* EB = ICE_NEW(IceEditBox)(EBD);
		EB->SetVisible(true);
		owner.Add(udword(EB));
	}
}
Example #2
0
TitleWindow* CreateTitleWindow(Container& owner, IceWidget* parent, sdword x, sdword y, sdword width, sdword height)
{
	// Texture size
	const udword TextureWidth = TITLE_WIDTH;
	const udword TextureHeight = TITLE_HEIGHT;

	// Create main window
	TitleWindow* TTWindow = null;
	if(1)
	{
		WindowDesc WD;
		WD.mParent	= parent;
		WD.mX		= x;
		WD.mY		= y;
		WD.mWidth	= width;
		WD.mHeight	= height;
		WD.mLabel	= "Raytracing window";
		WD.mType	= WINDOW_NORMAL;
//		WD.mType	= WINDOW_POPUP;
//		WD.mStyle	= WSTYLE_CLIENT_EDGES;
		WD.mStyle	= WSTYLE_NORMAL;
		TTWindow = ICE_NEW(TitleWindow)(WD);
		TTWindow->SetVisible(true);
		owner.Add(udword(TTWindow));
	}

	CreateBitmapWindow(owner, TTWindow->mRGBWindow, /*TTWindow->mRGBGroup,*/ TTWindow, BORDER_SIZE, BORDER_SIZE, TextureWidth, TextureHeight, "");

	return TTWindow;
}
Example #3
0
void Bullet_Init(const PINT_WORLD_CREATE& desc)
{
	gBullet_GetOptionsFromGUI();

	ASSERT(!gBullet);
	gBullet = ICE_NEW(Bullet);
	gBullet->Init(desc);
}
void Havok_Init(const PINT_WORLD_CREATE& desc)
{
//	gHavok_GetOptionsFromGUI();
	Havok_::GetOptionsFromGUI();

	ASSERT(!gHavok);
	gHavok = ICE_NEW(Havok)(Havok_::GetEditableParams());
	gHavok->Init(desc);
}
Example #5
0
static PintShapeRenderer* RegisterShapeRenderer(PintShapeRenderer* renderer)
{
	ASSERT(renderer);

	if(!gShapeRenderers)
		gShapeRenderers = ICE_NEW(Container);
	ASSERT(gShapeRenderers);

	gShapeRenderers->Add(udword(renderer));
	return renderer;
}
Example #6
0
bool CameraManager::TryLoadCameraData(const char* filename)
{
	IceFile BinFile(filename);
	if(!BinFile.IsValid())
		return false;

	const udword NbCameraPoses = BinFile.LoadDword();
	printf("Loading %d camera poses...\n", NbCameraPoses);
	mCameraPoses = ICE_NEW(Ray)[NbCameraPoses];
	mNbCameraPoses = NbCameraPoses;
	for(udword i=0;i<NbCameraPoses;i++)
	{
		BinFile.LoadBuffer(&mCameraPoses[i].mOrig, sizeof(Point));
		BinFile.LoadBuffer(&mCameraPoses[i].mDir, sizeof(Point));
	}
	return true;
}
Example #7
0
static ConvexHull* CreateConvexHull(udword nb_verts, const Point* verts)
{
	ConvexHull* CH = ICE_NEW(ConvexHull);
	ASSERT(CH);

	CONVEXHULLCREATE Create;
	Create.NbVerts		= nb_verts;
	Create.Vertices		= verts;
	Create.UnifyNormals	= true;
	Create.PolygonData	= true;

	bool status = CH->Compute(Create);
	ASSERT(status);
	if(!status)
	{
		DELETESINGLE(CH);
	}

	return CH;
}
	virtual	void	InitUI(PintGUIHelper& helper)
	{
		WindowDesc WD;
		WD.mParent	= null;
		WD.mX		= 50;
		WD.mY		= 50;
		WD.mWidth	= 300;
		WD.mHeight	= 160;
		WD.mLabel	= "Cylinder";
		WD.mType	= WINDOW_DIALOG;
		IceWindow* UI = ICE_NEW(IceWindow)(WD);
		RegisterUIElement(UI);
		UI->SetVisible(true);

		Container* UIElems = GetUIElements();

		const sdword OffsetX = 120;
		const sdword EditBoxWidth = 60;
		const sdword LabelWidth = 120;
		const sdword LabelOffsetY = 2;
		const sdword YStep = 20;
		sdword y = 0;

		{
			y += YStep;

			mCheckBox_UseConvexesForAll = helper.CreateCheckBox(UI, 0, 4, y, 200, 20, "Use convexes for all", UIElems, false, null, null);
			y += YStep;

			helper.CreateLabel(UI, 4, y+LabelOffsetY, LabelWidth, 20, "Cylinder tessellation:", UIElems);
			mEditBox_CylinderTess = helper.CreateEditBox(UI, 1, 4+OffsetX, y, EditBoxWidth, 20, "60", UIElems, EDITBOX_INTEGER_POSITIVE, null, null);
			y += YStep;
		}

		y += YStep;
		AddResetButton(UI, 4, y, 300-16);
	}
	virtual bool BulldozerTest::Setup(Pint& pint, const PintCaps& caps)
	{
		CreateMeshesFromRegisteredSurfaces(pint, caps, *this, &mHighFrictionMaterial);

		VehicleData* UserData = ICE_NEW(VehicleData);
		pint.mUserData = UserData;

		const float TrackWidth = mInsideCylinder.mHalfHeight + mOutsideCylinder.mHalfHeight*2.0f;
		const float TrackGap = 0.1f;

		const Point ChassisExtents(3.0f, 2.0f, 1.0f);

		const float GroundClearance = 0.5f;
		const Point ChassisPos(0.0f, ChassisExtents.y+GroundClearance, 0.0f);
		const float ChassisMass = 100.0f;

		const float ChassisGap = (TrackWidth+TrackGap)*2.0f;

		const float SideDistToGround = 0.5f*2.0f;
		const Point SideExtents(4.0f, 0.2f, 0.2f);
		const Point LeftSidePos(SideExtents.x-ChassisExtents.x, SideExtents.y+SideDistToGround, -ChassisExtents.z-ChassisGap-SideExtents.z);
		const Point RightSidePos(SideExtents.x-ChassisExtents.x, SideExtents.y+SideDistToGround, ChassisExtents.z+ChassisGap+SideExtents.z);
		const float SideMass = 1.0f;

		PINT_BOX_CREATE ChassisBoxDesc;
		ChassisBoxDesc.mExtents		= ChassisExtents;
		ChassisBoxDesc.mRenderer	= CreateBoxRenderer(ChassisExtents);
		PintObjectHandle ChassisObject = null;

		if(1)
		{
			// Caterpillar tracks
			const udword NbGears = 3;
			Point GearOffsets[3];
			const float GearMass = 10.0f;
			GearOffsets[0] = Point(0.0f, 2.0f, 0.0f);
			GearOffsets[1] = Point(-2.0f, 0.0f, 0.0f);
			GearOffsets[2] = Point(2.0f, 0.0f, 0.0f);
			if(0)
			{
				CaterpillarTrackObjects CTO;

				for(udword i=0;i<2;i++)
				{
					const float Coeff = i ? -1.0f : 1.0f;
					const Point Pos(0.0f, 1.5f, Coeff*(ChassisExtents.z+TrackGap+TrackWidth));

					CreateCaterpillarTrackWIP(pint, CTO, &mHighFrictionMaterial, Pos,
											mInsideCylinder, GetRegisteredRenderers()[0], mOutsideCylinder, GetRegisteredRenderers()[1],
											NbGears, GearOffsets, GearMass
						);
				}
			}
			else
			{
				PINT_SHAPE_CREATE* StartShape = null;
				PINT_SHAPE_CREATE* CurrentShape = null;
				for(udword i=0;i<2;i++)
				{
					const float Coeff = i ? -1.0f : 1.0f;
					/*const*/ Point Pos(0.0f, 1.5f, Coeff*(ChassisExtents.z+TrackGap+TrackWidth));
					Pos -= ChassisPos;

					{
						Point GearCenter(0.0f, 0.0f, 0.0f);
						for(udword i=0;i<NbGears;i++)
						{
							const Point GearPos = Pos + GearOffsets[i];
							GearCenter += GearPos;
						}
						GearCenter /= float(NbGears);

						StartShape = CreateGearHolderShapes(StartShape, CurrentShape, Pos, GearCenter, NbGears, GearOffsets, mInsideCylinder, &mHighFrictionMaterial, GearCenter);
					}
				}

				PintObjectHandle GearHolder = null;
				if(StartShape)
				{
					if(1)
					{
						ChassisBoxDesc.mNext = StartShape;

						PINT_OBJECT_CREATE ChassisObjectDesc;
						ChassisObjectDesc.mPosition	= ChassisPos;
						ChassisObjectDesc.mShapes	= &ChassisBoxDesc;
						ChassisObjectDesc.mMass		= ChassisMass;
						GearHolder = CreatePintObject(pint, ChassisObjectDesc);
						ChassisObject = GearHolder;
					}
					else
					{
						PINT_OBJECT_CREATE ObjectDesc;
						ObjectDesc.mShapes		= StartShape;
						ObjectDesc.mMass		= 10.0f;
						ObjectDesc.mPosition	= Point(0.0f, 0.0f, 0.0f);
						GearHolder = CreatePintObject(pint, ObjectDesc);
					}

					while(StartShape)
					{
						PINT_SHAPE_CREATE* NextShape = const_cast<PINT_SHAPE_CREATE*>(StartShape->mNext);
						DELETESINGLE(StartShape);
						StartShape = NextShape;
					}
				}

				if(1)
				{
					UserData->mChassis = GearHolder;
					UserData->mFront[0].mParent = GearHolder;
					UserData->mFront[1].mParent = GearHolder;
					UserData->mRear[0].mParent = GearHolder;
					UserData->mRear[1].mParent = GearHolder;

					for(udword i=0;i<2;i++)
					{
						const float Coeff = i ? -1.0f : 1.0f;
						/*const*/ Point Pos(0.0f, 1.5f, Coeff*(ChassisExtents.z+TrackGap+TrackWidth));

							Point GearCenter(0.0f, 0.0f, 0.0f);
							for(udword j=0;j<NbGears;j++)
							{
								const Point GearPos = Pos + GearOffsets[j];
								GearCenter += GearPos;
							}
							GearCenter /= float(NbGears);
							GearCenter -= ChassisPos;

							CaterpillarTrackObjects CTO;
							CreateCaterpillarTrackWIP(pint, CTO, &mHighFrictionMaterial, Pos,
													mInsideCylinder, GetRegisteredRenderers()[0], mOutsideCylinder, GetRegisteredRenderers()[1],
													NbGears, GearOffsets, GearMass, GearHolder, &GearCenter);

							{
								UserData->mFront[i].mWheel = CTO.mGears[1];
								UserData->mRear[i].mWheel = CTO.mGears[2];
							}
					}
				}
			}
		}

		PintObjectHandle LeftSideObject = CreateBoxObject(pint, SideExtents, LeftSidePos, SideMass);
		PintObjectHandle RightSideObject = CreateBoxObject(pint, SideExtents, RightSidePos, SideMass);

		const Point HingeAxis(0.0f, 0.0f, 1.0f);
		CreateHinge(pint, ChassisObject, LeftSideObject, Point(-ChassisExtents.x, -ChassisExtents.y+SideExtents.y, -ChassisExtents.z-ChassisGap), Point(-SideExtents.x, 0.0f, SideExtents.z), HingeAxis, HingeAxis);
		CreateHinge(pint, ChassisObject, RightSideObject, Point(-ChassisExtents.x, -ChassisExtents.y+SideExtents.y, ChassisExtents.z+ChassisGap), Point(-SideExtents.x, 0.0f, -SideExtents.z), HingeAxis, HingeAxis);

		// Blade
		if(1)
		{
			const float BladeMinSize = ChassisExtents.z + ChassisGap + SideExtents.z * 2.0f;
			const float BladeSize = BladeMinSize + 0.5f;

			const Point BladeExtents(0.1f, 0.75f, BladeSize);
			const Point BladePos(	LeftSidePos.x + SideExtents.x + BladeExtents.x,
									SideDistToGround + BladeExtents.y,
									0.0f);
			const float BladeMass = 1.0f;
			PintObjectHandle BladeObject = CreateBoxObject(pint, BladeExtents, BladePos, BladeMass);

			const float dz = fabsf(BladePos.z - LeftSidePos.z);
			CreateHinge(pint, BladeObject, LeftSideObject, Point(-BladeExtents.x, -BladeExtents.y+SideExtents.y, -dz), Point(SideExtents.x, 0.0f, 0.0f), HingeAxis, HingeAxis);
			CreateHinge(pint, BladeObject, RightSideObject, Point(-BladeExtents.x, -BladeExtents.y+SideExtents.y, dz), Point(SideExtents.x, 0.0f, 0.0f), HingeAxis, HingeAxis);

			{
				const Point Ext1(-BladeExtents.x, BladeExtents.y, dz);
				const Point p1 = BladePos + Ext1;

				const Point Ext0(0.0f, SideExtents.y, 0.0f);
				const Point p0 = RightSidePos + Ext0;

				CreatePrismatic(pint, p0, p1, RightSideObject, Ext0, BladeObject, Ext1);
			}

			{
				const Point Ext1(-BladeExtents.x, BladeExtents.y, -dz);
				const Point p1 = BladePos + Ext1;

				const Point Ext0(0.0f, SideExtents.y, 0.0f);
				const Point p0 = LeftSidePos + Ext0;

				CreatePrismatic(pint, p0, p1, LeftSideObject, Ext0, BladeObject, Ext1);
			}

			for(udword i=0;i<2;i++)
			{
				const float Coeff = i ? -1.0f : 1.0f;
				const float Offset = Coeff*0.5f;

				const Point Ext0(ChassisExtents.x, ChassisExtents.y, Offset);
				const Point p0 = ChassisPos + Ext0;

				const Point Ext1(-BladeExtents.x, 0.0f, Offset);
				const Point p1 = BladePos + Ext1;
				CreatePrismatic(pint, p0, p1, ChassisObject, Ext0, BladeObject, Ext1);
			}
		}

		if(1)
		{
			PINT_CONVEX_CREATE ConvexCreate[14];
			MyConvex C[14];
			for(udword i=0;i<14;i++)
			{
				C[i].LoadFile(i);
				ConvexCreate[i].mNbVerts	= C[i].mNbVerts;
				ConvexCreate[i].mVerts		= C[i].mVerts;
				ConvexCreate[i].mRenderer	= CreateConvexRenderer(ConvexCreate[i].mNbVerts, ConvexCreate[i].mVerts);
			}

			const float Amplitude = 1.5f;
			const udword NbLayers = 12;
			const udword NbX = 12+4;
			const udword NbY = 12+4;
			BasicRandom Rnd(42);
			for(udword j=0;j<NbLayers;j++)
			{
				const float Scale = 4.0f;
				for(udword y=0;y<NbY;y++)
				{
					for(udword x=0;x<NbX;x++)
					{
						const float xf = (float(x)-float(NbX)*0.5f)*Scale;
						const float yf = (float(y)-float(NbY)*0.5f)*Scale;

						const Point pos = Point(xf+40.0f, Amplitude + (Amplitude * 2.0f * float(j)), yf);

						const udword Index = 10 + Rnd.Randomize() % 4;

						PintObjectHandle Handle = CreateSimpleObject(pint, &ConvexCreate[Index], 0.1f, pos);

						ASSERT(Handle);
					}
				}
			}
		}
		return true;
	}
Example #10
0
sdword Common_CreateDebugVizUI(	IceWidget* parent, sdword x, sdword y, CBCallback check_box_callback, udword id, udword nb_params,
								const bool* debug_viz_params, const char** debug_viz_names, IceCheckBox** check_boxes, Container* gui)
{
	ASSERT(gui);
	ASSERT(check_boxes);
	ASSERT(debug_viz_names);
	ASSERT(debug_viz_params);

	const sdword YStepCB = 16;
	const sdword YSaved = y;

	CheckBoxDesc CBD;
	CBD.mParent		= parent;
	CBD.mX			= x+10;
	CBD.mWidth		= 170;
	CBD.mHeight		= 20;
	CBD.mCallback	= check_box_callback;

	for(udword i=0;i<nb_params;i++)
	{
		CBD.mID			= id++;
		CBD.mY			= y+20;
		CBD.mLabel		= debug_viz_names[i];
		CBD.mChecked	= debug_viz_params[i];
		check_boxes[i]	= ICE_NEW(IceCheckBox)(CBD);
		gui->Add(udword(check_boxes[i]));
		check_boxes[i]->SetVisible(true);
		if(i==0)
			check_boxes[i]->SetEnabled(true);
		else
			check_boxes[i]->SetEnabled(debug_viz_params[0]);
		y += YStepCB;
	}

	if(0)
	{
		GroupBoxDesc GBD;
		GBD.mParent		= parent;
		GBD.mX			= x;
		GBD.mY			= YSaved;
		GBD.mWidth		= 200;
		GBD.mHeight		= nb_params*20;
		GBD.mLabel		= "Debug visualization";
		IceGroupBox* GB = ICE_NEW(IceGroupBox)(GBD);
		gui->Add(udword(GB));
		GB->SetVisible(true);
	}
	else
	{
		EditBoxDesc EBD;
		EBD.mParent		= parent;
		EBD.mX			= x;
		EBD.mY			= YSaved;
		EBD.mWidth		= 200;
		EBD.mHeight		= 20*2 + nb_params*YStepCB;
		EBD.mLabel		= "======= Debug visualization ========";
//		EBD.mLabel		= ""
		EBD.mFilter		= EDITBOX_TEXT;
		EBD.mType		= EDITBOX_READ_ONLY;
		IceEditBox* EB = ICE_NEW(IceEditBox)(EBD);
		EB->SetVisible(true);
		gui->Add(udword(EB));
/*
		LabelDesc LD;
		LD.mParent		= EB;
//		LD.mX			= x+14;
		LD.mX			= 14;
//		LD.mY			= YSaved-5;
		LD.mY			= -5;
		LD.mWidth		= 95;
		LD.mHeight		= 14;
		LD.mLabel		= "Debug visualization";
		IceLabel* Label = ICE_NEW(IceLabel)(LD);
		Label->SetVisible(true);
		gui->Add(udword(Label));*/
	}
	return y;
}
Example #11
0
PintShapeRenderer* CreateMeshRenderer(const SurfaceInterface& surface)
{
	return RegisterShapeRenderer(ICE_NEW(PintMeshShapeRenderer)(surface));
}
Example #12
0
PintShapeRenderer* CreateConvexRenderer(udword nb_verts, const Point* verts)
{
	return RegisterShapeRenderer(ICE_NEW(PintConvexShapeRenderer)(nb_verts, verts));
}
Example #13
0
PintShapeRenderer* CreateBoxRenderer(const Point& extents)
{
	return RegisterShapeRenderer(ICE_NEW(PintBoxShapeRenderer)(extents));
}
Example #14
0
PintShapeRenderer* CreateCapsuleRenderer(float radius, float half_height)
{
	return RegisterShapeRenderer(ICE_NEW(PintCapsuleShapeRenderer)(radius, half_height));
}
Example #15
0
PintShapeRenderer* CreateSphereRenderer(float radius)
{
	return RegisterShapeRenderer(ICE_NEW(PintSphereShapeRenderer)(radius));
}