Jump to content
  • Advertisement

NinjaStar

Member
  • Content Count

    56
  • Joined

  • Last visited

Community Reputation

100 Neutral

About NinjaStar

  • Rank
    Member
  1. NinjaStar

    Spherical Harmonics HELP NEEDED

    sorry doesnt help... but thanks anyway, I am looking more for a solution to how to convert a CubeMap/Envi map to SH
  2. I've been looking at SH in Actual Games - by Tom Forsyth and I have no idea whther I have the coefficients the right way round... i.e. 1,x,y,z,xz,yx,xy,3z^2-1,x^2-y^2 obv there is more than one typo because in another place Forsyth puts them 1,x,y,z,xz,yx,xy,x^2-y^2,1-3z^2 which is frustrating A stanford paper and source put the coeffs 1,y,x,z,xy,yx,xz,3z^2-1,x^2-y^2 so I am totally lost I want to use 2nd order spherical harmonics with 9 coefficients, I dunno what I am doing wrong. I also think I have my constants/weights wrong too :( i.e. 0.282095 and so on The only thing I am positive I got right is the differential solid angle I'm planning to convert cubemaps into SH but for now I have a simple test app which simulates as if there is only 1 pixel per face... (6 colors) red,green,blue,yellow, white and black corresponding to the "dir" parameter (i.e. red is front/z+) I struggle with the math and just checking the differential solid angle took me 2 days so I would much appreciate if you could DUMBDOWN the topic for me or show me some piece of code that I could use the constants from Right here is my little code dir basically means 0=forward, 1= right, back,left, up and down float u,v,x,y,z,domega,c,fwt; u = 0; /* u ranges from -1 to 1 */ v = 0; /* v ranges from -1 to 1 */ fwt = u*u+v*v+1.f; c = sqrt(fwt); if (dir==0) { x=u; y=v; z=1.f; } else if (dir==1) { x=1.f; y=v; z=-u; } else if (dir==2) { x=-u; y=v; z=-1.f; } else if (dir==3) { x=-1.f; y=v; z=u; } else if (dir==4) { x=u; y=1.f; z=v; } else if (dir==5) { x=-u; y=-1.f; z=-v; } x /= c; y /= c; z /= c; c = 1.f/(fwt*c); fwtSum += c; domega = c; c = 0.282095*domega; coeff[0] += col.X*c; coeff[1] += col.Y*c; coeff[2] += col.Z*c; c = 0.488603*domega; coeff[3] += col.X*c*x; coeff[4] += col.Y*c*x; coeff[5] += col.Z*c*x; coeff[6] += col.X*c*y; coeff[7] += col.Y*c*y; coeff[8] += col.Z*c*y; coeff[9] += col.X*c*z; coeff[10] += col.Y*c*z; coeff[11] += col.Z*c*z; c = 1.092548*domega; coeff[12] += col.X*c*x*z; coeff[13] += col.Y*c*x*z; coeff[14] += col.Z*c*x*z; coeff[15] += col.X*c*y*z; coeff[16] += col.Y*c*y*z; coeff[17] += col.Z*c*y*z; coeff[18] += col.X*c*x*y; coeff[19] += col.Y*c*x*y; coeff[20] += col.Z*c*x*y; c = 1.092548*domega*(3.f*z*z-1.f); coeff[21] += col.X*c; coeff[22] += col.Y*c; coeff[23] += col.Z*c; c = 0.546274*domega*(x*x-y*y); coeff[24] += col.X*c; coeff[25] += col.Y*c; coeff[26] += col.Z*c; after all sides are processed I scale the entire harmonic by 4.f*core::PI/(fwtSum*6.f)
  3. NinjaStar

    the best ssao ive seen

    hail to you, my implementation has been slow... and bad quality Thanks a thousand times
  4. NinjaStar

    the best ssao ive seen

    one question, could I use this in my open-Source GPL v3 game?
  5. NinjaStar

    PhysX doesnt simulate?

    thank you but the problem was here -DCORELIB -DNX32 -DNX_DISABLE_FLUIDS flags :) i need to go on a trip to nvidia with a katana and find the guyz who wrote the documentation
  6. NinjaStar

    PhysX doesnt simulate?

    have you seen the thing at the top "how to use code tags here???" i simplified the code even further http://pastebin.org/34774 and that is the print out i get THE CUBE IS 10.000000. THE CUBE IS 10.000000. THE CUBE IS 10.000000. THE CUBE IS 10.000000. THE CUBE IS 10.000000. THE CUBE IS 10.000000. THE CUBE IS 10.000000. THE CUBE IS 10.000000. THE CUBE IS 10.000000. THE CUBE IS 10.000000. THE CUBE IS 10.000000. THE CUBE IS 10.000000. THE CUBE IS 10.000000. THE CUBE IS 10.000000. THE CUBE IS 10.000000. THE CUBE IS 10.000000. THE CUBE IS 10.000000. THE CUBE IS 10.000000. THE CUBE IS 10.000000. THE CUBE IS 10.000000. THE CUBE IS 10.000000. THE CUBE IS 10.000000. THE CUBE IS 10.000000. THE CUBE IS 10.000000. THE CUBE IS 10.000000. THE CUBE IS 10.000000. THE CUBE IS 10.000000. THE CUBE IS 10.000000. THE CUBE IS 10.000000. THE CUBE IS 10.000000. THE CUBE IS 10.000000. THE CUBE IS 10.000000. THE CUBE IS 10.000000. THE CUBE IS 10.000000. THE CUBE IS 10.000000. THE CUBE IS 10.000000. THE CUBE IS 10.000000. THE CUBE IS 10.000000. THE CUBE IS 10.000000. THE CUBE IS 10.000000. THE CUBE IS 10.000000. THE CUBE IS 10.000000. THE CUBE IS 10.000000. THE CUBE IS 10.000000. THE CUBE IS 10.000000. THE CUBE IS 10.000000. THE CUBE IS 10.000000. THE CUBE IS 10.000000. THE CUBE IS 10.000000. THE CUBE IS 10.000000. THE CUBE IS 10.000000. THE CUBE IS 10.000000. THE CUBE IS 10.000000. THE CUBE IS 10.000000. THE CUBE IS 10.000000. THE CUBE IS 10.000000. THE CUBE IS 10.000000. THE CUBE IS 10.000000. THE CUBE IS 10.000000. THE CUBE IS 10.000000. THE CUBE IS 10.000000. THE CUBE IS 10.000000. THE CUBE IS 10.000000. THE CUBE IS 10.000000. THE CUBE IS 10.000000. THE CUBE IS 10.000000. THE CUBE IS 10.000000. THE CUBE IS 10.000000. THE CUBE IS 10.000000. THE CUBE IS 10.000000. THE CUBE IS 10.000000. THE CUBE IS 10.000000. THE CUBE IS 10.000000. THE CUBE IS 10.000000. THE CUBE IS 10.000000. THE CUBE IS 10.000000. THE CUBE IS 10.000000. THE CUBE IS 10.000000. THE CUBE IS 10.000000. THE CUBE IS 10.000000. THE CUBE IS 10.000000. THE CUBE IS 10.000000. THE CUBE IS 10.000000. THE CUBE IS 10.000000. THE CUBE IS 10.000000. THE CUBE IS 10.000000. THE CUBE IS 10.000000. THE CUBE IS 10.000000. THE CUBE IS 10.000000. THE CUBE IS 10.000000. THE CUBE IS 10.000000. THE CUBE IS 10.000000. THE CUBE IS 10.000000. THE CUBE IS 10.000000. THE CUBE IS 10.000000. THE CUBE IS 10.000000. THE CUBE IS 10.000000. THE CUBE IS 10.000000. THE CUBE IS 10.000000. THE CUBE IS 10.000000. THE CUBE IS 10.000000. THE CUBE IS 10.000000. THE CUBE IS 10.000000. THE CUBE IS 10.000000. THE CUBE IS 10.000000. THE CUBE IS 10.000000. THE CUBE IS 10.000000. THE CUBE IS 10.000000. THE CUBE IS 10.000000. THE CUBE IS 10.000000. THE CUBE IS 10.000000. THE CUBE IS 10.000000. THE CUBE IS 10.000000. THE CUBE IS 10.000000. THE CUBE IS 10.000000. THE CUBE IS 10.000000. THE CUBE IS 10.000000. THE CUBE IS 10.000000. THE CUBE IS 10.000000. THE CUBE IS 10.000000. THE CUBE IS 10.000000. THE CUBE IS 10.000000. THE CUBE IS 10.000000. THE CUBE IS 10.000000. THE CUBE IS 10.000000. THE CUBE IS 10.000000. THE CUBE IS 10.000000. THE CUBE IS 10.000000. THE CUBE IS 10.000000. THE CUBE IS 10.000000. THE CUBE IS 10.000000. THE CUBE IS 10.000000. THE CUBE IS 10.000000. THE CUBE IS 10.000000. THE CUBE IS 10.000000. THE CUBE IS 10.000000. THE CUBE IS 10.000000. THE CUBE IS 10.000000. THE CUBE IS 10.000000. THE CUBE IS 10.000000. THE CUBE IS 10.000000. THE CUBE IS 10.000000. THE CUBE IS 10.000000. THE CUBE IS 10.000000. THE CUBE IS 10.000000. THE CUBE IS 10.000000. THE CUBE IS 10.000000. THE CUBE IS 10.000000. THE CUBE IS 10.000000. THE CUBE IS 10.000000. THE CUBE IS 10.000000. THE CUBE IS 10.000000. THE CUBE IS 10.000000. THE CUBE IS 10.000000. THE CUBE IS 10.000000. THE CUBE IS 10.000000. THE CUBE IS 10.000000. THE CUBE IS 10.000000. THE CUBE IS 10.000000. THE CUBE IS 10.000000. THE CUBE IS 10.000000. THE CUBE IS 10.000000. THE CUBE IS 10.000000. THE CUBE IS 10.000000. THE CUBE IS 10.000000. THE CUBE IS 10.000000. THE CUBE IS 10.000000. THE CUBE IS 10.000000. THE CUBE IS 10.000000. THE CUBE IS 10.000000. THE CUBE IS 10.000000. THE CUBE IS 10.000000. THE CUBE IS 10.000000. THE CUBE IS 10.000000. THE CUBE IS 10.000000. THE CUBE IS 10.000000. THE CUBE IS 10.000000. THE CUBE IS 10.000000. THE CUBE IS 10.000000. THE CUBE IS 10.000000. THE CUBE IS 10.000000. THE CUBE IS 10.000000. THE CUBE IS 10.000000. THE CUBE IS 10.000000. THE CUBE IS 10.000000. THE CUBE IS 10.000000. THE CUBE IS 10.000000. THE CUBE IS 10.000000. THE CUBE IS 10.000000. THE CUBE IS 10.000000. THE CUBE IS 10.000000. THE CUBE IS 10.000000. THE CUBE IS 10.000000. THE CUBE IS 10.000000. THE CUBE IS 10.000000. THE CUBE IS 10.000000. THE CUBE IS 10.000000. THE CUBE IS 10.000000. THE CUBE IS 10.000000. THE CUBE IS 10.000000. THE CUBE IS 10.000000. THE CUBE IS 10.000000. THE CUBE IS 10.000000. THE CUBE IS 10.000000. THE CUBE IS 10.000000. THE CUBE IS 10.000000. THE CUBE IS 10.000000. THE CUBE IS 10.000000. THE CUBE IS 10.000000. THE CUBE IS 10.000000. THE CUBE IS 10.000000. THE CUBE IS 10.000000. THE CUBE IS 10.000000. THE CUBE IS 10.000000. THE CUBE IS 10.000000. THE CUBE IS 10.000000. THE CUBE IS 10.000000. THE CUBE IS 10.000000. THE CUBE IS 10.000000. THE CUBE IS 10.000000. THE CUBE IS 10.000000. THE CUBE IS 10.000000. THE CUBE IS 10.000000. THE CUBE IS 10.000000. THE CUBE IS 10.000000. THE CUBE IS 10.000000. THE CUBE IS 10.000000. THE CUBE IS 10.000000. THE CUBE IS 10.000000. THE CUBE IS 10.000000. THE CUBE IS 10.000000. THE CUBE IS 10.000000. THE CUBE IS 10.000000. THE CUBE IS 10.000000. THE CUBE IS 10.000000. THE CUBE IS 10.000000. THE CUBE IS 10.000000. THE CUBE IS 10.000000. THE CUBE IS 10.000000. THE CUBE IS 10.000000. THE CUBE IS 10.000000. THE CUBE IS 10.000000. THE CUBE IS 10.000000. THE CUBE IS 10.000000. THE CUBE IS 10.000000. THE CUBE IS 10.000000. THE CUBE IS 10.000000. THE CUBE IS 10.000000. THE CUBE IS 10.000000. THE CUBE IS 10.000000. THE CUBE IS 10.000000. THE CUBE IS 10.000000. THE CUBE IS 10.000000. THE CUBE IS 10.000000. THE CUBE IS 10.000000. THE CUBE IS 10.000000. THE CUBE IS 10.000000. THE CUBE IS 10.000000. THE CUBE IS 10.000000. THE CUBE IS 10.000000. THE CUBE IS 10.000000. THE CUBE IS 10.000000. THE CUBE IS 10.000000. THE CUBE IS 10.000000. THE CUBE IS 10.000000. THE CUBE IS 10.000000. THE CUBE IS 10.000000. THE CUBE IS 10.000000. THE CUBE IS 10.000000. THE CUBE IS 10.000000. THE CUBE IS 10.000000. THE CUBE IS 10.000000. THE CUBE IS 10.000000. THE CUBE IS 10.000000. THE CUBE IS 10.000000. THE CUBE IS 10.000000. THE CUBE IS 10.000000. THE CUBE IS 10.000000. THE CUBE IS 10.000000. THE CUBE IS 10.000000. THE CUBE IS 10.000000. THE CUBE IS 10.000000. THE CUBE IS 10.000000. THE CUBE IS 10.000000. THE CUBE IS 10.000000. THE CUBE IS 10.000000. THE CUBE IS 10.000000. THE CUBE IS 10.000000. THE CUBE IS 10.000000. THE CUBE IS 10.000000. THE CUBE IS 10.000000. THE CUBE IS 10.000000. THE CUBE IS 10.000000. THE CUBE IS 10.000000. THE CUBE IS 10.000000. THE CUBE IS 10.000000. THE CUBE IS 10.000000. THE CUBE IS 10.000000. THE CUBE IS 10.000000. THE CUBE IS 10.000000. THE CUBE IS 10.000000. THE CUBE IS 10.000000. THE CUBE IS 10.000000. THE CUBE IS 10.000000. THE CUBE IS 10.000000. THE CUBE IS 10.000000. THE CUBE IS 10.000000. THE CUBE IS 10.000000. THE CUBE IS 10.000000. THE CUBE IS 10.000000. THE CUBE IS 10.000000. THE CUBE IS 10.000000. THE CUBE IS 10.000000. THE CUBE IS 10.000000. THE CUBE IS 10.000000. THE CUBE IS 10.000000. THE CUBE IS 10.000000. THE CUBE IS 10.000000. THE CUBE IS 10.000000. THE CUBE IS 10.000000. THE CUBE IS 10.000000. THE CUBE IS 10.000000. THE CUBE IS 10.000000. THE CUBE IS 10.000000. THE CUBE IS 10.000000. THE CUBE IS 10.000000. THE CUBE IS 10.000000. THE CUBE IS 10.000000. THE CUBE IS 10.000000. THE CUBE IS 10.000000. THE CUBE IS 10.000000. THE CUBE IS 10.000000. THE CUBE IS 10.000000. THE CUBE IS 10.000000. THE CUBE IS 10.000000. THE CUBE IS 10.000000. THE CUBE IS 10.000000. THE CUBE IS 10.000000. THE CUBE IS 10.000000. THE CUBE IS 10.000000. THE CUBE IS 10.000000. THE CUBE IS 10.000000. THE CUBE IS 10.000000. THE CUBE IS 10.000000. THE CUBE IS 10.000000. THE CUBE IS 10.000000. THE CUBE IS 10.000000. THE CUBE IS 10.000000. THE CUBE IS 10.000000. THE CUBE IS 10.000000. THE CUBE IS 10.000000. THE CUBE IS 10.000000. THE CUBE IS 10.000000. THE CUBE IS 10.000000. THE CUBE IS 10.000000. THE CUBE IS 10.000000. THE CUBE IS 10.000000. THE CUBE IS 10.000000. THE CUBE IS 10.000000. THE CUBE IS 10.000000. THE CUBE IS 10.000000. THE CUBE IS 10.000000. THE CUBE IS 10.000000. THE CUBE IS 10.000000. THE CUBE IS 10.000000. THE CUBE IS 10.000000. THE CUBE IS 10.000000. THE CUBE IS 10.000000. THE CUBE IS 10.000000. THE CUBE IS 10.000000. THE CUBE IS 10.000000. THE CUBE IS 10.000000. THE CUBE IS 10.000000. THE CUBE IS 10.000000. THE CUBE IS 10.000000. THE CUBE IS 10.000000. THE CUBE IS 10.000000. THE CUBE IS 10.000000. THE CUBE IS 10.000000. THE CUBE IS 10.000000. THE CUBE IS 10.000000. THE CUBE IS 10.000000. THE CUBE IS 10.000000. THE CUBE IS 10.000000. THE CUBE IS 10.000000. THE CUBE IS 10.000000. THE CUBE IS 10.000000. THE CUBE IS 10.000000. THE CUBE IS 10.000000. THE CUBE IS 10.000000. THE CUBE IS 10.000000. THE CUBE IS 10.000000. THE CUBE IS 10.000000. THE CUBE IS 10.000000. THE CUBE IS 10.000000. THE CUBE IS 10.000000. THE CUBE IS 10.000000. THE CUBE IS 10.000000. THE CUBE IS 10.000000. THE CUBE IS 10.000000. THE CUBE IS 10.000000. THE CUBE IS 10.000000. THE CUBE IS 10.000000. THE CUBE IS 10.000000. THE CUBE IS 10.000000. THE CUBE IS 10.000000. THE CUBE IS 10.000000. THE CUBE IS 10.000000. THE CUBE IS 10.000000. THE CUBE IS 10.000000. THE CUBE IS 10.000000. THE CUBE IS 10.000000. THE CUBE IS 10.000000. THE CUBE IS 10.000000. THE CUBE IS 10.000000. THE CUBE IS 10.000000. THE CUBE IS 10.000000. THE CUBE IS 10.000000. THE CUBE IS 10.000000. THE CUBE IS 10.000000. THE CUBE IS 10.000000. THE CUBE IS 10.000000. THE CUBE IS 10.000000. THE CUBE IS 10.000000. THE CUBE IS 10.000000. THE CUBE IS 10.000000. THE CUBE IS 10.000000. THE CUBE IS 10.000000. THE CUBE IS 10.000000. THE CUBE IS 10.000000. THE CUBE IS 10.000000. THE CUBE IS 10.000000. THE CUBE IS 10.000000. THE CUBE IS 10.000000. THE CUBE IS 10.000000. THE CUBE IS 10.000000. THE CUBE IS 10.000000. THE CUBE IS 10.000000. THE CUBE IS 10.000000. THE CUBE IS 10.000000. THE CUBE IS 10.000000. THE CUBE IS 10.000000. THE CUBE IS 10.000000. THE CUBE IS 10.000000. THE CUBE IS 10.000000. THE CUBE IS 10.000000. THE CUBE IS 10.000000. THE CUBE IS 10.000000. THE CUBE IS 10.000000. THE CUBE IS 10.000000. THE CUBE IS 10.000000. THE CUBE IS 10.000000. THE CUBE IS 10.000000. THE CUBE IS 10.000000. THE CUBE IS 10.000000. THE CUBE IS 10.000000. THE CUBE IS 10.000000. THE CUBE IS 10.000000. THE CUBE IS 10.000000. THE CUBE IS 10.000000. THE CUBE IS 10.000000. THE CUBE IS 10.000000. THE CUBE IS 10.000000. THE CUBE IS 10.000000. THE CUBE IS 10.000000. THE CUBE IS 10.000000. THE CUBE IS 10.000000. THE CUBE IS 10.000000. THE CUBE IS 10.000000. THE CUBE IS 10.000000. THE CUBE IS 10.000000. THE CUBE IS 10.000000. THE CUBE IS 10.000000. THE CUBE IS 10.000000. THE CUBE IS 10.000000. THE CUBE IS 10.000000. THE CUBE IS 10.000000. THE CUBE IS 10.000000. THE CUBE IS 10.000000. THE CUBE IS 10.000000. THE CUBE IS 10.000000. THE CUBE IS 10.000000. THE CUBE IS 10.000000. THE CUBE IS 10.000000. THE CUBE IS 10.000000. THE CUBE IS 10.000000. THE CUBE IS 10.000000. THE CUBE IS 10.000000. THE CUBE IS 10.000000. THE CUBE IS 10.000000. THE CUBE IS 10.000000. THE CUBE IS 10.000000. THE CUBE IS 10.000000. THE CUBE IS 10.000000. THE CUBE IS 10.000000. THE CUBE IS 10.000000. THE CUBE IS 10.000000. THE CUBE IS 10.000000. THE CUBE IS 10.000000. THE CUBE IS 10.000000. THE CUBE IS 10.000000. THE CUBE IS 10.000000. THE CUBE IS 10.000000. THE CUBE IS 10.000000. THE CUBE IS 10.000000. THE CUBE IS 10.000000. THE CUBE IS 10.000000. THE CUBE IS 10.000000. THE CUBE IS 10.000000. THE CUBE IS 10.000000. THE CUBE IS 10.000000.
  7. NinjaStar

    PhysX doesnt simulate?

    cmon is it that hard???
  8. NinjaStar

    PhysX doesnt simulate?

    well basically what happens... I invoke the sdk... I make a scene... I do asynchronous stepping and the position of a box does not change I tried to pass deltaTime/1000.f (because its in miliseconds) instead of 1.f/60.f however this seems to have no effect I am definitely positive that one box actor is created, because the pointer is not null and the physX_PNS class method prints out the first node's in the list Y global position, and it should be changing (gravity pulling the object down). So the actor is not null, the actor is valid, and returns 1 or true for isDynamic and 0 for isSleeping. What am I doing wrong here is code (how do you use code tags??) PhysX.h #ifndef PHYSXPNS_H #define PHYSXPNS_H #include "NxPhysics.h" #include "irrlicht.h" #include <NxCooking.h> /*====================API REFERENCE======================================= PNS_PhysX by devsh, matthew kielan HOW TO: 1) declare an instance of physX_PNS 2) instead of making a game loop in your game... make a game function that will/can be executed in the game loop NOTE IMPORTANT: The ONLY argument it can take in is UserData, the UserData class will provide you with the pointers to driver, device etc. NOTE IMPORTANT: The FUNCTION MUST BE VOID!!! NOTE IMPORTANT: NEVER ADD PHYSICS OBJECTS IN THE GAME FUNCTION 2) declare a UserData instance and pass the device pointer in it's constructor a) if you need any other pointers and/or special objects/nodes to be passed on to the function, derive your own class from UserData and then type cast it inside the game function NOTE: For variables already available in UserData look in the USERDATA section. 3) use physX_PNS member function called setGameRenderLoop(void (*gameRenderLoop)()) and pass a pointer to your game function 4) then in your game loop, call the member function physX_PNS::simulate(UserData) and feed it with your UserData, you do not need to call your game function because the physX_PNS::simulate(UserData) member function does it for you using the pointer. NOTE: calling your game function after or before physX_PNS::simulate() will not distabilize the game, but may lead to slowdowns. But more likely the physics simulations might be choppy. 5) 5a)To add a physics to a node, use the member function physX_PNS::makePhysXForSceneNode(irr::scene::ISceneNode* node, float density_kgm3, irr::core::vector3df linear_vel=irr::core::vector3df(0,0,0), irr::core::vector3df angular_vel=irr::core::vector3df(0,0,0), float angular_damping=0.05, float linear_damping=0.f) The physX wrapper will dynamically detect the kind of node, ie. mesh, cube, sphere and will cook it or make a simple actor for it. Cooking means to convert a mesh into a simple "mesh" made up of boxes for physics simulations. You also need to specify the density of the node, ie. - Water has a density of 1000 kg/m³ so you would enter 1000 kg as density_kgm3 - 1010 kg/m³ = average human body - 10490 kg/m³ = silver - 11340 kg/m³ = lead - 2000-8000 glass - 50-100 for a wooden crate - 8940 for copper - 7850 steel - 1750-2400 for concrete - 1760-2560 limestone - 1922-2563 for bricks - Cardboard 689 - 129-2165 cement - 2691 Granite Earth, loam, dry, excavated 1249 Earth, moist, excavated 1442 Earth, wet, excavated 1602 Earth, dense 2002 Earth, soft loose mud 1730 Earth, packed 1522 Earth, Fullers, raw 673 MOST woods will float (save for ebony) http://www.simetric.co.uk/si_wood.htm YOU CAN GOOGLE THE REST 5b) If you are more advanced in the fields of physX you can make an actor (PhysX term) for your node with a custom actor descriptor, the function is: NxActor* makePhysXForSceneNodeWithCustomDesc(irr::scene::ISceneNode* node, NxActorDesc actDesc); 6) both of the functions have their shorter versions, and they take in the same parameters: makePhysXForSceneNodeWithCustomDesc = mPFSNWCD makePhysXForSceneNode = mPFSN USERDATA: There are common pointers to stuff that you will most likely need in your game loop, They are all public members of the UserData class. These are their definitions: THESE ARE AUTOMATICALLY SET WITH THE UserData CONSTURCTOR irr::IrrlichtDevice* device; irr::gui::ICursorControl* CursorControl; irr::io::IFileSystem* FileSystem; irr::gui::IGUIEnvironment* guienv; irr::ILogger* Logger; irr::IOSOperator* OSOp; irr::scene::ISceneManager* smgr; irr::ITimer* Timer; irr::video::IVideoDriver* driver; THESE YOU CAN MANIPULATE irr::core::array<irr::scene::ISceneNode*> nodes; irr::core::array<irr::video::ITexture*> textures; ADVANCED: If you know the nVidia PhysX API and would like more flexibility, or even work as if the API is not there... There are pointers to stuff needed for direct PhysX interaction. The way PNS_PhysX is designed: --->|PNS |--> game -------------> Nvidia PhysX --->|PhysX|--> so you still have direct acess channel, the PhysX main include file is put in the PNS_PhysX header that you put in your game. You can use all the classes and types that nvidia uses. Here are the global variables and pointers that PNS_PhysX provides you with for full acess to PhysX: -pointer to the physX engine NxPhysicsSDK = through physX_PNS::getPhysXSDK() -the scene descriptor NxSceneDesc = through physX_PNS::getSceneDescriptor() -pointer to the scene NxScene = through physX_PNS::getScene() =========================================================================*/ class UserData; class physX_PNS { public: physX_PNS(irr::IrrlichtDevice* dev, irr::core::vector3df min = irr::core::vector3df(-10000.f,-10000.f,-10000.f), irr::core::vector3df max = irr::core::vector3df(10000.f,10000.f,10000.f), int number_of_threads=3, unsigned int threadmask=0xfffffffe); ~physX_PNS(); NxPhysicsSDK* getPhysXSDK() {return gPhysicsSDK;} NxSceneDesc& getSceneDescriptor() {return sceneDesc;} NxScene* getScene() {return gScene;} virtual void setGameRenderLoop(void (*gameRenderLoop)(UserData*)); virtual void simulate(UserData* dt); NxActor* addInfiniteFloor(irr::core::vector3df normal=irr::core::vector3df(0,1,0),float DFO=0.f); NxActor* makePhysXForSceneNode(irr::scene::ISceneNode* node, float density_kgm3, irr::core::vector3df linear_vel=irr::core::vector3df(0,0,0), irr::core::vector3df angular_vel=irr::core::vector3df(0,0,0), float angular_damping=0.5, float linear_damping=0.f, int flag = 0); NxActor* mPFSN(irr::scene::ISceneNode* node, float density_kgm3, irr::core::vector3df linear_vel=irr::core::vector3df(0,0,0), irr::core::vector3df angular_vel=irr::core::vector3df(0,0,0), float angular_damping=0.5, float linear_damping=0.f, int flag = NX_BF_VISUALIZATION | NX_BF_ENERGY_SLEEP_TEST) { return makePhysXForSceneNode(node, density_kgm3, linear_vel, angular_vel, angular_damping, linear_damping, flag); } NxActor* makePhysXForSceneNodeWithCustomDesc(irr::scene::ISceneNode* node, NxActorDesc actDesc); NxActor* mPFSNWCD(irr::scene::ISceneNode* node, NxActorDesc actDesc) { return makePhysXForSceneNodeWithCustomDesc(node, actDesc); } NxVec3 getNxVec3FromVector3df(irr::core::vector3df vec) { return NxVec3(vec.X,vec.Y,vec.Z); } irr::core::vector3df getVector3dfFromNxVec3(NxVec3 vec) { return irr::core::vector3df(vec.x,vec.y,vec.z); } private: irr::core::array<NxActor*> actorList; irr::f32 timeNow, deltaTime, lastTime; void (*GameRenderLoop)(UserData*); irr::IrrlichtDevice* device; NxPhysicsSDK* gPhysicsSDK; NxSceneDesc sceneDesc; NxScene* gScene; #if NX_SDK_VERSION_NUMBER >= 250 NxCookingInterface* gCooking; #endif }; NxMat33 rotationVectorToPhysxMatrix(irr::core::vector3df rot) { NxMat33 rotX, rotY, rotZ; rotX.rotX(rot.X * irr::core::DEGTORAD); rotY.rotY(rot.Y * irr::core::DEGTORAD); rotZ.rotZ(rot.Z * irr::core::DEGTORAD); return rotZ * rotY * rotX; } irr::core::vector3df physxMatrixToRotationVector(NxMat33 mat) { irr::f32 fM[16]; mat.getColumnMajorStride4(fM); irr::core::matrix4 irrM; irrM.setM(fM); return irrM.getRotationDegrees(); } #include "PhysX_UserData.h" #endif PhysX.cpp #include "PhysX.h" #include <iostream> physX_PNS::physX_PNS(irr::IrrlichtDevice* dev, irr::core::vector3df min, irr::core::vector3df max, int number_of_threads, unsigned int threadmask) { device = dev; if (!device) { return; } gPhysicsSDK = NxCreatePhysicsSDK(NX_PHYSICS_SDK_VERSION, NULL, NULL); if (!gPhysicsSDK) { device->closeDevice(); return; } gPhysicsSDK->setParameter(NX_SKIN_WIDTH, 0.01f); sceneDesc.gravity.set(0,-9.81,0); // 9.81 m/s is the gravity pull at the top of the earth's surface //sceneDesc.flags |= NX_SF_ENABLE_ACTIVETRANSFORMS; //sceneDesc.flags |= NX_SF_SIMULATE_SEPARATE_THREAD; //I'm gonna make your quad core scream for mercy //sceneDesc.flags |= NX_SF_ENABLE_MULTITHREAD; //sceneDesc.backgroundThreadCount = 1; //sceneDesc.threadMask = threadmask; //Havent implemented because of the danger for single cores that no thread will be made #ifdef INTELi9 sceneDesc.internalThreadCount = 5; #else //sceneDesc.internalThreadCount = number_of_threads; #endif gScene = gPhysicsSDK->createScene(sceneDesc); if (!gScene) { device->closeDevice(); return; } NxMaterial* defaultMaterial = gScene->getMaterialFromIndex(0); defaultMaterial->setRestitution(0.0f); defaultMaterial->setStaticFriction(0.5f); defaultMaterial->setDynamicFriction(0.5f); // Initialize the cooking library for converting meshes, I learned that the process is different for latest SDK #if NX_SDK_VERSION_NUMBER >= 250 gCooking = NxGetCookingLib(NX_PHYSICS_SDK_VERSION); if (!gCooking) { device->closeDevice(); return; } gCooking->NxInitCooking(NULL,NULL); #else if (!NxInitCooking(NULL, NULL)) { device->closeDevice(); return; } #endif } physX_PNS::~physX_PNS() { #if NX_SDK_VERSION_NUMBER >= 250 if (gCooking) gCooking->NxCloseCooking(); #else NxCloseCooking(); #endif if (gPhysicsSDK) { if (gScene) gPhysicsSDK->releaseScene(*gScene); gScene = 0; //the object is now deleted, //so don't use the pointer anymore! gPhysicsSDK->release(); } gPhysicsSDK = NULL; } // This is the non-blocking convention // unlike irrPhysX the simulation will // not block the gameLoop void physX_PNS::setGameRenderLoop(void (*gameRenderLoop)(UserData*)) { GameRenderLoop = gameRenderLoop; } void physX_PNS::simulate(UserData* dt) { if (!GameRenderLoop) return; timeNow = dt->Timer->getTime(); deltaTime = timeNow - lastTime; lastTime = timeNow; std::cout << actorList[0]->getGlobalPosition().y << "\n"; NxU32 Transforms = 0; NxActiveTransform* activeTransforms = gScene->getActiveTransforms(Transforms); for (NxU32 i=0; i<Transforms; i++) { ((irr::scene::ISceneNode*)activeTransforms.userData)->setPosition(getVector3dfFromNxVec3(activeTransforms.actor2World.t)); } gScene->simulate(1.f/60.f); gScene->flushStream(); do { GameRenderLoop(dt); } while(!gScene->fetchResults(NX_RIGID_BODY_FINISHED, false)); gScene->fetchResults(NX_RIGID_BODY_FINISHED, true); // To remove ========================================== } NxActor* physX_PNS::addInfiniteFloor(irr::core::vector3df normal,float DFO) { //irr::scene::ISceneNode* floor; NxPlaneShapeDesc planeDesc; normal.normalize(); planeDesc.normal = NxVec3( normal.X, normal.Y, normal.Z ); planeDesc.d = DFO; NxActorDesc actorDesc; actorDesc.shapes.pushBack( &planeDesc ); NxActor* pFloorActor = gScene->createActor(actorDesc); //pFloorActor->userData = (void*)floor; return pFloorActor; } NxActor* physX_PNS::makePhysXForSceneNode(irr::scene::ISceneNode* node, float density_kgm3, irr::core::vector3df linear_vel, irr::core::vector3df angular_vel, float angular_damping, float linear_damping, int flag) { if (!node) return NULL; node->removeAnimators(); node->updateAbsolutePosition(); // The actor descriptor NxActorDesc actorDesc; // create a body descriptor NxBodyDesc bodyDesc; bodyDesc.angularDamping = angular_damping; bodyDesc.angularVelocity = NxVec3(angular_vel.X,angular_vel.Y,angular_vel.Z); bodyDesc.linearDamping = linear_damping; bodyDesc.linearVelocity = NxVec3(linear_vel.X,linear_vel.Y,linear_vel.Z); bodyDesc.flags = flag; // set the body descriptor for the actor actorDesc.body = &bodyDesc; if (node->getType()==irr::scene::ESNT_CUBE) { irr::core::vector3df edges[8]; node->getBoundingBox().getEdges(edges); NxBoxShapeDesc boxDesc; boxDesc.dimensions = NxVec3( edges[0].X>-edges[0].X ? edges[0].X:-edges[0].X, edges[0].Y>-edges[0].Y ? edges[0].Y:-edges[0].Y, edges[0].Z>-edges[0].Z ? edges[0].Z:-edges[0].Z ); actorDesc.shapes.pushBack(&boxDesc); actorDesc.density = density_kgm3; // initial position actorDesc.globalPose.t = NxVec3( node->getAbsolutePosition().X , node->getAbsolutePosition().Y, node->getAbsolutePosition().Z ); NxActor* actor = gScene->createActor(actorDesc); actor->userData = (void*)node; if (actor) actorList.push_back(actor); return actor; } } NxActor* physX_PNS::makePhysXForSceneNodeWithCustomDesc(irr::scene::ISceneNode* node, NxActorDesc actDesc) { if (!node) return NULL; node->removeAnimators(); NxActor* actor = gScene->createActor(actDesc); actor->userData = (void*)node; return actor; } my application code snippet physX_PNS* physx = new physX_PNS(dev); physx->setGameRenderLoop(&singlePlayerGameFunction); //physx->addInfiniteFloor(); test = smgr->addCubeSceneNode(128.0); test->setMaterialType((irr::video::E_MATERIAL_TYPE)Depth); test->getMaterial(0).DiffuseColor = irr::video::SColor(255,225,225,225); test->getMaterial(0).AmbientColor = irr::video::SColor(255,115,115,115); test->setMaterialTexture(0, rock); test->setPosition(irr::core::vector3df(0,1000,0)); NxActor* actorcube = physx->makePhysXForSceneNode(test, 60.f); while (dev->run()) { physx->simulate(&data); }
  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!