Merged 1.4 branch 1075:1105.

git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@1105 dfc29bdd-3216-0410-991c-e03cc46cb475
master
hybrid 2007-12-08 13:11:39 +00:00
parent e11859e83c
commit 48e009de8f
17 changed files with 128 additions and 65 deletions

View File

@ -1,13 +1,32 @@
-------------------------------------------
Changes in version 1.4 (... 13.11.2007)
- Fixed somed CQuake3ShaderSceneNode problems.
- Changed BurningsVideo internal Vertex Format. version changed to 0.39
- SceneManager:
Removed the seperate rendering states for quake3 Shader Scene Nodes.
Nodes are now solid or transparent. ( but still more states are needed )
Changes in version 1.5 (... 2008)
- Hardware accelerated Vertex and Index Buffer support finally integrated into Irrlicht. Thanks to a ressource handling idea by Klasker and the almost immediate implementation by Luke, Irrlicht now supports VBOs under OpenGL. D3D will follow soon.
Hardware buffers make rendering the same vertices much faster. In some cases this can be more than 10x faster. To sue this feature with a mesh simple set a usage type, e.g. via MeshBuffer->setHardwareMappingHint(scene::EHM_STATIC). The driver will upload the vertices and indices on the next draw and reuse this information without the need to upload it each frame.
- MeshBuffers can now access the elements of the S3DVertex base class in all vertex types directly, instead of using teh getVertices() pointer access. This simplifies simple mesh manipulations as it does not require a switch statement over all vertex types.
- GLSL changes for setting arrays. Also allow for only pixel or vertex shader to be set.
- Some bugfixes for Joint handling and skinned meshes.
- Added WAL image format support based on the original loader by Murphy McCauley, written for Irrlicht around version 0.7.
- OpenGL RTTs now also support alpha values.
- New method driver->getVendorInfo() to query information about the actual hardware driver.
- Fixed somed CQuake3ShaderSceneNode problems.
- Changed BurningsVideo internal Vertex Format. version changed to 0.39
- SceneManager:
Removed the seperate rendering states for quake3 Shader Scene Nodes.
Nodes are now solid or transparent. ( but still more states are needed )
-------------------------------------------
Changes in version 1.4 (... 2007)
Changes in version 1.4 (30.11.2007)
- Major API change: All material properties which are available per texture layer (curently texture, texture matrix, texture filters, and texture wrap mode) are separated into a new struct SMaterialLayer. You can access them via the array TextureLayer[] in SMaterial. The texture matrix methods in SMaterial are still alive, and also textures can be accessed via methods in SMaterial now. But still, many places in user code need some update (usually changing material.Textures[i] to material.TextureLayer[i].Texture etc.)

View File

