how to place objects and gui components in panda3d

hello
i have been reading the manuals and it seems that the objects are positioned in panda 3d by the use of coordinates by the use of code which seems like that would take a allot of trial and error in order to get the objects places correctly in the world and to place the gui components on the screen which seems to have the same problem.I know there is a scene editor but that seems to be much worse.

can anyone tell me how they go about placing the 3d models in panda
thanks

Well, this is how I do it:
For example, I model in Blender.
1 blender unit = 1 panda3d unit.
When I want to place an object in my environment, I check my blender file on what position it must be.

Otherwise, it’s just the scene editor OR just trying out where it must be.

thanks for your quick reply
how do i check the objects position from blender.

I need to have a menu system on the game screen while the game is playing.how do i position the directgui buttons on the screen accuratley.Is there a way of going about it
thanks

You can calculate the position in pixels using the window size, but that’s not recommended.
The best way to position your GUI object is to set the direct-gui-edit option in the Config.prc file to edit your GUI at runtime. Use the middle mouse button to move around widgets, and resize them while holding the control key.
Afterwards, let the program print out the right positions.

Hello,

I am creating an 3D adventure game and what I am doing is to use 

Blender as world editor. I create the game scenes using Blender and, after that, I run a script that exports everything as an ‘.egg file’ and creates
a python file. The python file contains the code for loading the models and
positioning the models into the scene. The scene editor of Panda works in
this way.

Blender can be programmed in Python. So, it is easy to create script for

almost eveything. You can get the API doc from blender.org.

I hope this help you.

Alberto

If I understand your question correctly, you want to know how to correct position objects.

I made a simple ruler that shows me locations relative to the origin.

class Ruler:   
 """this function draws cubes in the x and y directions alternating red,green per one Panda unit. blue every ten units and a blue bar every fifty.""" 
	def __init__(self):
		toggle = 1
		countten = 0
		countfifty = 0
		length = 1250
		for x in range(length):
			cube = loader.loadModelCopy("models/cube.egg")
			cube.setPos(x,0,0)
			toggle = -toggle
			countten += 1
			countfifty += 1
			if toggle == 1: color = Vec4(1,0,0,1)
			else: color = Vec4(0,1,0,1)
			if countten == 10: 
				countten = 0
				color = Vec4(0,0,1,0)
			if countfifty == 50:
				countfifty = 0
				cube.setScale(1,7,1)
				color = Vec4(0,0,1,0)
			cube.setColor(color)
			cube.reparentTo(render)
		toggle = 1
		countten = 0
		countfifty = 0
		for y in range(length):
			cube = loader.loadModelCopy("models/cube.egg")
			cube.setPos(0,-y,0)
			toggle = -toggle
			countten += 1
			countfifty += 1
			if toggle == 1: color = Vec4(1,0,0,1)
			else: color = Vec4(0,1,0,1)
			if countten == 10: 
				countten = 0
				color = Vec4(0,0,1,0)
			if countfifty == 50:
				countfifty = 0
				cube.setScale(7,1,1)
				color = Vec4(0,0,1,0)
			cube.setColor(color)
			cube.reparentTo(render)	

You’ll need a unit cube model. This shouldn’t be too hard to find.

You can call in your main class like this:

measurerod = Ruler()

This helps me a lot to place objects in the scene so I know position, etc.

a warning is that the ruler is pretty graphics intensive if you need a great length I only use it for establishing the scene. Don’t leave it on if you’re not setting up the scene as it will slow it down.