• Create Account

# Dmytry

Member Since 09 Dec 2003
Offline Last Active Jun 14 2016 12:15 AM

### #5027472Adding or Concatenating Transforms (Scale, Rotation, Translation)

Posted by on 31 January 2013 - 12:31 AM

Hi Dmytry,

I am not sure I follow, what do you mean? in the end what my SRT operations do is a simplified matrix multiplication, so if you take S,R,and T as matrices with scale, rotation and translation respectively, and I as identity the operation you describe would be something along these lines:

( I * R * I ) * (S * I * I) * ( I * *R * I ),

which is the same as RSR, wouldn't the scale vector (diagonal) on the second matrix be doing the scale on world axes rather than object axes as well?
I think I see where you're going, but I haven't had time to think more about it.

The second part of your post, I am not sure if you're pointing out a (another?) problem or providing me with an optimization

Not really pointing out an error in the first part, just explaining that what you originally wanted to do - concatenate sequence of SRT into a single SRT where S scales using a vector that represents scaling on different axes, is (technically speaking) impossible - you indeed need a full blown matrix here, or if you want to optimize a tiny bit, 3x3 matrix and translation. That's because sequence of R S R can produce scaling along the diagonal, which you can not represent with one S R T . (I am assuming matrices apply in left to right, i.e. directx order)

edit:However if you are certain you only use non uniform scaling as the first transformation applied, then it can work. If U is uniform scaling and you only have S R T U R T U R T U R T .... sequence, then you're in the clear.

Second is indeed providing with an optimization. In my software I have a class that does rotation using quaternion and translation using a vector, it works pretty much same from outside as a matrix. The reason I'm using that is not so much optimization as convenience when doing physics or especially when interpolating rotations between frames (which I do because I run physics at constant framerate). In your case I'd probably just convert to matrices then multiply those together, I'd probably use 3x3 matrices with translation rather than full blown 4x4 , basically, you assume the right column (or bottom row, depending to convention) is always 0 0 0 1 .

### #5024374Adding or Concatenating Transforms (Scale, Rotation, Translation)

Posted by on 22 January 2013 - 12:04 PM

You could have a transformation that rotates by 45 degrees, then scales the x axis by a half, then rotates back. This transformation can not be represented with scaling vector, it happens along an axis that is at 45 degrees.

For the rotation and translation, your transform is like

V'=rotation*V+translation

and for two transforms, it is

V'=rotation2*(rotation1*V+translation1)+translation2

or

V'=rotation2*rotation1*V + rotation2 * translation1 + translation2

so you multiply your rotations and you add translations after multiplying the earlier translation by the later rotation.

The multiplication by rotation here means rotating by a quaternion, i.e. represents Q*a*~Q where ~ is inverse.

### #5018609Has Anyone Here Sold on Steam?

Posted by on 07 January 2013 - 09:21 AM

I sell through Steam, self-published.

Yes, I would recommend starting a company for that, though I released when I ran out of money for forming a corporation, so I released it as an individual. I have the advantage of living in EU where frivolous lawsuits against individuals are easier and cheaper to get thrown out. I'm not sure anything I say is relevant to you as I am dealing with international taxation. In any case, it will not be very difficult but I'd recommend having an accountant so that you can apply for the deductions and the like. Valve will report from their end to the IRS, but you may need to report to the IRS as well.

Re: analysis, yes, they'll look at your game and see if it is any good. Or that's how it was in 2010. Now they got greenlight, but they still review. Steam is a quality portal. And the advertisement slots you get depend to how well your game is doing. I got lucky to be spinning in the main banner rotation (on the Steam homepage) for a whole week plus on the holiday sales.

Re: the warz, I was tad surprised at shitstorm. I guess it is some sort of stupid viral thing.

### #4973684Game Engine Programming

Posted by on 27 August 2012 - 12:35 AM

Also, does someone have any tips for me I can use to create an efficient engine?

Yes; don't write an engine.

Write a game, extract parts from it, reuse those parts in another game and repeat. In time the reusable parts will form an 'engine' as you become more experianced.

Attempting to sit down and write an engine without a game to focus it will result in unusable junk which you will just end up re-writing as soon as you want to use it in any real sense. Lack of experiance making games will just make this problem even worse.

EVERY good game engine out there has grown out of being used in a game (or series of games) first and then recycled. This is the only way to ensure you get something usable.

Exactly. Just make a game, with some re-usability in mind but don't over-sweat it if it gets in the way of getting game done (it shouldn't get in the way of getting things done anyhow). If you want to get a game done it may, in most cases, be better to use something like Ogre.

On the timeframe, it can vary wildly with regards to what you want to do and how experienced and productive you are. Keep in mind that even old engines (Quake 2 for example) took a lot of manpower.

### #4955565Updating nested game objects - update child before parent or parent before ch...

Posted by on 04 July 2012 - 02:56 AM

