Jump to content

  • Log In with Google      Sign In   
  • Create Account

FREE SOFTWARE GIVEAWAY

We have 4 x Pro Licences (valued at $59 each) for 2d modular animation software Spriter to give away in this Thursday's GDNet Direct email newsletter.


Read more in this forum topic or make sure you're signed up (from the right-hand sidebar on the homepage) and read Thursday's newsletter to get in the running!


CmasterG

Member Since 12 Jul 2013
Offline Last Active Aug 12 2013 09:51 AM

Topics I've Started

Box Zoom

05 August 2013 - 12:30 PM

Hi!

After my fit to screen question I have the next problem. Now I want to box select a section of my screen and then zoom in that selection. So I have four corner points (my rectangle which I can drag with the mouse) in pixel coordinates. I have a perspective projection.

Can anyone help me with this? I have no idea how to do that. I guess that I have to calculate maybe a view frustum for my section?

 

Respectfully,

                   CmasterG


Focus to object

24 July 2013 - 01:43 PM

Hi!

I have the following problem. I want to zoom to my object. I have the camera in sphere coordinates. So the camera position has 2 angles and a length. For zooming I want to change the length of the camera, so that the object has the maximal expansion on the screen. The object is a bridge. So it has 8 corner points, which I transformed into screen space. This is what I tried to get the length, but it is not working correct. Can anyone help me? Can anyone see the problem:

float xmin, xmax, ymin, ymax, zmin, zmax;
	xmin = - m_width / 2;
	xmax = m_width / 2;
	ymin = -(m_height * scale_factor - m_height/2);
	ymax = m_height /2;
	zmin = -m_length / 2;
	zmax = m_length / 2;

	std::vector<D3DXVECTOR4> points;
	D3DXVECTOR4 point;

	point = D3DXVECTOR4(xmin, ymin, zmin,1.0f);
	points.push_back(point);

	point = D3DXVECTOR4(xmin, ymin, zmax, 1.0f);
	points.push_back(point);

	point = D3DXVECTOR4(xmin, ymax, zmax,1.0f);
	points.push_back(point);

	point = D3DXVECTOR4(xmin, ymax, zmin,1.0f);
	points.push_back(point);

	
	point = D3DXVECTOR4(xmax, ymin, zmin, 1.0f);
	points.push_back(point);

	point = D3DXVECTOR4(xmax, ymin, zmax, 1.0f);
	points.push_back(point);

	point = D3DXVECTOR4(xmax, ymax, zmax, 1.0f);
	points.push_back(point);

	point = D3DXVECTOR4(xmax, ymax, zmin,1.0f);
	points.push_back(point);

	D3DXMATRIX worldMatrix, projectionMatrix, viewMatrix;
	m_Begrenzung->GetWorldMatrix(worldMatrix);
	m_D3D->GetProjectionMatrix(projectionMatrix);
	m_Camera->GetViewMatrix(viewMatrix);


	for(int i = 0; i < points.size(); i++)
	{
		
		D3DXVec4Transform(&points.at(i), &points.at(i), &worldMatrix);
		D3DXVec4Transform(&points.at(i), &points.at(i), &viewMatrix);
		D3DXVec4Transform(&points.at(i), &points.at(i), &projectionMatrix);
		points.at(i).x = points.at(i).x / points.at(i).w;
		points.at(i).y = points.at(i).y / points.at(i).w;
		points.at(i).z = points.at(i).z / points.at(i).w;
		points.at(i).w = 1.0f;

	}



	xmin = xmax = points.at(0).x;
	ymin = ymax = points.at(0).y;

	for(int i = 1; i < points.size(); i++)
	{
		if(points.at(i).x < xmin)
			xmin = points.at(i).x;
		if(points.at(i).x > xmax)
			xmax = points.at(i).x;
		if(points.at(i).y < ymin)
			ymin = points.at(i).y;
		if(points.at(i).y > ymax)
			ymax = points.at(i).y;
	}

	float width, height, scale, length;


	if(abs(xmax) > abs(xmin))
		width = abs(xmax);
	else
		width = abs(xmin);

	if(abs(ymax) > abs(ymin))
		height = abs(ymax);
	else
		height = abs(ymin);

	
	if(width > height)
		scale = 1/width;
	
	else
	scale = 1 / height;

	

	length = m_Camera->getLength();
	m_Camera->setLength(length / scale);

