Newton Wrapper

Post those lines of code you feel like sharing or find what you require for your project here; or simply use them as tutorials.
Post Reply
sudi
Posts: 1686
Joined: Fri Aug 26, 2005 8:38 pm

Newton Wrapper

Post by sudi »

Well just a short newton wrapper it provides general rigidbody functions and collision sorting.

Download: Link

Edit: The license in there is somewhat wrong....u r ofcourse allowed to use that code but the rest still applies :P so don't charge if something goes boom!!
Edit: redownload please

Example:

Code: Select all

#include <ILogger.h>
#include <IPhysicsInterface.h>
#include <IPhysicMaterial.h>
#include <IPhysicObject.h>
#include <IPhysicShape.h>
#include <irrlicht.h>

class Callback : public AppFrame::physic::IPhysicMaterial
{
public:
	virtual int hitCollisionBox(AppFrame::physic::IPhysicObject* own, AppFrame::physic::IPhysicObject* body)
	{
		AppFrame::ILogger::log("I will soon hit an object bc our boundingboxes are intersecting");
		
		//return 0 if u dont't want them to calc collision
		return 1;
	}
	
	virtual void collide(AppFrame::physic::IPhysicObject* own, AppFrame::physic::IPhysicObject* body, irr::core::vector3df point, irr::core::vector3df normal, irr::f32 normalspeed, irr::f32 tangentspeedspeed)
	{
		AppFrame::ILogger::log("da it happend i did hit something");
	}
};

int main(int args, char* argv[])
{
	irr::IrrlichtDevice* device = irr::createDevice();
    
    irr::scene::ISceneManager* smgr = device->getSceneManager();
    irr::video::IVideoDriver* driver = device->getVideoDriver();
    
    AppFrame::physic::IPhysicsInterface* manager = new AppFrame::physic::CPhysicsInterface(smgr, irr::core::aabbox3d<irr::s32>(-1000,-1000,-1000,1000,1000,1000));

    manager->setWorldForce(irr::core::vector3df(0,-10,0));
    
    AppFrame::physic::IPhysicShape* shape = manager->getShape(irr::core::aabbox3d<irr::f32>(-5,-5,-5,5,5,5), AppFrame::physic::E_SHAPE_BOX);
    
    AppFrame::physic::IPhysicObject* object = manager->getDynamicObject(shape, AppFrame::physic::EPhysicMaterial_PLAYER, 60, irr::core::vector3df(0,100,0));
    
    //setup callback for object
    Callback * call = new Callback();
    object->setMaterialCallback(call);
    call->drop();
    
    AppFrame::physic::IPhysicObject* object2 = manager->getDynamicObject(shape, AppFrame::physic::EPhysicMaterial_PLAYER, 60, irr::core::vector3df(0,0,0));
    object2->setWorldForce(irr::core::vector3df(0,0,0));
    
    object->setSceneNode(smgr->addCubeSceneNode(5));
    
    smgr->addCameraSceneNodeFPS();
    
    while(device->run())
    {
		manager->Update(device->getTimer()->getTime());
		
		driver->beginScene(true, true, irr::video::SColor(255,255,255,255);
		smgr->drawAll();
		driver->endScene();
    }
    
    
    manager->addDynamicObjectToDeletion(object);
    manager->addShapeToDeletion(shape);
    manager->Update(0);
    manager->drop();
    
    device->drop();
    
    return 0;
}
Last edited by sudi on Wed Jan 07, 2009 6:37 pm, edited 1 time in total.
We're programmers. Programmers are, in their hearts, architects, and the first thing they want to do when they get to a site is to bulldoze the place flat and build something grand. We're not excited by renovation:tinkering,improving,planting flower beds.
Seven
Posts: 1034
Joined: Mon Nov 14, 2005 2:03 pm

Post by Seven »

question about newton please. Does newton support multiple worlds/levels/whatever simultaneously? For example, can you load 3 different worlds and switch between them without destroying/rebuilding the physics?
patricklucas
Posts: 34
Joined: Sun Jul 06, 2008 5:05 am
Location: NC, USA

Post by patricklucas »

I know you can in PhysX, but that, of course, doesn't answer your question.
Seven
Posts: 1034
Joined: Mon Nov 14, 2005 2:03 pm

Post by Seven »

sorry to hijack this thread, but ......

yes, Physx is doing exactly as I need. bouncing balls, collision detection, character controller etc... but I was looking to test my application interface by introducing a different physx engine and allowing users to switch between the two. The issue is that I tried newton before and could not get multiple worlds to exist simultaneously. maybe i was doing something wrong though. anyhow, just thining outloud. Thanks for listening :)
Post Reply