RenderTransformGoup - MIRROR X,Y,Z ?

If there is something important you think is missing in the current version of ZGameEditor then you can post a feature request here!

Moderator: Moderators

User avatar
jph_wacheski
Posts: 1005
Joined: Sat Feb 16, 2008 8:10 pm
Location: Canada
Contact:

RenderTransformGoup - MIRROR X,Y,Z ?

Post by jph_wacheski »

I was just building a little seaMonkey from primitives for my new seaMonkey sim,. as I want to keep things in the procedural realm as I feel it is pure and simple and mathematicaly more beautiful when I can create games this way,. and they stay super-small file-wise., and bandwith is costing,. for all this free stuff,. so small is beautiful.

anyhoo,. I built a tail piece and then went to flip it for a MIRROR image on the other side and find that doing this requires all the rotations to be refigured,. note; I use iterators to build stuff, and progressive rotations get all funky,. So I did it by hand/eye and wondered should there be a MIRROR X,Y,and Z tick box in the RenderTransformGoup ?!? I know I would use it a bunch,. as I say, I do plan to keep building things from simple mesh primitives to develop my procedural design skills,. and I like the resulting art style,. . any thoughts?
Attachments
The_Dark_Matter_is_Love__009.zip
the monkeys are in here,. probably not the right setting for them,. they grew while I was thinking about ways to do a track-based shooter,. . another story.
(38.32 KiB) Downloaded 571 times
iterationGAMES.com
User avatar
VilleK
Site Admin
Posts: 2274
Joined: Mon Jan 15, 2007 4:50 pm
Location: Stockholm, Sweden
Contact:

Post by VilleK »

I have to post a screen shot of this because I think it looks so cool. So a mirror checkbox for each axis maybe. Anyone else have a opinion on this?
Attachments
jph's latest wizardry
jph's latest wizardry
darkmatter.jpg (41.39 KiB) Viewed 15078 times
User avatar
jph_wacheski
Posts: 1005
Joined: Sat Feb 16, 2008 8:10 pm
Location: Canada
Contact:

Post by jph_wacheski »

just to be clear here is an example,. .

on the 'subTwo' group I have inverted the Scale X and this provides the needed geometry,.. however, since it is inverted, the geometry appears to be inside out?,. So yeah, what I am proposing is a tick-box for Mirror in (X,Y,and Z) that would somehow perform this 'scale-1 and invert the normals' or math to a similar effect.
Attachments
mirror_example.zgeproj
proj. file example,..
(2.14 KiB) Downloaded 540 times
iterationGAMES.com
User avatar
Kjell
Posts: 1878
Joined: Sat Feb 23, 2008 11:15 pm

Post by Kjell »

Hi guys,

One "InvertNormals" checkbox in RenderTransformGroup ( or a seperate component ) will be enough, you don't want to flip the normals 3 times when you use negative scaling on all 3 axes .. and when you only use 2 axes, you don't even need it at all :)

K
User avatar
VilleK
Site Admin
Posts: 2274
Joined: Mon Jan 15, 2007 4:50 pm
Location: Stockholm, Sweden
Contact:

Post by VilleK »

I've just tried your example. I think using negative scale values can lead to trouble like that you encountered with normals.

I tried setting scale back to 1 and then "0.5" on rotate y axis of the transformgroup, and that seems to work. Or does it not become mirrored in the way you want it to?

edit: yes I understand what you mean, it becomes rotated not mirrored.
User avatar
jph_wacheski
Posts: 1005
Joined: Sat Feb 16, 2008 8:10 pm
Location: Canada
Contact:

Post by jph_wacheski »

Kjell- ah you are of course quite right!
However what I am thinking about it as an overall Editor design issue,. Having the Mirror tick-boxes that just work right,. i.e take care of the boolian addition and mirror the geometry without inverting it,. That way the useage would be clear to designers who don't really care HOW it is done just that it is done! ;)

Ville - No, that is what I tried at first,. it is not "Mirrored" insted it is just rotated. Have a look at it from the top,. and you see the angles of the parts are rotated at opposit angles,. what I am thinking of here is things like arms, legs, wings, eyes, etc. sysmetrical design elements. Not sure if negative scale and inverted normals will work,. but there must be some simple math to mirror the meshes?

I have been playing with the Spore Creature Creator (you should try that if you have not!) and I see that we can do a bit of what that does in ZGE,. this feature will make building creatures and many other objects loads simpler.

[bonus]
Another thing that comes to mind from useing that; a basic bone animation system,. In the past I built some rigged chearacters in Maya buy just linking primitives (in that case sculpted NURBS) to a IK framework, you can do interesting animations without worrying about mesh deformations this way,. great for inscects and robots, or any hard shelled models. .but agian that is a whole other area for reasurch,. it would rock though!
iterationGAMES.com
User avatar
Kjell
Posts: 1878
Joined: Sat Feb 23, 2008 11:15 pm

Post by Kjell »

Hmm,

