Add new normal render method to all places where this is already supported. Thereby replacing some of the old and time consuming normal renders, as pointed out by pc0de
git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@4026 dfc29bdd-3216-0410-991c-e03cc46cb475master
parent
f1ec3dad93
commit
c575836343
|
@ -350,30 +350,15 @@ void CAnimatedMeshSceneNode::render()
|
|||
// show normals
|
||||
if (DebugDataVisible & scene::EDS_NORMALS)
|
||||
{
|
||||
core::vector3df normalizedNormal;
|
||||
const f32 DebugNormalLength = SceneManager->getParameters()->getAttributeAsFloat(DEBUG_NORMAL_LENGTH);
|
||||
const video::SColor DebugNormalColor = SceneManager->getParameters()->getAttributeAsColor(DEBUG_NORMAL_COLOR);
|
||||
const f32 debugNormalLength = SceneManager->getParameters()->getAttributeAsFloat(DEBUG_NORMAL_LENGTH);
|
||||
const video::SColor debugNormalColor = SceneManager->getParameters()->getAttributeAsColor(DEBUG_NORMAL_COLOR);
|
||||
const u32 count = m->getMeshBufferCount();
|
||||
|
||||
// draw normals
|
||||
for (u32 g=0; g < m->getMeshBufferCount(); ++g)
|
||||
for (u32 g=0; g < count; ++g)
|
||||
{
|
||||
const scene::IMeshBuffer* mb = m->getMeshBuffer(g);
|
||||
const u32 vSize = video::getVertexPitchFromType(mb->getVertexType());
|
||||
const video::S3DVertex* v = ( const video::S3DVertex*)mb->getVertices();
|
||||
const bool normalize = mb->getMaterial().NormalizeNormals;
|
||||
|
||||
for (u32 i=0; i != mb->getVertexCount(); ++i)
|
||||
{
|
||||
normalizedNormal = v->Normal;
|
||||
if (normalize)
|
||||
normalizedNormal.normalize();
|
||||
|
||||
driver->draw3DLine(v->Pos, v->Pos + (normalizedNormal * DebugNormalLength), DebugNormalColor);
|
||||
|
||||
v = (const video::S3DVertex*) ( (u8*) v+vSize );
|
||||
}
|
||||
driver->drawMeshBufferNormals(m->getMeshBuffer(g), debugNormalLength, debugNormalColor);
|
||||
}
|
||||
driver->setTransform(video::ETS_WORLD, AbsoluteTransformation);
|
||||
}
|
||||
|
||||
debug_mat.ZBuffer = video::ECFN_NEVER;
|
||||
|
@ -386,15 +371,13 @@ void CAnimatedMeshSceneNode::render()
|
|||
// show bounding box
|
||||
if (DebugDataVisible & scene::EDS_BBOX_BUFFERS)
|
||||
{
|
||||
|
||||
for (u32 g=0; g< m->getMeshBufferCount(); ++g)
|
||||
{
|
||||
const IMeshBuffer* mb = m->getMeshBuffer(g);
|
||||
|
||||
if (Mesh->getMeshType() == EAMT_SKINNED)
|
||||
driver->setTransform(video::ETS_WORLD, AbsoluteTransformation * ((SSkinMeshBuffer*)mb)->Transformation);
|
||||
driver->draw3DBox( mb->getBoundingBox(),
|
||||
video::SColor(255,190,128,128) );
|
||||
driver->draw3DBox(mb->getBoundingBox(), video::SColor(255,190,128,128));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -92,26 +92,14 @@ void CCubeSceneNode::render()
|
|||
if (DebugDataVisible & scene::EDS_NORMALS)
|
||||
{
|
||||
// draw normals
|
||||
core::vector3df normalizedNormal;
|
||||
const f32 DebugNormalLength = SceneManager->getParameters()->getAttributeAsFloat(DEBUG_NORMAL_LENGTH);
|
||||
const video::SColor DebugNormalColor = SceneManager->getParameters()->getAttributeAsColor(DEBUG_NORMAL_COLOR);
|
||||
const f32 debugNormalLength = SceneManager->getParameters()->getAttributeAsFloat(DEBUG_NORMAL_LENGTH);
|
||||
const video::SColor debugNormalColor = SceneManager->getParameters()->getAttributeAsColor(DEBUG_NORMAL_COLOR);
|
||||
const u32 count = Mesh->getMeshBufferCount();
|
||||
|
||||
const scene::IMeshBuffer* mb = Mesh->getMeshBuffer(0);
|
||||
const u32 vSize = video::getVertexPitchFromType(mb->getVertexType());
|
||||
const video::S3DVertex* v = ( const video::S3DVertex*)mb->getVertices();
|
||||
const bool normalize = mb->getMaterial().NormalizeNormals;
|
||||
|
||||
for (u32 i=0; i != mb->getVertexCount(); ++i)
|
||||
for (u32 i=0; i != count; ++i)
|
||||
{
|
||||
normalizedNormal = v->Normal;
|
||||
if (normalize)
|
||||
normalizedNormal.normalize();
|
||||
|
||||
driver->draw3DLine(v->Pos, v->Pos + (normalizedNormal * DebugNormalLength), DebugNormalColor);
|
||||
|
||||
v = (const video::S3DVertex*) ( (u8*) v+vSize );
|
||||
driver->drawMeshBufferNormals(Mesh->getMeshBuffer(i), debugNormalLength, debugNormalColor);
|
||||
}
|
||||
driver->setTransform(video::ETS_WORLD, AbsoluteTransformation);
|
||||
}
|
||||
|
||||
// show mesh
|
||||
|
@ -120,7 +108,7 @@ void CCubeSceneNode::render()
|
|||
m.Wireframe = true;
|
||||
driver->setMaterial(m);
|
||||
|
||||
driver->drawMeshBuffer( Mesh->getMeshBuffer(0) );
|
||||
driver->drawMeshBuffer(Mesh->getMeshBuffer(0));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -195,31 +195,15 @@ void CMeshSceneNode::render()
|
|||
|
||||
if (DebugDataVisible & scene::EDS_NORMALS)
|
||||
{
|
||||
|
||||
// draw normals
|
||||
core::vector3df normalizedNormal;
|
||||
const f32 DebugNormalLength = SceneManager->getParameters()->getAttributeAsFloat(DEBUG_NORMAL_LENGTH);
|
||||
const video::SColor DebugNormalColor = SceneManager->getParameters()->getAttributeAsColor(DEBUG_NORMAL_COLOR);
|
||||
const f32 debugNormalLength = SceneManager->getParameters()->getAttributeAsFloat(DEBUG_NORMAL_LENGTH);
|
||||
const video::SColor debugNormalColor = SceneManager->getParameters()->getAttributeAsColor(DEBUG_NORMAL_COLOR);
|
||||
const u32 count = Mesh->getMeshBufferCount();
|
||||
|
||||
for (u32 g=0; g<Mesh->getMeshBufferCount(); ++g)
|
||||
for (u32 i=0; i != count; ++i)
|
||||
{
|
||||
const scene::IMeshBuffer* mb = Mesh->getMeshBuffer(g);
|
||||
const u32 vSize = video::getVertexPitchFromType(mb->getVertexType());
|
||||
const video::S3DVertex* v = ( const video::S3DVertex*)mb->getVertices();
|
||||
const bool normalize = mb->getMaterial().NormalizeNormals;
|
||||
|
||||
for (u32 i=0; i != mb->getVertexCount(); ++i)
|
||||
{
|
||||
normalizedNormal = v->Normal;
|
||||
if (normalize)
|
||||
normalizedNormal.normalize();
|
||||
|
||||
driver->draw3DLine(v->Pos, v->Pos + (normalizedNormal * DebugNormalLength), DebugNormalColor);
|
||||
|
||||
v = (const video::S3DVertex*) ( (u8*) v+vSize );
|
||||
}
|
||||
driver->drawMeshBufferNormals(Mesh->getMeshBuffer(i), debugNormalLength, debugNormalColor);
|
||||
}
|
||||
driver->setTransform(video::ETS_WORLD, AbsoluteTransformation);
|
||||
}
|
||||
|
||||
// show mesh
|
||||
|
|
|
@ -159,38 +159,10 @@ void CSkyDomeSceneNode::render()
|
|||
|
||||
if ( DebugDataVisible & scene::EDS_NORMALS )
|
||||
{
|
||||
IAnimatedMesh * arrow = SceneManager->addArrowMesh (
|
||||
"__debugnormal2", 0xFFECEC00,
|
||||
0xFF999900, 4, 8, 1.f * 40.f, 0.6f * 40.f, 0.05f * 40.f, 0.3f * 40.f);
|
||||
if ( 0 == arrow )
|
||||
{
|
||||
arrow = SceneManager->getMesh ( "__debugnormal2" );
|
||||
}
|
||||
IMesh *mesh = arrow->getMesh(0);
|
||||
|
||||
// find a good scaling factor
|
||||
core::matrix4 m2;
|
||||
|
||||
// draw normals
|
||||
const scene::IMeshBuffer* mb = Buffer;
|
||||
const u32 vSize = video::getVertexPitchFromType(mb->getVertexType());
|
||||
const video::S3DVertex* v = ( const video::S3DVertex*)mb->getVertices();
|
||||
for ( u32 i=0; i != mb->getVertexCount(); ++i )
|
||||
{
|
||||
// align to v->Normal
|
||||
core::quaternion quatRot(v->Normal.X, 0.f, -v->Normal.X, 1+v->Normal.Y);
|
||||
quatRot.normalize();
|
||||
quatRot.getMatrix(m2, v->Pos);
|
||||
|
||||
m2 = AbsoluteTransformation * m2;
|
||||
|
||||
driver->setTransform(video::ETS_WORLD, m2);
|
||||
for (u32 a = 0; a != mesh->getMeshBufferCount(); ++a)
|
||||
driver->drawMeshBuffer(mesh->getMeshBuffer(a));
|
||||
|
||||
v = (const video::S3DVertex*) ( (u8*) v + vSize );
|
||||
}
|
||||
driver->setTransform(video::ETS_WORLD, AbsoluteTransformation);
|
||||
const f32 debugNormalLength = SceneManager->getParameters()->getAttributeAsFloat(DEBUG_NORMAL_LENGTH);
|
||||
const video::SColor debugNormalColor = SceneManager->getParameters()->getAttributeAsColor(DEBUG_NORMAL_COLOR);
|
||||
driver->drawMeshBufferNormals(Buffer, debugNormalLength, debugNormalColor);
|
||||
}
|
||||
|
||||
// show mesh
|
||||
|
|
|
@ -761,47 +761,14 @@ 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);
|
||||
const f32 debugNormalLength = SceneManager->getParameters()->getAttributeAsFloat(DEBUG_NORMAL_LENGTH);
|
||||
const video::SColor debugNormalColor = SceneManager->getParameters()->getAttributeAsColor(DEBUG_NORMAL_COLOR);
|
||||
driver->drawMeshBufferNormals(RenderBuffer, debugNormalLength, debugNormalColor);
|
||||
}
|
||||
|
||||
driver->setTransform(video::ETS_WORLD, AbsoluteTransformation);
|
||||
|
||||
static u32 lastTime = 0;
|
||||
|
||||
const u32 now = os::Timer::getRealTime();
|
||||
|
|
Loading…
Reference in New Issue