I would have the parent's update call updates of children so that parent can perform processing before and after processing children, or update children in particular order.

### #4943815Why is C++ the industry standard?

Posted by on 27 May 2012 - 04:12 PM

What i believe is the case is that in practice the differences between high level programming languages are so tiny as not to warrant use of other language for any reasons beyond "that's what I know"; the C++ has libraries written in it. The few issues in C++ that other programming languages solve, are very minor comparatively to the rest of the complexities in the big software. Ultimately, the issues like 'managing the memory' or 'multi threaded execution', etc. are very difficult for beginners and are nontrivial in small projects, but are trivially tiny part of the job in a big project.

Other programming languages also tend to force preferred programming ideology of the author (functional programming, some vision of what OOP should be, etc), tend not to implement some pet hated feature (operator overloading is bad! overloading is bad!), or follow some unwieldly maxim (everything is an object!), to the detriment of actual fitness in general use outside the area of expertise of the designer of that programming language.

### #4761799Ubuntu

Posted by on 20 January 2011 - 06:21 AM

Typical users lost their CDs, they don't know their hardware specs, they won't be installing drivers, and they won't be rebuilding kernels. Those users typically can't install windows and have all hardware work, but they can install Linux and have all hardware work. They don't have odd custom built computers with obscure components. They get some Dell or Asus or what ever, something that is very popular, and consequently well tested and Linux-supported out of the box.

The problem are all the people who want to, with minimal effort, feel like they are power users and can do anything. These people are not comparing usability - they are comparing effort it takes to believe that you can do anything that can be done.

### #4759232My game "The Polynomial" is available on Steam

Posted by on 15 January 2011 - 05:01 AM

What the title says. Out of beta, released on time, etc, and there was cake, all the usual Valve memes

There is a free demo. It works on Windows, OS X and Linux (For Windows and OSX I recommend using Steam, the Linux version is available through my website)

### #4759228Linux use and development, finally...

Posted by on 15 January 2011 - 04:30 AM

I use CodeBlocks. I'm thinking of trying QT IDE now. In my experience, a large majority of open source developers are very nice people who work well together making open source software, teaching new contributors, helping out users of their libraries, and the like. The code is comparable to commercial; if we're to speak of open source projects of any note, I would say, often better documented overall and clearer, as to minimize the learning curve for new contributors. It is easy to bash open source code for the auditorium of people majority of whom have never seen what real closed source code looks like after years of development, or had to maintain it.

I would say that large majority of Linux/ other Unix (OSX?) developers are a lot nicer than author of this:
"A large majority of Unix developers definitely are in that "lone hacker" group. And these are unbearable in commercial software development."

Seeing it as certain trolling moderator, an 'expert' by forum majority vote, is still around, and still driving any such discussion entirely off topic by making insulting statements towards groups of people for amusement of the forum majority (forum majority here i'd guess are not professional programmers yet, just learning / doing personal projects, and that's totally fine)... the classic trolling-by-stereotyping tactic - somehow i don't feel like returning. When the moderator does that, it sends a powerful message to other people that this sort of behaviour is acceptable. I am sure that any online forum is better off without such behaviour. Note, he's not talking about software, or anything technical, he's sharing his supposedly important view on the people using it - then when they get personal, he will play the offended party - standard forum diva trolling, deliberately trying to piss people off but look good himself. It is always pure flaming and flame-baiting.
edit: Did read this thread some more. The only remotely technical offtopic: 2 years old FUD about 2.6.25, proprietary drivers, "predictions" of doom. Well guess what, it's 2 years past 2.6.25, I'm using kernel 2.6.36, closed source drivers are doing fine, especially the USB drivers, running safely in the userspace. (Nearly all USB device drivers were already) NVidia drivers are doing just fine as well.

### #4759104What Does Everyone Think About The New Site Layout?

Posted by on 14 January 2011 - 07:27 PM

I hope it stays that posts can only be rated up. The way old rating system worked, it strongly encouraged posting in agreement with public opinion; with even well regarded individuals over time giving in to temptation to gain reputation increase by making extremely negative yet popular remarks (along the lines of bashing free software, any new technologies or development methodologies, and the like).

in other news I dropped by to see if there's any interesting political discussion here [just to read which opinion would be popular on relatively unbiased forums], I guess not, so gonna leave. In yet another news, I released my game on Steam, which makes me an actual game developer earning a living developing games. (previously I did 3D graphics for movies)

### #3073548pre or post multiplication for matrices?

Posted by on 26 May 2005 - 11:39 PM

Quote:
 Original post by esuvsThanks guys, that answers some questions but I'm more concerned about multiplying 4x4 matrices by 4x4 matrices, rather than matrices by vectors. So if I have an object whose position/orientation/scale is represented by a single 4x4 matrix do I pre or post multiply it by the transformation matrix?Or maybe it's like you said with vectors, in that it varies between OpenGL and Direct3D? And I can still switch between the two by using the transpose?

