Help with textures

All topics about ZGameEditor goes here.

Moderator: Moderators

Post Reply
User avatar
zakkwylde
Posts: 29
Joined: Sun Feb 24, 2008 1:38 am
Location: France

Help with textures

Post by zakkwylde »

Hi everyone its my first post here. Gotta say Zeditor is fantastic! With Villes help here, i managed a simple 3D rotational display of an aircraft. However, when i loaded it as a 3DS mesh, it came with several different meshes, like wings, tail, body, etc. So i am going to texture each one individually...but i am unable to do it. can anyone help? I can load the texture into the program but thats about it. Furthermore the aircraft as a 3DS shape seems to be translucent...how do i give it a solid look?
Thanks!
User avatar
VilleK
Site Admin
Posts: 2274
Joined: Mon Jan 15, 2007 4:50 pm
Location: Stockholm, Sweden
Contact:

Post by VilleK »

If the 3ds seems translucent then this might be because of a problem with the 3ds-file import function. It seems that some 3ds-files have the triangles in reversed order which makes them have their normals inverted in ZGE. If you want I can take a look if you zip the 3ds-file and post here or email.

About texturing you need to create a Material for every texture. Then UseMaterial before every RenderMesh. However it may be difficult to position the texture correctly. Try experimenting with texturex/y/scale on the material.
User avatar
zakkwylde
Posts: 29
Joined: Sun Feb 24, 2008 1:38 am
Location: France

Post by zakkwylde »

Ok sure heres my 3DS file, do take a look. Now about texturing the individual meshes, for the content folder, i go to the model subfolder and onRender i put the Usematerial node? or is there another way to texture the parts?
Attachments
g91.zip
G91 3DS
(10 KiB) Downloaded 573 times
User avatar
VilleK
Site Admin
Posts: 2274
Joined: Mon Jan 15, 2007 4:50 pm
Location: Stockholm, Sweden
Contact:

Post by VilleK »

Yes it was a problem with normals. Try downloading the 1.7.3 version and use the new "Invert normals" checkbox to import your model again!

About the textures: Create a Bitmap with a BitmapFromFile to import the textures. Then create a Material for every texture and connect with the bitmaps (set the Texture property on Material, you need to name your bitmaps first). Then insert a UseMaterial before each RenderMesh that should be textures. This is in the OnRender-list on your imported model. But as I said earlier it may not look very good because texture coordinates are not imported.
User avatar
zakkwylde
Posts: 29
Joined: Sun Feb 24, 2008 1:38 am
Location: France

Post by zakkwylde »

Yeah Ville, thanks for the update. It was a step upa lright but i theres still the slight prob of the wings. I attached 2 pics of the same aircraft, one with and without the inversion. If you see the no-invert, the wings are solid, but the body is translucent. In the other pic, u will see its reversed. The wings are now showing their insides and the body is solid. I tried to simplify things by making the wings just flat rectangular planes so they wont need much rendering and they became triangles instead. So how do we go around this small problem?
Attachments
pics.zip
(27.09 KiB) Downloaded 567 times
User avatar
Kjell
Posts: 1876
Joined: Sat Feb 23, 2008 11:15 pm

Post by Kjell »

Hello,

You might want to double-check the normals of your model in the tool you've created it in. Make sure you've got double-sided face rendering turned off in your viewport and that all normals are pointing outwards.

Good luck~
Kjell
User avatar
zakkwylde
Posts: 29
Joined: Sun Feb 24, 2008 1:38 am
Location: France

Post by zakkwylde »

Ok guys its quite difficult to solve it cuz i'm using Anim8or, i posted the qns to their forum and will wait out for the reply. wil post it here too in case someone gets d same prob. Meanwhile i will get on with the project, i have managed to make the aircraft roll and yaw and gave it a Y-axis turn if rolled. However, i simply cant make it move forward on the Z-axis if facing forward and subsequently move slower forward and sideways more if i've turned. So far i managed to get a X-axis movement but Z-axis velocity stays the same. Is there a command like G91model.velocity?
User avatar
Kjell
Posts: 1876
Joined: Sat Feb 23, 2008 11:15 pm

