[Tutor] Point in polygon intro please~!
Hello, I'm very new to both python and OpenGL, but I'm catching on pretty quick, and trying to make a little game. I'm stuck on being able to do this point-in-polygon test though. Everyone seems to say that I should create a ray and see how many sides of a polygon it intersects, (even vs odd) but I have no idea how to go about setting this up. I'm trying to have a 5-point polygon made from a list of trailing mouse positions (len(mouselist)=5, obviously), and checking to see if a bunch of points in a separate list (len(pointlist)=20) ever fall within the resultant polygon. The lists and program are all setup, but too large to copy here. It all works by itself though, so I just need to find out how to do this test. Any help on how to set something like this up would be extremely appreciated. Thank you very much for your time, ~Mike ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
[Tutor] cylinder texture map?
Hello, You guys gave fantastic advice for my last question about point in polygon testing, thanks. New question; I'd like to make a scrolling background for a game I'm working on. I was thinking, since it's all in orthographic view, that a horizontal cylinder which rotates with a texture would simulate this very well. I've never used textures before, and in all the sample code I see, they have polygons with defined points, so it's very straightforward to see what goes with what... but I don't see how to make the switch over to the glut primitives. Any samples/ insights would be awesome. Thanks a bunch, -Mike ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
[Tutor] move forward in arbitrary direction
Hello, I have what should be a basic math question, but I keep messing it up. How do I code an equation so that when I have an object facing an arbitrary vector, pressing a key will make it move forwards in that direction? (I understand all the key-based setup, it's just the equation for moving in the arbitrary vector direction that's got me stuck) right now i can make something move up and down, or left and right, but if I want to rotate a triangle, then move it so that the 'tip' always points in the direction it's going to move, I get stuck. the thing I have which doesn't work is something like _ vector = [0 0 0] def specialKey(key,x,y): if key == 'up': vector[0] = vector[0] + 1 ___ which I assume should be more like vector = [0 0 0] def specialKey(key,x,y): if key == 'up': vector[0] = vector[0] * math.cos(something???)+ 1 vector[2] = vector[2] * math.sin(something??)+1 -- Any help would be greatly appreciated! ty, Mike ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
[Tutor] changing a variable over simple network (with pyOpenGL)
Hello, I am trying to write a very simple py-opengl program pair causing a variable in each program to be changed by the other. I am able to open a command window in which I manually assign a value to the variable, but I cannot seem to implement the udp/ip information I wish to send into a function which I can call at will. I have tried updating the function through both a cyclic update function, and the keyboard (keyboard is preferred, but I tried eliminating it to see if that was the incompatibility). I do not list any coding for the receiving program, since it works perfectly with the above code, and is probably correct. Currently, the program crashes when I press the assigned key. I can't tell if the issue here is python, or OpenGL, but any help would be very greatly appreciated!!! ##Here is what DOES work: # from socket import * udpsock = socket(AF_INET, SOCK_DGRAM) udpsock.bind(('', 0)) udpsock.connect(('localhost', 4550)) try: while True: s = raw_input('command> ') udpsock.send(s) except EOFError: pass ### #This is what DOES NOT work: ## from socket import * udpsock = socket(AF_INET, SOCK_DGRAM) udpsock.bind(('', 0)) udpsock.connect(('localhost', 4550)) R = 0 def datasender(): global R try: while True: s = input(R) udpsock.send(s) except EOFError: pass def keyboard(key, x, y): ###the keyboard and window OpenGL calls are not mentioned here, but included properly in the program (they work with everything except this) global R if key == 'k': #key is arbitrary, I have also tried with "special keys" as defined by glut R = R + .01 datasender() ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor