Ogre 3D load models created with Easy Ogre Exporter - c++

I'm currently trying to export a .max file to .mesh and it success.
The problem is that I don't have any color on my form (it's a basic cylinder actually).
Easy Ogre Exporter gave me several more files like .scene .material .cg .program. I tried to set this .material to .mesh entity but it's still white.
Please help me, I really searched on the web but found nothing working.
Best regards,
Coucka

If Ogre encounters an issue with your materials / shaders / textures, it usually falls back to a material called "BaseWhite", which might be what you are experiencing.
First step: Check the Ogre.log file to see if the *.material file was loaded at all and if there were any error while parsing it. You should find an entry similar to this one:
23:45:10: Parsing script Test.material
If your material is also using the shader that was written into the *.cg shader file, check that it is loaded as well without any errors, plus check that a valid shader profile was used, that your hardware supports (otherwise you will find a note in the log, telling you that no supported profile was found). The supported shader profiles will also the output into the log file, like so:
23:45:10: * Supported Shader Profiles: hlsl ps_1_1 ps_1_2 ps_1_3 ps_1_4 ps_2_0 ps_2_a ps_2_b ps_2_x ps_3_0 vs_1_1 vs_2_0 vs_2_a vs_2_x vs_3_0
If you are using textures on your model, make sure that the needed texture files can be found by Ogre. To do so verify that all paths from where Ogre should load resources are listed in the configuration file resources.cfg. Also for textures to work, your model of course needs to have exported UV coordinates. If the texture was successfully loaded, the following entry should appear in the log (the types and formats of course could be different):
23:45:10: Texture: Texture.jpg: Loading 1 faces(PF_R8G8B8,256x256x1) Internal format is PF_X8R8G8B8,256x256x1.

Related

DirectX11 DirectXTK need a CSO file for testing

I am piecing together information on how to import models following a bunch of different tutorials, because there isn't a resource that explains how to do this in a simple way.
So far I can import and display my model, but it's shown in the Gouraud shader if I use DirectX::BasicEffect
This makes my mechanical models appear very badly shaded, because they were exported from Solidworks.
I want to try switching to DirectX::DGSLEffect , but I need to load a shader, and I don't have any shaders to test.
Can anyone point me to where I can find a pre-compiled *.cso shader?
I need one that can preferably do flat shading, but I can settle for any, just to test that my application is working right.
I know that I need to compile a shader myself from .hlsl files, but this is too many steps and I just need something that works right now before I can continue further,
Thank you,
-D
I want to point out that I am not making a video game, but a mechanical visualization tool, and I do not need to know how to write shaders or do any advanced features of DirectX at this time. Please do not recommend reading books as that would be counter-productive to the amount of time I can work on this project. I would like to learn more in the future, but not for this application. Thanks,
EDIT:
It looks like I can compile with the following line, but now I cant find any HLSL files.
ID3DBlob* PS_Buffer;
D3DCompileFromFile(L"PixelSHader.hlsl", 0, 0, "main", "ps_5_0", 0, 0, &PS_Buffer, 0);
CSO files are complied HLSL shaders. Visual Studio can generate them from HLSL files, and the DGSL pipeline can create pixel shaders using a visual language.
The DirectX Tool Kit BasicEffect system is quite flexible, so you can override in code the parameters or provide your own material information. See the wiki for more information.
If you want to use the Visual Studio content pipeline, you should look at Working with 3-D Assets for Games and Apps for the details. Visual Studio converts WaveFront obj or Autodesk fbx files and can include DGSL materials as part of that pipeline. The DirectX Tool Kit DGSLEffect provides a built-in vertex shader that will work with the DGSL shader designer output.
If you'd like an example of using the DGSLEffect pipeline, look at the tutorial Creating custom shaders with DGSL.

Make a model in Blender and load in opengl

I want to make a 3D model in Blender and load it in OpenGL. Can someone give a step-by-step approach on how to do so. I tried to google but did not get any proper results.
Programming language: C++,
Tools: GLFW + GLAD + GLM
Its a 3 step process, using external libraries.
Model in blender. Export from Blender to .obj format (also containing .mtl file with reference to textures used).
Refer to
https://blender.stackexchange.com/questions/121/how-do-i-export-a-model-to-obj-format
Use a library like Assimp to produce vertices and attributes.
Use the vertices and attributes in your OpenGL application, using a method like described in,
https://nickthecoder.wordpress.com/2013/01/20/mesh-loading-with-assimp/

Rendering Wavefront OBJ and associated material MTL using OpenGL

I have these files: sample.obj, sample.mtl and a folder sample containing image jpg. Can somebody give me an example code of opengl texture mapping using above input.
Your problem is not just texture mapping. What you are asking for is loading an Wavefront OBJ model and its material library, then passing this data to OpenGL rendering commands. Depending on how many preexisting code you want (not) to use this takes different amounts of code. However there's no such thing like a simple OpenGL function that does it all in a black box.
Although this is a FAQ and Google brings you some results I didn't find a tutorial that really explains what's going on.
If you want it to be really simple, use a Wavefront loader and render library:
http://www.evl.uic.edu/pape/sw/libwave.html

