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 

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:
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);

Create a Box 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));

Transform transform = new Transform();

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);


Updating Physics With:
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.
// This ?
Transform trans = new Transform();
float[] openGLMatrix = new float[16];

Vertex Shader:
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
Transform trans = new Transform();
         float[] arr = new float[16];

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.
High res :

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: No registered users 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