Jump to content

  • Log In with Google      Sign In   
  • Create Account


he3117

Member Since 29 Nov 2011
Offline Last Active Yesterday, 10:16 AM
-----

Topics I've Started

physx vehicle problem

13 May 2013 - 04:20 PM

When my vehicle is in air there is no problem but when wheel touch the ground my game crash.

and I'm getting this error:

 

First-chance exception at 0x00672cb7 in Game.exe: 0xC0000005: Access violation reading location 0x374a2c5c.
Unhandled exception at 0x00672cb7 in Game.exe: 0xC0000005: Access violation reading location 0x374a2c5c.

 

this is my call stack:

     Game.exe!physx::PxVehicleUpdate::updateDrive4W()  Line 2408 + 0x6 bytes    C++
     Game.exe!physx::PxVehicleUpdate::update()  Line 3599 + 0x24 bytes    C++
     Game.exe!physx::PxVehicleUpdates()  Line 3638 + 0x20 bytes    C++
 

I think there is some thing wrong in ray casts but I don't know what is it.

 

any idea how can I solve this problem?


multiply defined symbols when compiling physx 3.2.4

06 May 2013 - 07:53 AM

Hi

I want to add physx to my engine but I'm getting a very strange errors:

1>------ Build started: Project: Game, Configuration: Debug Win32 ------
1>PhysX3CommonCHECKED_x86.lib(PhysX3CommonCHECKED_x86.dll) : error LNK2005: "public: class physx::PxFlags<enum physx::PxSerialFlag::Enum,unsigned short> __thiscall physx::PxFlags<enum physx::PxSerialFlag::Enum,unsigned short>::operator~(void)const " (??S?$PxFlags@W4Enum@PxSerialFlag@physx@@G@physx@@QBE?AV01@XZ) already defined in FreeCamera.obj
1>PhysX3CommonCHECKED_x86.lib(PhysX3CommonCHECKED_x86.dll) : error LNK2005: "public: __thiscall physx::PxFlags<enum physx::PxSerialFlag::Enum,unsigned short>::PxFlags<enum physx::PxSerialFlag::Enum,unsigned short>(enum physx::PxSerialFlag::Enum)" (??0?$PxFlags@W4Enum@PxSerialFlag@physx@@G@physx@@QAE@W4Enum@PxSerialFlag@1@@Z) already defined in FreeCamera.obj
1>PhysX3CommonCHECKED_x86.lib(PhysX3CommonCHECKED_x86.dll) : error LNK2005: "public: class physx::PxFlags<enum physx::PxSerialFlag::Enum,unsigned short> & __thiscall physx::PxFlags<enum physx::PxSerialFlag::Enum,unsigned short>::operator&=(class physx::PxFlags<enum physx::PxSerialFlag::Enum,unsigned short> const &)" (??_4?$PxFlags@W4Enum@PxSerialFlag@physx@@G@physx@@QAEAAV01@ABV01@@Z) already defined in FreeCamera.obj
1>PhysX3CommonCHECKED_x86.lib(PhysX3CommonCHECKED_x86.dll) : error LNK2005: "public: __thiscall physx::PxFlags<enum physx::PxSerialFlag::Enum,unsigned short>::PxFlags<enum physx::PxSerialFlag::Enum,unsigned short>(void)" (??0?$PxFlags@W4Enum@PxSerialFlag@physx@@G@physx@@QAE@XZ) already defined in FreeCamera.obj
1>PhysX3CommonCHECKED_x86.lib(PhysX3CommonCHECKED_x86.dll) : error LNK2005: "public: __thiscall physx::PxFlags<enum physx::PxSerialFlag::Enum,unsigned short>::PxFlags<enum physx::PxSerialFlag::Enum,unsigned short>(class physx::PxFlags<enum physx::PxSerialFlag::Enum,unsigned short> const &)" (??0?$PxFlags@W4Enum@PxSerialFlag@physx@@G@physx@@QAE@ABV01@@Z) already defined in FreeCamera.obj
1>PhysX3CommonCHECKED_x86.lib(PhysX3CommonCHECKED_x86.dll) : error LNK2005: "public: __thiscall physx::PxFlags<enum physx::PxSerialFlag::Enum,unsigned short>::operator bool(void)const " (??B?$PxFlags@W4Enum@PxSerialFlag@physx@@G@physx@@QBE_NXZ) already defined in FreeCamera.obj
1>PhysX3CommonCHECKED_x86.lib(PhysX3CommonCHECKED_x86.dll) : error LNK2005: "public: class physx::PxFlags<enum physx::PxSerialFlag::Enum,unsigned short> __thiscall physx::PxFlags<enum physx::PxSerialFlag::Enum,unsigned short>::operator&(enum physx::PxSerialFlag::Enum)const " (??I?$PxFlags@W4Enum@PxSerialFlag@physx@@G@physx@@QBE?AV01@W4Enum@PxSerialFlag@1@@Z) already defined in FreeCamera.obj
1>E:\Tools\game_engine\MyEngine\Engine\Debug\Game.exe : fatal error LNK1169: one or more multiply defined symbols found

