Solved

Primitives loaded from .x files are see-through

Posted on 2001-08-12
17
318 Views
Last Modified: 2013-12-26
I load some 3D primitives from .x files, and even after applying textures, I can see geometry on the other side of the object, which is to say that the objects are see through. What setrenderstate(..) or whatever invocation do I make before rendering to fix this? Or is there a problem with the way the file is exported?

conv3ds -m -T -s0.04 hind.3DS

Kindly help

Zawar Qayyum.
0
Comment
Question by:zawar
  • 7
  • 6
  • 3
  • +1
17 Comments
 
LVL 2

Expert Comment

by:cybermike3d
Comment Utility
There are several posibilities. Are the objects semi transparent or are they just incorrectly rendered. Check the alpha setting on the materials. Then, check if you have backface culling enabled. Then, some cards have a glitch. If you select the reference rasterizer (software rendering) is there a difference in the image? Check your lights ... they too have alpha paramaters. If u have a program like MAX ... load the .3ds file and re assign a new materaial then try converting the mesh again. Then there is the scale transform ... when you go to larger or smaller scales ... the drawing order sometimes goes a little screwy. So the key here is ... is the far side geometry visible because a) the alpha paramaters of the lighting and materials are incorrect, or  b) is it because the polygon drawing order is screwed up ? There are other causes too ... like if you have large polygons in close proximity to each other it confuses the rendering engine and it battles trying to decide which poly to draw first. Breaking up a large polygon into 2 or 3 smaller ones also tends to cure that problem. Example ... if u have 1 polygon consisting of multiple triangles stretching from say the front of a craft to the back of a craft, and one polygon with multiple faces stretching from wingtip to wingtip ... the renderer doesnt know which one to draw first so sometimes u see the wing through the fuselage, and sometimes the fuselage through the wing... a common problem with low polygon multiple triangle meshes.

see what you can figure out and let me know ... then you will know in what area to start looking for the solution

regards
cybermike.

(are you working in C or VB?)  


 
0
 
LVL 2

Expert Comment

by:cybermike3d
Comment Utility
An afterthought here ... I know that this unlikely but certain 3d packages like Maya use a reverse winding order for the polygons ... so u should try the -r param in the conv3ds program. like I said ... its unlikely but I just thought i'd mention it. (Does the .x mesh view correctly in the default viewer provided with the DX8 SDK ? ... I assume u are using DX8?)
0
 

Author Comment

by:zawar
Comment Utility
Cybermike, I have been a fan of yours since you posted that detailed account of creating an introvert cylinder in 3D Studio Max (I guess the guy who actually posted the question never thanked you :)).

OK, I am using DX7, Visual C++ 6.0, 3D Studio Max 3.0. The alpha settings are ok since I tried upgrading the alpha values in conv3ds using the -z option by 0.5 for the whole geometry, but there were no changes in the output (I did that even though the objects are perfectly opaque in the MAX viewer). The materials are opaque as well. I tried the software rasterizer but no effect. If by alpha portion of lighting you are refering to the ambient lighting, then its setting is something like 0xF0F0F0F0. I will try to change that (possible a solution) when I get home from university. The problem isn't with scaling since I haven't done any (unless you are refering to the option in conv3ds, but transparency also showed with instances without scaling).

>>the renderer doesnt know which one to draw
>>first so sometimes u see the wing through the fuselage, >>and sometimes the fuselage through the wing...

If you mean that the rendered output will vacillate between the two possibilities, then that is not the case.

Also I viewed my model in the XFile viewer provided in DX7 samples and the object didn't look see through; I couldn't see its other-side's geometry.

Thankyou Cyberdude

Zawar Qayyum.
0
 
LVL 2

Expert Comment

by:cybermike3d
Comment Utility
could u possibly take a screenshot of the object and post it somewhere or email it to me ? mike@cybermike3d.co.za
0
 

Expert Comment

by:GuyJohnston
Comment Utility
If the X-File viewer showed an opaque object,
then maybe it is an alpha-blending problem in
the program.

Try: ( Just before you draw the primitive )

lp3DDev -> SetRenderState( D3DRENDERSTATE_ALPHABLENDENABLE,
                                 FALSE );
Where lp3DDev is your 3D Device.

Also, is there anything in your program that might turn
on alpha-blending ? I doubt your problem is a random bug.
Especially if the X-File Viewer shows an opaque object.
Does'nt it have to be a SetRenderState thingy somewhere ?

Guy

0
 

Author Comment

by:zawar
Comment Utility
lp3DDev -> SetRenderState( D3DRENDERSTATE_ALPHABLENDENABLE,
                                FALSE );
I already have that in my code. I will try to send you the screen shot as soon as possible CyberMike.

Zawar.
0
 
LVL 2

Expert Comment

by:cybermike3d
Comment Utility
use something like paintshop pro ... it does a good screen shot of dx8
0
 
LVL 2

Expert Comment

by:cybermike3d
Comment Utility
Your problem is definately the polygon drawing order. Things that are at the back are being drawn last (so they appear to be in front) ... how did u create the models ? 3d Max or bryce or maya or what ? Then, are these multiple texture models? They look like it... and they also look like multiple object models .. The mis model ... are the spheres in the same mesh structure as the body of the missile. The more I look at them, the more they seem to be inside out. Did u try using the -r switch in the conv3ds program ?
It reverses the polygon winding order.

conv3ds -m -T -s0.04 hind.3DS
conv3ds -m -T -r -s0.04 hind.3DS

Are u using the immediate or retained mode (looks like retained mode)  I had so many problems with DX7 RM and IM that i scrapped everything and changed over to DX8. I know that this is not what one wants to hear but I never looked back. Maybe the easiest way out is to redisign your models. Start with a simple cube ... see if it renders correctly. One has to try and establish if the problem is in the code or the model. I am going to give u a model to use and lets see how that renders. I will upload the zip file a bit later and give u the link.



