473,385 Members | 1,372 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

3d engine help. What did I do wrong?

raubana
56
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.com/?dggmjfnfts0

If you can tell me how to make a better one, please do!
Apr 29 '08 #1
14 1739
raubana
56
I made the first one in the "Python" forum, so I decided to put a local call for help out. Here's the link:

http://bytes.com/forum/thread795115.html

PLEASE HELP!
Apr 30 '08 #2
Stang02GT
1,208 Expert 1GB
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.
Apr 30 '08 #3
raubana
56
......................................okay.
May 2 '08 #4
RedSon
5,000 Expert 4TB
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.com/?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.
May 2 '08 #5
RedSon
5,000 Expert 4TB
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.
May 2 '08 #6
raubana
56
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.
May 5 '08 #7
RedSon
5,000 Expert 4TB
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.
May 5 '08 #8
raubana
56
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.
May 6 '08 #9
raubana
56
Hey! And isn't mediafire.com a protected website? ...yeah! It scans for possable viruses so you don't get infected!
May 6 '08 #10
RedSon
5,000 Expert 4TB
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.
May 6 '08 #11
Atli
5,058 Expert 4TB
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
Expand|Select|Wrap|Line Numbers
  1. import pygame
  2. from pygame.locals import*
  3. import math
  4. import random
  5. import time
  6.  
  7. pygame.init()
  8.  
  9. size = [800,400]
  10. screen = pygame.display.set_mode(size)
  11.  
  12. def rotate_point(point, center, rotation):
  13.     import math
  14.     info= [math.sqrt(  (point[0]-center[0])**2+ (point[1]-center[1])**2 ), math.atan( (point[1]-center[1])/(point[0]-center[0]) ) ]
  15.  
  16.     info[1]+=math.radians(rotation)
  17.     if info[1]>math.pi*2: info[1]-=math.pi*2
  18.  
  19.     return[math.cos(info[1])*info[0]+center[0],math.sin(info[1])*info[0]+center[1]]
  20.  
  21. class Face(object):
  22.     def __init__(self, face_vectors, color):
  23.         self.shape = face_vectors
  24.         self.color = color
  25.     def update(self, camera, cam_range, rotation):
  26.         p = []
  27.         min_magn = camera[2]-self.shape[0][2]
  28.         for point in self.shape:
  29.  
  30.             rot_points=rotate_point([point[0],point[2]],[camera[0],camera[2]],rotation[1])
  31.             cam_view = [ camera[0]-rot_points[0], camera[1]-point[1], camera[2]-rot_points[1]]
  32.  
  33.             presp_view = get_3d_view(cam_view, camera_range)
  34.  
  35.             presp_view[0]+=screen.get_width()/2
  36.             presp_view[1]+=screen.get_height()/2
  37.  
  38.  
  39.             p.append(presp_view)
  40.             if cam_view[2]<min_magn:
  41.                 min_magn = cam_view[2]
  42.  
  43.         self.threedshape = p
  44.         self.closest = min_magn
  45.  
  46.     def render(self, screen, disappear_distance):
  47.         min_magn = self.closest
  48.         if min_magn>0.1:
  49.             red = int(min(abs(disappear_distance/float(min_magn)*self.color[0]),self.color[0]))
  50.             green = int(min(abs(disappear_distance/float(min_magn)*self.color[1]),self.color[1]))
  51.             blue = int(min(abs(disappear_distance/float(min_magn)*self.color[2]),self.color[2]))
  52.             pygame.draw.polygon(screen, [red,green,blue], self.threedshape)
  53.  
  54. def Face_closest(faces):
  55.     return faces.closest
  56.  
  57. def get_3d_view(vector, d):
  58.     x,y,z=vector
  59.     return [-int(x*float(d)/z), int(y*float(d)/z)]
  60.  
  61.  
  62.  
  63.  
  64. camera_range = 900
  65. disappear_distance=100
  66. cam_speed = 0.1
  67. res = 100
  68. rot_speed = 1
  69.  
  70. camera =[ 1.0001,1.0001,10.0001 ]
  71.  
  72. faces = [ Face(  [  [15.,0.,15.], [15.,1.,15.], [16.,1.,15.], [16.,0.,15.] ], [255,255,255]) ]
  73.  
  74. rotate = [0.0001,0.0001,0.0001]
  75.  
  76.  
  77. while True:
  78.     print rotate
  79.     while rotate[1]>360:
  80.         rotate[1]-=360
  81.     while rotate[1]<0:
  82.         rotate[1]+=360
  83.  
  84.     keys = pygame.key.get_pressed()
  85.  
  86.     if keys[K_DOWN]:
  87.         camera[2]-=math.cos(math.radians(rotate[1]))*cam_speed
  88.         camera[0]-=math.sin(math.radians(rotate[1]))*cam_speed
  89.     elif keys[K_UP]:
  90.         camera[2]+=math.cos(math.radians(rotate[1]))*cam_speed
  91.         camera[0]+=math.sin(math.radians(rotate[1]))*cam_speed
  92.  
  93.     if keys[K_LEFT]:
  94.         rotate[1]+=rot_speed
  95.     elif keys[K_RIGHT]:
  96.         rotate[1]-=rot_speed
  97.  
  98.     if keys[K_q]:
  99.         camera[1]+=cam_speed
  100.     elif keys[K_a]:
  101.         camera[1]-=cam_speed
  102.  
  103.     for face in faces:
  104.         face.update(camera, camera_range, rotate)
  105.     faces.sort(key=Face_closest, reverse=True)
  106.     for face in faces:
  107.         face.render(screen, disappear_distance)
  108.  
  109.  
  110.     pygame.draw.rect(screen, [0,0,255], [camera[0],camera[2],0,0])
  111.     pygame.display.update()
  112.     screen.fill([0,0,0])
  113.  
  114.      # === ANTI-CRASH ===
  115.     for event in pygame.event.get():
  116.         if event.type == QUIT or keys[K_ESCAPE]:
  117.             pygame.quit(); sys.exit()
  118.  
