You can download this code by clicking the button below.
This code is now available for download.
This function creates a cube model with a random position and scale.
Technology Stack : Panda3D, ShowBase, Point3, loadModel
Code Type : Function
Code Difficulty : Intermediate
def create_random_cube(position, scale):
from direct.showbase.ShowBase import ShowBase
from panda3d.core import Point3
from panda3d.core import loadModel
class RandomCubeApp(ShowBase):
def __init__(self):
ShowBase.__init__(self)
self.create_cube(position, scale)
def create_cube(self, position, scale):
cube_model = loadModel("models/cube.egg")
cube_model.reparentTo(self.camera)
cube_model.setPos(position)
cube_model.setScale(scale)
app = RandomCubeApp()
app.run()