I found a single line in my code that cause these errors but the code is true here my code for starting physx:

CPhysxPhysic::CPhysxPhysic(void)
{
	m_Physics=NULL;
	m_Foundation=NULL;

   //static PxDefaultErrorCallback gDefaultErrorCallback;
   //static PxDefaultAllocator gDefaultAllocatorCallback;

   printf("initializing PhysX\n");
 
   printf("creating Foundation\n");
 // create foundation object with default error and allocator callbacks.
   m_Foundation = PxCreateFoundation(PX_PHYSICS_VERSION,gDefaultAllocatorCallback,gDefaultErrorCallback);
 
   printf("creating Physics\n");
   // create Physics object with the created foundation and with a 'default' scale tolerance.
   m_Physics = PxCreatePhysics(PX_PHYSICS_VERSION,*m_Foundation,PxTolerancesScale());

   m_Cooking = PxCreateCooking(PX_PHYSICS_VERSION, *m_Foundation, PxCookingParams());
   if (!m_Cooking)
    printf("PxCreateCooking failed!\n");

   if (!PxInitExtensions(*m_Physics))//This line is the problem!!!
    printf("PxInitExtensions failed!\n");

   m_ProfileZoneManager = &PxProfileZoneManager::createProfileZoneManager(m_Foundation);
	if(!m_ProfileZoneManager)
		printf("PxProfileZoneManager::createProfileZoneManager failed!\n");

	#ifdef PX_WINDOWS
		pxtask::CudaContextManagerDesc cudaContextManagerDesc;
		m_CudaContextManager = pxtask::createCudaContextManager(*m_Foundation, cudaContextManagerDesc, m_ProfileZoneManager);
		if( m_CudaContextManager )
		{
			if( !m_CudaContextManager->contextIsValid() )
			{
				m_CudaContextManager->release();
				m_CudaContextManager = NULL;
			}
		}
#endif



   PxInitVehicleSDK(*m_Physics);
   PxVehicleSetBasisVectors(PxVec3(0,1,0),PxVec3(0,0,1));

  // static PxDefaultSimulationFilterShader gDefaultFilterShader;

   PxSceneDesc sceneDesc(m_Physics->getTolerancesScale());
   sceneDesc.gravity = PxVec3(0.0f, -9.81f, 0.0f);
   // customizeSceneDesc(sceneDesc);

    if(!sceneDesc.cpuDispatcher)
    {
      m_CpuDispatcher = PxDefaultCpuDispatcherCreate(2);
       if(!m_CpuDispatcher)
          printf("PxDefaultCpuDispatcherCreate failed!\n");
       sceneDesc.cpuDispatcher    = m_CpuDispatcher;
    }
    if(!sceneDesc.filterShader)
        sceneDesc.filterShader    = PxDefaultSimulationFilterShader;

    #ifdef PX_WINDOWS
    if(!sceneDesc.gpuDispatcher && m_CudaContextManager)
    {
        sceneDesc.gpuDispatcher = m_CudaContextManager->getGpuDispatcher();
    }
    #endif

    m_Scene = m_Physics->createScene(sceneDesc);
    if (!m_Scene)
        printf("createScene failed!\n");


 
   printf("PhysX initialized\n");
}

