コード例 #1
0
//----------------------------------------------------------------------------
void TriggerActor::SetAreaType(AreaType type)
{
	mAreaType = type;

	CreateGetHelpNode()->DetachChild(mAreaMovable);

	VertexFormat *vf = PX2_GR.GetVertexFormat(GraphicsRoot::VFT_PC);
	if (AT_SPHERE == mAreaType)
	{
		StandardMesh stdMesh(vf);
		stdMesh.SetVertexColor(Float4(1.0f, 1.0f, 0.0f, 1.0f));
		TriMesh *mesh = stdMesh.Sphere(16, 16, 1.0f);
		VertexColor4MaterialPtr mtl = new0 VertexColor4Material();
		mtl->GetWireProperty(0, 0)->Enabled = true;
		mtl->GetCullProperty(0, 0)->Enabled = false;
		mesh->LocalTransform.SetUniformScale(0.5f);
		mesh->SetMaterialInstance(mtl->CreateInstance());
		mAreaMovable = mesh;
	}
	else if (AT_BOX == mAreaType)
	{
		StandardMesh stdMesh(vf);
		stdMesh.SetVertexColor(Float4(1.0f, 1.0f, 0.0f, 1.0f));
		TriMesh *mesh = stdMesh.Box(1, 1, 1);
		VertexColor4MaterialPtr mtl = new0 VertexColor4Material();
		mtl->GetWireProperty(0, 0)->Enabled = true;
		mtl->GetCullProperty(0, 0)->Enabled = false;
		mesh->LocalTransform.SetUniformScale(0.5f);
		mesh->SetMaterialInstance(mtl->CreateInstance());
		mAreaMovable = mesh;
	}

	CreateGetHelpNode()->AttachChild(mAreaMovable);
}
コード例 #2
0
//----------------------------------------------------------------------------
void EU_CanvasStage::_CreateGridGeometry()
{
	float gridSize = PX2_EDIT.GetEditParams()->GridSize;

	VertexFormat *vf = PX2_GR.GetVertexFormat(GraphicsRoot::VFT_PC);
	StandardMesh sM(vf);
	mGrid = sM.LineRectangleForEditor(81, 81, gridSize, gridSize,
		Float4(0.43f, 0.43f, 0.43f, 0.7f));

	PX2::RenderablePtr mGridAxis;
	PX2::VertexBufferAccessor mGridAxisAssessor;

	VertexBuffer *vb = new0 VertexBuffer(4, vf->GetStride(), Buffer::BU_DYNAMIC);
	VertexBufferAccessor vba;

	vba.ApplyTo(vf, vb);
	vba.Position<Float3>(0) = Float3(-gridSize, 0.0f, 0.0f);
	vba.Color<Float4>(0, 0) = Float4::RED;
	vba.Position<Float3>(1) = Float3(gridSize, 0.0f, 0.0f);
	vba.Color<Float4>(0, 1) = Float4::RED;

	vba.Position<Float3>(2) = Float3(0.0f, -gridSize, 0.0f);
	vba.Color<Float4>(0, 2) = Float4::GREEN;
	vba.Position<Float3>(3) = Float3(0.0f, gridSize, 0.0f);
	vba.Color<Float4>(0, 3) = Float4::GREEN;

	mGridAxis = new0 Polysegment(vf, vb, false);
	mGridAxis->UpdateModelSpace(Renderable::GU_MODEL_BOUND_ONLY);

	VertexColor4MaterialPtr mtl = new0 VertexColor4Material();
	mtl->GetAlphaProperty(0, 0)->BlendEnabled = true;

	mGrid->SetMaterialInstance(mtl->CreateInstance());
	mGridAxis->SetMaterialInstance(mtl->CreateInstance());

	mGridNode = new0 Node();
	mGridNode->AttachChild(mGridAxis);
	mGridNode->AttachChild(mGrid);
	mGridNode->Update(Time::GetTimeInSeconds(), true);

	mGridCanvas = new0 UICanvas();
	AttachChild(mGridCanvas);
	mGridCanvas->SetName("SceneGridCanvas");
	mGridCanvas->SetRenderNode(mGridNode);
	mGridCanvas->SetRenderNodeUpdate(true);
	mGridCanvas->SetAnchorHor(0.0f, 1.0f);
	mGridCanvas->SetAnchorVer(0.0f, 1.0f);
	mGridCanvas->SetClearFlag(false, false, false);
}
コード例 #3
0
ファイル: PX2CurveCtrl.cpp プロジェクト: cyecp/Phoenix3D_2.1
//----------------------------------------------------------------------------
CurveCtrl::CurveCtrl (Curve *curve, CurveCtrlType type, int index)
    :
    mIndex(index),
    mSelected(false),
    mCurve(curve),
    mCtrlType(type),
    mXScale(1.0f),
    mZScale(1.0f),
    mDragLength(1.0f),
    mInVal(-1.0f),
    mSelectMode(SM_MAX_MODE)
{
    mCtrlNode = new0 Node();

    float dragSize = 0.1f;

    VertexFormat *vFormat = PX2_GR.GetVertexFormat(GraphicsRoot::VFT_PC);
    StandardMesh sm(vFormat);

    Float3 curveColor = mCurve->GetCurveColor();

    VertexColor4MaterialPtr mtl = new0 VertexColor4Material();
    MaterialInstancePtr mtlInst = mtl->CreateInstance();

    sm.SetVertexColor(Float4(curveColor[0], curveColor[1], curveColor[2], 1.0f));
    mDragBox = sm.Box(dragSize, dragSize, dragSize);
    mDragBox->SetMaterialInstance(mtlInst);

    sm.SetVertexColor(Float4::WHITE);

    mDragBoxArrive = sm.Box(dragSize, dragSize, dragSize);
    mDragBoxArrive->SetMaterialInstance(mtlInst);

    mDragBoxLeave = sm.Box(dragSize, dragSize, dragSize);
    mDragBoxLeave->SetMaterialInstance(mtlInst);

    VertexBuffer *vBuffer = new0 VertexBuffer(2, vFormat->GetStride(),
                            Buffer::BU_DYNAMIC);
    mDragLineArrive = new0 Polysegment(vFormat, vBuffer, true);
    mDragLineArrive->SetMaterialInstance(mtlInst);

    VertexBuffer *vBuffer1 = new0 VertexBuffer(2, vFormat->GetStride(),
                             Buffer::BU_DYNAMIC);
    mDragLineLeave = new0 Polysegment(vFormat, vBuffer1, true);
    mDragLineLeave->SetMaterialInstance(mtlInst);

    sm.SetVertexColor(Float4::YELLOW);

    mCtrlNode->AttachChild(mDragBox);
    mCtrlNode->AttachChild(mDragBoxArrive);
    mCtrlNode->AttachChild(mDragBoxLeave);
    mCtrlNode->AttachChild(mDragLineArrive);
    mCtrlNode->AttachChild(mDragLineLeave);

    mDragBoxArrive->Culling = Movable::CULL_ALWAYS;
    mDragBoxLeave->Culling = Movable::CULL_ALWAYS;
    mDragLineArrive->Culling = Movable::CULL_ALWAYS;
    mDragLineLeave->Culling = Movable::CULL_ALWAYS;

    mCtrlNode->Update();
}