3d engine help. What did I do wrong?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • raubana
    New Member
    • Feb 2008
    • 55

    3d engine help. What did I do wrong?

    I made a simple 3d engine with python, but it's slow, intersections don't show, and faces dissapear when your at a certian place. Here's the link:

    MediaFire is a simple to use free service that lets you put all your photos, documents, music, and video in a single place so you can access them anywhere and share them everywhere.


    If you can tell me how to make a better one, please do!
  • raubana
    New Member
    • Feb 2008
    • 55

    #2
    3d engine help. What did I do wrong?

    I made the first one in the "Python" forum, so I decided to put a local call for help out. Here's the link:



    PLEASE HELP!

    Comment

    • Stang02GT
      Recognized Expert Top Contributor
      • Jun 2007
      • 1206

      #3
      Well 1st of all. If you posted a question and it hasn't been answered in the correct thread, please do not go and start posting it other places. It's not going to get you an answer faster. You have enough posts and seem to have been here long enough that you should have read the posting guidelines and saw that you shouldn't double post questions.

      In case you don't know where the POSTING GUIDELINES are i have posted the link.


      Secondly, when i looked at your post in the other forum, you only posted it yesterday. Give it time for someone to look at. Please do not go around posting things like this to draw attention to your question. When our experts have time to look at it they will. Give it sometime.


      Thank You.

      Comment

      • raubana
        New Member
        • Feb 2008
        • 55

        #4
        ............... ............... ........okay.

        Comment

        • RedSon
          Recognized Expert Expert
          • Jan 2007
          • 4980

          #5
          Originally posted by raubana
          I made a simple 3d engine with python, but it's slow, intersections don't show, and faces dissapear when your at a certian place. Here's the link:

          http://www.mediafire.c om/?dggmjfnfts0

          If you can tell me how to make a better one, please do!
          It would be better for you to try to identify the problem yourself or at least narrow it down and then post the relavent code for us to look at.

          You arn't getting any help because people are not interested in downloading some random files from someone who they don't know and then go through it line by line telling you how to make it better. It is up to you to make it better, or you can join a site like sf.net and start a project then recruit people to help you. We are here to troubleshoot problems and help you solve specific issues.

          Comment

          • RedSon
            Recognized Expert Expert
            • Jan 2007
            • 4980

            #6
            Also, I moved your post from Misc forum and merged it into this one. Please pay attention to Stang02GT's post. Further issues regarding your ignorance of the posting guidelines will be met more harshly then with warnings.

            Comment

            • raubana
              New Member
              • Feb 2008
              • 55

              #7
              Yes, I know. I already got in a little trouble.
              (I still don't know how I missed that...)

              The fact is I have now way of showing you the code cause I'm on an old computer. I have to go to my school, plug in a flashdrive, then upload a file, but the only way I can do that is if I'm on a newer computer.

              Also, if you are too afraid to download the file, that's fine. But I make a strong promise that it will cause your computer no harm.

              Comment

              • RedSon
                Recognized Expert Expert
                • Jan 2007
                • 4980

                #8
                Originally posted by raubana
                Yes, I know. I already got in a little trouble.
                (I still don't know how I missed that...)

                The fact is I have now way of showing you the code cause I'm on an old computer. I have to go to my school, plug in a flashdrive, then upload a file, but the only way I can do that is if I'm on a newer computer.

                Also, if you are too afraid to download the file, that's fine. But I make a strong promise that it will cause your computer no harm.
                What do you mean you can't show the code? You already put it online, just download it to any computer you want. Then you can post the code in this forum or if you don't want to do that you can use something like http://pastebin.ca/ and post it there.

                I'm afraid I don't see what the problem is. Also for future reference, no matter how strong your promise is, doesn't mean I'm going to trust you any more then I did previously.

                Comment

                • raubana
                  New Member
                  • Feb 2008
                  • 55

                  #9
                  I guess you right. My explination didn't make much sense. Let me try again:

                  (1) I don't have internet at home so I have to plug in a flash drive into my computer and put my files on it

                  (2) I then go to my school to upload my files onto mediafire.com. The only time I can do this is when one of my classes is in a computer lab because the computer lab has new Dell computers, not crapy old macs (like the one I'm on right now)

                  (3) This crappy computer cannot handle flashdrives, and even though I can access this computer any time I want, I cannot get to the newer ones when ever I want.

                  (4) The schools computers block many things (websites, files, etc.), one of those things is downloading and uploading. This specific problem isn't built into the new computers, just the old ones, so I can't just download the files and show it to you.

                  There, I think that sums it up. So you see, the only way you could help me is if you downloaded the file. Sorry.

                  Comment

                  • raubana
                    New Member
                    • Feb 2008
                    • 55

                    #10
                    Hey! And isn't mediafire.com a protected website? ...yeah! It scans for possable viruses so you don't get infected!

                    Comment

                    • RedSon
                      Recognized Expert Expert
                      • Jan 2007
                      • 4980

                      #11
                      Originally posted by raubana
                      Hey! And isn't mediafire.com a protected website? ...yeah! It scans for possable viruses so you don't get infected!
                      The thing about virus's is the fact that a virus first has to be seen in the wild and a signature has to be made for it, it doesn't do heuristic scanning very well. Furthermore a text file (a .py) is considered low risk because it is not an executable and you cannot embed executable code in it.

                      I'll see if someone might be willing to look at it but don't get your hopes up.

                      Comment

                      • Atli
                        Recognized Expert Expert
                        • Nov 2006
                        • 5062

                        #12
                        Seeing as the OP is having technical difficulties, let me just help out by posting his code here where everybody can see it.
                        Not knowing the first thing about python, I'll just post the whole thing.
                        Good luck :P
                        [code=python]
                        import pygame
                        from pygame.locals import*
                        import math
                        import random
                        import time

                        pygame.init()

                        size = [800,400]
                        screen = pygame.display. set_mode(size)

                        def rotate_point(po int, center, rotation):
                        import math
                        info= [math.sqrt( (point[0]-center[0])**2+ (point[1]-center[1])**2 ), math.atan( (point[1]-center[1])/(point[0]-center[0]) ) ]

                        info[1]+=math.radians( rotation)
                        if info[1]>math.pi*2: info[1]-=math.pi*2

                        return[math.cos(info[1])*info[0]+center[0],math.sin(info[1])*info[0]+center[1]]

                        class Face(object):
                        def __init__(self, face_vectors, color):
                        self.shape = face_vectors
                        self.color = color
                        def update(self, camera, cam_range, rotation):
                        p = []
                        min_magn = camera[2]-self.shape[0][2]
                        for point in self.shape:

                        rot_points=rota te_point([point[0],point[2]],[camera[0],camera[2]],rotation[1])
                        cam_view = [ camera[0]-rot_points[0], camera[1]-point[1], camera[2]-rot_points[1]]

                        presp_view = get_3d_view(cam _view, camera_range)

                        presp_view[0]+=screen.get_wi dth()/2
                        presp_view[1]+=screen.get_he ight()/2


                        p.append(presp_ view)
                        if cam_view[2]<min_magn:
                        min_magn = cam_view[2]

                        self.threedshap e = p
                        self.closest = min_magn

                        def render(self, screen, disappear_dista nce):
                        min_magn = self.closest
                        if min_magn>0.1:
                        red = int(min(abs(dis appear_distance/float(min_magn) *self.color[0]),self.color[0]))
                        green = int(min(abs(dis appear_distance/float(min_magn) *self.color[1]),self.color[1]))
                        blue = int(min(abs(dis appear_distance/float(min_magn) *self.color[2]),self.color[2]))
                        pygame.draw.pol ygon(screen, [red,green,blue], self.threedshap e)

                        def Face_closest(fa ces):
                        return faces.closest

                        def get_3d_view(vec tor, d):
                        x,y,z=vector
                        return [-int(x*float(d)/z), int(y*float(d)/z)]




                        camera_range = 900
                        disappear_dista nce=100
                        cam_speed = 0.1
                        res = 100
                        rot_speed = 1

                        camera =[ 1.0001,1.0001,1 0.0001 ]

                        faces = [ Face( [ [15.,0.,15.], [15.,1.,15.], [16.,1.,15.], [16.,0.,15.] ], [255,255,255]) ]

                        rotate = [0.0001,0.0001,0 .0001]


                        while True:
                        print rotate
                        while rotate[1]>360:
                        rotate[1]-=360
                        while rotate[1]<0:
                        rotate[1]+=360

                        keys = pygame.key.get_ pressed()

                        if keys[K_DOWN]:
                        camera[2]-=math.cos(math. radians(rotate[1]))*cam_speed
                        camera[0]-=math.sin(math. radians(rotate[1]))*cam_speed
                        elif keys[K_UP]:
                        camera[2]+=math.cos(math .radians(rotate[1]))*cam_speed
                        camera[0]+=math.sin(math .radians(rotate[1]))*cam_speed

                        if keys[K_LEFT]:
                        rotate[1]+=rot_speed
                        elif keys[K_RIGHT]:
                        rotate[1]-=rot_speed

                        if keys[K_q]:
                        camera[1]+=cam_speed
                        elif keys[K_a]:
                        camera[1]-=cam_speed

                        for face in faces:
                        face.update(cam era, camera_range, rotate)
                        faces.sort(key= Face_closest, reverse=True)
                        for face in faces:
                        face.render(scr een, disappear_dista nce)


                        pygame.draw.rec t(screen, [0,0,255], [camera[0],camera[2],0,0])
                        pygame.display. update()
                        screen.fill([0,0,0])

                        # === ANTI-CRASH ===
                        for event in pygame.event.ge t():
                        if event.type == QUIT or keys[K_ESCAPE]:
                        pygame.quit(); sys.exit()
                        [/code]

                        Comment

                        • raubana
                          New Member
                          • Feb 2008
                          • 55

                          #13
                          Yep! That's my code! Thanks a ton, man!

                          My typing is very messy and I might have spelling errors everywhere. I also should have put notes in everyplace, but...you know.

                          Once again, thanks a lot!

                          Comment

                          • jlm699
                            Contributor
                            • Jul 2007
                            • 314

                            #14
                            I don't get it. When I run this all I get is a black screen with a blue pixel that I can move around with the arrow keys. Occasionally there is a white rectangle that will zoom by in the background.

                            Is this what the problem is? Or am I missing something?

                            Comment

                            • raubana
                              New Member
                              • Feb 2008
                              • 55

                              #15
                              Yes, that's the problem.

                              OH! the dot is like a map thing that shows where your at and you start out with the face behind you. To see it, movge untill the dot is still visable and is diaganal to the corner it starts at. Then turn to see the face.

                              Comment

                              Working...