0
Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

 

Author Comment

by:zawar
Comment Utility
Thanks Cyber. I will reverse the winding order and let you know soon. I am using Immediate Mode. I will also start with the cube and see if it works. But did you check the models in the  X.file viewer shipped with DX? Kindly comment on that as well.

Zawar.
0
 

Author Comment

by:zawar
Comment Utility
I reversed the winding order on my polygons but it didn't help. Figures out that the models are correct since they look ok in the Xfile viewer. I await your test model CyberDude3D.
0
 
LVL 2

Expert Comment

by:smitty1276
Comment Utility
I'm more of an OpenGL guy, but do you have depth-testing enabled ?
0
 

Author Comment

by:zawar
Comment Utility
I think there is a problem similiar to that smitty. If it is so that I haven't enabled the Z-buffer, then can anyone tell me how to do it explicitly (d3d samples don't seem to do it)?
0
 
LVL 2

Accepted Solution

by:
smitty1276 earned 37 total points
Comment Utility
Try using SetRenderState() with these state constants to enable it... I would imagine that the first one is the one you are looking for.


D3DRENDERSTATE_ZENABLE
TRUE to enable the z-buffer comparison test when writing to the frame buffer. The default value is FALSE.

D3DRENDERSTATE_ZVISIBLE
TRUE to enable z-checking. The default value is FALSE. Z-checking is a culling technique in which a polygon representing the screen space of an entire group of polygons is tested against the z-buffer to discover whether any of the polygons should be drawn.
0
 
LVL 2

Expert Comment

by:smitty1276
Comment Utility
Hello?  Did you get it working?
0
 

Author Comment

by:zawar
Comment Utility
Yes sir! The Z-buffer wasn't enabled :((((. I didn't expect myself to be such a loser. Anyway, once I enabled it my sky line looked pretty constrained, so I figured out that I will have to enable it after rendering the ground, skyline and the Sun-lens flare. Thanks for the help. But you see CybreMike has been an immense help too, even though he didn't hit the bulls eye. So do you want the points, or do you want me to give them to him. You decide :).

Regards,

Zawar.
0
 
LVL 2

Expert Comment

by:cybermike3d
Comment Utility
Im glad u came right dude ... give the points to smitty, he answered your question. I also kind of overlooked the obvious. hehehe ;-)
0
 
LVL 2

Expert Comment

by:cybermike3d
Comment Utility
Maybe I should have just verified the initilaisation process. Just for interest, this is the standard prologue I use when starting to do 3d stuff

    ' Device state would normally be set here
    ' Turn off culling, so we see the front and back of the triangle
    'g_D3DDevice.SetRenderState D3DRS_CULLMODE, D3DCULL_NONE

    ' Turn on the zbuffer
    g_D3DDevice.SetRenderState D3DRS_MULTISAMPLE_ANTIALIAS, 1
    g_D3DDevice.SetRenderState D3DRS_ZENABLE, 1
   
    ' Turn on lighting
    g_D3DDevice.SetRenderState D3DRS_LIGHTING, 0
   
    ' Turn on full ambient light to white
    'g_D3DDevice.SetRenderState D3DRS_AMBIENT, &HFFFFFFFF
   
    g_D3DDevice.SetRenderState D3DRS_FOGCOLOR, &HFF000000
    g_D3DDevice.SetRenderState D3DRS_FOGSTART, FtoDW(1)
    g_D3DDevice.SetRenderState D3DRS_FOGEND, FtoDW(8)
    g_D3DDevice.SetRenderState D3DRS_FOGVERTEXMODE, D3DFOG_LINEAR
    g_D3DDevice.SetRenderState D3DRS_FOGENABLE, 1
   
    g_D3DDevice.SetRenderState D3DRS_CULLMODE, 3
    g_D3DDevice.SetRenderState D3DRS_ALPHABLENDENABLE, 1  'TRUE
    g_D3DDevice.SetRenderState D3DRS_SRCBLEND, D3DBLEND_SRCALPHA
    g_D3DDevice.SetRenderState D3DRS_DESTBLEND, D3DBLEND_INVSRCALPHA

        '
' The code below assumes that D3D is a valid pointer
' to a Direct3D8 object.
'

'    g_D3DDevice.CheckDeviceMultiSampleType( D3DADAPTER_DEFAULT, _
'                                 D3DDEVTYPE_HAL , D3DFMT_R8G8B8, _
'                                 FALSE, D3DMULTISAMPLE_2_SAMPLES )
                                 
'   g_D3D.CheckDeviceMultiSampleType( D3DADAPTER_DEFAULT, _
                                  D3DDEVTYPE_HAL , D3DFMT_R8G8B8, _
                                  FALSE, D3DMULTISAMPLE_2_SAMPLES )
                                 
'
' The example below assumes that pD3D is a valid Direct3D8
' object and D3DDevice is a valid Direct3DDevice8 object.
0

Featured Post

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Best CODE lenguaje to learn 3 512
PS3 GAMES CONVERTING 5 666
any impressive Python code for a child? 3 102
Fibonacci challenge 11 82
Artificial Intelligence comes in many forms, and for game developers, Path-Finding is an important ability for making an NPC (Non-Playable Character) maneuver through terrain.  A* is a particularly easy way to approach it.  I’ll start with the algor…
As game developers, we quickly learn that Artificial Intelligence (AI) doesn’t need to be so tough.  To reference Space Ghost: “Moltar, I have a giant brain that is able to reduce any complex machine into a simple yes or no answer. (http://www.youtu…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…

771 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now