diff --git a/source/Irrlicht/CImage.cpp b/source/Irrlicht/CImage.cpp index 24067656..61cbe82d 100644 --- a/source/Irrlicht/CImage.cpp +++ b/source/Irrlicht/CImage.cpp @@ -408,11 +408,10 @@ void CImage::fill(const SColor &color) return; } break; + default: + // TODO: Handle other formats + return; } - if (Format != ECF_A1R5G5B5 && Format != ECF_R5G6B5 && - Format != ECF_A8R8G8B8) - return; - memset32( Data, c, getImageDataSizeInBytes() ); } diff --git a/source/Irrlicht/CPLYMeshFileLoader.cpp b/source/Irrlicht/CPLYMeshFileLoader.cpp index de931a61..498a770d 100644 --- a/source/Irrlicht/CPLYMeshFileLoader.cpp +++ b/source/Irrlicht/CPLYMeshFileLoader.cpp @@ -28,6 +28,7 @@ CPLYMeshFileLoader::CPLYMeshFileLoader(scene::ISceneManager* smgr) { } + CPLYMeshFileLoader::~CPLYMeshFileLoader() { // delete the buffer in case we didn't earlier @@ -44,6 +45,7 @@ CPLYMeshFileLoader::~CPLYMeshFileLoader() ElementList.clear(); } + //! returns true if the file maybe is able to be loaded by this class bool CPLYMeshFileLoader::isALoadableFileExtension(const io::path& filename) const { @@ -80,18 +82,18 @@ IAnimatedMesh* CPLYMeshFileLoader::createMesh(io::IReadFile* file) else { // cut the next line out - c8 *line = getNextLine(); + getNextLine(); // grab the word from this line c8 *word = getNextWord(); // ignore comments while (strcmp(word, "comment") == 0) { - line = getNextLine(); + getNextLine(); word = getNextWord(); } - bool readingHeader = true; + bool readingHeader = true; bool continueReading = true; IsBinaryFile = false; IsWrongEndian= false; @@ -102,8 +104,8 @@ IAnimatedMesh* CPLYMeshFileLoader::createMesh(io::IReadFile* file) { word = getNextWord(); - if (strcmp(word, "binary_little_endian") == 0) - { + if (strcmp(word, "binary_little_endian") == 0) + { IsBinaryFile = true; #ifdef __BIG_ENDIAN__ IsWrongEndian = true; @@ -186,10 +188,10 @@ IAnimatedMesh* CPLYMeshFileLoader::createMesh(io::IReadFile* file) el->Properties.push_back(prop); } } - else if (strcmp(word, "element") == 0) + else if (strcmp(word, "element") == 0) { SPLYElement* el = new SPLYElement; - el->Name = getNextWord(); + el->Name = getNextWord(); el->Count = atoi(getNextWord()); el->IsFixedWidth = true; el->KnownSize = 0; @@ -218,7 +220,7 @@ IAnimatedMesh* CPLYMeshFileLoader::createMesh(io::IReadFile* file) if (readingHeader && continueReading) { - line = getNextLine(); + getNextLine(); word = getNextWord(); } } @@ -282,6 +284,7 @@ IAnimatedMesh* CPLYMeshFileLoader::createMesh(io::IReadFile* file) return animMesh; } + bool CPLYMeshFileLoader::readVertex(const SPLYElement &Element, scene::CDynamicMeshBuffer* mb) { if (!IsBinaryFile) @@ -300,7 +303,7 @@ bool CPLYMeshFileLoader::readVertex(const SPLYElement &Element, scene::CDynamicM { E_PLY_PROPERTY_TYPE t = Element.Properties[i].Type; - if (Element.Properties[i].Name == "x") + if (Element.Properties[i].Name == "x") vert.Pos.X = getFloat(t); else if (Element.Properties[i].Name == "y") vert.Pos.Z = getFloat(t); @@ -354,6 +357,7 @@ bool CPLYMeshFileLoader::readVertex(const SPLYElement &Element, scene::CDynamicM return result; } + bool CPLYMeshFileLoader::readFace(const SPLYElement &Element, scene::CDynamicMeshBuffer* mb) { if (!IsBinaryFile) @@ -362,7 +366,7 @@ bool CPLYMeshFileLoader::readFace(const SPLYElement &Element, scene::CDynamicMes for (u32 i=0; i < Element.Properties.size(); ++i) { if ( (Element.Properties[i].Name == "vertex_indices" || - Element.Properties[i].Name == "vertex_index") && Element.Properties[i].Type == EPLYPT_LIST) + Element.Properties[i].Name == "vertex_index") && Element.Properties[i].Type == EPLYPT_LIST) { // get count s32 count = getInt(Element.Properties[i].Data.List.CountType); @@ -395,6 +399,7 @@ bool CPLYMeshFileLoader::readFace(const SPLYElement &Element, scene::CDynamicMes return true; } + // skips an element and all properties. return false on EOF void CPLYMeshFileLoader::skipElement(const SPLYElement &Element) { @@ -408,6 +413,7 @@ void CPLYMeshFileLoader::skipElement(const SPLYElement &Element) getNextLine(); } + void CPLYMeshFileLoader::skipProperty(const SPLYProperty &Property) { if (Property.Type == EPLYPT_LIST) @@ -444,11 +450,11 @@ bool CPLYMeshFileLoader::allocateBuffer() // blank memory memset(Buffer, 0, PLY_INPUT_BUFFER_SIZE); - StartPointer = Buffer; - EndPointer = Buffer; + StartPointer = Buffer; + EndPointer = Buffer; LineEndPointer = Buffer-1; - WordLength = -1; - EndOfFile = false; + WordLength = -1; + EndOfFile = false; // get data from the file fillBuffer(); @@ -456,6 +462,7 @@ bool CPLYMeshFileLoader::allocateBuffer() return true; } + // gets more data from the file. returns false on EOF void CPLYMeshFileLoader::fillBuffer() { @@ -470,7 +477,7 @@ void CPLYMeshFileLoader::fillBuffer() } // reset start position StartPointer = Buffer; - EndPointer = StartPointer + length; + EndPointer = StartPointer + length; if (File->getPos() == File->getSize()) { @@ -496,6 +503,7 @@ void CPLYMeshFileLoader::fillBuffer() } } + // skips x bytes in the file, getting more data if required void CPLYMeshFileLoader::moveForward(u32 bytes) { @@ -507,38 +515,39 @@ void CPLYMeshFileLoader::moveForward(u32 bytes) StartPointer = EndPointer; } + E_PLY_PROPERTY_TYPE CPLYMeshFileLoader::getPropertyType(const c8* typeString) const { - if (strcmp(typeString, "char") == 0 || - strcmp(typeString, "uchar") == 0 || - strcmp(typeString, "int8") == 0 || - strcmp(typeString, "uint8") == 0) + if (strcmp(typeString, "char") == 0 || + strcmp(typeString, "uchar") == 0 || + strcmp(typeString, "int8") == 0 || + strcmp(typeString, "uint8") == 0) { return EPLYPT_INT8; } - else if (strcmp(typeString, "uint") == 0 || - strcmp(typeString, "int16") == 0 || - strcmp(typeString, "uint16") == 0 || - strcmp(typeString, "short") == 0 || - strcmp(typeString, "ushort") == 0) + else if (strcmp(typeString, "uint") == 0 || + strcmp(typeString, "int16") == 0 || + strcmp(typeString, "uint16") == 0 || + strcmp(typeString, "short") == 0 || + strcmp(typeString, "ushort") == 0) { return EPLYPT_INT16; } - else if (strcmp(typeString, "int") == 0 || - strcmp(typeString, "long") == 0 || - strcmp(typeString, "ulong") == 0 || - strcmp(typeString, "int32") == 0 || - strcmp(typeString, "uint32") == 0) + else if (strcmp(typeString, "int") == 0 || + strcmp(typeString, "long") == 0 || + strcmp(typeString, "ulong") == 0 || + strcmp(typeString, "int32") == 0 || + strcmp(typeString, "uint32") == 0) { return EPLYPT_INT32; } - else if (strcmp(typeString, "float") == 0 || - strcmp(typeString, "float32") == 0) + else if (strcmp(typeString, "float") == 0 || + strcmp(typeString, "float32") == 0) { return EPLYPT_FLOAT32; } else if (strcmp(typeString, "float64") == 0 || - strcmp(typeString, "double") == 0) + strcmp(typeString, "double") == 0) { return EPLYPT_FLOAT64; } @@ -612,6 +621,8 @@ c8* CPLYMeshFileLoader::getNextLine() return StartPointer; } } + + // null terminate the next word on the previous line and move the next word pointer along // since we already have a full line in the buffer, we never need to retrieve more data c8* CPLYMeshFileLoader::getNextWord() @@ -640,6 +651,8 @@ c8* CPLYMeshFileLoader::getNextWord() // return pointer to the start of the word return StartPointer; } + + // read the next float from the file and move the start pointer along f32 CPLYMeshFileLoader::getFloat(E_PLY_PROPERTY_TYPE t) { @@ -716,6 +729,8 @@ f32 CPLYMeshFileLoader::getFloat(E_PLY_PROPERTY_TYPE t) } return retVal; } + + // read the next int from the file and move the start pointer along u32 CPLYMeshFileLoader::getInt(E_PLY_PROPERTY_TYPE t) { diff --git a/source/Irrlicht/CSceneNodeAnimatorCameraMaya.cpp b/source/Irrlicht/CSceneNodeAnimatorCameraMaya.cpp index 60d1ad89..eeaa11e7 100644 --- a/source/Irrlicht/CSceneNodeAnimatorCameraMaya.cpp +++ b/source/Irrlicht/CSceneNodeAnimatorCameraMaya.cpp @@ -15,9 +15,10 @@ namespace scene //! constructor CSceneNodeAnimatorCameraMaya::CSceneNodeAnimatorCameraMaya(gui::ICursorControl* cursor, f32 rotate, f32 zoom, f32 translate) - : CursorControl(cursor), Zooming(false), Rotating(false), Moving(false), - Translating(false), ZoomSpeed(zoom), RotateSpeed(rotate), TranslateSpeed(translate), - CurrentZoom(70.0f), RotX(0.0f), RotY(0.0f), OldCamera(0), MousePos(0.5f, 0.5f) + : CursorControl(cursor), OldCamera(0), MousePos(0.5f, 0.5f), + ZoomSpeed(zoom), RotateSpeed(rotate), TranslateSpeed(translate), + CurrentZoom(70.0f), RotX(0.0f), RotY(0.0f), + Zooming(false), Rotating(false), Moving(false), Translating(false) { #ifdef _DEBUG setDebugName("CSceneNodeAnimatorCameraMaya"); @@ -89,8 +90,6 @@ bool CSceneNodeAnimatorCameraMaya::OnEvent(const SEvent& event) //! 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. void CSceneNodeAnimatorCameraMaya::animateNode(ISceneNode *node, u32 timeMs) { //Alt + LM = Rotate around camera pivot @@ -103,26 +102,23 @@ void CSceneNodeAnimatorCameraMaya::animateNode(ISceneNode *node, u32 timeMs) ICameraSceneNode* camera = static_cast(node); // If the camera isn't the active camera, and receiving input, then don't process it. - if(!camera->isInputReceiverEnabled()) + if (!camera->isInputReceiverEnabled()) return; scene::ISceneManager * smgr = camera->getSceneManager(); - if(smgr && smgr->getActiveCamera() != camera) + if (smgr && smgr->getActiveCamera() != camera) return; if (OldCamera != camera) { - OldTarget = camera->getTarget(); + LastCameraTarget = OldTarget = camera->getTarget(); OldCamera = camera; - LastCameraTarget = OldTarget; } else { OldTarget += camera->getTarget() - LastCameraTarget; } - core::vector3df target = camera->getTarget(); - f32 nRotX = RotX; f32 nRotY = RotY; f32 nZoom = CurrentZoom; @@ -133,7 +129,6 @@ void CSceneNodeAnimatorCameraMaya::animateNode(ISceneNode *node, u32 timeMs) { ZoomStart = MousePos; Zooming = true; - nZoom = CurrentZoom; } else { @@ -157,15 +152,18 @@ void CSceneNodeAnimatorCameraMaya::animateNode(ISceneNode *node, u32 timeMs) // Translation --------------------------------- - core::vector3df translate(OldTarget), upVector(camera->getUpVector()); + core::vector3df translate(OldTarget); + const core::vector3df upVector(camera->getUpVector()); + const core::vector3df target = camera->getTarget(); - core::vector3df tvectX = Pos - target; + core::vector3df pos = camera->getPosition(); + core::vector3df tvectX = pos - target; tvectX = tvectX.crossProduct(upVector); tvectX.normalize(); const SViewFrustum* const va = camera->getViewFrustum(); core::vector3df tvectY = (va->getFarLeftDown() - va->getFarRightDown()); - tvectY = tvectY.crossProduct(upVector.Y > 0 ? Pos - target : target - Pos); + tvectY = tvectY.crossProduct(upVector.Y > 0 ? pos - target : target - pos); tvectY.normalize(); if (isMouseKeyDown(2) && !Zooming) @@ -215,32 +213,29 @@ void CSceneNodeAnimatorCameraMaya::animateNode(ISceneNode *node, u32 timeMs) Rotating = false; } - // Set Pos ------------------------------------ + // Set pos ------------------------------------ - target = translate; + pos = translate; + pos.X += nZoom; - Pos.X = nZoom + target.X; - Pos.Y = target.Y; - Pos.Z = target.Z; + pos.rotateXYBy(nRotY, translate); + pos.rotateXZBy(-nRotX, translate); - Pos.rotateXYBy(nRotY, target); - Pos.rotateXZBy(-nRotX, target); + camera->setPosition(pos); + camera->setTarget(translate); // Rotation Error ---------------------------- // jox: fixed bug: jitter when rotating to the top and bottom of y - upVector.set(0,1,0); - upVector.rotateXYBy(-nRotY); - upVector.rotateXZBy(-nRotX+180.f); - - camera->setPosition(Pos); - camera->setTarget(target); - camera->setUpVector(upVector); + pos.set(0,1,0); + pos.rotateXYBy(-nRotY); + pos.rotateXZBy(-nRotX+180.f); + camera->setUpVector(pos); LastCameraTarget = camera->getTarget(); } -bool CSceneNodeAnimatorCameraMaya::isMouseKeyDown(s32 key) +bool CSceneNodeAnimatorCameraMaya::isMouseKeyDown(s32 key) const { return MouseKeys[key]; } @@ -294,6 +289,7 @@ f32 CSceneNodeAnimatorCameraMaya::getZoomSpeed() const return ZoomSpeed; } + ISceneNodeAnimator* CSceneNodeAnimatorCameraMaya::createClone(ISceneNode* node, ISceneManager* newManager) { CSceneNodeAnimatorCameraMaya * newAnimator = diff --git a/source/Irrlicht/CSceneNodeAnimatorCameraMaya.h b/source/Irrlicht/CSceneNodeAnimatorCameraMaya.h index d46bbf89..bba79543 100644 --- a/source/Irrlicht/CSceneNodeAnimatorCameraMaya.h +++ b/source/Irrlicht/CSceneNodeAnimatorCameraMaya.h @@ -80,29 +80,27 @@ namespace scene void allKeysUp(); void animate(); - bool isMouseKeyDown(s32 key); + bool isMouseKeyDown(s32 key) const; bool MouseKeys[3]; gui::ICursorControl *CursorControl; - core::vector3df Pos; + scene::ICameraSceneNode* OldCamera; + core::vector3df OldTarget; + core::vector3df LastCameraTarget; // to find out if the camera target was moved outside this animator + core::position2df RotateStart; + core::position2df ZoomStart; + core::position2df TranslateStart; + core::position2df MousePos; + f32 ZoomSpeed; + f32 RotateSpeed; + f32 TranslateSpeed; + f32 CurrentZoom; + f32 RotX, RotY; bool Zooming; bool Rotating; bool Moving; bool Translating; - f32 ZoomSpeed; - f32 RotateSpeed; - f32 TranslateSpeed; - core::position2df RotateStart; - core::position2df ZoomStart; - core::position2df TranslateStart; - f32 CurrentZoom; - f32 RotX, RotY; - core::vector3df OldTarget; - core::vector3df LastCameraTarget; // to find out if the camera target was moved outside this animator - scene::ICameraSceneNode* OldCamera; - - core::position2df MousePos; }; } // end namespace scene diff --git a/source/Irrlicht/CSceneNodeAnimatorCollisionResponse.cpp b/source/Irrlicht/CSceneNodeAnimatorCollisionResponse.cpp index 42924b22..f7141915 100644 --- a/source/Irrlicht/CSceneNodeAnimatorCollisionResponse.cpp +++ b/source/Irrlicht/CSceneNodeAnimatorCollisionResponse.cpp @@ -178,7 +178,7 @@ void CSceneNodeAnimatorCollisionResponse::animateNode(ISceneNode* node, u32 time CollisionResultPosition = core::vector3df(); CollisionNode = 0; - core::vector3df force = vel + FallingVelocity; + // core::vector3df force = vel + FallingVelocity; if ( AnimateCameraTarget ) { diff --git a/source/Irrlicht/Makefile b/source/Irrlicht/Makefile index 5d4cc40f..569a2501 100644 --- a/source/Irrlicht/Makefile +++ b/source/Irrlicht/Makefile @@ -84,7 +84,7 @@ STATIC_LIB = libIrrlicht.a LIB_PATH = ../../lib/$(SYSTEM) INSTALL_DIR = /usr/local/lib sharedlib install: SHARED_LIB = libIrrlicht.so -staticlib sharedlib: LDFLAGS += --no-export-all-symbols --add-stdcall-alias +#staticlib sharedlib: LDFLAGS += --no-export-all-symbols --add-stdcall-alias sharedlib: LDFLAGS += -L/usr/X11R6/lib$(LIBSELECT) -lGL -lXxf86vm staticlib sharedlib: CXXINCS += -I/usr/X11R6/include @@ -101,7 +101,7 @@ sharedlib_osx: LDFLAGS += -L/usr/X11R6/lib$(LIBSELECT) -lGL -lXxf86vm #Windows specific options IRRLICHT_DLL := ../../bin/Win32-gcc/Irrlicht.dll sharedlib_win32 staticlib_win32: SYSTEM = Win32-gcc -sharedlib_win32: LDFLAGS += -lgdi32 -lopengl32 -ld3dx9d -lwinmm +sharedlib_win32: LDFLAGS += -lgdi32 -lopengl32 -ld3dx9d -lwinmm -Wl,--no-export-all-symbols -Wl,--add-stdcall-alias sharedlib_win32 staticlib_win32: CPPFLAGS += -DIRR_COMPILE_WITH_DX9_DEV_PACK -D__GNUWIN32__ -D_WIN32 -DWIN32 -D_WINDOWS -D_MBCS -D_USRDLL staticlib_win32: CPPFLAGS += -D_IRR_STATIC_LIB_