मैं सीखने की कोशिश कर रहा हूं कि जिस परियोजना पर मैं काम कर रहा हूं उसमें जेबलेट का उपयोग कैसे किया जाए और मैंने उस डेमो की समीक्षा की है जो स्रोत प्रदान करता है लेकिन मैं यह नहीं समझ सकता कि इन डेमो वस्तुओं को कैसे प्रदर्शित करते हैं। क्या किसी के पास कोई अच्छा संसाधन है, वे मुझे इंगित कर सकते हैं या एक मूल उदाहरण प्रदान कर सकते हैं जो स्क्रीन पर एक या दो ऑब्जेक्ट प्रदर्शित करता है?jBullet उदाहरण
अग्रिम धन्यवाद, मुझे खेद है कि मेरे पास दिखाने के लिए कोई कोड नहीं है, यदि आवश्यक हो तो मैं जल्दी से कुछ लिख सकता हूं लेकिन वास्तव में जाने के लिए एक दिशा की तलाश कर रहा हूं।
आप घन कि मैं उपयोग कर रहा हूँ के लिए धन्यवाद,
कोड, तो मैं यह करने के लिए टक्कर जोड़ने की कोशिश कर रहा हूँ, लेकिन मैं अनिश्चित हूं कैसे jbullet का उपयोग कर:
public void Draw() {
// center point posX, posY, posZ
float radius = size/2;
//top
glPushMatrix();
glBegin(GL_QUADS);
{
glColor3f(1.0f,0.0f,0.0f); // red
glVertex3f(posX + radius, posY + radius, posZ - radius);
glVertex3f(posX - radius, posY + radius, posZ - radius);
glVertex3f(posX - radius, posY + radius, posZ + radius);
glVertex3f(posX + radius, posY + radius, posZ + radius);
}
glEnd();
glPopMatrix();
//bottom
glPushMatrix();
glBegin(GL_QUADS);
{
glColor3f(1.0f,1.0f,0.0f); // ?? color
glVertex3f(posX + radius, posY - radius, posZ + radius);
glVertex3f(posX - radius, posY - radius, posZ + radius);
glVertex3f(posX - radius, posY - radius, posZ - radius);
glVertex3f(posX + radius, posY - radius, posZ - radius);
}
glEnd();
glPopMatrix();
//right side
glPushMatrix();
glBegin(GL_QUADS);
{
glColor3f(1.0f,0.0f,1.0f); // ?? color
glVertex3f(posX + radius, posY + radius, posZ + radius);
glVertex3f(posX + radius, posY - radius, posZ + radius);
glVertex3f(posX + radius, posY - radius, posZ - radius);
glVertex3f(posX + radius, posY + radius, posZ - radius);
}
glEnd();
glPopMatrix();
//left side
glPushMatrix();
glBegin(GL_QUADS);
{
glColor3f(0.0f,1.0f,1.0f); // ?? color
glVertex3f(posX - radius, posY + radius, posZ - radius);
glVertex3f(posX - radius, posY - radius, posZ - radius);
glVertex3f(posX - radius, posY - radius, posZ + radius);
glVertex3f(posX - radius, posY + radius, posZ + radius);
}
glEnd();
glPopMatrix();
//front side
glPushMatrix();
glBegin(GL_QUADS);
{
glColor3f(0.0f,0.0f,1.0f); //blue
glVertex3f(posX + radius, posY + radius, posZ + radius);
glVertex3f(posX - radius, posY + radius, posZ + radius);
glVertex3f(posX - radius, posY - radius, posZ + radius);
glVertex3f(posX + radius, posY - radius, posZ + radius);
}
glEnd();
glPopMatrix();
//back side
glPushMatrix();
glBegin(GL_QUADS);
{
glColor3f(0.0f,1.0f,0.0f); // green
glVertex3f(posX + radius, posY - radius, posZ - radius);
glVertex3f(posX - radius, posY - radius, posZ - radius);
glVertex3f(posX - radius, posY + radius, posZ - radius);
glVertex3f(posX + radius, posY + radius, posZ - radius);
}
glEnd();
glPopMatrix();
}
यहाँ मेरी परिवर्तित कोड है हैलो वर्ल्ड टेस्ट कोड से, क्या यह हर किसी के लिए सही दिखता है? :
public static void HelloWorld() {
BroadphaseInterface broadphase = new DbvtBroadphase();
DefaultCollisionConfiguration collisionConfiguration = new DefaultCollisionConfiguration();
CollisionDispatcher dispatcher = new CollisionDispatcher(collisionConfiguration);
SequentialImpulseConstraintSolver solver = new SequentialImpulseConstraintSolver();
DiscreteDynamicsWorld dynamicsWorld = new DiscreteDynamicsWorld(dispatcher, broadphase, solver, collisionConfiguration);
// set the gravity of our world
dynamicsWorld.setGravity(new Vector3f(0, -10, 0));
// setup our collision shapes
CollisionShape groundShape = new StaticPlaneShape(new Vector3f(0, 1, 0), 1);
CollisionShape fallShape = new SphereShape(1);
// setup the motion state
DefaultMotionState groundMotionState = new DefaultMotionState(new Transform(new Matrix4f(new Quat4f(0, 0, 0, 1), new Vector3f(0, -1, 0), 1.0f)));
RigidBodyConstructionInfo groundRigidBodyCI = new RigidBodyConstructionInfo(0, groundMotionState, groundShape, new Vector3f(0,0,0));
RigidBody groundRigidBody = new RigidBody(groundRigidBodyCI);
dynamicsWorld.addRigidBody(groundRigidBody); // add our ground to the dynamic world..
// setup the motion state for the ball
DefaultMotionState fallMotionState = new DefaultMotionState(new Transform(new Matrix4f(new Quat4f(0, 0, 0, 1), new Vector3f(0, 50, 0), 1.0f)));
//This we're going to give mass so it responds to gravity
int mass = 1;
Vector3f fallInertia = new Vector3f(0,0,0);
fallShape.calculateLocalInertia(mass,fallInertia);
RigidBodyConstructionInfo fallRigidBodyCI = new RigidBodyConstructionInfo(mass,fallMotionState,fallShape,fallInertia);
RigidBody fallRigidBody = new RigidBody(fallRigidBodyCI);
//now we add it to our physics simulation
dynamicsWorld.addRigidBody(fallRigidBody);
for (int i=0 ; i<300 ; i++) {
dynamicsWorld.stepSimulation(1/60.f, 10);
Transform trans = new Transform();
fallRigidBody.getMotionState().getWorldTransform(trans);
System.out.println("sphere height: " + trans.origin.y);
}
}
शायद आप क़ौम आप पर देख रहे थे करने के लिए लिंक कर सकते हैं? – theJollySin
मैं लाइब्रेरी के साथ शामिल डेमो को देख रहा था, मुझे खेद है, लेकिन उन्होंने उन्हें लिंक नहीं किया है। मैं कोड पोस्ट करूंगा लेकिन इसे कई क्लास फाइलों में विभाजित किया जाएगा, और यहां पर बोझिल होगा।मैं बुलेट ट्यूटोरियल देख रहा हूं, लेकिन वे वास्तव में जेबलेट के लिए अच्छी तरह से लागू नहीं होते हैं क्योंकि फ़ंक्शन नाम अलग हैं: http://bulletphysics.org/mediawiki-1.5.8/index.php/Hello_World – Kenneth
यदि आप बात कर रहे हैं स्क्रीन पर भौतिकी डीबग जानकारी प्रदर्शित करने के बारे में आपको अपनी 'आईडीबग ड्रा' कक्षा को लागू करने की आवश्यकता होगी। यदि आप उन वस्तुओं को चित्रित करने के बारे में बात कर रहे हैं जिन्हें आप भौतिकी द्वारा नियंत्रित करना चाहते हैं, तो आप भौतिकी लाइब्रेरी के बिना भी इसमें शामिल होते हैं। जेबलेट का उपयोग सिर्फ अपनी वस्तुओं के भौतिकी को नियंत्रित करने के लिए किया जाना चाहिए, यानी उन्हें चारों ओर ले जाना और एक-दूसरे के साथ टकराने देना चाहिए। अपने मॉडल या वस्तुओं को चित्रित करना आपके कोड द्वारा किया जाना चाहिए। यदि आप परिभाषित करते हैं कि आप क्या करने की कोशिश कर रहे हैं, तो मैं इसे कैसे करना है इसका उत्तर दूंगा। – MichaelHouse