Jump to content

  • Log In with Google      Sign In   
  • Create Account

Calling all IT Pros from Canada and Australia.. we need your help! Support our site by taking a quick sponsored surveyand win a chance at a $50 Amazon gift card. Click here to get started!


masterbubu

Member Since 27 Aug 2009
Offline Last Active Jul 31 2013 11:58 AM

Posts I've Made

In Topic: Frustum Culling - Need help

15 March 2013 - 05:50 AM

Hi,

 

I found the problem, it was related to something else.wacko.png

tnx anyway 


In Topic: Gpu skinning and VBO

08 March 2013 - 12:37 AM

BTW, I'm using opengl ES 2, so maybe there are some limitations?


In Topic: Gpu skinning and VBO

07 March 2013 - 01:48 PM

Hi, I cut some parts of the code that relevant to the issue.

 

I still did not manage to spot the problematic area.

 

Please note that the same code and shaders works for VA, but not for VBO.

struct sBoneData
{
	vec4 vWeights,
	vIndices;
};

Vertex Arrays

	glVertexAttribPointer( iPositionAttribLoc, 3, GL_FLOAT, GL_FALSE,  sizeof( vec3 ), &pGeo->vVertices[0].x );
    glEnableVertexAttribArray( iPositionAttribLoc );

	glVertexAttribPointer( iBoneWeightsAttribLoc, 4, GL_FLOAT, GL_FALSE, sizeof( sBoneData ), &pGeo->vBonesData[0].vWeights.x );
	glEnableVertexAttribArray( iBoneWeightsAttribLoc );
	           
	glVertexAttribPointer( iBoneIndexesAttribLoc, 4, GL_FLOAT, GL_FALSE, sizeof( sBoneData ), &pGeo->vBonesData[0].vIndices.x );
	glEnableVertexAttribArray( iBoneIndexesAttribLoc );
	

	unsigned int *ptr = &pGeo->vFaces[ m_pObj->iFacesStartPos ].uIndex[ 0 ];
	unsigned int  sz = (unsigned int)( m_pObj->iFacesEndPos - m_pObj->iFacesStartPos ) * 3;
	glDrawElements( GL_TRIANGLES, m_uNumElements, GL_UNSIGNED_INT, 0 );

VBO

Generate ...
{
	
	glGenBuffers(3, m_Buffers);

	glBindBuffer(GL_ARRAY_BUFFER, m_Buffers[0]);
	
	size_t size = sizeof(vec3) * pGeo->vVertices.size(); 

	glBufferData(GL_ARRAY_BUFFER, size ,0 , GL_STATIC_DRAW);

	size_t startOff = 0,
		   currSize = sizeof(vec3) *pGeo->vVertices.size();
	
	m_VertexOffset = startOff;

	glBufferSubData(GL_ARRAY_BUFFER, startOff, currSize, &pGeo->vVertices[0].x );

	glBindBuffer(GL_ARRAY_BUFFER, m_Buffers[1]);

	// Indices and weights
	size_t size2 = sizeof(vec4) *pGeo->vBonesData.size() * 2; 

	glBufferData(GL_ARRAY_BUFFER, size2 ,0 , GL_STATIC_DRAW);

	startOff = 0;
	currSize = sizeof(vec4) *pGeo->vBonesData.size();
	m_BonesWeightsOffset = startOff;

	glBufferSubData(GL_ARRAY_BUFFER, startOff, currSize, &pGeo->vBonesData[0].vWeights.x );

	startOff += currSize;
	currSize = sizeof(vec4) *pGeo->vBonesData.size();
	m_BonesIndicesOffset = startOff;

	glBufferSubData(GL_ARRAY_BUFFER, startOff,currSize,	&pGeo->vBonesData[0].vIndices.x  );

	glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, m_Buffers[2]);

	unsigned int *ptr = &pGeo->vFaces[ m_pObj->iFacesStartPos ].uIndex[ 0 ];
	unsigned int  sz = (unsigned int)( m_pObj->iFacesEndPos - m_pObj->iFacesStartPos ) * 3;
	glBufferData(GL_ELEMENT_ARRAY_BUFFER, sizeof(GL_UNSIGNED_INT) * sz,ptr, GL_STATIC_DRAW);

	glBindBuffer(GL_ARRAY_BUFFER, 0);
	glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);


Bind ...
{
	glBindBuffer(GL_ARRAY_BUFFER, m_Buffers[0]);
		
	if ( handlers[0] != -1 && m_VertexOffset != -1)
	{
		//glBindBuffer(GL_ARRAY_BUFFER, m_Buffers[0]);
		glEnableVertexAttribArray( handlers[0] );
		glVertexAttribPointer( handlers[0] ,3,GL_FLOAT, GL_FALSE,  sizeof( vec3 ), reinterpret_cast<void*>( m_VertexOffset ));
	}
	{
		
	glBindBuffer(GL_ARRAY_BUFFER, m_Buffers[1]);

	if ( handlers[5] != -1 &&  m_BonesWeightsOffset != -1 )
	{
		glVertexAttribPointer( handlers[1], 4, GL_FLOAT, GL_FALSE, sizeof( sBoneData ), reinterpret_cast<void*>(m_BonesWeightsOffset) );
		glEnableVertexAttribArray( handlers[1] );
	}
	if ( handlers[6] != -1 &&  m_BonesIndicesOffset != -1 )
	{
		glVertexAttribPointer( handlers[2], 4, GL_FLOAT, GL_FALSE, sizeof( sBoneData ), reinterpret_cast<void*>(m_BonesIndicesOffset) );
		glEnableVertexAttribArray( handlers[2] );
	}
      
	glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, m_Buffers[2]);
}

Draw ...
{
	glDrawElements( GL_TRIANGLES, m_uNumElements, GL_UNSIGNED_INT, 0 );
}

UnBind ...

	for ( int i = 0 ; i < size ; ++i )
		if ( handlers[i] != -1 )
			glDisableVertexAttribArray( handlers[i] );

	glBindBuffer(GL_ARRAY_BUFFER, 0);
	glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
}
	
	

 

 


In Topic: Ray Picking - Need help.

11 December 2012 - 06:40 AM

Maybe visual reference will help to understand the problem:

http://www.screencas...m/t/bhlS5fBXN50
the ray settings are:
m_Direction = _far - *pCamera->GetCameraPos();
m_Direction.normalize();
m_Origen = *pCamera->GetCameraPos();


http://www.screencas.../t/KC0WpYICfQ1T
in here I tried different settings, where the most noticeable thing is that the blue dot is always on the center of the screen.

m_Direction = _far - _near;
m_Direction.normalize();
m_Origen = *pCamera->GetCameraPos();

The blue dot. is a sphere at the far plane ( p = m_Origen + m_Direction * pCamera->GetFar() ).

I get intersection only when the blue dot is on the bounding box of the teapot.
I want to create the effect, where the ray is injected from the mouse toward the scene.

What am I missing ?

In Topic: Creating OBB

11 November 2012 - 07:36 AM

HI,

max343 : can u please refer me to some reference regarding that thing ?


I'm trying to update the OBB according the bones movement. Each OBB has its corresponding bone, which deforms it. The problem is the coords system of the

bone, does not matches to the OBB coords system, which causes wrong rotations. setting the OBB rotation axes to be the same as the bone, gives the correct

rotation, but the OBB loose its original shape. Any ideas?

PARTNERS