May 7 '08 #12
raubana
56
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!
May 7 '08 #13
jlm699
314 100+
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?
May 8 '08 #14
raubana
56
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.
May 11 '08 #15

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: jianchiwei | last post by:
question: I run c:\python23\Lib\site-packages\win32comext\axscript\client\pyscript.py and it told me Registered: Python Registration of Python ActiveX Scripting Engine complete. But, when I...
2
by: Som | last post by:
A clients website is a combination of ASP pages and COM/COM+ objects - The following errors are being reported. Once this happens on the server the entire script engine fails... we have to...
2
by: dito | last post by:
I have a .asp page that contains an activex componet. When I launch it in a browser, it returns an error that the viewer is unable to create it's resource objects. "To rectify this problem,...
11
by: Petre Huile | last post by:
I have designed a site for a client, but they have hired an internet marketing person to incrase their search engine ranking and traffic. He wants to put extra-large fonts on every page which will...
2
by: Phil McKrackin | last post by:
Hello all, I've been blazing through John Sharp and Jon Jagger's "Microsoft Visual C# .NET Step by Step" book, but I've hit a bit of a roadblock once I made it to the database section....
0
by: raf_z | last post by:
Hi, I think i'm doing something simple, although i may be wrong. I was able to load a Crystal report file up until today, and even now, its only 1 report that's misbehaving. I'll confess that i...
1
by: Carl Waldbieser | last post by:
Has anyone had any experience embedding a CPython engine in a .NET application? In the COM/ActiveX world, it was pretty easy to use Mark Hammond's win32 modules to create a script engine component...
3
by: hazly | last post by:
I'm very new in the web technology and need advice on search engine. I want to develop a portal using PHP and MySQL on Linux. Need to know on the following features : 1. search engine that could...
110
by: alf | last post by:
Hi, is it possible that due to OS crash or mysql itself crash or some e.g. SCSI failure to lose all the data stored in the table (let's say million of 1KB rows). In other words what is the worst...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.