In example - drawing smal "floor" chunk with two triangles:

Code :

triangles.add(new Triangle(new Vector3f(x, (float) map[x][z] * 100, z),
new Vector3f(+0.5f, 1, -0.5f),
new Vector3f(-0.5f, 1, -0.5f),
new Vector3f(+0.5f, 1, +0.5f), rgb, rgb, rgb));
triangles.add(new Triangle(new Vector3f(x, (float) map[x][z] * 100, z),
new Vector3f(-0.5f, 1, +0.5f),
new Vector3f(-0.5f, 1, -0.5f),
new Vector3f(+0.5f, 1, +0.5f), rgb, rgb, rgb));

start point XYZ coordinates, first triangle point "sub" coords, second triangle point "sub" coords, third triangle point "sub" coords, rgb for first point, rgb color for second point, rgb color for third point,

I cant do it... I think it is very easy and Im so stupid or so tired. Can you help me? ]]>

Math question here about finding theta between a line and a plane. I've gotten by the dot cross result for the top of the equation and am working the "magnitude" of each in the bottom part. Question: should I take the ABS of the two sqrt functions below? The tutorial showed the denominator initially having the abs symbol || but disappeared from the work up. Perhaps its assumed.

cos theta =

n dot a

------------------

sqrt(values...) sqrt(values)

Should the sqrt be | sqrt(values...)| |sqrt(values...)| ]]>

I wrote a function for that which uses

Code :

std::vector<Eigen::Vector3f> points; // input set of points
typedef Eigen::ParametrizedLine<float, 3> Line3;
static Line3 start_to_end = Line3::Through(points[0], points.back());
float max_dist_squared = 0.0f;
size_t max_idx = 0;
for (size_t i = 0; i<points.size(); ++i)
{
float dist2 = start_to_end.distance(points[i]);
if (dist2 > max_dist_squared)
{
max_dist_squared = dist2;
max_idx = i;
std::cout << "\n Distance is " << dist2 << " and i " << i << std::endl;
}
}

PROBLEM : I want to write same method using GLM. I mean to ask is any method that help me to find

i'm having problem to correctly animate separate nodes of a model. the nodes are hierarchically structured, and each node has a "mat4 Transform" (relative to its parent). to animate nodes, each nodes has an additional member "mat4 Animation" (relative to the base transform "mat4 Transform").

to get the final "mat4 world_transform":

Code cpp:

mat4 Node::WorldTransform() const
{
return
m_parent ?
inverse(inverse(Animation) * inverse(Transform) * inverse(m_parent->WorldTransform())) :
Transform * Animation;
}

in other words:

--> assimp gives me [Transform * Animation] and [Transform]

--> i want [Animation] only (separated)

how do i do that ??

http://assimp.sourceforge.net/lib_ht...ctai_node.html

http://assimp.sourceforge.net/lib_ht...node_anim.html

beside that:

is it better to pre-calculate all the possible animation matrices for each "key frame tick" or just do the calculations "on-the-fly" ? ]]>

I work on my little CAD 3d editor and has a problem how to organize any transformation in the scene with a future work of algorithms: boolean, mouse picker, intersection and other. I have a gizmo wich moves any objects in the scene. As I already know, is the usual way of storing any local transformations is store that transformation in the model matrices of this objects and execute any local transformation directly in the shader. BUT, for example, in my program I implement a classic ray-picking algorythm: the ray is in the world space and detect any intersection with the real (transformed in world space, locally) vertex positions. For example, I have a box and a sphere and I move it by gizmo (I edit their model matrix) on 1,0,0 and 0,1,0 respectively. His model matrices is now different. HERE I get data that I need for ray-picking ant another algorithms - ever objects has own local individual places.

My question is how to interact with the objects, wich the real place is unknown until it's will locally transformed into the shaders? What is the usual way to store data for CAD or 3d editor program, where a real position of object is a base of work of any algorithm?

I gathered some ideas:

1) Multiply any local transformation immediatly on CPU and store already transformed data. I think it's a clear way but it's expensive: each frame I convert the delta of moving to matrices and multiply the whole data by it on the CPU.

2) Produce any transformation by directly changing data. This is a not multiplication of matrices and much easier. But how to implement rotation? Hmm..But this is another story. ))

3) Store any transformation in the model matrices until the mouse picking will starts and then quick multiply verticies by matrix on CPU to prepare data for picking. This is very fancy but there is ways to optimize it.

4) Store the inversed version of model matrices of each object and multiply ray by this matrices when picking is run.This seems to me is helpful only for the picking algorithm.

5) Organize the picking and other algorithms in the shaders or by CUDA, OpenCL.

Which is the more usual way to work in CAD programs? Wich method is more convenient and easy for a future work of boolean algorithm, for example? Or may be I'm not on the right track and there is some other method?

Thank you! ]]>