How should I exactly mix refracted and reflected color, fresnel - reflection

I am building a raytracer in C for the school. Yesterday I successfully implemented my first recursive refraction, however I am not very satisfied with the result. a picture of my raytracer with 2 reflective spheres
I find that the water ball doesn't look like a water ball so if you have some advice on what I should do next tell me please, from what I had read:
Beer law
Making the darkness of the shadow depend on how long a ray light traveled trough a refractive material (I guess I can use beer law for that)
I suspect this could come from my implementation, here is what I did:
first I set a material like that:
-DIFFUSE 1
-SPECULAR 10
-REFLEXION 0.1
-REFRACTION 0.9
-IOR 1.33
This are the characteristics of my water material.
Since I am using fresnel to calculate how much transmitted and refracted colore I should take to compute my final colore I am wondering if my reflection and refraction coef shouldn't be simply Boolean. Right now I am using them to ponderate how much reflection and refraction colore I should use, but isn't it too much since I am also using fresnel? I am a bit confused about this part and red a lot of PDF from a lot a university but the precise mix isn't cover by them, they just tell us to use fresnel to choose how much reflected or transmitted light we should use but when they put pseudo code you can read that they call recursively them function: if (material->is_reflective)
if (material->is_refractive)

Related

Recognize line of plants

I am trying to build an alternative to the standard line-following robot. I would like it to recognize a row of plants and follow it.
The challenge is to see a row of plants and recognize it as that. It is naturally not a solid line, but will be planted neatly in a row. It will be surrounded by weeds etc that do not grow in a neat line.
I would just like some pointers on how to approach this. Is this even feasible using Arduino?
you might need CMOS camera, and maybe RGB readings from it, then apply computer vision algorithms to try to differ the plants from everything else. Too much complicated in my opinion. But yes check the Sensors from Digikey and see maybe you could you a laser or lidar to measure the distance from reference points and then implement PID on top of that, but then you need at least Arduino Due or higher. ATMEL SAM etc...

Ogre3D - render water with waves by vertex? nurbs?

I have an Ogre3D application and I would like to render a surface that represents the water with waves.
I think I am not the only one that has this purpose, so I was looking for an example to follow.
I imagine that if I want to create a water surface and want to move it like a wave I have to create a surface with many vertexes (according to which precision I want) and then control the height of each vertexes.
As the water will be quite big, I think that the water will take long time to be rendered, so I was wandering if it was better to render it by vertex or nurbs? Or are there any better way?
There's an Ocean example included in Ogre distribution that you can use as starting point. I don't remember if it uses any LOD system but it has quite nice random waves and Fresnel shader.
The nurbs won't help you much as there's no easy way to push them into GPU. They're good for some modelling tasks but at the end you need to convert them to 'real' geometry.

How to apply physics force to speed ship vessel

i know buoyancy and apply ed it ; my ship is float on the water now. but i don't know how to apply force to control and navigate my speed boat ?
i'm using havok physics engine.
my code's like this
body->applyForce( stepInfo.m_deltaTime,forwardWorld, pointx );
pointx = my apply force point (-75,0,0); this point is a 3d point in back side of my ship
forwardWorld = force value and direction of it (100,0,0); apply 100Nm to back side of my ship
my pointx value is always static.
my forwardWorld values change every time for exam :
when i want to my ship go to front set it to (100,0,0)
when i want to my ship go to right i set it to (0,0,100)
when i want to my ship go to left i set it to (0,0,-100)
but this is'n a good way because my ship will drag and shift to left or right in upper speed
and this is mistake
please help me.
You didn't say what you need the model for. If it's a game then perhaps my advice will not satisfy you but if it's for some sort of engineering problem solving then I recommend building your own manoeuvring model. This may sound intimidating but in reality it boils down to solving three differential equations (roll, yaw and surge; you can also add sway depending on what you are interested in). You can easily solve them by integration using, say, Range-Kutta method.
Here is a paper giving a nice overview of what I'm talking about (there are lots on-line):
https://scl.snu.ac.kr/SCL_Research/data/research/science.pdf
You will need to find coefficients for your equations of motion. There are some in the paper I listed above, many more can be found on the web. For a start, I recommend going for the KRISO data, they are widely available and well presented in the literature.
Edit: I don't like MatLab but if you have access to it then you can solve your equations really easily by building a Simulink model.

implement prismaticJoint physics

I'm trying to implement my own physics for an app I'm making in C++, OpenframeWorks. I'm currently using Box2D but I don't need collision detection so I want something much lighter.
I have a world with gravity and a dynamic object with movement constrained by a prismatic joint of an arbitrary length at an arbitrary angle, attached to a static object. Friction is simulated using the joint motor.
I've looked at
Resources for 2d game physics
But everything here seems to focus on building complete physics engines which I don't need to do. Could anyone point me in the right direction for the maths on this?
You just need to separate the force of gravity into two components; Along the Prismatic Joint Axis, and anything else. (See Free body diagrams)
This is easily achieved with the vector dot product between the gravity vector and axis vector. If you first scale the axis vector to length 1, the result of the dot product will be the force along the axis.
To translate the force into acceleration, you just need to divide by the mass of the moving object.
If Box2D has what you want, I'd recommend you reconsider your "lighter" requirement. Unless you can quantify the harm caused by using a library with a few more bytes, I'd say that the benefit will outweigh the cost of you writing it for yourself.
If you have a good understanding of the physics, and want to learn how to do it, by all means go ahead. If not, use what someone more knowledgeable than you has provided and forget the size of the library.

How do you create 2D vines procedurally for a game?

For a game I am making I want to create 2D vines and vine like structures procedurally. Is there some paper or code snippet that someone can point me to?
Googling results in procedural trees which have straight spiky branches, but I need to create vines which are curvy. Think Jack and the beanstalk type of growth.
http://youtu.be/2wq541W6LyE?t=2m11s
Your particular approach is going to depend on how you game handles drawing and collisions.
An approach popular with flash-based games is to draw the vine to a bitmap: Since you don't list your programming environemnt, I'll just explain the steps, not the code.
Start with a circle,
1 draw it,
2 move it,
3 scale it down.
4 At a random interval, spawn a "branch" and or a leaf.
Set the scale and position of the branch to match the parent. Start a 1-5 loop on the branch.
5 repeat 1 until fully grown (scale is too small to proceed).
In the move phase it can be handy to use Sin curve to make your vine weave in and out.
Youcan tweak the settings for how much it curves to get different types of vines.
Here is a link to a discussion fo teh topic. Some good source to be found in the links.
http://groups.google.com/group/flashcodersny/browse_thread/thread/9906041e557e620c
Including source code inf flash:
http://xfiles.funnygarbage.com/~colinholgate/swf/varicoseg.zip
And a javascript version that looks more like lightning, but couild be adapted to vines without much change:
http://www.brainjam.ca/hyperbolic/01_spite_mrdoob.html

Resources