@ -73,7 +73,7 @@ namespace scene
children from being able to register them selfes if they are clipped by simply
not calling their OnRegisterSceneNode-Method.
If you are implementing your own scene node, you should overwrite this method
with an implementtion code looking like this:
with an implementation code looking like this:
\code
if (IsVisible)
SceneManager->registerNodeForRendering(this);
@ -95,9 +95,9 @@ namespace scene
//! OnAnimate() is called just before rendering the whole scene.
//! Nodes may calculate or store animations here, and may do other useful things,
//! dependent on what they are. Also, OnAnimate() should be called for all
//! child scene nodes here. This method will called once per frame, independent
//! child scene nodes here. This method will be called once per frame, independent
//! of if the scene node is visible or not.
//! \param timeMs: Current time in milli seconds.
//! \param timeMs: Current time in milliseconds.
virtual void OnAnimate(u32 timeMs)
{
if (IsVisible)

View File

@ -65,16 +65,16 @@ struct S3DVertex
//! Texture coordinates
core::vector2d<f32> TCoords;
bool operator == (const S3DVertex& other) const
bool operator==(const S3DVertex& other) const
{
return (Pos == other.Pos && Normal == other.Normal &&
Color == other.Color && TCoords == other.TCoords);
return ((Pos == other.Pos) && (Normal == other.Normal) &&
(Color == other.Color) && (TCoords == other.TCoords));
}
bool operator != (const S3DVertex& other) const
bool operator!=(const S3DVertex& other) const
{
return (Pos != other.Pos || Normal != other.Normal ||
Color != other.Color || TCoords != other.TCoords);
return ((Pos != other.Pos) || (Normal != other.Normal) ||
(Color != other.Color) || (TCoords != other.TCoords));
}
E_VERTEX_TYPE getType() const
@ -127,17 +127,17 @@ struct S3DVertex2TCoords : public S3DVertex
core::vector2d<f32> TCoords2;
//! Equality operator
bool operator == (const S3DVertex2TCoords& other) const
bool operator==(const S3DVertex2TCoords& other) const
{
return (static_cast<S3DVertex>(*this)==other &&
TCoords2 == other.TCoords2);
return ((static_cast<S3DVertex>(*this)==other) &&
(TCoords2 == other.TCoords2));
}
//! Inequality operator
bool operator != (const S3DVertex2TCoords& other) const
bool operator!=(const S3DVertex2TCoords& other) const
{
return (static_cast<S3DVertex>(*this)!=other &&
TCoords2 != other.TCoords2);
return ((static_cast<S3DVertex>(*this)!=other) ||
(TCoords2 != other.TCoords2));
}
E_VERTEX_TYPE getType() const
@ -178,16 +178,18 @@ struct S3DVertexTangents : public S3DVertex
//! Binormal vector (tangent x normal)
core::vector3df Binormal;
bool operator == (const S3DVertexTangents& other) const
bool operator==(const S3DVertexTangents& other) const
{
return (static_cast<S3DVertex>(*this)==other &&
Tangent == other.Tangent && Binormal == other.Binormal);
return ((static_cast<S3DVertex>(*this)==other) &&
(Tangent == other.Tangent) &&
(Binormal == other.Binormal));
}
bool operator != (const S3DVertexTangents& other) const
bool operator!=(const S3DVertexTangents& other) const
{
return (static_cast<S3DVertex>(*this)!=other &&
Tangent != other.Tangent || Binormal != other.Binormal);
return ((static_cast<S3DVertex>(*this)!=other) ||
(Tangent != other.Tangent) ||
(Binormal != other.Binormal));
}
E_VERTEX_TYPE getType() const

View File

@ -218,8 +218,7 @@ namespace video
//! Gets the texture transformation matrix for level i
core::matrix4& getTextureMatrix(u32 i)
{
if (i<MATERIAL_MAX_TEXTURES)
return TextureLayer[i].getTextureMatrix();
return TextureLayer[i].getTextureMatrix();
else // this should not happen
{
_IRR_DEBUG_BREAK_IF(true)

View File

@ -399,16 +399,24 @@ bool C3DSMeshFileLoader::readMaterialChunk(io::IReadFile* file, ChunkData* paren
// read texture file name
c8* c = new c8[data.header.length - data.read];
file->read(c, data.header.length - data.read);
if (matSection == C3DS_MATTEXMAP)
switch (matSection)
{
case C3DS_MATTEXMAP:
CurrentMaterial.Filename[0] = c;
else if (matSection == C3DS_MATSPECMAP)
break;
case C3DS_MATSPECMAP:
CurrentMaterial.Filename[1] = c;
else if (matSection == C3DS_MATOPACMAP)
break;
case C3DS_MATOPACMAP:
CurrentMaterial.Filename[2] = c;
else if (matSection == C3DS_MATREFLMAP)
break;
case C3DS_MATREFLMAP:
CurrentMaterial.Filename[3] = c;
else if (matSection == C3DS_MATBUMPMAP)
break;
case C3DS_MATBUMPMAP:
CurrentMaterial.Filename[4] = c;
break;
}
data.read += data.header.length - data.read;
delete [] c;
}
@ -433,6 +441,27 @@ bool C3DSMeshFileLoader::readMaterialChunk(io::IReadFile* file, ChunkData* paren
#ifdef __BIG_ENDIAN__
value = os::Byteswap::byteswap(value);
#endif
u32 i=0;
if (matSection != C3DS_MATTEXMAP)
i=1;
u32 j=0,k=0;
if (data.header.id == C3DS_MAT_VSCALE)
{
j=1;
k=1;
}
else if (data.header.id == C3DS_MAT_UOFFSET)
{
j=2;
k=0;
}
else if (data.header.id == C3DS_MAT_VOFFSET)
{
j=2;
k=1;
}
CurrentMaterial.Material.getTextureMatrix(i)(j,k)=value;
data.read += 4;
}
break;
@ -889,8 +918,7 @@ void C3DSMeshFileLoader::composeObject(io::IReadFile* file, const core::stringc&
mb->getMaterial() = Materials[0].Material;
mb->drop();
// add an empty mesh buffer name
core::stringc c = "";
MeshBufferNames.push_back(c);
MeshBufferNames.push_back("");
}
}

View File

@ -912,10 +912,12 @@ core::stringc CB3DMeshFileLoader::stripPathFromString(core::stringc string, bool
if (backSlash>slashIndex) slashIndex=backSlash;
if (slashIndex==-1)//no slashes found
{
if (returnPath)
return core::stringc(); //no path to return
else
return string;
}
if (returnPath)
return string.subString(0, slashIndex + 1);

View File

@ -2054,7 +2054,7 @@ IImage* CD3D8Driver::createScreenShot()
// returns the current size of the screen or rendertarget
core::dimension2d<s32> CD3D8Driver::getCurrentRenderTargetSize()
const core::dimension2d<s32>& CD3D8Driver::getCurrentRenderTargetSize() const
{
if ( CurrentRendertargetSize.Width == 0 )
return ScreenSize;

View File

@ -235,7 +235,7 @@ namespace video
virtual video::ITexture* createDeviceDependentTexture(IImage* surface, const char* name);
// returns the current size of the screen or rendertarget
core::dimension2d<s32> getCurrentRenderTargetSize();
virtual const core::dimension2d<s32>& getCurrentRenderTargetSize() const;
//! Adds a new material renderer to the VideoDriver, using pixel and/or
//! vertex shaders to render geometry.

View File

@ -2155,7 +2155,7 @@ IImage* CD3D9Driver::createScreenShot()
// returns the current size of the screen or rendertarget
core::dimension2d<s32> CD3D9Driver::getCurrentRenderTargetSize()
const core::dimension2d<s32>& CD3D9Driver::getCurrentRenderTargetSize() const
{
if ( CurrentRendertargetSize.Width == 0 )
return ScreenSize;

View File

@ -232,7 +232,7 @@ namespace video
virtual video::ITexture* createDeviceDependentTexture(IImage* surface, const char* name);
// returns the current size of the screen or rendertarget
core::dimension2d<s32> getCurrentRenderTargetSize();
virtual const core::dimension2d<s32>& getCurrentRenderTargetSize() const;
//! Adds a new material renderer to the VideoDriver, using pixel and/or
//! vertex shaders to render geometry.

View File

@ -481,10 +481,12 @@ IMesh* CGeometryCreator::createSphereMesh(f32 radius, u32 polyCountX, u32 polyCo
if (polyCountY < 2)
polyCountY = 2;
if (polyCountX * polyCountY > 32767) // prevent u16 overflow
{
if (polyCountX > polyCountY) // prevent u16 overflow
polyCountX = 32767/polyCountY-1;
else
polyCountY = 32767/(polyCountX+1);
}
u32 polyCountXPitch = polyCountX+1; // get to same vertex on next level
buffer->Vertices.set_used((polyCountXPitch * polyCountY) + 2);

View File

@ -581,10 +581,12 @@ core::stringc CMS3DMeshFileLoader::stripPathFromString(const core::stringc& inSt
if (backSlash>slashIndex) slashIndex=backSlash;
if (slashIndex==-1)//no slashes found
{
if (returnPath)
return core::stringc(); //no path to return
else
return inString;
}
if (returnPath)
return inString.subString(0, slashIndex + 1);

View File

@ -50,7 +50,7 @@ public:
//! Constructor
COpenGLSLMaterialRenderer(
video::COpenGLDriver* driver,
COpenGLDriver* driver,
s32& outMaterialTypeNr,
const c8* vertexShaderProgram,
const c8* vertexShaderEntryPointName,
@ -59,14 +59,14 @@ public:
const c8* pixelShaderEntryPointName,
E_PIXEL_SHADER_TYPE psCompileTarget,
IShaderConstantSetCallBack* callback,
video::IMaterialRenderer* baseMaterial,
IMaterialRenderer* baseMaterial,
s32 userData);
//! Destructor
virtual ~COpenGLSLMaterialRenderer();
virtual void OnSetMaterial(const video::SMaterial& material, const video::SMaterial& lastMaterial,
bool resetAllRenderstates, video::IMaterialRendererServices* services);
virtual void OnSetMaterial(const SMaterial& material, const SMaterial& lastMaterial,
bool resetAllRenderstates, IMaterialRendererServices* services);
virtual bool OnRender(IMaterialRendererServices* service, E_VERTEX_TYPE vtxtype);
@ -100,7 +100,7 @@ protected:
bool createShader(GLenum shaderType, const char* shader);
bool linkProgram();
video::COpenGLDriver* Driver;
COpenGLDriver* Driver;
IShaderConstantSetCallBack* CallBack;
IMaterialRenderer* BaseMaterial;

View File

@ -43,15 +43,15 @@ class COpenGLShaderMaterialRenderer : public IMaterialRenderer
public:
//! Constructor
COpenGLShaderMaterialRenderer(video::COpenGLDriver* driver,
COpenGLShaderMaterialRenderer(COpenGLDriver* driver,
s32& outMaterialTypeNr, const c8* vertexShaderProgram, const c8* pixelShaderProgram,
IShaderConstantSetCallBack* callback, IMaterialRenderer* baseMaterial, s32 userData);
//! Destructor
virtual ~COpenGLShaderMaterialRenderer();
virtual void OnSetMaterial(const video::SMaterial& material, const video::SMaterial& lastMaterial,
bool resetAllRenderstates, video::IMaterialRendererServices* services);
virtual void OnSetMaterial(const SMaterial& material, const SMaterial& lastMaterial,
bool resetAllRenderstates, IMaterialRendererServices* services);
virtual bool OnRender(IMaterialRendererServices* service, E_VERTEX_TYPE vtxtype);
@ -74,7 +74,7 @@ protected:
bool createPixelShader(const c8* pxsh);
bool createVertexShader(const char* vtxsh);
video::COpenGLDriver* Driver;
COpenGLDriver* Driver;
IShaderConstantSetCallBack* CallBack;
IMaterialRenderer* BaseMaterial;

View File

@ -16,16 +16,20 @@ CSceneNodeAnimatorFlyCircle::CSceneNodeAnimatorFlyCircle(u32 time, const core::v
#ifdef _DEBUG
setDebugName("CSceneNodeAnimatorFlyCircle");
#endif
Direction.normalize();
init();
}
//! destructor
CSceneNodeAnimatorFlyCircle::~CSceneNodeAnimatorFlyCircle()
void CSceneNodeAnimatorFlyCircle::init()
{
}
Direction.normalize();
if (Direction.Y != 0)
VecV = core::vector3df(50,0,0).crossProduct(Direction).normalize();
else
VecV = core::vector3df(0,50,0).crossProduct(Direction).normalize();
VecU = VecV.crossProduct(Direction).normalize();
}
//! animates a scene node
@ -36,10 +40,7 @@ void CSceneNodeAnimatorFlyCircle::animateNode(ISceneNode* node, u32 timeMs)
const f32 t = (timeMs-StartTime) * Speed;
core::vector3df circle(Radius * sinf(t), 0, Radius * cosf(t));
circle = circle.crossProduct ( Direction );
node->setPosition(Center + circle);
node->setPosition(Center + Radius * ((VecU*cosf(t)) + (VecV*sinf(t))));
}
@ -60,15 +61,16 @@ void CSceneNodeAnimatorFlyCircle::deserializeAttributes(io::IAttributes* in, io:
Radius = in->getAttributeAsFloat("Radius");
Speed = in->getAttributeAsFloat("Speed");
Direction = in->getAttributeAsVector3d("Direction");
StartTime = 0;
if (Direction.equals(core::vector3df(0,0,0)))
Direction.set(0,1,0); // irrlicht 1.1 backwards compatibility
else
Direction.normalize();
init();
}
} // end namespace scene
} // end namespace irr

View File

@ -16,11 +16,9 @@ namespace scene
public:
//! constructor
CSceneNodeAnimatorFlyCircle(u32 time, const core::vector3df& center, f32 radius, f32 speed,
const core::vector3df& direction);
//! destructor
virtual ~CSceneNodeAnimatorFlyCircle();
CSceneNodeAnimatorFlyCircle(u32 time,
const core::vector3df& center, f32 radius,
f32 speed, const core::vector3df& direction);
//! animates a scene node
virtual void animateNode(ISceneNode* node, u32 timeMs);
@ -35,9 +33,16 @@ namespace scene
virtual ESCENE_NODE_ANIMATOR_TYPE getType() const { return ESNAT_FLY_CIRCLE; }
private:
// do some initial calculations
void init();
// circle center
core::vector3df Center;
// up-vector, normal to the circle's plane
core::vector3df Direction;
// Two helper vectors
core::vector3df VecU;
core::vector3df VecV;
f32 Radius;
f32 Speed;
u32 StartTime;

View File

@ -2083,10 +2083,12 @@ core::stringc CXMeshFileLoader::stripPathFromString(core::stringc string, bool r
if (backSlash>slashIndex) slashIndex=backSlash;
if (slashIndex==-1)//no slashes found
{
if (returnPath)
return core::stringc(); //no path to return
else
return string;
}
if (returnPath)
return string.subString(0, slashIndex + 1);