The thing is .. that when you add a mirror checkbox to each axis in for example RenderTransformGroup, the component has to dig through the whole tree in which it's located to see if there are any other components that have mirror activated to determine whether or not to invert the normals. Code wise, that would be quite messy and inefficient. Besides, I don't think the concept is that hard to grasp. Anybody that has ever dealt with 3d knows about Inverting Normals. Having to add a InvertNormals component to your RenderTransformGroup ( for example ) shouldn't be that difficult for the average user I think. Apart from that, sometimes you don't want the normals to be flipped at all, think of skyboxes, cartoon outlines or certain effects.

And you can pull of FK, IK and even hardware skinning already if you really wanted to :)

K
Last edited by Kjell on Wed Jun 25, 2008 4:02 pm, edited 1 time in total.
User avatar
jph_wacheski
Posts: 1005
Joined: Sat Feb 16, 2008 8:10 pm
Location: Canada
Contact:

Post by jph_wacheski »

well yeah I am all for what ever is easy to do, that does the job, and could be in the next ver.! so a single invert the normals toggle would, is seems, do the job. Yeah if that is possible Ville than by all means,. I just was thinking about the clear GUI bit that would make sense to the most ppl,. I suppose its not hard to explain the toggle in the wiki anyhow,. . and as you probly know I sometimes go at things from the most difficult direction,. I really don't know how I got on the Black Diamond life level I was aiming for the Green Square,. . (?are ski-hill difficulty symbols universal? hope so, other wise my referencing humor is useless,.. )
iterationGAMES.com
User avatar
VilleK
Site Admin
Posts: 2274
Joined: Mon Jan 15, 2007 4:50 pm
Location: Stockholm, Sweden
Contact:

Post by VilleK »

The problem with the invertnormals-suggestion is that it implies having to loop through and change the normals which is a geometry generation functionality that shouldn't be in the render-components in my opinion. Perhaps if there is a way to tell opengl to invert the normals automatically with a state change that would be a better solution. Using two different materials with vertexshaders is another way of achieving this but I guess it is not very easy and intuitive as a checkbox. This feature needs some more consideration.
User avatar
VilleK
Site Admin
Posts: 2274
Joined: Mon Jan 15, 2007 4:50 pm
Location: Stockholm, Sweden
Contact:

Post by VilleK »

I googled and found an article about this: http://www.blender.org/development/rele ... l-normals/

The technique for telling opengl that a material is inside-out is switching the triangle direction betweeen counter-clockwise and clockwise. This could be added to the rendertransformgroup, or perhaps to material.

The easiest solution that doesn't require any changes is to use a material with "DrawBackFace" set. I tried that with your example and it works. Use this material for the whole model. The only downside is that you may get a lower frame rate because more triangles are drawn.
User avatar
Kjell
Posts: 1878
Joined: Sat Feb 23, 2008 11:15 pm

Post by Kjell »

:idea:

Twice as much polygons to be precise. You might want to copy the meshes you want to mirror and use the new this.N function in MeshExpression to invert the normals yourself. Or instead of inverting the normals, adjusting your calculations so that a mirrored mesh is generated to start with. Your game will be slightly bigger in filesize, but should run significantly faster.

K
User avatar
jph_wacheski
Posts: 1005
Joined: Sat Feb 16, 2008 8:10 pm
Location: Canada
Contact:

Post by jph_wacheski »

ah ok, this drawBackFace material works with double the polys,. so we have a way to do this currently,. at a cost.

I tried to get the normals inverted in a meshExpression and it looks to work when you look at the normals,. however the polys are not shaded correctly. Am I inverteing the normals properly? As I would rather have double the mesh data once, than draw double the polys on every frame!

Thanks guys!
Attachments
mirror_example.zgeproj
upated example,. meterial working,. inverting not,. any ideas??
(2.38 KiB) Downloaded 539 times
iterationGAMES.com
User avatar
Kjell
Posts: 1878
Joined: Sat Feb 23, 2008 11:15 pm

Post by Kjell »

Hej jph,

Sorry, the first method I suggested ( Inverting the Normals using MeshExpression ) only corrects the light, but still renders the triangles facing away from the camera instead of the opposite ( I had forgotten for a moment that normals are only for light calculation, it's the vertex order in the mesh that defines what is front and back like Ville mentioned :roll: ). So I'd go with the second method for now, generating a separate mirrored mesh.

K
Last edited by Kjell on Thu Jun 26, 2008 5:28 pm, edited 1 time in total.
User avatar
jph_wacheski
Posts: 1005
Joined: Sat Feb 16, 2008 8:10 pm
Location: Canada
Contact:

Post by jph_wacheski »

Ok cool that's what I will do for now,. Kattle got any input., (finnish your studies first!)
iterationGAMES.com
kattle87
Posts: 402
Joined: Wed Sep 26, 2007 9:06 am
Location: Italy

Post by kattle87 »

going for 2 meshes, one normal and one mirrored, can be made very easily I think :D

As soon as the primitive mesh is generated (EG: Sphere, Box, and so on) invert the vertex along X axis:
this.V.X *= -1;

At the end of the mesh expression(s) simply do it again:
this.V.X *= -1;

you should get your mesh mirrored without needing for any doubling of polygons :D :D :D

PS: I've not tried it yet, let me know if it works!
Post Reply