Focus to object

24 July 2013 - 01:29 PM

Hi!

I have the following problem. I want to zoom to my object. I have the camera in sphere coordinates. So the camera position has 2 angles and a length. For zooming I want to change the length of the camera, so that the object has the maximal expansion on the screen. The object is a bridge. So it has 8 corner points, which I transformed into screen space. This is what I tried to get the length, but it is not working correct. Can anyone help me? Can anyone see the problem:

float xmin, xmax, ymin, ymax, zmin, zmax;
	xmin = - m_width / 2;
	xmax = m_width / 2;
	ymin = -(m_height * scale_factor - m_height/2);
	ymax = m_height /2;
	zmin = -m_length / 2;
	zmax = m_length / 2;

	std::vector<D3DXVECTOR4> points;
	D3DXVECTOR4 point;

	point = D3DXVECTOR4(xmin, ymin, zmin,1.0f);
	points.push_back(point);

	point = D3DXVECTOR4(xmin, ymin, zmax, 1.0f);
	points.push_back(point);

	point = D3DXVECTOR4(xmin, ymax, zmax,1.0f);
	points.push_back(point);

	point = D3DXVECTOR4(xmin, ymax, zmin,1.0f);
	points.push_back(point);

	
	point = D3DXVECTOR4(xmax, ymin, zmin, 1.0f);
	points.push_back(point);

	point = D3DXVECTOR4(xmax, ymin, zmax, 1.0f);
	points.push_back(point);

	point = D3DXVECTOR4(xmax, ymax, zmax, 1.0f);
	points.push_back(point);

	point = D3DXVECTOR4(xmax, ymax, zmin,1.0f);
	points.push_back(point);

	D3DXMATRIX worldMatrix, projectionMatrix, viewMatrix;
	m_Begrenzung->GetWorldMatrix(worldMatrix);
	m_D3D->GetProjectionMatrix(projectionMatrix);
	m_Camera->GetViewMatrix(viewMatrix);


	for(int i = 0; i < points.size(); i++)
	{
		
		D3DXVec4Transform(&points.at(i), &points.at(i), &worldMatrix);
		D3DXVec4Transform(&points.at(i), &points.at(i), &viewMatrix);
		D3DXVec4Transform(&points.at(i), &points.at(i), &projectionMatrix);
		points.at(i).x = points.at(i).x / points.at(i).w;
		points.at(i).y = points.at(i).y / points.at(i).w;
		points.at(i).z = points.at(i).z / points.at(i).w;
		points.at(i).w = 1.0f;

	}



	xmin = xmax = points.at(0).x;
	ymin = ymax = points.at(0).y;

	for(int i = 1; i < points.size(); i++)
	{
		if(points.at(i).x < xmin)
			xmin = points.at(i).x;
		if(points.at(i).x > xmax)
			xmax = points.at(i).x;
		if(points.at(i).y < ymin)
			ymin = points.at(i).y;
		if(points.at(i).y > ymax)
			ymax = points.at(i).y;
	}

	float width, height, scale, length;
	

	if(abs(xmax) > abs(xmin))
		width = abs(xmax);
	else
		width = abs(xmin);

	if(abs(ymax) > abs(ymin))
		height = abs(ymax);
	else
		height = abs(ymin);

	
	if(width > height)
		scale = 1/width;
		
	else
	scale = 1 / height;

	

	length = m_Camera->getLength();
	m_Camera->setLength(length / scale);

Blur + multiple Pixelshader

12 July 2013 - 11:06 AM

Hi!

 

I have the following problem.

I have an object, which I have to blur and this object is in sort of a box, but only in the edges of this box (box is an open box).

To blur the object, I render it in a texture -> then in the next step I downscale this texture -> then I blur it vertically and back to a texture -> then I blur this texture horizontal -> then I scale the texture up and render it to the screen

 

To draw also the box object, I render this object to another texture but only with lighting and then I draw this with additive blending on the screen.

 

The problem is that the blurred object is now transparent, and I have lost my depth values. So I have the choice if the box object is rendered over the blurred object or the other way round. But I want that the blurred object is inside the box object.

 

How can I make this the right way. I guess it is impossible the way I do that. Has anyone an idea?

 

I am using C++ with DirectX 11.

 

Respectfully,

                CmasterG


PARTNERS