Jump to content

  • Log In with Google      Sign In   
  • Create Account


Member Since 30 Apr 2004
Offline Last Active Jul 22 2015 05:27 PM

Topics I've Started

[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.


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.


View Frustum Culling Corner Cases

03 January 2014 - 03:05 PM

I was reviewing my view frustum culling code for a new OpenGL project I am working on, and was noticing a bit too many corner cases with large bounding volumes (e.g. spheres) and smaller frustums. Corner cases where the bounding volume is in no way intersecting will my frustum volume, yet getting accepted as visible. I am using the Lighthouse3d (http://www.lighthouse3d.com/tutorials/view-frustum-culling/) method (geometric frustum plane method not radar) for extracting planes and testing against bounding volumes.


Here is an example (all frustum plane normals face inward (blue lines) )



The above image is top down, but neither the top or bottom frustum planes reject the sphere either.


This family of intersect methods rely on having at least one of the frustum planes reject the volume as outside. But there are corner cases where the volumes do not intersect, yet none of the frustum planes reject the volume, for example in the image I posted.


How does one deal typically deal with such cases (while still using world space frustum plane culling techniques, if possible)?


Normal oriented elliptical shapes (surfels) using point sprites.

10 December 2013 - 02:45 PM

I am trying to reproduce this effect with point sprites (given vertices with a position and normal). 




Essentially discarding fragments of a point sprite, dependent on the normal of that point, to produce an an elliptical shape tangent to the point normal (essentially approximated ortho projection of a 3D circle to a 2D ellipse).


From the equation I found d = -(n.x/n.z)*x-(n.y/n.z)*y, where a fragment is discarded if the world space distance from the point center to a point (x,y,d) is greater that the disk radius (as indicated by the text above the image).


I am trying to figure the right way of doing this in my GLSL vertex and fragment shaders, using point sprites.  


in my  shaders I am doing something like this, which isn't working:


//vertex shader
#version 400

layout (location = 0) in vec3 VertexPosition;
layout (location = 1) in vec3 VertexNormal;

out vec3 Color;
flat out vec3 PtPosition;
flat out vec3 PtNormal;
out vec3 FragPosition;

uniform mat4 MVP;
uniform float heightMin;
uniform float heightMax;
uniform bool invertGrad = false;

uniform mat4 MV;
uniform float pointSize;
uniform float viewportDim;

float perspPtSize(vec3 ptPos, mat4 mv, float ptWorldSize, float viewportDim)
  vec3 posEye = vec3(mv * vec4(ptPos, 1.0));
  return ptWorldSize * (viewportDim / length(posEye));

void main()
  Color = vec3(1.0,1.0,1.0);
  PtPosition = vec3(MV * vec4(VertexPosition,1.0));
  FragPosition = PtPosition; 
  PtNormal = vec3(MV * vec4(VertexNormal,1.0));
  gl_Position = MVP * vec4(VertexPosition,1.0);

  gl_PointSize = perspPtSize(VertexPosition.xyz,MV,pointSize,viewportDim);

//fragment shader
#version 400

layout( location = 0 ) out vec4 FragColor;

in vec3 Color;
flat in vec3 PtPosition;
flat in vec3 PtNormal;

void main() 
  vec2 ptC = gl_PointCoord- vec2(0.5);
  float depth = -PtNormal.x/PtNormal.z*ptC.x - 
  float sqrMag = ptC.x*ptC.x + ptC.y*ptC.y + depth*depth; 

  if(sqrMag > 0.25) 
  { discard; } 
  { fragColor = vec4(color, 1.0); }

Has anyone successfully implemented an effect like this? I tried doing this in world space as well but ended up getting incorrect results, I figured if i left it all in point sprite expressed space it might be easier.


I think I am missing some basic concept for doing this, any suggestions?

Choosing specific GPU for OpenGL context?

23 October 2013 - 03:06 PM

I have an issue with my application (Win7 64bit OpenGL 4.0), picking the wrong GPU on some peoples machine for OpenGL acceleration such as the Intel HD3000 embedded GPU vs the Nvidia or ATI GPU. HD3000 does not support OpenGL 4.0 (AFAIK), which is my min requirement, so the app fails to run.


BTW, my app is intended to be cross platform (but for right now Windows 7 is most important, then Linux, then Mac). 


I am currently creating my OpenGL 4.x context with the aid of SDL 1.2 (started this code base a while back) and glew. With SDL 1.2 there is no way to enumerate the available devices (GPUs) and select one. I remember back in my DX days, device enumeration and selection was supported.


Does anyone know if any other cross platform OpenGL context creating libraries such as SDL 2.0, SFML, GLFW, support device enumeration and device specific gl context creation (with glew support)?


My only work around right now is forcing the app to use the Nvidia card under the Nvidia control panel (or ATI), and turning off Intel Optimus at the bios level, neither of which (I think) can be automated. This is alot to ask of a user, and is a horrid kludge.


Thanks for any guidance.