\r
void AvatarAnimationChanged(object sender, AvatarAnimationEventArgs e)\r
{\r
- \r
+\r
// We don't currently have UUID -> RenderAvatar mapping so we need to walk the list\r
foreach (RenderAvatar av in Avatars.Values)\r
{\r
if (av.avatar.ID == e.AvatarID)\r
{\r
- foreach(Animation anim in e.Animations)\r
+ foreach (Animation anim in e.Animations)\r
{\r
Client.Assets.RequestAsset(anim.AnimationID, AssetType.Animation, false, animRecievedCallback);\r
av.animlist.Add(anim.AnimationID, anim);\r
if (transfer.Success)\r
{\r
BinBVHAnimationReader b = new BinBVHAnimationReader(asset.AssetData);\r
- \r
+\r
}\r
}\r
\r
void Avatars_AvatarAppearance(object sender, AvatarAppearanceEventArgs e)\r
{\r
- // We don't currently have UUID -> RenderAvatar mapping so we need to walk the list\r
+ // We don't currently have UUID -> RenderAvatar mapping so we need to walk the list\r
foreach (RenderAvatar av in Avatars.Values)\r
{\r
if (av.avatar.ID == e.AvatarID)\r
direction.Normalize();\r
Vector3 vy = direction % new Vector3(0f, 0f, 1f);\r
Vector3 vx = vy % direction;\r
- Vector3 vxy = vx * deltaY * pixelToM + vy * deltaX * pixelToM;\r
+ Vector3 vxy = vx * deltaY * pixelToM * 3 + vy * deltaX * pixelToM * 3;\r
Camera.Position += vxy;\r
Camera.FocalPoint += vxy;\r
}\r
}\r
else if (ModifierKeys == Keys.Alt)\r
{\r
- Camera.TimeToTarget = timeToFocus;\r
Camera.FocalPoint = PrimPos(picked.Prim);\r
Cursor.Position = glControl.PointToScreen(new Point(glControl.Width / 2, glControl.Height / 2));\r
}\r
RenderAvatar av = (RenderAvatar)clicked;\r
if (ModifierKeys == Keys.Alt)\r
{\r
- Camera.TimeToTarget = timeToFocus;\r
Vector3 pos = PrimPos(av.avatar);\r
pos.Z += 1.5f; // focus roughly on the chest area\r
Camera.FocalPoint = pos;\r
else\r
{\r
GLAvatar ga = new GLAvatar();\r
- \r
+\r
//ga.morph(av);\r
RenderAvatar ra = new Rendering.RenderAvatar();\r
ra.avatar = av;\r
// Prim roation and position\r
//GL.MultMatrix(Math3D.CreateTranslationMatrix(av.avatar.Position));\r
//GL.MultMatrix(Math3D.CreateRotationMatrix(av.avatar.Rotation));\r
- GL.MultMatrix(Math3D.CreateSRTMatrix(new Vector3(1,1,1),av.avatar.Rotation,av.avatar.Position));\r
+ GL.MultMatrix(Math3D.CreateSRTMatrix(new Vector3(1, 1, 1), av.avatar.Rotation, av.avatar.Position));\r
\r
// Special case for eyeballs we need to offset the mesh to the correct position\r
// We have manually added the eyeball offset based on the headbone when we\r
GL.DisableClientState(ArrayCap.NormalArray);\r
GL.DisableClientState(ArrayCap.VertexArray);\r
GL.DisableClientState(ArrayCap.TextureCoordArray);\r
- \r
+\r
}\r
}\r
#endregion avatars\r
Vector3 point = parentav.glavatar.skel.getOffset(apoint.joint) + apoint.position;\r
Quaternion qrot = parentav.glavatar.skel.getRotation(apoint.joint) * apoint.rotation;\r
//Vector3 point = Bone.getOffset(apoint.joint) + apoint.position;\r
- // Quaternion qrot = Bone.getRotation(apoint.joint) * apoint.rotation;\r
+ // Quaternion qrot = Bone.getRotation(apoint.joint) * apoint.rotation;\r
\r
GL.MultMatrix(Math3D.CreateTranslationMatrix(point));\r
GL.MultMatrix(Math3D.CreateRotationMatrix(qrot));\r
//Quaternion qrot = Bone.getRotation(apoint.joint) * apoint.rotation;\r
Vector3 point = parentav.glavatar.skel.getOffset(apoint.joint) + apoint.position;\r
Quaternion qrot = parentav.glavatar.skel.getRotation(apoint.joint) * apoint.rotation;\r
- \r
+\r
GL.MultMatrix(Math3D.CreateTranslationMatrix(point));\r
GL.MultMatrix(Math3D.CreateRotationMatrix(qrot));\r
}\r
Frustum.CalculateFrustum(ProjectionMatrix, ModelMatrix);\r
UpdateCamera();\r
Camera.Modified = false;\r
- }\r
-\r
- if (Camera.TimeToTarget != 0)\r
- {\r
Camera.Step(lastFrameTime);\r
}\r
\r
mesh.applyjointweights();\r
}\r
\r
- }\r
+ }\r
}\r
\r
private void textBox_vparamid_TextChanged(object sender, EventArgs e)\r
Bone b;\r
if (av.glavatar.skel.mBones.TryGetValue(bone, out b))\r
{\r
- textBox_sx.Text = (b.scale.X-1.0f).ToString();\r
- textBox_sy.Text = (b.scale.Y-1.0f).ToString();\r
- textBox_sz.Text = (b.scale.Z-1.0f).ToString();\r
+ textBox_sx.Text = (b.scale.X - 1.0f).ToString();\r
+ textBox_sy.Text = (b.scale.Y - 1.0f).ToString();\r
+ textBox_sz.Text = (b.scale.Z - 1.0f).ToString();\r
\r
- float x,y,z;\r
+ float x, y, z;\r
b.rot.GetEulerAngles(out x, out y, out z);\r
textBox_x.Text = x.ToString();\r
textBox_y.Text = y.ToString();\r
}\r
\r
}\r
- \r
+\r
\r
}\r
\r
\r
}\r
\r
- \r
+\r
\r
}\r
\r
\r
}\r
\r
- \r
+\r
\r
}\r
}\r
\r
public static class RHelp\r
{\r
+ static float t1 = 0.04f;\r
+ static float t2 = t1 / 5.7f;\r
+\r
+ public static Vector3 Smoothed1stOrder(Vector3 curPos, Vector3 targetPos, double lastFrameTime)\r
+ {\r
+ int numIterations = (int)(lastFrameTime * 100);\r
+ do\r
+ {\r
+ curPos += (targetPos - curPos) * t1;\r
+ numIterations--;\r
+ }\r
+ while (numIterations > 0);\r
+ if (Vector3.DistanceSquared(curPos, targetPos) < 0.000001)\r
+ {\r
+ curPos = targetPos;\r
+ }\r
+ return curPos;\r
+ }\r
+\r
+ public static Vector3 Smoothed2ndOrder(Vector3 curPos, Vector3 targetPos, ref Vector3 accel, double lastFrameTime)\r
+ {\r
+ int numIterations = (int)(lastFrameTime * 100);\r
+ do\r
+ {\r
+ accel += (targetPos - accel - curPos) * t1;\r
+ curPos += accel * t2;\r
+ numIterations--;\r
+ }\r
+ while (numIterations > 0);\r
+ if (Vector3.DistanceSquared(curPos, targetPos) < 0.000001)\r
+ {\r
+ curPos = targetPos;\r
+ }\r
+ return curPos;\r
+ }\r
+\r
public static OpenTK.Vector2 TKVector3(Vector2 v)\r
{\r
return new OpenTK.Vector2(v.X, v.Y);\r
void Modify()\r
{\r
mModified = true;\r
- if (TimeToTarget <= 0)\r
+ }\r
+\r
+ public void Step(double time)\r
+ {\r
+ if (RenderPosition != Position)\r
+ {\r
+ RenderPosition = RHelp.Smoothed1stOrder(RenderPosition, Position, time);\r
+ Modified = true;\r
+ }\r
+ if (RenderFocalPoint != FocalPoint)\r
{\r
- RenderPosition = Position;\r
- RenderFocalPoint = FocalPoint;\r
+ RenderFocalPoint = RHelp.Smoothed1stOrder(RenderFocalPoint, FocalPoint, time);\r
+ Modified = true;\r
}\r
}\r
\r
- public void Step(double time)\r
+ [Obsolete("Use Step(), left in here for reference")]\r
+ public void Step2(double time)\r
{\r
TimeToTarget -= time;\r
if (TimeToTarget <= time)\r
\r
public byte[] VisualAppearanceParameters = new byte[1024];\r
bool vpsent = false;\r
+ static bool lindenMeshesLoaded = false;\r
\r
public GLAvatar()\r
{\r
\r
public static void loadlindenmeshes2(string LODfilename)\r
{\r
+ // Already have mashes loaded?\r
+ if (lindenMeshesLoaded) return;\r
+\r
attachment_points.Clear();\r
\r
\r
}\r
}\r
\r
+ lindenMeshesLoaded = true;\r
}\r
\r
public void morphtest(Avatar av, int param, float weight)\r