First, think what you want these matrices do.
Let we have transformation matrices A and B . We want to transform vector V by both and get vector V'.
But above is not enough to specify what we want to do, as
first transform by A then transform by B
and
first transform by B then transform by A
are different. You can just try to play with rotations in real world.(get a cube, paint x,y,z on sides, etc.)

Now, more on how it's done:

first transform by A then transform by B
It is easy to see that this is accomplished by:
In openGL's convention:
V'=B*(A*V)
Note that it is same as
V'=(B*A)*V
so you can do it as
C=B*A;
V'=C*V;
In DX's convention:
V'=(V*A)*B
C=A*B;
V'=V*C;
(note: real operations done on memory is the same. It's just matter how we map matrix indices to memory)
As you see, V*A*B and B*A*V is kind of symmetrical. Same for consequently applied transforms like V*A*B*C*D*E*F or F*E*D*C*B*A*V

Now, write it down for "transform by B then transform by A" yourself to remember it better.

When you render something , you want points to be transformed by
matrix of object
matrix of parent object
matrix of grandparent object ...
matrix of camera
(and done by API, projection matrix)
From there you can find what order of multiplications you want. In OGL, you need to
m=matrix_of_camera*matrix_of_grandparent_objectmatrix_of_parent object*matrix_of_object;
...
then if you'll glLoadMatrix, OpenGL will do
vertice=m*vertice;

Some more notes: Let you have spacecraft with spacecraft-to-world matrix M
And you use OpenGL convention.
For example, to turn spacecraft around spacecraft's local X direction, you need to
M=M*axis_angle_to_matrix(Vector(1,0,0),angle);
(note: you need to reorthonormalize matrix if you do that incrementally)
To turn spacecraft around global X direction, you need to
M=axis_angle_to_matrix(Vector(1,0,0),angle)*M;

On openGL:

This sequence

glMatrixMode(GL_MODELVIEW);
glMultMatrix(A);
glMultMatrix(B);
works as if your mesh would be transformed by C,then B, then A
It makes lot of sense, if you for example want to render a robot with matrices giving positions of child nodes (fingers) relativelty to parent (arm), and arm are responsible for positioning fingers, you can do
RenderArm(){
glPushMatrix();
glMultMatrix(matrix_of_first_finger);
RenderFinger();
glPopMatrix();
glPushMatrix();
glMultMatrix(matrix_of_second_finger);
RenderFinger();
glPopMatrix();
}
and so-on(simplified example)
Then, you can have
glPushMatrix();
glMultMatrix(matrix_of_arm);
RenderArm();
glPopMatrix();

and it will work properly.

If you have more questions, ask.

### #2965857Line segment plane intersection code issues...

Posted by on 21 March 2005 - 01:08 AM

haven't readed long post above mine, but note that result you get is same as you should if your d = 24 (not -24) and it looks rather like you have incorrect sign for d.

Let we have plane normal = N , plane distance = d , and line segment A,B
Line segment have equation A+t*(B-A)
So, we need to find t that
(A+t*(B-A)).N=d
that is,
A.N+t*(B-A).N=d
t=(d-A.N)/((B-A).N)

That is, code becomes just two lines:

// of course you can better test your denom for 0, but anyway, that quite well gives you basic idea:
double t=(plane_distance-P1*plane_Normal)/((P2-P1)*plane_Normal);
intersection_point=t*(P2-P1);

where * stands for dot product. (actually it is valid as there's aint no other meaningful overload for vector*vector, and definately overloading "%" or "&" to do that is lot wors

### #2734124Rotation matrix ortho-normalization

Posted by on 25 October 2004 - 04:29 AM

Quote:
 Original post by gaimplayI'm trying to figure out how to orthonormalize a rotation matrix so that the basis vectors would be unit length and perpendicular. This is to combat floating point precision errors that accumulate in the matrix.The way I figured it, all you need to do is take a unit vector, transform it by your current rotation matrix, then inspect the resulting vector and build a some kind of a scaling matrix that makes the resulting vector unit length, then concatenate this matrix with your current one to fix it.If I'm way off course, it would be great if someone could post some pseudo code or actual code to demonstate the correct algorithm.I'm currently using DX9 but can't find a built-in function to do this kind of thing.Any help appreciated.

As others have said, use quaternions. Anyway, it can be done as

Column1=Normalized(CrossProduct(Column2,Column3));
Column2=Normalized(CrossProduct(Column3,Column1));
// and ther you don't really need to Column3=Normalized(CrossProduct(Column1,Column2));
Column3=Normalized(Column3);

Where ColumnN contains nth column of 3x3 rotation matrix as vector. If you use 4x4 matrix, it's submatrix in top-left corner.
You can do the same with rows if you want.
Note that one column/row may be selected to be distorted the least.

Also, don't do it when matrix is unchanged, or your things might start slowly turn.

PARTNERS