If I remove this line I an compile the code:

 if (!PxInitExtensions(*m_Physics))//This line is the problem!!!
    printf("PxInitExtensions failed!\n");

 

Why I got multiply defined symbols?and how should I solve it?

 

EDIT:I solve it my self(after 3 days of testing I finally found the answer 5 minutes after asking here :D).I included <PxPhysicsAPI.h> before any other header file and it solved my problem.
 


forward rendering idea

12 February 2013 - 01:17 AM

Hi

I want to start writing forward rendering pipeline for my deferred engine and I'm looking for efficient way to pass light information to shader.

I have an idea about it.I don't want to pass light info as constant or array so I'm thinking about sending them as textures.

for point lights I need:

 

struct PointLight

{

   COLOR LightColor;

   Vector3 LightPosition;

   float LightRadius;

}

 

It seems I can store this structure in 2 pixel of a texture:

RGB=LightColor;

alpha=LightRadius;

 

RGB=xyz of light position

 

struct SpotLight

{

   COLOR LightColor;

   Vector3 LightPosition;

   float LightRadius;

   float CosAngel;

}

RGB=LightColor;

alpha=LightRadius;

 

RGB=xyz of light position

alpha=CosAngel;

 

so with a texture 128*2 I can pass 128 point light to the shader.

But what is the best way to fill this texture?Should I make a vertex buffer with light info and pass it to a shader to writing in texture or use LockRect and fill the texture on CPU?

 

also I can pack all light info in one texture and use another texture to pass ligh Ids to shader


Bug in my shadow map

05 December 2012 - 02:38 PM

Hi
I'm working on shadow mapping for my Game engine and I have a big problem.It makes me crazy and I can't find it for last week of debugging. Posted Image

The problem is my shadow maps work when objects are fix.But after moving the light or other objects it doesn't work any more.When I want to debug it by PIX it shows the correct image in PIX.Posted Image Also after resetting the device(for device lost)It shows the correct image before moving the light or other objects.After a while this shadow complettly disappears.
It seems vertex shader for deph pass uses incorrect matrix but I can't find the problem.Posted Image
P.S:I'm using deferred shading.
[source lang="cpp"]float4x4 WorldViewProjection;struct VertexShaderInput{ float4 Position : POSITION0; };struct VertexShaderOutput{ float4 Position : POSITION0; float2 Depth : TEXCOORD0;};VertexShaderOutput VertexShaderFunction(VertexShaderInput input){ VertexShaderOutput output; //float4 worldPosition = mul(World,input.Position); //float4x4 worldview = mul(World, View); //worldview = mul(worldview, Projection); //output.Position = mul(input.Position,worldview); output.Position = mul( WorldViewProjection,input.Position); //output.Depth = worldPosition-SpotlightPosition; output.Depth.x = output.Position.z; output.Depth.y = output.Position.w; return output;}struct PixelShaderOutput{ float4 Depth : COLOR0;};PixelShaderOutput PixelShaderFunction(VertexShaderOutput input): COLOR0{ PixelShaderOutput output; //float4 l=input.Depth-SpotlightPosition; //input.Depth/=input.Depth.w; //output.Depth =float4(0,0,0,0); //output Depth output.Depth =input.Depth.x/input.Depth.y; //output Depth return output;}technique buildPass{ pass Pass1 { VertexShader = compile vs_2_0 VertexShaderFunction(); PixelShader = compile ps_2_0 PixelShaderFunction(); }}[/source]




First image is the image befor rotating the car.
Attached File  first.JPG   23.95KB   42 downloads


second image is what I see after rotating the car.
Attached File  second.JPG   45.72KB   37 downloads

Third pic is what I see in PIX
Attached File  pic_from_pix.jpg   61.1KB   31 downloads

PARTNERS