Post by Kjell »

Hi,

I've googled for backface culling in Anim8tor, and it seems like there is a disable/enable backside switch in the options menu.

Each model in ZGE has it's own Velocity property ( vector ) that you can access through for example Model.Velocity.X. However ( and this is directed to VilleK ), I noticed that the Position of a model does not get updated by it's Velocity. Bug?

Regards,
Kjell

1st Edit: Whitened the incorrect remark
Last edited by Kjell on Sat Mar 01, 2008 3:51 pm, edited 1 time in total.
User avatar
VilleK
Site Admin
Posts: 2274
Joined: Mon Jan 15, 2007 4:50 pm
Location: Stockholm, Sweden
Contact:

Post by VilleK »

Hmm... I thought the "invert normals" would solve this.

A good thing to try is import your 3ds-file back into your 3d-modeling program (or another modeler). If it doesn't look ok then the problem is in Anim8or's 3ds-export.

A complication to the above suggestion is that ZGE does not import the normals from the model, instead it automatically calculates new normals depending on triangle direction. The reason for this behavior is to save space in the final executable.

Maybe each individual mesh inside a 3ds-file can have a independent setting for triangle direction. If an expert on the 3ds-file format happens to read this then please provide info on how to detect triangle order (clockwise or anti-clockwise) for each triangle in a mesh. This determines which direction normals point in.

Kjell: please elaborate on the problem with Velocity and Position, I'm not sure I understand what you mean, thanks.
User avatar
Kjell
Posts: 1876
Joined: Sat Feb 23, 2008 11:15 pm

Post by Kjell »

Hi VilleK,

When reproducing the problem, I noticed I was actually mistaken about the Velocity issue. This was due to me being unaware of the Velocity property being multiplied with the DeltaTime by default. Probably should have read the Component reference more carefully :roll:

Concerning the 3ds format, I'm pretty sure it was counterclockwise.

Kind Regards,
Kjell
User avatar
zakkwylde
Posts: 29
Joined: Sun Feb 24, 2008 1:38 am
Location: France

Enemy

Post by zakkwylde »

hi guys am doing something like spawning enemies and making them come towards me exactly. does anyone have an ideas on the coding?
I know that 3 variables or 2 must be formed to store muy current X and Y position but how do i make the enemy move toward it and in the proper angle??help pls thanks!
User avatar
Kjell
Posts: 1876
Joined: Sat Feb 23, 2008 11:15 pm

Post by Kjell »

Hi zakkwylde,

Are the enemies restricted to a 2D plane or can they move freely in 3D? In case it's 2D take a look at the example I've attached. If it's 3D you're after, let me know and I'll hook you up with a 3D version ;)

Kind Regards,
Kjell
Attachments
EF.zip
(37.46 KiB) Downloaded 581 times
User avatar
zakkwylde
Posts: 29
Joined: Sun Feb 24, 2008 1:38 am
Location: France

Post by zakkwylde »

most definitely 3D, thanks....I was thinking of spawning the enemy if the player collided with a object and thereafter the enemy keeps spawning on random places and comes to the player location. any ideas on how that works?
User avatar
Kjell
Posts: 1876
Joined: Sat Feb 23, 2008 11:15 pm

Post by Kjell »

Hi zakkwylde,

Not quite sure what you are asking there ... in any case, here is the Enemy Follow example executed over all 3 axes. The player sphere can be controlled using the Arrow Keys again + A to ascent and Z to descent.

And we should have made a separate topic as this has nothing to do with Normals or Textures anymore :roll:

Good luck,
Kjell
Attachments
EF3D.zip
(37.62 KiB) Downloaded 618 times
Post Reply