Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 Simple pointers
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
Raknarg




PostPosted: Fri Nov 25, 2011 6:48 pm   Post subject: Simple pointers

My friend is really good with 3D stuff in turing. Right now what he has is to make a cube for instance, you would have six different faces, each face with four veteces that are cinstantly tracked. However, to shorten the coding, he wants to use pointers so that the verteces that are constantly in the same spot dont all have tobe moved individually, he can just change one variable and have them all change.

Is it possible to do something along the lines of this:
Turing:

var a : int
var b : ^ a


Thats basically all he needs.
Sponsor
Sponsor
Sponsor
sponsor
Tony




PostPosted: Fri Nov 25, 2011 7:15 pm   Post subject: RE:Simple pointers

That seems like an odd approach. In 3D, vertices typically describe faces, not the other way around. In your friend's model, the same vertex would be described by 3 different faces.

But yes, one could have a pointer to int (documentation says so)
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
Raknarg




PostPosted: Fri Nov 25, 2011 7:17 pm   Post subject: RE:Simple pointers

Lol yeah Im not quite sure how his works, but it seems to work well. He figured it out mostly by himself, and so this is how he learned.
smool




PostPosted: Tue Dec 06, 2011 6:40 pm   Post subject: RE:Simple pointers

Ya thought of it all myself Very Happy
i fixed it, used objects, here's how it all goes down:
-i have a points class, each points has x y z coordinate, and a dx dy (draw x and draw y) variable, which is where to draw the point on screen based on their 3d coordinate and where the viewpoint is in space.
-polygon class, which has variables numvertices (number of vertices) and then an array of ^points, 1 .. numvertices (its flexible).

To draw everything to the screen, i calculate all the dx and dy coordinates of each point. then i calculate the average depth of each polygon by averaging the depth of each of its vertices' depth. then i use recursive merge sort all the polygons, so that it draws the ones with higher depth first. then i just go through all the polygons and Draw.FillPolygon.

So ya, thats waht i came up with on my own, it works pre good up to about 30 polygons at which point it starts to lag a bit. I also added basic lighting (intesity based on how far polygon is from light source)

aha thx anyway Raknarg Smile
Zren




PostPosted: Tue Dec 06, 2011 7:20 pm   Post subject: RE:Simple pointers

If your looking for some mentor-like code, I must point to this incredible piece of work by Zylum. It runs 600 polys easy. Incorperates basic lighting... It doesn't use perspective (camera/field of view) however. Uses QuickSort for the Z-Order. Normals for lighting. Don't remember if he used BackFaced culling or not (since he did do normals).

http://compsci.ca/v3/viewtopic.php?t=9639

One of my favourite tricks he used was pre-calculating Sine and Cosine for all integer values in degrees. Less accuracy for a significant speed boost. One of the few times I'd ever use degrees over radians.
Raknarg




PostPosted: Tue Dec 06, 2011 7:25 pm   Post subject: RE:Simple pointers

O.o wow. That's pretty amazing.
smool




PostPosted: Tue Dec 06, 2011 9:06 pm   Post subject: RE:Simple pointers

... i dont know what to say. thats ridiculous
Display posts from previous:   
   Index -> Programming, Turing -> Turing Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 7 Posts ]
Jump to:   


Style:  
Search: