Revision: 9003
http://playerstage.svn.sourceforge.net/playerstage/?rev=9003&view=rev
Author: natepak
Date: 2010-12-06 05:23:17 +0000 (Mon, 06 Dec 2010)
Log Message:
-----------
Fixes
Modified Paths:
--------------
code/gazebo/branches/dev/server/Matrix4.cc
code/gazebo/branches/dev/server/Matrix4.hh
code/gazebo/branches/dev/server/MeshManager.cc
code/gazebo/branches/dev/server/MeshManager.hh
code/gazebo/branches/dev/server/rendering/Visual.cc
Modified: code/gazebo/branches/dev/server/Matrix4.cc
===================================================================
--- code/gazebo/branches/dev/server/Matrix4.cc 2010-12-04 02:43:10 UTC (rev
9002)
+++ code/gazebo/branches/dev/server/Matrix4.cc 2010-12-06 05:23:17 UTC (rev
9003)
@@ -6,16 +6,16 @@
using namespace gazebo;
const Matrix4 Matrix4::IDENTITY(
- 1, 0, 0, 0,
- 0, 1, 0, 0,
- 0, 0, 1, 0,
- 0, 0, 0, 1 );
+ 1.0, 0.0, 0.0, 0.0,
+ 0.0, 1.0, 0.0, 0.0,
+ 0.0, 0.0, 1.0, 0.0,
+ 0.0, 0.0, 0.0, 1.0 );
const Matrix4 Matrix4::ZERO(
- 0, 0, 0, 0,
- 0, 0, 0, 0,
- 0, 0, 0, 0,
- 0, 0, 0, 0 );
+ 0.0, 0.0, 0.0, 0.0,
+ 0.0, 0.0, 0.0, 0.0,
+ 0.0, 0.0, 0.0, 0.0,
+ 0.0, 0.0, 0.0, 0.0 );
////////////////////////////////////////////////////////////////////////////////
@@ -53,6 +53,11 @@
this->m[2][1] = v21;
this->m[2][2] = v22;
this->m[2][3] = v23;
+
+ this->m[3][0] = v30;
+ this->m[3][1] = v31;
+ this->m[3][2] = v32;
+ this->m[3][3] = v33;
}
////////////////////////////////////////////////////////////////////////////////
@@ -137,7 +142,10 @@
Vector3 Matrix4::TransformAffine( const Vector3 &v ) const
{
if (!this->IsAffine())
+ {
+ std::cout << "****\n" << *this << "***\n";
gzthrow("Not and affine matrix");
+ }
return Vector3(
this->m[0][0]*v.x + this->m[0][1]*v.y + this->m[0][2]*v.z +
this->m[0][3],
Modified: code/gazebo/branches/dev/server/Matrix4.hh
===================================================================
--- code/gazebo/branches/dev/server/Matrix4.hh 2010-12-04 02:43:10 UTC (rev
9002)
+++ code/gazebo/branches/dev/server/Matrix4.hh 2010-12-06 05:23:17 UTC (rev
9003)
@@ -39,6 +39,8 @@
}
out << "\n";
}
+
+ return out;
}
public: static const Matrix4 IDENTITY;
Modified: code/gazebo/branches/dev/server/MeshManager.cc
===================================================================
--- code/gazebo/branches/dev/server/MeshManager.cc 2010-12-04 02:43:10 UTC
(rev 9002)
+++ code/gazebo/branches/dev/server/MeshManager.cc 2010-12-06 05:23:17 UTC
(rev 9003)
@@ -314,6 +314,8 @@
mesh->SetName(name);
this->meshes.insert( std::make_pair(name, mesh) );
+ std::cout << "Plane Name[" << name << "]\n";
+
SubMesh *subMesh = new SubMesh();
mesh->AddSubMesh(subMesh);
@@ -326,13 +328,11 @@
Matrix4 xlate, xform, rot;
xlate = rot = Matrix4::IDENTITY;
- std::cout << xlate << "\n";
-
Matrix3 rot3;
rot3.SetFromAxes(xAxis, yAxis, zAxis);
rot = rot3;
-
+
xlate.SetTrans( normal * -d );
xform = xlate * rot;
@@ -345,9 +345,9 @@
double xTex = uvTile.x / segments.x;
double yTex = uvTile.y / segments.y;
- for (int y = 0; y < segments.y; y++)
+ for (int y = 0; y <= segments.y; y++)
{
- for (int x = 0; x < segments.x; x++)
+ for (int x = 0; x <= segments.x; x++)
{
// Compute the position of the vertex
vec.x = (x * xSpace) - halfWidth;
@@ -356,6 +356,8 @@
vec = xform.TransformAffine(vec);
subMesh->AddVertex(vec);
+ std::cout << "Vec[" << vec << "]\n";
+
// Compute the normal
vec = xform.TransformAffine(norm);
subMesh->AddNormal(vec);
@@ -364,6 +366,8 @@
subMesh->AddTexCoord(x * xTex, 1 - (y * yTex));
}
}
+
+ this->Tesselate2DMesh( subMesh, segments.x + 1, segments.y + 1, false );
}
////////////////////////////////////////////////////////////////////////////////
@@ -905,3 +909,70 @@
mesh->RecalculateNormals();
}
+void MeshManager::Tesselate2DMesh(SubMesh *sm, int meshWidth, int meshHeight,
+ bool doubleSided)
+{
+ int vInc, uInc, v, u, iterations;
+ int vCount, uCount;
+
+ if (doubleSided)
+ {
+ iterations = 2;
+ vInc = 1;
+ v = 0; // Start with the front
+ }
+ else
+ {
+ iterations = 1;
+ vInc = 1;
+ v = 0;
+ }
+
+ int v1, v2, v3;
+
+ while (iterations--)
+ {
+ // Make tris in a zigzag pattern (compatible with strips)
+ u = 0;
+ uInc = 1; // Start with moving +u
+
+ vCount = meshHeight - 1;
+ while (vCount--)
+ {
+ uCount = meshWidth - 1;
+ while (uCount--)
+ {
+ // First tri in cell
+ v1 = ((v + vInc) * meshWidth) + u;
+ v2 = (v * meshWidth) + u;
+ v3 = ((v + vInc) * meshWidth) + (u + uInc);
+ // Output indexes
+ sm->AddIndex(v1);
+ sm->AddIndex(v2);
+ sm->AddIndex(v3);
+ std::cout << v1 <<" " << v2 <<" " << v3 << "\n";
+ // Second Tri in cell
+ v1 = ((v + vInc) * meshWidth) + (u + uInc);
+ v2 = (v * meshWidth) + u;
+ v3 = (v * meshWidth) + (u + uInc);
+ std::cout << v1 <<" " << v2 <<" " << v3 << "\n";
+ // Output indexes
+ sm->AddIndex(v1);
+ sm->AddIndex(v2);
+ sm->AddIndex(v3);
+
+ // Next column
+ u += uInc;
+ }
+
+ // Next row
+ v += vInc;
+ u = 0;
+ }
+
+ // Reverse vInc for double sided
+ v = meshHeight - 1;
+ vInc = -vInc;
+ }
+}
+
Modified: code/gazebo/branches/dev/server/MeshManager.hh
===================================================================
--- code/gazebo/branches/dev/server/MeshManager.hh 2010-12-04 02:43:10 UTC
(rev 9002)
+++ code/gazebo/branches/dev/server/MeshManager.hh 2010-12-06 05:23:17 UTC
(rev 9003)
@@ -15,6 +15,7 @@
class STLLoader;
class Mesh;
class Plane;
+ class SubMesh;
class MeshManager : public SingletonT<MeshManager>
{
@@ -80,6 +81,9 @@
const Vector2<double> &segments,
const Vector2<double> uvTile);
+ private: void Tesselate2DMesh(SubMesh *sm, int meshWidth, int meshHeight,
+ bool doubleSided);
+
/// \brief Create a Camera mesh
public: void CreateCamera(const std::string &name, float scale);
Modified: code/gazebo/branches/dev/server/rendering/Visual.cc
===================================================================
--- code/gazebo/branches/dev/server/rendering/Visual.cc 2010-12-04 02:43:10 UTC
(rev 9002)
+++ code/gazebo/branches/dev/server/rendering/Visual.cc 2010-12-06 05:23:17 UTC
(rev 9003)
@@ -227,10 +227,8 @@
if (msg->plane.normal != Vector3(0,0,0))
{
MeshManager::Instance()->CreatePlane(msg->id, msg->plane,
- Vector2<double>(10,10), Vector2<double>(msg->uvTile_x, msg->uvTile_y)
);
-
- // NATY: Fix
- //msg->mesh = OgreCreator::CreatePlane( msg->plane.normal,
msg->plane.size, Vector2<double>(10,10), Vector2<double>(msg->uvTile_x,
msg->uvTile_y), msg->material, msg->castShadows, this, msg->id);
+ Vector2<double>(2,2), Vector2<double>(msg->uvTile_x, msg->uvTile_y) );
+ msg->mesh = msg->id;
}
this->meshNameP->SetValue(msg->mesh);
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
------------------------------------------------------------------------------
What happens now with your Lotus Notes apps - do you make another costly
upgrade, or settle for being marooned without product support? Time to move
off Lotus Notes and onto the cloud with Force.com, apps are easier to build,
use, and manage than apps on traditional platforms. Sign up for the Lotus
Notes Migration Kit to learn more. http://p.sf.net/sfu/salesforce-d2d
_______________________________________________
Playerstage-commit mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/playerstage-commit