Jump to content

  • Log In with Google      Sign In   
  • Create Account


Shawn619

Member Since 17 Mar 2012
Offline Last Active May 06 2014 11:51 AM

#5074287 Better FPS with high-poly terrain

Posted by Shawn619 on 30 June 2013 - 05:00 PM

Update:

 

I randomly thought of a method that allows me to create a short list of faces to test intersection each frame, instead of testing all faces in the terrain(O(N)) on every frame.

 

With my method, I was able to narrow down the amount of intersection tests from the original 33000(all terrain faces) to ~100 each frame, which is quite manageable and resolved the FPS issue.

 

In computational complexity, I was able to reduce intersection tests from O(N)->O(sqrt(N)).




#5068079 Raytracing

Posted by Shawn619 on 07 June 2013 - 02:54 PM

I'm not quite sure which section this question be better suited, so feel free to move it.

 

This question is about raytracing line-triangle, more specifically, a vertical line intersecting with a triangle.

 

I'm following the algorithm from http://www.angelfire.com/fl/houseofbartlett/solutions/line2tri.html#Code

 

Goal: Place a vertical line anywhere on a non-flat surface(terrain) and be able to detect which triangle it hits. 

 

I'll try to make my question simple:

 

When my line point starts above the terrain and has a negative vertical vector direction(enough to pierce the terrain and create intersection), I produce correct results: 

 

 

//vertical line from 10y to -10y
vec3f linept = {0.0, 10.0, 0.0}; //start line point
vec3f linevect = {0.0, -20.0, 0.0}; // line vector direction

 

1elvsl.jpg

 

*the black triangle means the line-triangle algorithm has returned true for that polygon.

 

While simply having the line start below the terrain, instead of the top, and changing the direction of the line direction(from down->top), which you would think have no effect and still pierce the terrain because it's really still the same line, now does not recognize intersecting with the triangle:

 

 

//vertical line from -10y to 10y
vec3f linept = {0.0, -10.0, 0.0}; //start line point
vec3f linevect = {0.0, 20.0, 0.0}; // line vector direction

 

fdfv9y.jpg

 

*the algorithm does not deal with normalized vectors of direction, so that's why the line's direction is (0,10,0) instead of (0,1,0).

 

Why does changing the vector direction make the algorithm fail?




#5057408 Confusion About Rotating Camera Around Point

Posted by Shawn619 on 27 April 2013 - 11:35 PM

Just wondering how the components for eyeX, eyeY, eyeZ are derived

 

I'll give you an idea on how I would approach this assignment and answer your question at the same time.

For rotation, you say that your rotation method is working, instead of using the traditional glrotate, so i'll leave the rotation alone.

For translation, the first 3 components of gluLookAt are the position of your eye in world space, which you seem to have calculated correctly, assuming your rotation are correct.

The next 3 components are where your eye will be looking. So, in your scenario of an earth orbiting around a sun, assuming your sun in centered at the origin, these 3 components would be (0,0,0), which would have your eye looking towards the origin(at the sun). 

 

http://www.opengl.org/sdk/docs/man2/xhtml/gluLookAt.xml

 

Also, shouldn't

gluLookAt(eyeZ * cos(theta) * sin(phi), eyeZ * sin(theta), eyeZ * cos(theta) * cos(phi), 0, 0, 0, 0, 1, 0);

 

be

gluLookAt(eyeX * cos(theta) * sin(phi), eyeY * sin(theta), eyeZ * cos(theta) * cos(phi), 0, 0, 0, 0, 1, 0);



#5055893 Opengl - Light rotating around object (video)

Posted by Shawn619 on 22 April 2013 - 07:34 PM

I translate my object(soccer ball) -20z pixels away from the camera, keep the camera and rotating sphere(blue sphere=light, so you know where the light is) at origin, and rotate the light(represented by the sphere) around the origin to simulate moving light.

 

I think this short video(00:14) should clear things up:

*note: blue sphere=light, soccer ball=object, grey plane=flat ground

 

Why is my object acting as if it is at the origin, where the light is rotating around, but in reality it is -20z further away from the origin?

 

main function:

void drawScene() {
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
 
    glMatrixMode(GL_MODELVIEW);
    glLoadIdentity();
 
 
 
    //lighting+sphere
    rot+=1.0f;
    glPushMatrix();
 
    //glTranslatef(0.0f, 0.0f, -20.0f);
    glRotatef(rot,0.0f,1.0f,0.0);
    glTranslatef(0.0f, 0.0f, 10.0f);
 
    initSceneLighting();//set position light[0] {0,0,0,1}
    drawSceneSphereLight();//blue sphere
    glPopMatrix();
 
    //soccer ball(object)
    glPushMatrix();
    glTranslatef(0.0f, 0.0f, -20.0f);
 
    glColor3f(1.0f,0.0f,0.0f);
    glCallList(soccerBall);
    glPopMatrix();
 
 
    //floor
    glPushMatrix();
 
    glColor3f(0.5f,0.5f,0.4f);
    drawSceneFloor();//grey ground
 
    glPopMatrix();
 
 
    glutSwapBuffers();
}



#4924852 5$ - 200x100 image

Posted by Shawn619 on 24 March 2012 - 03:56 AM

(Edited by mod. Not appropriate for Game Design forum. For Help Wanted posts, try the Classifieds.)


PARTNERS