I search terrain generator Compatible with panda3d. I find freeworld3d and EarthSculptor but i don’t know how to export to :.bam ,egg .flt .DXF .dxf .wrl .x. Or how to convert .map or .obj to ^up file type
I don’t know about freeworld3d, but EarthSculptor will export heightfield images. There is an option to export .obj too, and you could use e.g. Blender to convert from .obj to .egg/.bam, but you are probably better of with the heightmap. Search the forum for examples on how to use the heightfield tesselator that comes with Panda3D, or how to create static optimized meshes from a heightfield image.
EarthSculptor is a nice choice. Though, you cannot load EarthSculptor models textured using the detail tool.
You have to use the Color Tool (in earthsculptor) for texturing for it to be compatible with Panda3D.
You can load the terrains using the HeightfieldTesselator class, built-in in Panda3D.
Here’s a little Panda3D terrain script to load an EarthSculptor terrain: (Written by enn0x i think, partially by me)
#!/usr/bin/python import direct.directbase.DirectStart #from direct.showbase.DirectObject import DirectObject from pandac.PandaModules import HeightfieldTesselator from pandac.PandaModules import Filename from pandac.PandaModules import TextureStage from pandac.PandaModules import TexGenAttrib,VBase3 from direct.task.Task import Task def terrainGenerator( ): filename = Filename( 'terrain.png' ) tex = loader.loadTexture( 'terrain_c0.png' ) #NOTE: make sure texture size is the same as the heightmap size!!! texXScale = tex.getXSize() #get texture width texYScale = tex.getYSize() #get texture height x0 = -.5*texXScale #Origin of terrain mesh, panda units y0 = -.5*texYScale #Origin of terrain mesh, panda units texXScale **= -1 #invert xscale texYScale **= -1 #invert yscale fx = 0 # Focal point, pixel units fy = 0 # Focal point, pixel units threshhold = 8 # Threshhold for moving the focal point, pixel units hscale = 1.0 vscale = 36.880001 #mapHeight. read this from the terrain.map file, under mapHeight # Create the tesselator tesselator = HeightfieldTesselator( 'Terrain' ) tesselator.setHeightfield( filename ) tesselator.setHorizontalScale( hscale ) tesselator.setVerticalScale( vscale ) tesselator.setFocalPoint( fx, fy ) # Dummy node for first loop node = tesselator.generate() while 1: x = int( ( x0 - camera.getX( ) ) / -hscale ) y = int( ( y0 - camera.getY( ) ) / hscale ) if abs( x - fx ) > threshhold or abs( y - fy ) > threshhold: fx = x fy = y tesselator.setFocalPoint( fx, fy ) yield( ) node.removeNode( ) node = tesselator.generate( ) node.setTexGen( TextureStage.getDefault( ), TexGenAttrib.MWorldPosition ) node.setTexScale( TextureStage.getDefault( ), texXScale, texYScale ) node.setTexOffset( TextureStage.getDefault( ), 0.5, 0.5 ) node.setTexture( tex ) node.reparentTo( render ) node.setPos( x0, y0, 0 ) yield( ) yield( ) yield( ) yield( ) yield( ) class app(DirectObject.DirectObject): def __init__( self ): # Input self.accept( 'escape', self.exit ) self.accept( '1', self.toggleWireframe ) self.accept( '2', self.toggleTexture ) self.accept( '3', self.screenshot ) # Base setup base.setBackgroundColor( 0, 0, 0 ) # Terrain self.terrain = terrainGenerator( ) self.terrain.next( ) # Tasks taskMgr.add( self.move, 'moveTask' ) def move( self, task ): self.terrain.next( ) return Task.cont def exit( self ): sys.exit( ) def toggleWireframe( self ): base.toggleWireframe( ) def toggleTexture( self ): base.toggleTexture( ) def screenshot( self ): base.screenshot( 'screenshot' ) w = app( ) run( )
In this code you need to change one thing. Load the .map file of your ES terrain with a texteditor, scroll a bit down and you will see MapHeight. Write down that value.
In this script, you will see the line:
vscale = 36.880001
Change that to the MapHeight value.
DirectStart: Starting the game. Warning: DirectNotify: category 'Interval' already exists Known pipe types: wglGraphicsPipe (3 aux display modules not yet loaded.) :display:gsg:glgsg(warning): BlendEquation advertised as supported by OpenGL runtime, but could not get pointers to extension function. :display:gsg:glgsg(warning): BlendColor advertised as supported by OpenGL runtime, but could not get pointers to extension function. :util(warning): Adjusting global clock's real time by 2.06102 seconds. Traceback (most recent call last): File "view.py", line 67, in ? class app(DirectObject.DirectObject): AttributeError: class DirectObject has no attribute 'DirectObject' **** End of process output ****
I delete “#” in this code line" #from direct.showbase.DirectObject import "DirectObject
Pudget Sound seems to be very popular
You can use either this…
from direct.showbase.DirectObject import DirectObject class Foo( DirectObject ):
import direct.showbase.DirectObject class Foo( DirectObject.DirectObject ):
…but mixing isn’t possible. For an explanation have a look at the Python manuals, especially information about namespaces.
Sorry but i don’t understand you.
#!/usr/bin/python import direct.directbase.DirectStart from direct.showbase.DirectObject import DirectObject class Foo( DirectObject ): from pandac.PandaModules import HeightfieldTesselator from pandac.PandaModules import Filename from pandac.PandaModules import TextureStage from pandac.PandaModules import TexGenAttrib,VBase3 from direct.task.Task import Task ....
File “view.py”, line 6
from pandac.PandaModules import HeightfieldTesselator
Can somone send working script to sendspace.com?
Those lines I posted are not meant to be “copy and paste”-ed to the script that pro-rsoft has posted. They are meant to show you a pattern.
I don’t think a “working script” will help you. Panda3D is not a click-and-drag game builder. Panda3D offers a Python API, and you have to write Python code to use Panda3D. So, in order to use Panda3D, you have to be able to code in Python.
Python is one of the most easy languages I ever have seen, and learning Python is not hard. Still, you have to learn. About 2 hours if you already have done some other coding before will get you started. And after one or two weeks you will feel comfortable with Python.
The script from above contains at least one advanced Python feature, a generator pattern. Don’t expect to be able to use such coding patterns without spending at least two weeks on learning Python.
For learning Python you should do the following:
1.) read the Python tutorial: http://docs.python.org/tut/tut.html
2.) write some small (console) applications and modules
3.) modify simple Python code.
Now it is time to start playing around with Panda3D:
4.) read the Panda3D tutorials.
5.) modify the Panda3D tutorials.
I know this answer sucks, but look at it this way: if you don’t know how to wield a hammer you will never be able to forge a sword. And Panda3D is a mighty and complex tool.
Ok my run mi script but i don’t see terrain, do you know why? I change mapHeight.
When i try turn map i see in console
Terrain mesh is 0 triangles. Terrain mesh is 0 triangles. Terrain mesh is 0 triangles. Terrain mesh is 0 triangles. Terrain mesh is 0 triangles.
That can mean one of the following things:
-The camera is not near the terrain. The closer you get to the terrain, the value gets more.
-It failed to load the heightmap. check for another error.
I urge caution with earthsculptor, even thougth Ive mentioned its use myself, as it definitely is buggy at least on my system.
It is a nice app, but somehow dont ask me how,eventually it messes up , and due to how the author displays the UI buttons, they in time turn black, with underlying bits of white on them…its rather annoying so I just thought I"d make you aware. It is one of the nicest ones out there, is free but atm its ‘beta’ quality. OThers may n ot experience this, but I thought I’d offer this as a warning, since its also something showing up on their forum page.
It’s a shame we can’t do all this in blender and just export via chicken , that or in the SceneEditor, though someday I hope to make at least the latre doable . ( panda makes it possible , I just need time to look into it )