Commit ed9e453d authored by hybrid's avatar hybrid

Add debugdata normal rendering to terrain node.

git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@1809 dfc29bdd-3216-0410-991c-e03cc46cb475
parent 8d288d32
...@@ -20,6 +20,7 @@ ...@@ -20,6 +20,7 @@
#include "IFileSystem.h" #include "IFileSystem.h"
#include "IReadFile.h" #include "IReadFile.h"
#include "ITextSceneNode.h" #include "ITextSceneNode.h"
#include "IAnimatedMesh.h"
namespace irr namespace irr
{ {
...@@ -631,6 +632,49 @@ namespace scene ...@@ -631,6 +632,49 @@ namespace scene
} }
} }
if ( DebugDataVisible & scene::EDS_NORMALS )
{
IAnimatedMesh * arrow = SceneManager->addArrowMesh (
"__debugnormal", 0xFFECEC00,
0xFF999900, 4, 8, 1.f, 0.6f, 0.05f,
0.3f);
if ( 0 == arrow )
{
arrow = SceneManager->getMesh ( "__debugnormal" );
}
IMesh *mesh = arrow->getMesh(0);
// find a good scaling factor
core::matrix4 m2;
// draw normals
driver->setTransform(video::ETS_WORLD, core::IdentityMatrix);
for ( u32 i=0; i != RenderBuffer->getVertexCount(); ++i )
{
const core::vector3df& v = RenderBuffer->getNormal(i);
// align to v->Normal
if (core::vector3df(0,-1,0)==v)
{
m2.makeIdentity();
m2[5]=-m2[5];
}
else
{
core::quaternion quatRot;
m2=quatRot.rotationFromTo(v,core::vector3df(0,1,0)).getMatrix();
}
m2.setTranslation(RenderBuffer->getPosition(i));
m2=AbsoluteTransformation*m2;
driver->setTransform(video::ETS_WORLD, m2 );
for ( u32 a = 0; a != mesh->getMeshBufferCount(); ++a )
driver->drawMeshBuffer ( mesh->getMeshBuffer ( a ) );
}
driver->setTransform(video::ETS_WORLD, AbsoluteTransformation);
}
static u32 lastTime = 0; static u32 lastTime = 0;
const u32 now = os::Timer::getRealTime(); const u32 now = os::Timer::getRealTime();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment