Page 1 of 1

ProjectMatrix for control

Posted: 04 Dec 2021, 10:36
by Logrus
Hi,
How can I set the Project matrix for the control (like Canvas)?

Setting a common Project matrix for IView doesn't suit me.

Have an idea to implement a custom FrameworkElement but not sure if this solution will work:
class Viewport3D : public Noesis::FrameworkElement
{
	using Base = Noesis::FrameworkElement;
public:
	void OnRender(Noesis::DrawingContext* drawingContext) override
	{
		PushProjMatrix(); //store current proj matrix for Iview
		SetProjMatrix(mViewProjMatrix); //set proj matrix for control
		Base::OnRender(drawingContext);
		PopProjMatrix();
	}
	//////
	// override some other methods...
	/////
};

Re: ProjectMatrix for control

Posted: 06 Dec 2021, 12:46
by sfernandez
If you want to position a control in 3D you can use the Transform3D property.
In code you can set that property directly in any UIElement:
Ptr<CompositeTransform3D> transform = *new CompositeTransform3D();
transform->SetRotationX(30.0f);
element->SetTransform3D(transform);
Is that what you are looking for?

Re: ProjectMatrix for control

Posted: 06 Dec 2021, 13:22
by Logrus
Unfortunately no,
I am using multiple Viewports,
so for each Viewport it will be necessary to calculate and store copies WorldViewProjMatrix , instead of one

Re: ProjectMatrix for control

Posted: 06 Dec 2021, 15:13
by jsantos
Views only support a single ProjectionMatrix (at the root). If you need more than one, I think you can use several views.

Re: ProjectMatrix for control

Posted: 06 Dec 2021, 16:01
by Logrus
my 3d elements are interactive,
and the Main and 3d IView overlap
in this case, there will be problems with management display events

Re: ProjectMatrix for control

Posted: 06 Dec 2021, 16:54
by jsantos
I don't think you need a projection matrix for that. As Sergio explained, Transform3D can be used to position UI element in 3D space.

Only one projection matrix can be used per view.

Re: ProjectMatrix for control

Posted: 07 Dec 2021, 14:17
by Logrus
thanks