Physics Simulation Forum

 

All times are UTC




Post new topic Reply to topic  [ 1 post ] 
Author Message
 Post subject: Stuck with rendering
PostPosted: Fri May 19, 2017 10:29 am 
Offline

Joined: Fri May 19, 2017 10:00 am
Posts: 1
I am trying to render my game objects with shaders using lwjgl and jbullet. But i am stuck with transforming vertices.

My Bullet Configs:
Code:
collisionShapes = new ObjectArrayList<CollisionShape>();
collisionConfiguration = new DefaultCollisionConfiguration();
dispatcher = new CollisionDispatcher(collisionConfiguration);
overlappingPairCache = new AxisSweep3(worldAabbMin, worldAabbMax, maxProxies);
solver = new SequentialImpulseConstraintSolver();
dynamicsWorld = new DiscreteDynamicsWorld(dispatcher, overlappingPairCache, solver, collisionConfiguration);
dynamicsWorld.setGravity(gravity);


Create a Box Code:
Code:
// Game Object
this.position = postion;
this.rotation = rotation;
this.scale = scale;
this.mass = mass;

// Physics Object
CollisionShape shape = new BoxShape(new Vector3f(entity.getScale().x, entity.getScale().y, entity.getScale().z));
collisionShapes.add(shape);

Transform transform = new Transform();
transform.setIdentity();

boolean isDynamic = (entity.getMass() != 0f);
Vector3f localInertia = new Vector3f(0, 0, 0);
if (isDynamic)
   shape.calculateLocalInertia(entity.getMass(), localInertia);

transform.origin.set(new Vector3f(entity.getPosition().x, entity.getPosition().y, entity.getPosition().z));

DefaultMotionState myMotionState = new DefaultMotionState(transform);
RigidBodyConstructionInfo rbInfo = new RigidBodyConstructionInfo(entity.getMass(), myMotionState, shape, localInertia);
RigidBody body = new RigidBody(rbInfo);

dynamicsWorld.addRigidBody(body);


Updating Physics With:
Code:
dynamicsWorld.stepSimulation(1.f / 60.f, 10);


Im stuck here. What should i load to shaders ? I have a cube vertice map. Im trying with it and it isnt work.
Code:
// This ?
Transform trans = new Transform();
body.getMotionState().getWorldTransform(trans);
float[] openGLMatrix = new float[16];
trans.getOpenGLMatrix(openGLMatrix);
//



Vertex Shader:
Code:
in vec3 position;

uniform mat4 projectionMatrix;
uniform mat4 viewMatrix;
uniform mat4 transformationMatrix;

void main(void){
   vec4 worldPosition = transformationMatrix * vec4(position, 1.0);
   gl_Position = projectionMatrix * viewMatrix * worldPosition;
}


Situation Summary:
Im very confused what to do with this transform data. Tryed everything but nothing worked. A picture of current system
Currently doing
Code:
Transform trans = new Transform();
         e.getRigidBody().getMotionState().getWorldTransform(trans);
         float[] arr = new float[16];
         trans.getOpenGLMatrix(arr);
         
         entityShader.loadTransformationFloat(arr);

Ground = pos(0,-56,0) scale(50,50,50)
Boxes = pos(cam) scale(1,1,1)
Most Right Box ground but not scaling in shaders. Dont know why.
Image
High res : https://ibb.co/neOmXa


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 1 post ] 

All times are UTC


Who is online

Users browsing this forum: Bing [Bot] and 21 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group