elcoo Posted July 6, 2012 Share Posted July 6, 2012 And another thread by me, sorry about that I played around with physics a bit and I got this weird problem in the following code: // ==================================================================== // This file was generated by LEBuilder // http://leadwerks.com/werkspace // ==================================================================== #include "engine.h" #include <iostream> #include <string> #define LW_SSAO const int ScreenWidth = 1024; const int ScreenHeight = 768; const char* MediaDir = "C:/Program Files/Leadwerks Engine SDK"; const char* AppTitle = "LeadwerksTest"; void createPSphere(float,float,float,TMaterial); void ErrOut( const std::string& message ) { std::cerr << message << std::endl; } // ------------------------------- int main( int argn, char* argv[] ) { // Initialize if( !Initialize() ) return 1; SetAppTitle( AppTitle ) ; RegisterAbstractPath( MediaDir ); // Set graphics mode if( !Graphics(ScreenWidth,ScreenHeight) ) { ErrOut( "Failed to set graphics mode." ); return 1; } // Create framework object and set it to a global object so other scripts can access it TFramework fw = CreateFramework(); if( fw == NULL ) { ErrOut( "Failed to initialize engine." ); return 1; } // Set Lua framework object SetGlobalObject( "fw", fw ); // Set Lua framework variable BP lua = GetLuaState(); lua_pushobject( lua, fw ); lua_setglobal( lua, "fw" ); lua_pop( lua, 1 ); // Get framework main camera TCamera camera = GetLayerCamera( GetFrameworkLayer(0) ); PositionEntity( camera, Vec3(2,2,-10) ); // Create cube TMaterial material = LoadMaterial( "abstract::cobblestones.mat" ); Collisions(1,1,1); TMesh mesh2 = CreateSphere(4); PaintEntity( mesh2, material ); TBody body2=CreateBodySphere(); EntityType(body2,1); EntityParent(mesh2,body2); SetBodyMass(body2,1); PositionEntity( body2, Vec3(0.01,10,0) ); SetBodyMassCenter(body2, Vec3(0,0,0)); TMesh mesh = CreateSphere(4); PaintEntity( mesh, material ); TBody body=CreateBodySphere(); EntityType(body,1); EntityParent(mesh,body); SetBodyMass(body,1); PositionEntity( body, Vec3(0,20,0) ); SetBodyMassCenter(body, Vec3(0,0,0)); // Create ground TMesh ground = CreateCube(); ScaleEntity( ground, Vec3(20,1,20) ); PositionEntity( ground, Vec3(0,-1.4,0) ); PaintEntity( ground, material ); body=CreateBodyBox(); ScaleEntity( body, Vec3(20,1,20) ); PositionEntity( body, Vec3(0,-1.4,0) ); EntityType(body,1); SetBodyMass(body,0); // Add some light TLight light = CreateDirectionalLight(); RotateEntity( light, Vec3(45,45,45) ); SetShadowSoftness( light, 50); // DebugPhysics(1); while( !KeyHit() && !AppTerminate() ) { if( !AppSuspended() ) { UpdateFramework(); RenderFramework(); Flip( 0 ); } } return Terminate(); } It's based on the spinning cube template. The problem is, that "body2" with the small offset of 0.01 in the x-coord just falls through the ground. It seems the spheres can only collide with the ground when they are perfectly placed in the middle of it. It works fine when using box-colliders though. What am I doing wrong? Quote Link to comment Share on other sites More sharing options...
elcoo Posted July 6, 2012 Author Share Posted July 6, 2012 Argl, I found the fault. I used ScaleEntity on the ground, instead of initializing it with the right size. It's so typical for me - After trying around for an hour and not finding the error I post a thread about it and immidiatly find the cause Quote Link to comment Share on other sites More sharing options...
Roland Posted July 6, 2012 Share Posted July 6, 2012 Its a very common thing that when you have explained a problem , you will get the answer from you self. We use this method at my work. If I have problems with some programming thing I can go to some other guy and explain my problem, he does not even has to know any details about it. Its just the procedure of explaining that often leads to a solution, without the listener having to say one word. In fact I have many times not even finished my explaining of the problem before coming up with the solution on the problem. So keep on telling us of the problems Quote Roland Strålberg Website: https://rstralberg.com Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.