From a03ab4a47e544cc9ff09ec042a8628f75fd13911 Mon Sep 17 00:00:00 2001 From: hybrid Date: Sat, 9 Feb 2008 14:12:28 +0000 Subject: [PATCH] Merged from 1.4 branch revisions 1218:1234 git-svn-id: http://svn.code.sf.net/p/irrlicht/code/trunk@1235 dfc29bdd-3216-0410-991c-e03cc46cb475 --- include/SMaterial.h | 2 +- source/Irrlicht/CAnimatedMeshSceneNode.cpp | 36 +++------- source/Irrlicht/CD3D9Driver.cpp | 84 ++++++++++------------ source/Irrlicht/CGUIEnvironment.cpp | 3 + source/Irrlicht/COpenGLDriver.cpp | 49 ++++++------- source/Irrlicht/CSkyDomeSceneNode.cpp | 47 ++++++------ source/Irrlicht/CSkyDomeSceneNode.h | 1 - 7 files changed, 94 insertions(+), 128 deletions(-) diff --git a/include/SMaterial.h b/include/SMaterial.h index 1b75e806..06840e73 100644 --- a/include/SMaterial.h +++ b/include/SMaterial.h @@ -71,7 +71,7 @@ namespace video EmissiveColor(0,0,0,0), SpecularColor(255,255,255,255), Shininess(0.0f), MaterialTypeParam(0.0f), MaterialTypeParam2(0.0f), Thickness(1.0f), Wireframe(false), PointCloud(false), GouraudShading(true), Lighting(true), - ZBuffer(true), ZWriteEnable(true), BackfaceCulling(true), + ZBuffer(1), ZWriteEnable(true), BackfaceCulling(true), FogEnable(false), NormalizeNormals(false) { } diff --git a/source/Irrlicht/CAnimatedMeshSceneNode.cpp b/source/Irrlicht/CAnimatedMeshSceneNode.cpp index b64c6fd4..c0a8a65d 100644 --- a/source/Irrlicht/CAnimatedMeshSceneNode.cpp +++ b/source/Irrlicht/CAnimatedMeshSceneNode.cpp @@ -75,7 +75,7 @@ void CAnimatedMeshSceneNode::setCurrentFrame(f32 frame) } -//! Returns the current displayed frame number. +//! Returns the currently displayed frame number. f32 CAnimatedMeshSceneNode::getFrameNr() const { return CurrentFrameNr; @@ -103,15 +103,14 @@ f32 CAnimatedMeshSceneNode::buildFrameNr(u32 timeMs) { // play animation looped + const s32 lenInMs = abs(s32( (EndFrame - StartFrame) / FramesPerSecond)); if (FramesPerSecond > 0.f) //forwards... { - const s32 lenInTime = s32( f32(EndFrame - StartFrame) / FramesPerSecond); - return StartFrame + ( (timeMs - BeginFrameTime) % lenInTime) *FramesPerSecond; + return StartFrame + ( (timeMs - BeginFrameTime) % lenInMs) * FramesPerSecond; } else //backwards... { - const s32 lenInTime = s32( f32(EndFrame - StartFrame) / -FramesPerSecond); - return EndFrame - ( (timeMs - BeginFrameTime) % lenInTime)*-FramesPerSecond; + return EndFrame - ( (timeMs - BeginFrameTime) % lenInMs)* -FramesPerSecond; } } else @@ -122,7 +121,7 @@ f32 CAnimatedMeshSceneNode::buildFrameNr(u32 timeMs) if (FramesPerSecond > 0.f) //forwards... { - const f32 deltaFrame = floorf( f32 ( timeMs - BeginFrameTime ) * FramesPerSecond ); + const f32 deltaFrame = ( timeMs - BeginFrameTime ) * FramesPerSecond; frame = StartFrame + deltaFrame; @@ -135,7 +134,7 @@ f32 CAnimatedMeshSceneNode::buildFrameNr(u32 timeMs) } else //backwards... (untested) { - const f32 deltaFrame = floorf( f32 ( timeMs - BeginFrameTime ) * -FramesPerSecond ); + const f32 deltaFrame = ( timeMs - BeginFrameTime ) * -FramesPerSecond; frame = EndFrame - deltaFrame; @@ -152,6 +151,7 @@ f32 CAnimatedMeshSceneNode::buildFrameNr(u32 timeMs) } } + //! frame void CAnimatedMeshSceneNode::OnRegisterSceneNode() { @@ -200,11 +200,9 @@ void CAnimatedMeshSceneNode::OnRegisterSceneNode() } - //! OnAnimate() is called just before rendering the whole scene. void CAnimatedMeshSceneNode::OnAnimate(u32 timeMs) { - CurrentFrameNr = buildFrameNr ( timeMs ); if ( Mesh ) @@ -218,25 +216,10 @@ void CAnimatedMeshSceneNode::OnAnimate(u32 timeMs) */ } - IAnimatedMeshSceneNode::OnAnimate ( timeMs ); - } -/* - angle = dotproduct ( v(0,1,0), up ) - axis = crossproduct ( v(0,1,0), up ) -*/ -inline void AlignToUpVector(core::matrix4 &m, const core::vector3df &up ) -{ - core::quaternion quatRot( up.Z, 0.f, -up.X, 1 + up.Y ); - quatRot.normalize(); - quatRot.getMatrix ( m ); -} - - - //! renders the node. void CAnimatedMeshSceneNode::render() { @@ -452,7 +435,10 @@ void CAnimatedMeshSceneNode::render() const video::S3DVertex* v = ( const video::S3DVertex*)mb->getVertices(); for ( u32 i=0; i != mb->getVertexCount(); ++i ) { - AlignToUpVector ( m2, v->Normal ); + // Align to v->normal + core::quaternion quatRot( v->Normal.Z, 0.f, -v->Normal.X, 1 + v->Normal.Y ); + quatRot.normalize(); + quatRot.getMatrix ( m2 ); m2.setTranslation(v->Pos); m2*=AbsoluteTransformation; diff --git a/source/Irrlicht/CD3D9Driver.cpp b/source/Irrlicht/CD3D9Driver.cpp index 1c2609e9..c4847ddf 100644 --- a/source/Irrlicht/CD3D9Driver.cpp +++ b/source/Irrlicht/CD3D9Driver.cpp @@ -264,8 +264,8 @@ bool CD3D9Driver::initDriver(const core::dimension2d& screenSize, HWND hwnd DWORD qualityLevels = 0; if (SUCCEEDED(pID3D->CheckDeviceMultiSampleType(D3DADAPTER_DEFAULT, - devtype, present.BackBufferFormat, !fullScreen, - D3DMULTISAMPLE_4_SAMPLES, &qualityLevels))) + devtype, present.BackBufferFormat, !fullScreen, + D3DMULTISAMPLE_4_SAMPLES, &qualityLevels))) { // enable multi sampling present.MultiSampleType = D3DMULTISAMPLE_4_SAMPLES; @@ -274,8 +274,8 @@ bool CD3D9Driver::initDriver(const core::dimension2d& screenSize, HWND hwnd } else if (SUCCEEDED(pID3D->CheckDeviceMultiSampleType(D3DADAPTER_DEFAULT, - devtype, present.BackBufferFormat, !fullScreen, - D3DMULTISAMPLE_2_SAMPLES, &qualityLevels))) + devtype, present.BackBufferFormat, !fullScreen, + D3DMULTISAMPLE_2_SAMPLES, &qualityLevels))) { // enable multi sampling present.MultiSampleType = D3DMULTISAMPLE_2_SAMPLES; @@ -549,7 +549,7 @@ bool CD3D9Driver::queryFeature(E_VIDEO_DRIVER_FEATURE feature) const case EVDF_MIP_MAP: return (Caps.TextureCaps & D3DPTEXTURECAPS_MIPMAP) != 0; case EVDF_MIP_MAP_AUTO_UPDATE: - // always return false because a lot of drivers claim they do + // always return false because a lot of drivers claim they do // this but actually don't do this at all. return false; //(Caps.Caps2 & D3DCAPS2_CANAUTOGENMIPMAP) != 0; case EVDF_STENCIL_BUFFER: @@ -902,7 +902,7 @@ void CD3D9Driver::draw2DImage(const video::ITexture* texture, const core::rectSetRenderState(D3DRS_SPECULARENABLE, enable); - pID3DDevice->SetRenderState(D3DRS_NORMALIZENORMALS, enable); pID3DDevice->SetRenderState(D3DRS_SPECULARMATERIALSOURCE, D3DMCS_MATERIAL); } @@ -1376,7 +1374,7 @@ void CD3D9Driver::setBasicRenderStates(const SMaterial& material, const SMateria mode=D3DTADDRESS_BORDER; break; } - + pID3DDevice->SetSamplerState(st, D3DSAMP_ADDRESSU, mode ); pID3DDevice->SetSamplerState(st, D3DSAMP_ADDRESSV, mode ); } @@ -1408,7 +1406,6 @@ void CD3D9Driver::setBasicRenderStates(const SMaterial& material, const SMateria } - //! sets the needed renderstates void CD3D9Driver::setRenderStatesStencilShadowMode(bool zfail) { @@ -1492,7 +1489,6 @@ void CD3D9Driver::setRenderStatesStencilShadowMode(bool zfail) } - //! sets the needed renderstates void CD3D9Driver::setRenderStatesStencilFillMode(bool alpha) { @@ -1551,7 +1547,6 @@ void CD3D9Driver::setRenderStatesStencilFillMode(bool alpha) } - //! sets the needed renderstates void CD3D9Driver::setRenderStates2DMode(bool alpha, bool texture, bool alphaChannel) { @@ -1560,42 +1555,41 @@ void CD3D9Driver::setRenderStates2DMode(bool alpha, bool texture, bool alphaChan if (CurrentRenderMode != ERM_2D || Transformation3DChanged) { + // unset last 3d material + if (CurrentRenderMode != ERM_2D) + { + if (static_cast(Material.MaterialType) < MaterialRenderers.size()) + MaterialRenderers[Material.MaterialType].Renderer->OnUnsetMaterial(); + setBasicRenderStates(SMaterial(), SMaterial(), true); + // everything that is wrongly set by SMaterial default + pID3DDevice->SetRenderState(D3DRS_ZENABLE, FALSE); + pID3DDevice->SetRenderState(D3DRS_LIGHTING, FALSE); + + pID3DDevice->SetTextureStageState(1, D3DTSS_COLOROP, D3DTOP_DISABLE); + pID3DDevice->SetTextureStageState(1, D3DTSS_ALPHAOP, D3DTOP_DISABLE); + pID3DDevice->SetTextureStageState(2, D3DTSS_COLOROP, D3DTOP_DISABLE); + pID3DDevice->SetTextureStageState(2, D3DTSS_ALPHAOP, D3DTOP_DISABLE); + pID3DDevice->SetTextureStageState(3, D3DTSS_COLOROP, D3DTOP_DISABLE); + pID3DDevice->SetTextureStageState(3, D3DTSS_ALPHAOP, D3DTOP_DISABLE); + + pID3DDevice->SetRenderState( D3DRS_STENCILENABLE, FALSE ); + + pID3DDevice->SetRenderState( D3DRS_CULLMODE, D3DCULL_CCW ); + + pID3DDevice->SetSamplerState(0, D3DSAMP_ADDRESSU, D3DTADDRESS_WRAP ); + pID3DDevice->SetSamplerState(0, D3DSAMP_ADDRESSV, D3DTADDRESS_WRAP ); + + pID3DDevice->SetTextureStageState( 0, D3DTSS_TEXTURETRANSFORMFLAGS, D3DTTFF_DISABLE ); + pID3DDevice->SetTextureStageState( 0, D3DTSS_TEXCOORDINDEX, 0); + pID3DDevice->SetTransform( D3DTS_TEXTURE0, &UnitMatrixD3D9 ); + } + core::matrix4 mat; pID3DDevice->SetTransform(D3DTS_VIEW, (D3DMATRIX*)((void*)mat.pointer())); pID3DDevice->SetTransform(D3DTS_WORLD, (D3DMATRIX*)((void*)mat.pointer())); pID3DDevice->SetTransform(D3DTS_PROJECTION, (D3DMATRIX*)((void*)mat.pointer())); - pID3DDevice->SetRenderState(D3DRS_ZENABLE, FALSE); - //pID3DDevice->SetRenderState(D3DRS_SHADEMODE, D3DSHADE_FLAT); - pID3DDevice->SetRenderState(D3DRS_FILLMODE, D3DFILL_SOLID); - pID3DDevice->SetRenderState(D3DRS_LIGHTING, FALSE); - pID3DDevice->SetRenderState(D3DRS_FOGENABLE, FALSE); - pID3DDevice->SetRenderState(D3DRS_SPECULARENABLE, FALSE); - - pID3DDevice->SetTextureStageState(1, D3DTSS_COLOROP, D3DTOP_DISABLE); - pID3DDevice->SetTextureStageState(1, D3DTSS_ALPHAOP, D3DTOP_DISABLE); - pID3DDevice->SetTextureStageState(2, D3DTSS_COLOROP, D3DTOP_DISABLE); - pID3DDevice->SetTextureStageState(2, D3DTSS_ALPHAOP, D3DTOP_DISABLE); - pID3DDevice->SetTextureStageState(3, D3DTSS_COLOROP, D3DTOP_DISABLE); - pID3DDevice->SetTextureStageState(3, D3DTSS_ALPHAOP, D3DTOP_DISABLE); - - pID3DDevice->SetRenderState( D3DRS_STENCILENABLE, FALSE ); - - pID3DDevice->SetRenderState( D3DRS_CULLMODE, D3DCULL_CCW ); - - pID3DDevice->SetSamplerState(0, D3DSAMP_ADDRESSU, D3DTADDRESS_WRAP ); - pID3DDevice->SetSamplerState(0, D3DSAMP_ADDRESSV, D3DTADDRESS_WRAP ); - - pID3DDevice->SetTextureStageState( 0, D3DTSS_TEXTURETRANSFORMFLAGS, D3DTTFF_DISABLE ); - pID3DDevice->SetTextureStageState( 0, D3DTSS_TEXCOORDINDEX, 0); - pID3DDevice->SetTransform( D3DTS_TEXTURE0, &UnitMatrixD3D9 ); - Transformation3DChanged = false; - - // unset last 3d material - if (CurrentRenderMode == ERM_3D && - Material.MaterialType >= 0 && Material.MaterialType < (s32)MaterialRenderers.size()) - MaterialRenderers[Material.MaterialType].Renderer->OnUnsetMaterial(); } if (texture) @@ -1673,7 +1667,6 @@ void CD3D9Driver::setRenderStates2DMode(bool alpha, bool texture, bool alphaChan } - //! deletes all dynamic lights there are void CD3D9Driver::deleteAllDynamicLights() { @@ -1686,7 +1679,6 @@ void CD3D9Driver::deleteAllDynamicLights() } - //! adds a dynamic light void CD3D9Driver::addDynamicLight(const SLight& dl) { @@ -1733,7 +1725,6 @@ void CD3D9Driver::addDynamicLight(const SLight& dl) } - //! returns the maximal amount of dynamic lights the device can handle u32 CD3D9Driver::getMaximalDynamicLightAmount() const { @@ -1741,7 +1732,6 @@ u32 CD3D9Driver::getMaximalDynamicLightAmount() const } - //! Sets the dynamic ambient light color. The default color is //! (0,0,0,0) which means it is dark. //! \param color: New color of the ambient light. @@ -1756,7 +1746,6 @@ void CD3D9Driver::setAmbientLight(const SColorf& color) } - //! \return Returns the name of the video driver. Example: In case of the DIRECT3D9 //! driver, it would return "Direct3D9.0". const wchar_t* CD3D9Driver::getName() const @@ -1765,7 +1754,6 @@ const wchar_t* CD3D9Driver::getName() const } - //! Draws a shadow volume into the stencil buffer. To draw a stencil shadow, do //! this: Frist, draw all geometry. Then use this method, to draw the shadow //! volume. Then, use IVideoDriver::drawStencilShadow() to visualize the shadow. diff --git a/source/Irrlicht/CGUIEnvironment.cpp b/source/Irrlicht/CGUIEnvironment.cpp index d1635aec..99f98346 100644 --- a/source/Irrlicht/CGUIEnvironment.cpp +++ b/source/Irrlicht/CGUIEnvironment.cpp @@ -549,6 +549,9 @@ IGUISkin* CGUIEnvironment::getSkin() const //! Sets a new GUI Skin void CGUIEnvironment::setSkin(IGUISkin* skin) { + if (CurrentSkin==skin) + return; + if (CurrentSkin) CurrentSkin->drop(); diff --git a/source/Irrlicht/COpenGLDriver.cpp b/source/Irrlicht/COpenGLDriver.cpp index ecaf7423..6f18d3e6 100644 --- a/source/Irrlicht/COpenGLDriver.cpp +++ b/source/Irrlicht/COpenGLDriver.cpp @@ -1432,6 +1432,7 @@ video::ITexture* COpenGLDriver::createDeviceDependentTexture(IImage* surface, co return new COpenGLTexture(surface, name, this); } + //! Sets a material. All 3d drawing functions draw geometry now //! using this material. //! \param material: Material to be used from now on. @@ -1447,7 +1448,6 @@ void COpenGLDriver::setMaterial(const SMaterial& material) } - //! prints error if an error happened. bool COpenGLDriver::testGLError() { @@ -1479,7 +1479,6 @@ bool COpenGLDriver::testGLError() } - //! sets the needed renderstates void COpenGLDriver::setRenderStates3DMode() { @@ -1512,11 +1511,11 @@ void COpenGLDriver::setRenderStates3DMode() // unset old material if (LastMaterial.MaterialType != Material.MaterialType && - LastMaterial.MaterialType >= 0 && LastMaterial.MaterialType < static_cast(MaterialRenderers.size())) + static_cast(LastMaterial.MaterialType) < MaterialRenderers.size()) MaterialRenderers[LastMaterial.MaterialType].Renderer->OnUnsetMaterial(); // set new material. - if (Material.MaterialType >= 0 && Material.MaterialType < static_cast(MaterialRenderers.size())) + if (static_cast(Material.MaterialType) < MaterialRenderers.size()) MaterialRenderers[Material.MaterialType].Renderer->OnSetMaterial( Material, LastMaterial, ResetRenderStates, this); @@ -1524,7 +1523,7 @@ void COpenGLDriver::setRenderStates3DMode() ResetRenderStates = false; } - if (Material.MaterialType >= 0 && Material.MaterialType < static_cast(MaterialRenderers.size())) + if (static_cast(Material.MaterialType) < MaterialRenderers.size()) MaterialRenderers[Material.MaterialType].Renderer->OnRender(this, video::EVT_STANDARD); CurrentRenderMode = ERM_3D; @@ -1615,12 +1614,11 @@ void COpenGLDriver::setBasicRenderStates(const SMaterial& material, const SMater } // fillmode - if (resetAllRenderStates || lastmaterial.Wireframe != material.Wireframe || lastmaterial.PointCloud != material.PointCloud) + if (resetAllRenderStates || (lastmaterial.Wireframe != material.Wireframe) || (lastmaterial.PointCloud != material.PointCloud)) glPolygonMode(GL_FRONT_AND_BACK, material.Wireframe ? GL_LINE : material.PointCloud? GL_POINT : GL_FILL); // shademode - - if (resetAllRenderStates || lastmaterial.GouraudShading != material.GouraudShading) + if (resetAllRenderStates || (lastmaterial.GouraudShading != material.GouraudShading)) { if (material.GouraudShading) glShadeModel(GL_SMOOTH); @@ -1629,8 +1627,7 @@ void COpenGLDriver::setBasicRenderStates(const SMaterial& material, const SMater } // lighting - - if (resetAllRenderStates || lastmaterial.Lighting != material.Lighting) + if (resetAllRenderStates || (lastmaterial.Lighting != material.Lighting)) { if (material.Lighting) glEnable(GL_LIGHTING); @@ -1669,7 +1666,6 @@ void COpenGLDriver::setBasicRenderStates(const SMaterial& material, const SMater } // back face culling - if (resetAllRenderStates || lastmaterial.BackfaceCulling != material.BackfaceCulling) { if (material.BackfaceCulling) @@ -1784,16 +1780,21 @@ void COpenGLDriver::setBasicRenderStates(const SMaterial& material, const SMater } - //! sets the needed renderstates void COpenGLDriver::setRenderStates2DMode(bool alpha, bool texture, bool alphaChannel) { if (CurrentRenderMode != ERM_2D || Transformation3DChanged) { // unset last 3d material - if (CurrentRenderMode == ERM_3D && Material.MaterialType >= 0 && - Material.MaterialType < static_cast(MaterialRenderers.size())) - MaterialRenderers[Material.MaterialType].Renderer->OnUnsetMaterial(); + if (CurrentRenderMode == ERM_3D) + { + if (static_cast(Material.MaterialType) < MaterialRenderers.size()) + MaterialRenderers[Material.MaterialType].Renderer->OnUnsetMaterial(); + setBasicRenderStates(SMaterial(), SMaterial(), true); + // everything that is wrongly set by SMaterial default + glDisable(GL_DEPTH_TEST); + glDisable(GL_LIGHTING); + } GLfloat glmat[16]; core::matrix4 m; @@ -1815,17 +1816,6 @@ void COpenGLDriver::setRenderStates2DMode(bool alpha, bool texture, bool alphaCh glLoadIdentity(); Transformation3DChanged = false; - - glDisable(GL_DEPTH_TEST); - glDisable(GL_FOG); - glPolygonMode(GL_FRONT_AND_BACK, GL_FILL); - glDisable(GL_LIGHTING); - - glDisable(GL_TEXTURE_GEN_S); - glDisable(GL_TEXTURE_GEN_T); - - glDisable(GL_ALPHA_TEST); - glCullFace(GL_BACK); } if (texture) @@ -2052,7 +2042,7 @@ void COpenGLDriver::drawStencilShadowVolume(const core::vector3df* triangles, s3 // unset last 3d material if (CurrentRenderMode == ERM_3D && - Material.MaterialType >= 0 && Material.MaterialType < static_cast(MaterialRenderers.size())) + static_cast(Material.MaterialType) < MaterialRenderers.size()) { MaterialRenderers[Material.MaterialType].Renderer->OnUnsetMaterial(); ResetRenderStates = true; @@ -2365,6 +2355,7 @@ s32 COpenGLDriver::addShaderMaterial(const c8* vertexShaderProgram, return nr; } + //! Adds a new material renderer to the VideoDriver, using GLSL to render geometry. s32 COpenGLDriver::addHighLevelShaderMaterial( const c8* vertexShaderProgram, @@ -2445,7 +2436,7 @@ u32 COpenGLDriver::getMaximalPrimitiveCount() const //! checks triangle count and print warning if wrong bool COpenGLDriver::setRenderTarget(video::ITexture* texture, bool clearBackBuffer, - bool clearZBuffer, SColor color) + bool clearZBuffer, SColor color) { // check for right driver type @@ -2595,6 +2586,7 @@ bool COpenGLDriver::setClipPlane(u32 index, const core::plane3df& plane, bool en return true; } + void COpenGLDriver::uploadClipPlane(u32 index) { // opengl needs an array of doubles for the plane equation @@ -2606,6 +2598,7 @@ void COpenGLDriver::uploadClipPlane(u32 index) glClipPlane(GL_CLIP_PLANE0 + index, clip_plane); } + //! Enable/disable a clipping plane. //! There are at least 6 clipping planes available for the user to set at will. //! \param index: The plane index. Must be between 0 and MaxUserClipPlanes. diff --git a/source/Irrlicht/CSkyDomeSceneNode.cpp b/source/Irrlicht/CSkyDomeSceneNode.cpp index 23c309c9..d65db72c 100644 --- a/source/Irrlicht/CSkyDomeSceneNode.cpp +++ b/source/Irrlicht/CSkyDomeSceneNode.cpp @@ -40,7 +40,7 @@ CSkyDomeSceneNode::CSkyDomeSceneNode(video::ITexture* sky, u32 horiRes, u32 vert f64 radius = 1000.0; /* Adjust this to get more or less perspective distorsion. */ f64 azimuth, azimuth_step; f64 elevation, elevation_step; - u32 k, c; + u32 k; video::S3DVertex vtx; @@ -60,57 +60,54 @@ CSkyDomeSceneNode::CSkyDomeSceneNode(video::ITexture* sky, u32 horiRes, u32 vert spherePercentage=2.; elevation_step = spherePercentage*core::PI64/2./(f64)vertRes; - Buffer.Vertices.set_used((horiRes+1)*(vertRes+1)); - Buffer.Indices.set_used(3*(2*vertRes-1)*horiRes); + Buffer.Vertices.reallocate((horiRes+1)*(vertRes+1)); + Buffer.Indices.reallocate(3*(2*vertRes-1)*horiRes); vtx.Color.set(255,255,255,255); vtx.Normal.set(0.0f,0.0f,0.0f); - c = 0; + const f32 tcV = (f32)texturePercentage/(f32)vertRes; for (k = 0, azimuth = 0; k <= horiRes; ++k) { elevation = core::PI64/2.; + const f32 tcU = (f32)k/(f32)horiRes; + const f64 sinA = sin(azimuth); + const f64 cosA = cos(azimuth); for (u32 j = 0; j <= vertRes; ++j) { - vtx.Pos.set((f32) (radius*cos(elevation)*sin(azimuth)), - (f32) (radius*sin(elevation)+50.0f), - (f32) (radius*cos(elevation)*cos(azimuth))); + const f64 cosEr = radius*cos(elevation); + vtx.Pos.set((f32) (cosEr*sinA), + (f32) (radius*sin(elevation)+50.0f), + (f32) (cosEr*cosA)); - vtx.TCoords.set((f32)k/(f32)horiRes, (f32)j/(f32)vertRes*(f32)texturePercentage); + vtx.TCoords.set(tcU, (f32)j*tcV); - Buffer.Vertices[c++] = vtx; + Buffer.Vertices.push_back(vtx); elevation -= elevation_step; } azimuth += azimuth_step; } - c = 0; for (k = 0; k < horiRes; ++k) { - Buffer.Indices[c++] = vertRes+2+(vertRes+1)*k; - Buffer.Indices[c++] = 1+(vertRes+1)*k; - Buffer.Indices[c++] = 0+(vertRes+1)*k; + Buffer.Indices.push_back(vertRes+2+(vertRes+1)*k); + Buffer.Indices.push_back(1+(vertRes+1)*k); + Buffer.Indices.push_back(0+(vertRes+1)*k); for (u32 j = 1; j < vertRes; ++j) { - Buffer.Indices[c++] = vertRes+2+(vertRes+1)*k+j; - Buffer.Indices[c++] = 1+(vertRes+1)*k+j; - Buffer.Indices[c++] = 0+(vertRes+1)*k+j; + Buffer.Indices.push_back(vertRes+2+(vertRes+1)*k+j); + Buffer.Indices.push_back(1+(vertRes+1)*k+j); + Buffer.Indices.push_back(0+(vertRes+1)*k+j); - Buffer.Indices[c++] = vertRes+1+(vertRes+1)*k+j; - Buffer.Indices[c++] = vertRes+2+(vertRes+1)*k+j; - Buffer.Indices[c++] = 0+(vertRes+1)*k+j; + Buffer.Indices.push_back(vertRes+1+(vertRes+1)*k+j); + Buffer.Indices.push_back(vertRes+2+(vertRes+1)*k+j); + Buffer.Indices.push_back(0+(vertRes+1)*k+j); } } } -//! destructor -CSkyDomeSceneNode::~CSkyDomeSceneNode() -{ -} - - //! renders the node. void CSkyDomeSceneNode::render() { diff --git a/source/Irrlicht/CSkyDomeSceneNode.h b/source/Irrlicht/CSkyDomeSceneNode.h index 8422c989..291bab29 100644 --- a/source/Irrlicht/CSkyDomeSceneNode.h +++ b/source/Irrlicht/CSkyDomeSceneNode.h @@ -20,7 +20,6 @@ class CSkyDomeSceneNode : public ISceneNode CSkyDomeSceneNode(video::ITexture* texture, u32 horiRes, u32 vertRes, f64 texturePercentage, f64 spherePercentage, ISceneNode* root, ISceneManager* smgr, s32 id); - virtual ~CSkyDomeSceneNode(); virtual void OnRegisterSceneNode(); virtual void render(); virtual const core::aabbox3d& getBoundingBox() const;