Jump to content

Error on buliding a brush


Dreikblack
 Share

Go to solution Solved by Josh,

Recommended Posts

With latest updates app crashes when i'm building a brush. Had no problem with exactly method from my example before, but this example from Learn  still works tho https://www.ultraengine.com/learn/CreateBrush?lang=cpp

image.png.e46f070c81b3ea6a552fc54c6ffda548.png

#include "UltraEngine.h"

using namespace UltraEngine;

shared_ptr<Brush> createConeBrush(shared_ptr<World> world, float initWidth, float width, float length, float height, float minHeightArg) {
	auto brush = CreateBrush(world);

	float minHeight = minHeightArg != 0 ? minHeightArg * 0.5f : Max(2 * 0.4f, -height * 0.1f);
	brush->AddVertex(-initWidth * 0.5f, -minHeight, 0); //SW l
	brush->AddVertex(-width * 0.5, -height * 0.5, length);//NW
	brush->AddVertex(width * 0.5, -height * 0.5, length);//NE

	brush->AddVertex(-width * 0.5, height * 0.5, length);//NW h
	brush->AddVertex(width * 0.5, height * 0.5, length);//NE h
	brush->AddVertex(-initWidth * 0.5f, minHeight, 0); //SW h 5
	brush->AddVertex(initWidth * 0.5f, minHeight, 0); //SE h    6
	brush->AddVertex(initWidth * 0.5f, -minHeight, 0); //SE 7

	//back
	auto face = brush->AddFace();
	face->AddIndice(0);//SW
	face->AddIndice(5);//NW
	face->AddIndice(7);//NE

	face = brush->AddFace();
	face->AddIndice(5);//SW
	face->AddIndice(6);//NW
	face->AddIndice(7);//NE

	//bottom
	face = brush->AddFace();
	face->AddIndice(0);//SW
	face->AddIndice(1);//NW
	face->AddIndice(2);//NE

	face = brush->AddFace();
	face->AddIndice(2);//SW
	face->AddIndice(7);//NW
	face->AddIndice(0);//NE

	//top
	face = brush->AddFace();
	face->AddIndice(6);//SW h
	face->AddIndice(4);//NW h
	face->AddIndice(3);//NE h
	face->AddIndice(5);//SE h

	face = brush->AddFace();//left
	face->AddIndice(3);
	face->AddIndice(1);
	face->AddIndice(0);
	face->AddIndice(5);

	face = brush->AddFace();//"face"
	face->AddIndice(1);
	face->AddIndice(2);
	face->AddIndice(4);
	face->AddIndice(3);

	face = brush->AddFace();//right
	face->AddIndice(2);
	face->AddIndice(4);
	face->AddIndice(6);
	face->AddIndice(7);

	brush->Build();
	brush->SetPickMode(PICK_NONE);
	brush->SetCollisionType(COLLISION_NONE);
	brush->SetRenderLayers(0);
	return brush;
}

int main(int argc, const char* argv[]) {
    //Get the displays
    auto displays = GetDisplays();

    //Create a window
    auto window = CreateWindow("Ultra Engine", 0, 0, 1280, 720, displays[0], WINDOW_CLIENTCOORDS | WINDOW_CENTER | WINDOW_TITLEBAR);

    //Create a framebuffer
    auto framebuffer = CreateFramebuffer(window);

    //Create a world
    auto world = CreateWorld();

    //Create a camera
    auto camera = CreateCamera(world);
    camera->SetPosition(0, 1, -2);
    camera->SetClearColor(0.125f);

	createConeBrush(world, 1, 2, 2, 1, 0.1 );

    //Main loop
    while (window->Closed() == false and window->KeyDown(KEY_ESCAPE) == false) {
        world->Update();
        world->Render(framebuffer);
    }
    return 0;
}

 

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...