#1
|
|||
|
|||
About intersect function
Hi Everyone,
I have a question about the intersect function. I have an InfiniteTerrain object and since it's not flat, I want to find the y coordinate of a point at the InfiniteTerrain. I do the following and I always get 0: Code:
x = SOME_X z = SOME_Z hillLevel = 6 terrain = viz.add('InfiniteTerrain.dlc',1,'456',hillLevel,6,15000,0.0005) intersection = terrain.intersect([x,100,z],[x,-100,z], True, viz.ABS_GLOBAL) for p in intersection: print p.point [SOME_X, 0.0, SOME_Z] But I think it shouldn't be 0.0. Am I missing something? Best, Omid |
#2
|
|||
|
|||
Unfortunately the current version of the InfiniteTerrain plugin does not work with the intersect function. If you were to supply your own terrain generation function to the plugin, then you would be able to determine the height of the terrain at any given (x,z) coordinate. Here is a sample script showing how to use your own function to generate the terrain:
Code:
import viz import math viz.go() #Add a skybox sky = viz.add('skydome.dlc') env = viz.add(viz.ENVIRONMENT_MAP,'sky.jpg') sky.texture(env) sky.disable(viz.FOG) grass = viz.add('grass.jpg') #Need to set texture mode to repeat for terrain texture grass.wrap(viz.WRAP_S,viz.REPEAT) grass.wrap(viz.WRAP_T,viz.REPEAT) # Initialize random number generator with string '456' # Set tesselation level to 7 (default is 6) Smaller value means less detail, faster rendering # Set texture repeat level to 6 (default is 4) # Set viewing distance to 15000 (default is 4096) # Set LOD factor to 0.0005 (default is 0.001) Smaller numbers mean LOD changes further away, # (i.e 'popping' will be less noticeable) #terrain = viz.add('InfiniteTerrain.dlc',1,'456',7,6,15000,0.0005) terrain = viz.add('InfiniteTerrain.dlc',1,'456',4,4,15000,0.0001) terrain.texture(grass) #Set heightscale1 to 150 #Set heightscale2 to 5 #Height scales are used for generating terrain height #Formula = heightscale1 * random() + heightscale2 * random(); terrain.command(1,'',150,5) # Large a, steep curve # http://astronomy.swin.edu.au/~pbourke/analysis/sigmoid/ def sigmoid(x, a): y = 1.0 / ( 1 + math.exp(-a * x)) return y def sumsines(theta, periods): sum = 0.0 for p in periods: sum += math.sin(theta/p) return sum p1 = [500, 1000] p2 = [500, 1000] def terrainfunc(x,z): #Input: x,z position of terrain #Output: height of terrain at that position height = (sumsines(x,p1) + sumsines(z,p2) +5) * 100 distance = abs(x - math.sin(z/1500)*850) weight = sigmoid(distance - 800, .006) return height * weight #Use the python function 'terrainfunc' instead of builtin random height generator terrain.command(3,'terrainfunc') #Hide ground plane terrain.command(5) #Create fog viz.fogcolor(0.784,0.867,0.941) viz.fog(0.00007,-1) #Create static lighting light = viz.add(viz.LIGHT) light.position(-0.5,0.4,0.5,0) light.enable() viz.get(viz.HEAD_LIGHT).disable() #Crank up sensitivity viz.sensitivity(1000,1) |
#3
|
|||
|
|||
Thanks for the reply
Thanks a lot for the reply. I wonder why all the advanced commands are not documented in the manual, while they look quite useful in certain situations.
Best, Omid |
#4
|
|||
|
|||
Collisions with InfiniteTerrain
I also noticed that collisions with InfiniteTerrain are not handled automatically. Is it true? This is the code that I used to enable collisions:
Code:
view = viz.add(viz.VIEWPOINT) view.collision(viz.ON) view.collisionbuffer(1) Best Regards, Omid |
#5
|
|||
|
|||
It looks like you'll have to handle it manually. Have you had any success creating the code to do that?
|
#6
|
|||
|
|||
I haven't tried yet but I'll post if I managed to do that.
|
Thread Tools | |
Display Modes | Rate This Thread |
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Documentating function names | aaThomas | Vizard | 5 | 05-15-2007 09:50 AM |
Do you know how to send a value for 'pool' to the onActionEnd function? | ghazanfar | Vizard | 1 | 03-22-2007 10:25 AM |
timers and director function | Jerry | Vizard | 1 | 06-22-2006 09:47 AM |
node3d.center function | tavaksai | Vizard | 3 | 08-13-2004 11:05 AM |
walkTo function | poolshark | Vizard | 4 | 10-09-2003 12:45 PM |