Simple pointers
Author |
Message |
Raknarg
![](http://compsci.ca/v3/uploads/user_avatars/3745510004d8be6689b92f.jpg)
|
Posted: 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. |
|
|
|
|
![](images/spacer.gif) |
Sponsor Sponsor
![Sponsor Sponsor](templates/subSilver/images/ranks/stars_rank5.gif)
|
|
![](images/spacer.gif) |
Tony
![](http://wiki.compsci.ca/images/f/f4/OniTony.gif)
|
Posted: 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) |
Tony's programming blog. DWITE - a programming contest. |
|
|
|
![](images/spacer.gif) |
Raknarg
![](http://compsci.ca/v3/uploads/user_avatars/3745510004d8be6689b92f.jpg)
|
Posted: 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. |
|
|
|
|
![](images/spacer.gif) |
smool
![](http://compsci.ca/v3/uploads/user_avatars/19584221104f5399411b2b3.jpg)
|
Posted: Tue Dec 06, 2011 6:40 pm Post subject: RE:Simple pointers |
|
|
Ya thought of it all myself
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 Smile](images/smiles/icon_smile.gif) |
|
|
|
|
![](images/spacer.gif) |
Zren
![](http://compsci.ca/v3/uploads/user_avatars/1110053965512db6185954b.png)
|
Posted: 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. |
|
|
|
|
![](images/spacer.gif) |
Raknarg
![](http://compsci.ca/v3/uploads/user_avatars/3745510004d8be6689b92f.jpg)
|
Posted: Tue Dec 06, 2011 7:25 pm Post subject: RE:Simple pointers |
|
|
O.o wow. That's pretty amazing. |
|
|
|
|
![](images/spacer.gif) |
smool
![](http://compsci.ca/v3/uploads/user_avatars/19584221104f5399411b2b3.jpg)
|
Posted: Tue Dec 06, 2011 9:06 pm Post subject: RE:Simple pointers |
|
|
... i dont know what to say. thats ridiculous |
|
|
|
|
![](images/spacer.gif) |
|
|