Delta Engine
»
Support
»
Rendering
»
[Bug] GeometryHelper.CreateCube
Joined: 8/24/2011(UTC) Posts: 95
Thanks: 6 times Was thanked: 2 time(s) in 2 post(s)
|
Hello, with code produces a weird bugged plane instead of cube(cube.jpg) : Code:
static void Main()
{
LookAtCamera cam = new LookAtCamera(new Vector(0, 0, 20), Vector.Zero);
Application.Start(delegate {
MaterialData materialData = new MaterialData
{
ShaderName = "TexturedShader3D",
Ambient = Color.White,
DiffuseMapName = "",
Diffuse = Color.White
};
Shader shader = Shader.Create(materialData.ShaderName);
BaseMaterial material = new MaterialColored(materialData);
GeometryData geometryData = GeometryHelper.CreateCube(shader.VertexFormat, 2, 2, 2, "SceneGraphNodeCube", 0, Color.White);
// using GeometryData geometryData = GeometryHelper.CreateCube(shader.VertexFormat, 2, 2, 2); has no effect, same bug
Geometry geometry = Geometry.Create(geometryData);
material.Draw(geometry);
});
}
But with this code it produces a sphere as it should (though no material works on either cases, sphere.jpg) : Code:
static void Main()
{
LookAtCamera cam = new LookAtCamera(new Vector(0, 0, 20), Vector.Zero);
Application.Start(delegate {
MaterialData materialData = new MaterialData
{
ShaderName = "TexturedShader3D",
Ambient = Color.White,
DiffuseMapName = "",
Diffuse = Color.White
};
Shader shader = Shader.Create(materialData.ShaderName);
BaseMaterial material = new MaterialColored(materialData);
GeometryData geometryData = GeometryHelper.CreateSphere(shader.VertexFormat, 2, Color.White);
Geometry geometry = Geometry.Create(geometryData);
material.Draw(geometry);
});
}
Edited by user Wednesday, September 7, 2011 6:18:28 PM(UTC)
| Reason: Not specified saviilsy attached the following image(s):  cube.jpg (37kb) downloaded 13 time(s). sphere.jpg (42kb) downloaded 11 time(s).You cannot view/download attachments. Try to login or register.
|
|
|
|
Medals:  Joined: 8/20/2011(UTC) Posts: 1,421 Location: Hannover
Thanks: 18 times Was thanked: 97 time(s) in 92 post(s)
|
I think one of our devs encountered the same problem yesterday when he was adding thousands of cubes on top of each other for a physics pyramid and quickly fixed it ^^ maybe he can post here too
|
|
|
|
Joined: 8/21/2011(UTC) Posts: 28
Thanks: 1 times
|
Originally Posted by: Benjamin Nitschke  I think one of our devs encountered the same problem yesterday when he was adding thousands of cubes on top of each other for a physics pyramid and quickly fixed it ^^ maybe he can post here too Hi, During work on 3D physics, i fixed all the stuff regarding Cube/Box/Sphere etc. Anyway, don't use this way of creating geometry data, try this one: Code:
MaterialData materialData = new MaterialData()
{
ShaderName = "TexturedShader3D",
Ambient = Color.White,
DiffuseMapName = "DeltaEngineLogo",
Diffuse = Color.White
};
Mesh mesh = Mesh.CreateBox("TestBox", setWidth, setDepth, setHeight, materialData );
// Draw
mesh.Draw();
I think GeometryHelper would be internal in next release and all creation can be done throught Mesh class, by setting DiffuseMapName you can apply all your texture you want, quick preview of DeltaEngine Physics pyramid with textured cube. Hope you like it ^^ Edited by user Wednesday, September 7, 2011 9:27:27 PM(UTC)
| Reason: Not specified Amer attached the following image(s):  PyramicCube.jpg (252kb) downloaded 12 time(s).You cannot view/download attachments. Try to login or register.
|
|
|
|
Joined: 8/24/2011(UTC) Posts: 95
Thanks: 6 times Was thanked: 2 time(s) in 2 post(s)
|
Originally Posted by: Amer  Hi, During work on 3D physics, i fixed all the stuff regarding Cube/Box/Sphere etc. Anyway, don't use this way of creating geometry data, try this one: Code:
MaterialData materialData = new MaterialData()
{
ShaderName = "TexturedShader3D",
Ambient = Color.White,
DiffuseMapName = "DeltaEngineLogo",
Diffuse = Color.White
};
Mesh mesh = Mesh.CreateBox("TestBox", setWidth, setDepth, setHeight, materialData );
// Draw
mesh.Draw();
I think GeometryHelper would be internal in next release and all creation can be done throught Mesh class, by setting DiffuseMapName you can apply all your texture you want, quick preview of DeltaEngine Physics pyramid with textured cube. Hope you like it ^^ Hi! Thanks for fixing those :) I only tested the "raw" geometrydata because I wanted to add support for that type in my scene graph. Eventually I will of course use meshes, but someone might use pure Geometry/GeometryData for something. Meshes actually work in my scene graph already (it's actually 80% done). And cool pyramid btw ;)
|
|
|
|
Medals:  Joined: 8/20/2011(UTC) Posts: 1,421 Location: Hannover
Thanks: 18 times Was thanked: 97 time(s) in 92 post(s)
|
Btw: We changed the access to the old Screen class (which was renamed to Display shortly after v0.8.6.1 and now is called ScreenSpace like the Wiki page and makes more sense overall). All of the matrices that only were used in Graphics and selected rendering classes are now internal and should not be changed from the outside. This forces everyone to use the Draw methods with matrices (you can even have your own "World" matrix or view matrices in your code, which will just be applied to all rendering, the Level class is a good example for that).
|
|
|
|
Joined: 8/24/2011(UTC) Posts: 95
Thanks: 6 times Was thanked: 2 time(s) in 2 post(s)
|
Ok, I'm almost done with the scene graph (except commenting ahem) but I stumbled upon yet another weird thing which could be a bug : This code Code:
public SceneGraphNodeSphereGeometry(Color color, float size)
{
MaterialData materialData = new MaterialData
{
ShaderName = "LineShader3D",
DiffuseMapName = "",
Diffuse = color
};
Shader shader = Shader.Create(materialData.ShaderName);
Material = new MaterialColored(materialData);
GeometryData = GeometryHelper.CreateSphere(shader.VertexFormat, size, color);
}
public override void Render()
{
if (Geometry != null && Material != null)
{
Material.Draw(Geometry, ref mWorldTransformation);
}
}
works beautifully with the color being what the color is defined to be. Yet this code Code:
public SceneGraphNodeSphereMesh(Color color, float size)
{
MaterialData materialData = new MaterialData
{
ShaderName = "LineShader3D",
DiffuseMapName = "",
Diffuse = color
};
Mesh = Delta.Rendering.Models.Mesh.CreateSphere("SceneGraphNodeSphereMesh", size, materialData);
}
public override void Render()
{
if (Mesh != null)
{
Mesh.Draw(ref mWorldTransformation);
}
}
renders every sphere white. Size and so on are correct though. Edited by user Thursday, September 8, 2011 6:58:51 PM(UTC)
| Reason: added render code
|
|
|
|
Medals:  Joined: 8/20/2011(UTC) Posts: 1,421 Location: Hannover
Thanks: 18 times Was thanked: 97 time(s) in 92 post(s)
|
Mesh should work like the code above, seems to be a bug if it is not doing so. Maybe Amer can test and report back if this still happens after his fixes he did the last few days.
|
|
|
|
Joined: 8/21/2011(UTC) Posts: 28
Thanks: 1 times
|
Originally Posted by: Benjamin Nitschke  Mesh should work like the code above, seems to be a bug if it is not doing so. Maybe Amer can test and report back if this still happens after his fixes he did the last few days. Hi, the problem is that MaterialData.Diffuse does not do nothing on vertex coloring, on the next release you can do something like this: Code:MaterialData materialData = new MaterialData()
{
DiffuseMapName = "DeltaEngineLogo";
ShaderName = "TexturedColoredShader3D";
};
Mesh.CreateSphere("PhysicSphere", radius, Color.Green, materialData);
Take look at green colored spheres on screenshot ^^ Hope this helps, Edited by user Thursday, September 8, 2011 10:14:56 PM(UTC)
| Reason: Not specified Amer attached the following image(s):  ColoredSpheres.PNG (77kb) downloaded 6 time(s).You cannot view/download attachments. Try to login or register.
|
|
|
|
Medals:  Joined: 8/20/2011(UTC) Posts: 1,421 Location: Hannover
Thanks: 18 times Was thanked: 97 time(s) in 92 post(s)
|
That makes sense, thanks for the detailed post Amer. I remember we have an open feature to reimplement all MaterialData fields into the shaders and material classes.
|
|
|
|
Delta Engine
»
Support
»
Rendering
»
[Bug] GeometryHelper.CreateCube
Forum Jump
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.