Using Blender/SketchUp Models in OpenGL

I'm making a renderer using OpenGL. I have textured models in Blender / Sketchup (I can exchange between the two easily), and I'd like to be able to export those files into my renderer. My initial idea was to simply export the raw faces and render those triangles, but I'd like to easily slice my texture files into texture coordinates as well.
By that, I mean that my model faces get carved into triangles. You can see in this image (reproduced below) that my curve becomes 24 triangles. I would like to know what texture coordinates to use for each triangle.
Would a DAE file be the easiest way to do that? I've been reading the specs for the format and it looks easy enough. I think I could parse the XML and faithfully recreate the models in OpenGL. I'm wondering if there is an easier way (i.e. one that doesn't reinvent the wheel).
If you're comfortable with parsing the .dae-format, sure use it. However, if you're only interested in exporting textured triangle meshes I would consider using the .obj format which is much more simple to parse. From what I can tell both Sketchup and Blender can export this format.
If binary formats don't scare you, I'd suggest writing a Blender & Sketchup plug-in and exporting the geometry pre-baked into packed vertex arrays.
The beautiful thing about this method is that there's no parsing or type conversion in your app. Everything is ready to be sent to the GPU in simple contiguous memory copies. Great for static geometry.
A stripped down blender exporter looks something like this:
#!BPY
import bpy, struct
from Blender import *
self.fh = open("MyFileName", "w")
m = bpy.data.meshes["MyMeshName"]
faces = m.faces
for face in faces:
for (vertex, uv) in zip(face.verts, face.uv):
self.fh.write(struct.pack('<fff', *vertex.co)) # coords
self.fh.write(struct.pack('<fff', *vertex.no)) # normals
self.fh.write(struct.pack('<ff', uv.x, uv.y)) # uvs
self.fh.close()
If you wish to parse .dae files, i would suggest to look into Collada parsers.
.dae is actually the extension for Collada files, the latest effort from the Khronos group (maintainers of OpenGL) to have a single unified file format for 3D data exchange.
As for the existing parsers, here is what I've come across:
collada-dom, the reference implementation. As the name suggests, it is just an abstraction of the XML tree.
FCollada, a nicer abstraction. However, this project has been dead for almost two years, and, from what I've gathered, it is unlikely that we'll see any update in the future.
OpenCollada, a recent new effort. Haven't tried it, but there is an active community behind it.
That being said, if your only goal is loading a simple piece of geometry with vertices, normals and texture coordinates, going with the .obj file format might be a quicker way.
Any decent file format used by modeling programs (such as Blender or Sketchup) will include all information necessary to recreate the geometry you see. This should include the geometry type (e.g. triangle strips, individual triangles, etc), the vertices and normals for the geometry, the material properties used, and also the textures used along with the appropriate texture coordinates. If anything is lacking from a potential file format, choose another one.
If you think that parsing XML is simple, then I hope you're planning on using existing libraries to do this, such as expat, Xerces, or some other language specific implementation.
When considering import/export, first try to find an open source library that can handle the import for you and make the data available to your program in a reasonable format. If that's not available, and you must write your own importer, then try to find a simple ASCII (not XML-based) or binary format that fits your needs. PLY might be suitable. Only as a a last resort, would I recommend trying to implement an importer for an XML-based format.
There's also:
Lib3DS - http://www.lib3ds.org/
LibOBJ (won't let me post link)
You should take a look at:
http://sketchup.google.com/community/developers.html
The sketchup team provides a C++ COM server for free. Using this, you can get access to lots of information about a .skp file.
You should be able to use this COM server to write a .skp importer for your application.
You should try to get the .tlb file if you can. This will give you access to smart pointers, which will simplify your importer (COM client)
I used the version 6 SDK (which included the tlb file). The current version of the SDK does not appear to include this file.
Someone posted a solution (for the missing tlb file) on the developer forums:
http://groups.google.com/group/su-sdk-fileshare/topics

3ds max object to opengl

I am trying to assemble a scene in opengl, using already made objects. The problem is that the object are in .max format and have no external textures. How could I import my objects in opengl, without retexturing them. I am thinking about exporting them to 3ds and using a 3ds file loader. Could you recommend one, and of course it has to work only with the 3ds file itself, no external texture files.
3ds max already allows me to export the file to obj. I have an object that has no external texture file, but it is already fully colored as a 3ds file. Is there any way to import in opengl and have the same colors, for the trunk, leaves?
You might want to check out lib3ds which will parse the 3ds binary format for you and give you access to all of the objects properties. I think Autodesk also has their own toolkit for doing this.
You should look at this link. It is a 3DS viewer with source code that renders using OpenGL. The code is simple.
Another option could be Assimp, an open source asset import library for C or C++, which seems like a pretty good way to get 3DS assets into an opengl program. It'd be especially useful if you want it for skeletal animations, and supports embedded textures. Though at this point, this answer may be less for you than it is for other people coming across this question.
If I remember correctly, the 3ds file does not store the vertex normals so you will probably have to calculate them yourself somehow or otherwise it will use the normal of the face itself which is will be quite ugly.