Jump to content

Ender1618

Member Since 30 Apr 2004
Offline Last Active Jun 02 2016 04:14 PM

Topics I've Started

Having trouble using glGetTexImage with a depth texture of an FBO

01 June 2016 - 02:01 PM

I am having trouble using glGetTexImage with a depth texture of an FBO.

 

My FBO is set up like so:

GLfloat border[] ={ 1.0f, 0.0f, 0.0f, 0.0f};

// depth texture setup
m_DepthTexture.Create(dbFormat,m_Width,m_Height);
m_TextureID = m_DepthTexture.GetTextureID();
m_DepthTexture.SetFilterMode(GL_NEAREST,GL_NEAREST);
m_DepthTexture.SetWrapMode(GL_CLAMP_TO_BORDER,GL_CLAMP_TO_BORDER);

glBindTexture(GL_TEXTURE_2D, m_TextureID);
glTexParameterfv(GL_TEXTURE_2D, GL_TEXTURE_BORDER_COLOR, border);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_COMPARE_MODE,
                GL_COMPARE_REF_TO_TEXTURE);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_COMPARE_FUNC, GL_LESS);

// Assign the depth map to texture unit 0
glActiveTexture(GL_TEXTURE0);
glBindTexture(GL_TEXTURE_2D, m_TextureID);

// Create and set up the FBO
glGenFramebuffers(1,&m_FBOID);
glBindFramebuffer(GL_FRAMEBUFFER, m_FBOID);
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT,
                       GL_TEXTURE_2D, m_TextureID, 0);
GLenum drawBuffers[] = {GL_NONE};
glDrawBuffers(1, drawBuffers);

GLenum status = glCheckFramebufferStatus(GL_DRAW_FRAMEBUFFER);

glBindFramebuffer(GL_DRAW_FRAMEBUFFER, 0);
glBindRenderbuffer(GL_RENDERBUFFER, 0);
glBindTexture(GL_TEXTURE_2D,0);

if(status != GL_FRAMEBUFFER_COMPLETE)
{ return false; }

I draw to it like so:

glBindFramebuffer(GL_DRAW_FRAMEBUFFER, m_FBOID);
 
// draw some things
 
glBindFramebuffer(GL_DRAW_FRAMEBUFFER, 0);

And I attempt to copy the depth texture to system memory like so:

glBindTexture(GL_TEXTURE_2D, m_TextureID);
glGetTexImage(GL_TEXTURE_2D, 0, GL_DEPTH_COMPONENT, GL_FLOAT,
                       m_DepthImage.data);
glCheckErrorRetB();
glBindTexture(GL_TEXTURE_2D, 0);

The function glGetTexImage throws an error invalid operation;

 

This same code works in another project i have, but not in this project, so I am sure it has to do with some internal state that is being incorrectly set.

 

Any ideas?


3D printer for hobby robotics

20 December 2015 - 03:42 PM

I am getting into hobby robotics, and I am finding that I more and more am in need of the ability to create custom parts.

 

What would be a good 3D printer to buy (couple grand max cost), for creating parts such as: chassis, wheels, servo armatures and holders, gears, etc.

 

For me one of the most important things to be able to make would be my own custom gear trains.

 

What would be a good 3D printer, precise enough and using tough enough materials to great gears for robots on the size scale of a cat. Such as differential wheeled, hexapod, and quadrapod platforms?

 

Thanks,

-Ryan


Properly Mixing NavMesh Pathfing with Steering Behaviors

22 October 2015 - 11:19 AM

So I am working in Unity (5.x) Pro and have my AI agents moving about via calls to Unity's built in path finding and movement system (NavMesh base).

 

I also, in the past did alot of work with Reynold style steering behaviors, and had alot of nice (uselfull) emergent behaviors come about. But when I used them there was a low density of static obstacles, so a true global path finding solution was unnessisary.

 

But for this new Unity project, my maps have a high density of obstacles (also some areas of low density, e.g. large courtyards, etc), and a global path finder is quite nessisary (some places can be maze like).

 

So what I want to do is somehow properly mix NavMesh based path planning with Steering Behaviors (Evade, Chase, Formations, etc.). It is not quite clear to me how that would work.

 

The NavMesh does give me all walk-able areas, which I can query with ray casts. I also can compute paths from any location on the navmesh to any other location on the navmesh, without having to traverse them (Ive used that to know if even a path exists), but this is an expensive operation and can not be perform too often (like once an update frame, would not work). The number of AI agents I am dealing with right now is anywhere from 1 to 32.

 

I was just wondering if others have tried to mix these two movement systems, and how they went about it?

 

Thanks,

-Ryan


[Mecanim] Mixing translational rootMotion and scripted rotation in OnAnimatorMove?

20 July 2015 - 03:59 PM

I am trying to have character motion controlled by a mix of RootMotion for translation and code for rotation, and I am having difficulty.

Like so:

void OnAnimatorMove()
{
  if(m_CurDeltaAngle != 0)
  { transform.rotation = Quaternion.Euler(Vector3.up * m_CurDeltaAngle); }
  if(m_CurTranslSpeed != 0)
  { transform.position = m_Animator.rootPosition; }
}

 

Now as long a transform. rotation is never set (in the function), m_Animator.rootPosition is updated with the correct value. But once m_CurDeltaAngle != 0 and transform.rotation assigned to, from then on Animator.rootPosition is never updated (neither is Animator.deltaPosition). The character now turns in place correctly but does not translate.

Why would this be? What could I be doing wrong? Can anyone suggest another way of achieving this mix of using tranlational motion from root, but rotation from code?

I need to do this because I have a rather large animation set that has plenty of translation movement for locomotion animations, but no turning animations.

Thx,
-Ryan


Unity 5.1 and Rune Locomotion system?

16 June 2015 - 03:36 PM

I am currently using Unity 4.6, but I plan on upgrading my Unity 4.6 commercial license to Unity 5.1 soon.

Part of my project still uses the legacy animation system for character animation (will be porting that to Mecanim in the future), and it currently makes extensive use of the Rune Locomotion System for foot planting over uneven terrain during character locomotion.

I just read a user comment on the Rune Locomotion System asset store page, that said the system would not work at all in Unity 5+ (even if you are still using the legacy animation system for character animation), for undisclosed reasons. But it does still work in Unity 4.6.

Does anyone know if this is true?

Does anyone know of a good replacement for abilities of the Rune Locomotion System, but works with Mecanim?

I came across "Mecanim - Basic Foot Placement", in the asset store, but it doesn't claim to support a large amount of what the Rune system could do.

Thx,
-Ryan